Skip to content

Share combined diff publication snapshots - #35036

Closed
OrcaWin wants to merge 1 commit into
OrcaWin/editor-content-event-admissionfrom
OrcaWin/editor-combined-diff-event-snapshot
Closed

OrcaWin wants to merge 1 commit into
OrcaWin/editor-content-event-admissionfrom
OrcaWin/editor-combined-diff-event-snapshot

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​280 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​280
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34 $\color{#cf222e}{\Huge{\mathbf{−}}}$​27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​7

ELI5

Split panes of the same combined Changes section share one text snapshot for each model event, while both panes still retain their drafts and dirty state.

What Changed

Extract the synchronous actual-model/version snapshot reader introduced by #34920 and reuse it in DiffSectionItem. Each publisher still runs; the first reads the text, later publishers reuse it, and a microtask releases it. This draft is based on #34920 to reuse that implementation.

Why

With ten panes on one actual combined-diff model, typing, Undo and Redo each read the same full document ten times for publication. They now read it once. Wrapper equality reads are covered separately by #35017; a two-pane probe atop that exact published head independently reproduced the remaining two publication reads.

Linked Issue

Internal editor performance audit; no existing issue.

Visual Proof

N/A — both section drafts, dirty state and presentation are preserved. This removes duplicate text reads during synchronous delivery.

Testing

  • Ten real-model/installed-wrapper cases pass across the source and combined-section publisher paths.
  • One- and ten-pane edit/Undo/Redo controls retain every section publication; teardown stops reads. The ten-pane count regression fails before the fix.
  • Existing source controls cover separate models, nested publisher edits, programmatic synchronization, paste and retired owners.
  • Required pnpm check:changed --maxWorkers=2: all 21 checks passed in 183.6s (ORCA_BACKGROUND_LAUNCH=1; gate includes the Admit source content events before reading and share pane snapshots #34920 stack).

Review

Actual model identity and version bound reuse; content survives only through synchronous delivery and is released by microtask. Existing workspace/model routing is retained. Native macOS/Windows, physical mobile and live SSH were not executed. Counts establish avoided reads; CPU, latency and heap impact were not measured.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer content copied.

@OrcaWin

OrcaWin commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator Author

Closing after an adversarial review pass (correctness + value lenses, judged per cluster).

Closing. This spreads #34920's version-keyed WeakMap/microtask snapshot cache into the combined-diff publication path to skip one getValue() per extra pane per keystroke. That only happens when the same worktree's combined-diff section is mounted and edited in two or more split panes, and each pane still does its own compare, setSections, re-render and diff-worker recompute. No CPU, latency or heap numbers were measured. Under #27143 a shared mutable cache across panes in the draft/dirty path is not a free win, and this one is not substantial. The cache is also being removed from the parent #34920, so this PR has nothing left to build on. The 280-line test is a mock-heavy getValue call-count harness.

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