Skip to content

feat(editor): replace monaco with pierre's editor, parse user code with babel - #10250

Merged
waleedlatif1 merged 5 commits into
stagingfrom
refactor/runtime-parsing-off-ts6
Nov 20, 2026
Merged

waleedlatif1 merged 5 commits into
stagingfrom
refactor/runtime-parsing-off-ts6

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two related moves off heavyweight editor and compiler dependencies.

1. Monaco → Pierre's editor. One CodeEditor built on @pierre/diffs, which we already ship for diffs, replaces Monaco in the file viewer (editable) and the workflow Code tab (read-only).

Opening a .ts file Pierre Monaco
JS transferred ~460 KB ~1.25 MB, plus up to 9 MB of language workers
First paint (3k / 30k / 120k lines) 75 / 100 / 100 ms 300 / 320 / 390 ms
Heap after GC (3k / 30k lines) 23–26 / 40–68 MB 72 / 81 MB
Longest main-thread task (30k lines) none ~85 ms
  • Highlighting: runs on Pierre's WebAssembly highlighter, which tokenizes in slices around the viewport.
    • The CSP adds 'wasm-unsafe-eval' to script-src. That keyword allows WebAssembly compilation only, not JS eval.
    • Without it, Shiki tokenizes the whole file up front (≈0.5 s at 3k lines, ≈3.7 s at 30k). Shiki remains the fallback for browsers without Wasm SIMD.
  • Read-only: a guard sits in front of a live editor, so search, selection and copy keep working. Every edit is refused (typing, paste, cut, drop, editing shortcuts, the replace panel), and Tab leaves the editor.
  • External updates: agent streaming, Code tab refreshes and reloads keep the scroll position and never join the undo history. A growing document follows its end until you scroll away.
  • Chrome, in app tokens only:
    • the caret line is a full-width --surface-hover band, not an outlined row;
    • selections and the current match use the app's ::selection tint (--selection-muted);
    • other matches use --highlight-match-bg, as chat's find does;
    • a matched bracket gets a quiet --surface-active fill with no underline.
    • The editor sits on --bg, as Monaco did. Diffs keep --surface-2.
  • One syntax palette: both highlighter backends read it. @sim/emcn/syntax-theme gains a Zed-format theme whose colors are the same code.css variables.
  • Removed:
    • the Monaco wrapper, its two themes and its workers;
    • the Code tab's TypeScript language registration and minimal-edit helper;
    • the Monaco typings shim and the Monaco-only PostHog Canceled filter;
    • the context menu's Find item (⌘F opens search);
    • the monaco-editor and @monaco-editor/react dependencies.

2. User code is parsed by Babel, not the TypeScript 6 compiler. TypeScript 7 has no compiler API, and the 7.1 API is project-based on the Go compiler.

  • MCP code mode: strips types with sucrase after @babel/parser checks the syntax. Each error keeps its own line number.
  • Function import scan and document file-reference scanner: both use one shared strict parser for user JavaScript.
  • Behavior change: a Function body that does not parse now runs where its syntax error is reported. Before, it started a remote sandbox for imports found in broken code.
  • Not in this PR: code-placeholders/javascript.ts still uses TS6. It parses source with raw {{NAME}} placeholders and relies on TS6's error tolerance to find secret reads, so porting it is a redesign.

Type of Change

  • New feature
  • Other: dependency removal, refactor

Testing

  • Unit: 853 tests across the touched suites pass. New tests cover type stripping, import hoisting and routing, recoverable errors, and backtick file references; the regression tests fail on the parent commit.
  • Component QA: the real CodeEditor and TextEditor, run in a browser harness in light and dark, pass 27 checks with no page errors:
    • typing, undo and redo;
    • external updates (no echo, not undoable, scroll kept);
    • find, the read-only guard, and Tab leaving read-only;
    • follow-output;
    • Cmd+S, the right-click menu (Add to Chat, Cut, Copy, Paste, Select all), copy-to-chat context, and the streaming lock.
  • Shortcuts: ⌘/, ⌥↑/↓, ⌘[ and ⌘], Enter keeping indent, ⌘Z, ⌘⇧Z and ⌘A all verified.
  • e2e: the workflow-code-ui script now drives the Pierre editor (text, focus, read-only typing and paste).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@waleedlatif1
