Skip to content

Suppress selectionchange echo in completion pipeline#2228

Merged
curtisman merged 2 commits intomicrosoft:mainfrom
curtisman:dup
Apr 22, 2026
Merged

Suppress selectionchange echo in completion pipeline#2228
curtisman merged 2 commits intomicrosoft:mainfrom
curtisman:dup

Conversation

@curtisman
Copy link
Copy Markdown
Member

Suppresses redundant update() calls in the shell partial completion pipeline that were caused by selectionchange events firing after every content mutation, and adds a matching dedup guard in the dispatcher's PartialCompletionSession.

Changes

  • shell/src/renderer/src/partial.ts: Replace the contentUpdated flag (which suppressed the next selectionchange after a content mutation) with a previousInput-based guard. This correctly skips selectionchange echoes without flipping the computed direction (backwardforward) when the input string hasn't actually changed. Reset on hide so re-focus re-activates the controller.
  • dispatcher/src/helpers/completion/session.ts: Mirror the dedup at the controller level — skip if input and direction match the last call and a session is already active or pending.
  • Updated debug strings (update entry:, content changed, update skipped:, selection not at end) for clearer tracing.
  • Tests updated to assert the invariant: every update() entry is accounted for as a content-change, a dedup skip, or a hide.
  • Added renderDispatch test for the new "same input + different direction" path.

Commits

  • Suppress selectionchange echo in completion pipeline
  • Address review feedback on selectionchange dedup

Use previousInput to deduplicate selectionchange echoes in the shell's
PartialCompletion.update(), preventing the echo from recomputing
direction against the already-mutated previousInput (which would flip
"backward" to "forward" and corrupt reconcileTypeAhead).

Add defense-in-depth dedup in PartialCompletionSession.update() that
skips when input+direction are unchanged and the session is active or
pending.

- Remove lastControllerInput field; reuse previousInput for dedup
- Reset previousInput to "" on hide so re-focus re-activates
- Add onUpdate debug trace and Playwright tests for update counts
- Add unit tests for same-input dedup and direction-change passthrough
- Fix stale 'lastControllerInput' reference in session.ts comment
  (now correctly references previousInput).
- Fix misplaced quote in partial.ts debug log so input is quoted
  separately from the change-type label.
- Add 'update entry:' debug trace at top of PartialCompletion.update()
  and strengthen Playwright tests to assert the accounting identity
  entries == content-changed + skipped + hidden, directly verifying
  the previousInput dedup guard fires.
@curtisman curtisman enabled auto-merge April 22, 2026 04:51
@curtisman curtisman added this pull request to the merge queue Apr 22, 2026
Merged via the queue into microsoft:main with commit 4b2da4f Apr 22, 2026
13 of 15 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