Repository navigation
Admit source content events before reading and share pane snapshots - #34920
Conversation
d75d7d5 to
14181b2
Compare
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThe PR moves source-editor content events into
|
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.
14181b2 to
8de5372
Compare
Problem
MonacoEditorreceived content events through the@monaco-editor/reactonChangeprop. In 4.7.0 the wrapper's listener callseditor.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
useMonacoContentSyncBridgesubscribes tomountedEditor.onDidChangeModelContentitself in a layout effect, and theonChangeprop is removed. The existing ownership, model URI and programmatic-sync checks run first, andgetValue()runs only when the event is going to be used. Publication semantics stay the same:defaultValue, nevervalue, so the wrapper'spreventTriggerChangeEventguard (set only while it syncs thevalueprop) never applied.setModel. This subscription is also editor-level and is rebuilt whenmodelKey, the editor oronContentChangechanges, which matches the wrapper re-subscribing whenonChangechanges.mountedEditorresets to null).Tests
use-monaco-content-sync-bridge.events.test.tsxruns 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.tsnow drives edits through the model event instead of callinghandleChangeby hand.pnpm check:changed --maxWorkers=2passes.