Skip to content

Package Monaco locally and fix editor model ownership - #641

Open
parsakhaz wants to merge 1 commit into
mainfrom
codex/audit-monaco
Open

parsakhaz wants to merge 1 commit into
mainfrom
codex/audit-monaco

Conversation

@parsakhaz

@parsakhaz parsakhaz commented Sep 14, 2026

Copy link
Copy Markdown
Member

Monaco loaded executable code from its default CDN despite the installed package, and file changes could dispose a model still owned by the React wrapper. Package the installed runtime and its language workers, and give each session/file a wrapper that owns its model through unmount.

The editor now preserves text outside the error boundary, offers one explicit recovery attempt, releases cursor subscriptions when the editor is disposed, and ignores position saves from an outgoing file. Remove the Google Fonts import that could make Vite's production CSS preload fail before the offline renderer started. The editor retains the existing lazy panel boundary and the existing font fallback stack. No dependency or lockfile changes.

Closes #614
Closes #615
Closes #635

Validation:

  • Code Quality and React Doctor passed at 4ffe8045d2bf70eb61acbf2906db71ac849ae066, including all six wrapper OS/runtime combinations, Windows/macOS main tests, functional browser tests, and the packaged offline Electron check.
  • Workspace pnpm lint and pnpm typecheck.
  • All 334 frontend unit tests.
  • Four actual-editor browser regressions: blocked external requests and working language workers/TypeScript diagnostics; retarget/edit/remount with model disposal; bounded recovery; dirty Markdown preview retention.
  • Production frontend build, including xterm and React Scan bundle checks.
  • Built application loaded from file:// in Chromium with file access enabled and all external requests blocked: local TypeScript/editor workers, diagnostics, and saving verified.

CI now builds the frontend and runs a separate isolated Electron window against the packaged file:// entry. It checks TypeScript diagnostics, local workers, and saving with all external responses blocked, using sandboxed renderer settings and mocked file IPC without starting Pane's database or daemon.

Built app with external requests blocked:

Offline editor

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T07:49:13.015149Z 4ffe804 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

React Doctor found 2 new issues in 1 file · 2 warnings · score 88 / 100 (Great) · 1 fixed · vs main

2 warnings

src/components/panels/editor/monacoRuntime.ts

  • ⚠️ L1 Heavy library loaded eagerly prefer-dynamic-import
  • ⚠️ L2 Heavy library loaded eagerly prefer-dynamic-import

Reviewed by React Doctor for commit 4ffe804. See inline comments for fixes.

@@ -0,0 +1,29 @@
import Editor, { loader } from '@monaco-editor/react';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/prefer-dynamic-import (warning)

"@monaco-editor/react" ships extra code to your users up front & slows page load. Load it on demand with React.lazy() or next/dynamic.

Fix → Load it only when needed: const Component = dynamic(() => import('library'), { ssr: false }) from next/dynamic, or React.lazy().

Docs

@@ -0,0 +1,29 @@
import Editor, { loader } from '@monaco-editor/react';
import * as monaco from 'monaco-editor';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React Doctor · react-doctor/prefer-dynamic-import (warning)

"monaco-editor" ships extra code to your users up front & slows page load. Load it on demand with React.lazy() or next/dynamic.

Fix → Load it only when needed: const Component = dynamic(() => import('library'), { ssr: false }) from next/dynamic, or React.lazy().

Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant