Skip to content

refactor(core): one owner for interaction sessions, editors and context menus - #87

Closed
chh-ay wants to merge 11 commits into
arch/prepare-oncefrom
arch/interaction-sessions
Closed

chh-ay wants to merge 11 commits into
arch/prepare-oncefrom
arch/interaction-sessions

Conversation

@chh-ay

@chh-ay chh-ay commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Architecture layer: one private owner for pointer, editor and context-menu sessions.

The grid spread pointer, editor and context-menu ownership across GridImpl and a loose input controller, so gestures, editors and context menus could outlive the state they were captured against. A single InteractionSessionController now owns all three. The review's five defects are fixed as one change, and the hot paths the review touched were measured:

  • Resize previews stay out of the document: row and column resize paint a preview while dragging and commit one undoable change on release. Before, each preview step mutated the document, so a cancelled drag left changes behind.
  • Gestures end with their context: an active pointer gesture is cancelled on sheet, view, structure or read-only changes, and a second pointer cannot take over a drag in progress.
  • Editors keep their cell: stock and custom editors both commit to the document cell they opened on, through sorting and filtering, instead of resolving the target differently.
  • Rejected fills leave the selection alone: a fill whose admission is rejected no longer moves the selection to cells it did not write.
  • Selection before edit-begin: selection changes are reported before the edit-begin event, and reentrant handlers no longer reopen a stale editor.
  • No public change: the same events in the same order with the same payloads. Behavior that the review classified as a defect changed; published signatures did not.
  • Edit notifications: the bridge builds an edit notification only while at least one consumer is subscribed, so applications without an edit handler stop paying for the address list.
Interaction Baseline Branch Change A/A band
Edit commit 0.202 ms 0.194 ms −3.7% 2.4%
Column resize 0.168 ms 0.151 ms −10.4% 2.6%
Row resize 0.218 ms 0.144 ms −34.2% 3.3%
Selection 0.0077 ms 0.0078 ms +0.5% 2.1%
Get cell 0.0402 ms 0.0404 ms +0.5% 3.3%
Lookup median (ns) 20.545 20.493 −0.3% 1.7%
Lookup p95 (ns) 235.2 241.2 +2.5% 9.3%
Inverse index bytes 4,000,000 4,000,000 0% 0%
Dirty-100 bytes 5,679 5,679 0% 0%
Owned cold long task 0 ms 0 ms 0% 0%
Unattributed cold long task 89.09 ms 88.43 ms −0.7% 1.8%
Usable time 1,152.2 ms 1,150.8 ms −0.1% 14.9%

Gate: baseline 4997890, five A/A control rounds and five alternating rounds, each scenario in a fresh Bun process pinned to CPU 4 under the shared lock. Every changed path is at or better than its A/A band and no untouched workload is slower. Owned cold long task stays at zero, under the 50 ms ceiling; the inverse index and dirty-100 bytes stay at their ceilings.

The layer also adds the interaction benchmark producer (bench/src/interaction-sessions-bench.ts) and documents its paired-noise protocol, so the release capture regenerates the interaction-current-v2 evidence from the checked-in producer.

Changesets

interaction-sessions: @sheetwrite/core patch.

Verification

  • Core and docs tests: 601 across 75 files; typecheck, lint (two existing unrelated warnings), api:check and docs:check pass.
  • Full Chromium suite: 83 tests pass on this branch, including the new interaction and example specs.
  • New tests: input.test.ts covers cancellation and resize-history contracts; semantic-grid.test.ts covers the editor-target and selection contracts; examples.spec.ts drives the browser paths.

@chh-ay
chh-ay added this pull request to stack #69 October 9, 2026 01:33
@chh-ay chh-ay changed the title perf(core): allocate edit notifications only for subscribed consumers refactor(core): one owner for interaction sessions, editors and context menus Oct 9, 2026
@chh-ay

chh-ay commented Oct 17, 2026

Copy link
Copy Markdown
Owner Author

Landed on develop in the 0.5.0 release squash: #112 (55cfa82).

@chh-ay chh-ay closed this Oct 17, 2026
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