Skip to content

Admit source content events before reading and share pane snapshots - #34920

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-content-event-admission
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-content-event-admission

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 $\color{#cf222e}{\Huge{\mathbf{−}}}$​26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​12

Problem

MonacoEditor received content events through the @monaco-editor/react onChange prop. In 4.7.0 the wrapper's listener calls editor.getValue() for every model content event before Orca's handler runs. Orca then drops the value for events it ignores, mainly programmatic echoes of its own syncs (external reloads, shared-record commits, read-only live-tail appends). Each of those echoes builds the full document string and then discards it, so large live-tailed logs pay one O(n) read per append for nothing.

Fix

useMonacoContentSyncBridge subscribes to mountedEditor.onDidChangeModelContent itself in a layout effect, and the onChange prop is removed. The existing ownership, model URI and programmatic-sync checks run first, and getValue() runs only when the event is going to be used. Publication semantics stay the same:

  • Orca passes defaultValue, never value, so the wrapper's preventTriggerChangeEvent guard (set only while it syncs the value prop) never applied.
  • The wrapper subscribes at the editor level and keeps that subscription across setModel. This subscription is also editor-level and is rebuilt when modelKey, the editor or onContentChange changes, which matches the wrapper re-subscribing when onChange changes.
  • It is disposed on unmount and when the mounted editor is disposed (mountedEditor resets to null).

Tests

  • use-monaco-content-sync-bridge.events.test.tsx runs the bridge against a real Monaco model. It checks that programmatic echoes are not published while later user edits reach both panes, and that nothing publishes from a retired editor or after unmount.
  • editor-shared-record-clean-view.test.ts now drives edits through the model event instead of calling handleChange by hand.
  • pnpm check:changed --maxWorkers=2 passes.

@OrcaWin OrcaWin changed the title Skip ignored source content events before reading text Admit source content events before reading and share pane snapshots Oct 28, 2026
@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-content-event-admission branch 2 times, most recently from d75d7d5 to 14181b2 Compare October 28, 2026 23:09
@OrcaWin
OrcaWin marked this pull request as ready for review October 29, 2026 00:08
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 968cdb93-8cea-4bd8-82e8-b76642d97c3e
Commits

Reviewing files that changed from the base of the PR and between bc6a5ec and 8de5372.

Files selected for processing: 4
  • src/renderer/src/components/editor/MonacoEditor.tsx
  • src/renderer/src/components/editor/editor-shared-record-clean-view.test.ts
  • src/renderer/src/components/editor/use-monaco-content-sync-bridge.events.test.tsx
  • src/renderer/src/components/editor/use-monaco-content-sync-bridge.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR moves source-editor content events into useMonacoContentSyncBridge. Ignored events now return before the editor reads the full document.

  • Monaco checks content events before reading the full document.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Monaco content event] --> B{Editor and model still match?}
  B -- No --> C[Ignore without reading text]
  B -- Yes --> D{Programmatic update?}
  D -- Yes --> C
  D -- No --> E[Read editor text]
  E --> F[Update lastSyncedContentRef]
  F --> G[Call onContentChange]
Loading

Reviews (2) · Last reviewed commit: "perf(editor): skip full-text reads for i..." · Reviewed by Greptile

Subscribe to onDidChangeModelContent directly instead of the
@monaco-editor/react onChange prop, which calls editor.getValue() before
Orca's ownership and programmatic-sync checks run. Programmatic echoes
(external reloads, shared-record commits, read-only live tail) no longer
materialize the full model text only to discard it.
@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-content-event-admission branch from 14181b2 to 8de5372 Compare October 29, 2026 00:32
@OrcaWin
OrcaWin merged commit d57e554 into main Oct 29, 2026
35 checks passed
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