waleedlatif1 requested a review from a team as a code owner November 20, 2026 19:07
@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 20, 2026 8:44pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The latest changes appear safe to merge, with no new actionable issue found.

Summary

Replaces Monaco with Pierre’s editor and moves user-code parsing to Babel. The latest change runs menu Cut and Copy through native clipboard commands instead of copying and deleting in separate steps.

  • The file viewer and workflow Code tab now share one Pierre editor.
  • MCP code mode checks TypeScript with Babel and strips its types with Sucrase.
  • Function execution parses JavaScript before scanning imports or choosing a sandbox.
  • Document file-reference scanning uses Babel and recognizes plain template strings.
  • The exception filter lets Monaco's canceled-operation reports reach PostHog again.

Reviews (4) · Last reviewed commit: "fix(editor): run the context menu's cut ..." · Reviewed by Greptile

… compiler

TypeScript 7 ships no compiler API, so the server kept @typescript/typescript6
only to parse and transpile code users write. Three of its four runtime uses move
to libraries built for the job:

- MCP code mode strips types with sucrase after Babel checks the syntax, so a
  program that does not parse still reports every error with its own line.
- The Function block's import scan and the document file-reference scanner
  parse with Babel through one shared parser for user JavaScript.

A Function body that does not parse now runs where its syntax error is
reported, instead of first starting a remote sandbox for the imports found in it.
… from broken code

- A template literal with nothing substituted into it is one string token again, so
  getFileBase64(`photo-1`) keeps its file reference.
- The import scan parses strictly: a recoverable error is still an error, so imports
  are never hoisted out of code that will not run.
…and the Code tab

One CodeEditor on @pierre/diffs (already shipped for diffs) replaces Monaco in both
places: the editable file viewer and the read-only workflow Code tab.

- Lighter and faster: opening a .ts file loads ~460 KB instead of ~1.25 MB plus up to
  9 MB of language workers; first paint is 4x faster, the heap a third to a half of
  Monaco's up to 30k lines, and highlighting never blocks the main thread.
- Highlighting runs on Pierre's WebAssembly highlighter, so the CSP allows
  'wasm-unsafe-eval' (WebAssembly compilation only); Shiki is the fallback.
- Read-only is a guard in front of a live editor, so search, selection and copy
  keep working; Tab leaves the editor, every edit is refused.
- External updates (streaming, refresh, reload) keep the scroll position and never
  join the undo history; a growing document follows its end.
- Chrome uses the app's tokens: a --surface-hover caret line, ::selection and find
  colors, a quiet bracket match, and one syntax palette for Shiki and Zed themes.
- Removes the Monaco wrapper, its themes and workers, the Code tab's language
  registration and minimal-edit helper, and the Monaco-only PostHog filter.
@waleedlatif1
waleedlatif1 force-pushed the refactor/runtime-parsing-off-ts6 branch from 08267f0 to 3bae054 Compare November 20, 2026 20:11
@waleedlatif1 waleedlatif1 changed the title refactor(execution): parse user code with babel, not the typescript 6 compiler feat(editor): replace monaco with pierre's editor, parse user code with babel Nov 20, 2026
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 29 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

…ithin engine limits

- The context menu's Cut and Copy take every selected passage, and Cut deletes only
  after the clipboard write succeeds, so nothing is removed that never reached it.
- The import scan sees require?.() calls and walks array children one push at a
  time, so a 100,000-element literal stays under Bun's argument limit.
- The Code tab e2e seeds the clipboard before pasting into the read-only view.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 29 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

…commands

Cut and Copy run as native commands on the refocused editor, like ⌘X and ⌘C: one
synchronous step that copies every selection, cuts exactly what it copied, keeps
the chat selection reference, and leaves focus in the editor. Copy all returns
focus too.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 29 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 8d12171 into staging Nov 20, 2026
92 of 95 checks passed
@waleedlatif1
waleedlatif1 deleted the refactor/runtime-parsing-off-ts6 branch November 20, 2026 21:11

This branch was previously deployed

1 inactive deployment
Preview — 4c9e19ac Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant