Skip to content

fix(session): drop deferred side channels on dispose from the step verdict - #453

Merged
mtskf merged 2 commits into
mainfrom
chore/is-edit-applied-drops-on-disposed
Oct 8, 2026
Merged

mtskf merged 2 commits into
mainfrom
chore/is-edit-applied-drops-on-disposed

Conversation

@mtskf

@mtskf mtskf commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Summary

isEditApplied now answers false (DROP) for the disposed event, so the edit-settled barrier drops deferred side channels on dispose from the step's own verdict instead of relying on the panel having set its local disposed flag before dispatching. The e2e that pinned that line order (#452) is removed in the same change, because the dependency it guarded no longer exists.

Changes

  • host-session-step.ts: disposed moves out of the return true group into its own false arm. Like settlementTransitionFailed, it releases the write lock without looking at an outcome, so it must not claim the edit landed.
  • Comments that the change made untrue are corrected (isEditApplied doc, the barrier's settle doc, the panel's step recap and onDidDispose note, and the two step-module paragraphs that read as if the barrier needed the flag-first order).
  • New unit pin next to the settlementTransitionFailed one: isEditApplied({ type: "disposed" }) is false and reaches an explicit arm (no console.error).
  • Removed drops a deferred context-handoff when the panel is disposed while the lock is held from handoff-edit-applied-barrier.test.ts.

Behaviour

No observable change with the current wiring: settle evaluates isDisposed() || !applied, and isDisposed() already reads true on that step, so the same dropAll runs. The difference only shows if the two lines in onDidDispose were ever swapped: deferred save / clipboard / command / editor-switch thunks are now still dropped.

Not changed: the order of the two lines in onDidDispose (flag-first stays as the defence for a disposed transition that throws; that double-failure path still depends on it).

Why the e2e goes

After this change no single-point mutation turns only that test red. Removing isDisposed() from the drop condition is caught by edit-settled-barrier.test.ts and the real-barrier test in host-session-step.test.ts; reverting the disposed arm is caught by the new unit pin. The e2e cost two 1.2 s "nothing happened" windows and about 70 lines of setup duplicated from its neighbours.

Known gap, left as is: no test pins on its own that the panel's isDisposed wiring or the disposed step's verdict reaches barrier.settle. The removed e2e did not isolate those either.

Test Plan

  • New unit test observed red before the arm change (expected true to be false), green after
  • pnpm compile
  • pnpm test:unit (5789 passed)
  • env -u ELECTRON_RUN_AS_NODE pnpm test:e2e (114 passing)
  • Existing barrier / step / dispose tests pass unmodified

mtskf added 2 commits October 8, 2026 15:18
…rdict

isEditApplied answered true for the disposed event and left the drop to the barrier's isDisposed check, which reads the panel's local flag. That made the drop depend on the flag being set before the dispatch in onDidDispose. disposed now answers false, so the barrier drops on that step regardless of the line order. Observable behaviour is unchanged with the current wiring.

The e2e that pinned the line order is removed: with the dependency gone, no single mutation turns only that test red. A unit pin beside the settlementTransitionFailed one covers the new arm.
@mtskf
mtskf merged commit 0e47bb7 into main Oct 8, 2026
2 checks passed
@mtskf
mtskf deleted the chore/is-edit-applied-drops-on-disposed branch October 8, 2026 04:35
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