Skip to content

fix(tui): stop one bad event from dropping the rest of a flush batch - #13125

Draft
johnnyeric wants to merge 1 commit into
mainfrom
johnnyeric/tui-turn-end-batch-drop
Draft

fix(tui): stop one bad event from dropping the rest of a flush batch#13125
johnnyeric wants to merge 1 commit into
mainfrom
johnnyeric/tui-turn-end-batch-drop

Conversation

@johnnyeric

@johnnyeric johnnyeric commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What

Fixes the TUI stall where a turn visibly finishes (footer shows the completed duration) but the prompt keeps spinning and the transcript stops updating.

Why

The SSE client batches events and flush() clears the queue before iterating, emitting each event unguarded inside a single Solid batch(). The legacy message.removed / message.part.removed handlers in sync.tsx called search(...) on store.message[...] / store.part[...] without checking they exist — for a session this TUI never hydrated (background-session cleanup, revert, another window), that is undefined and search throws reading items.length. One such event mid-batch permanently dropped every later event in that flush, including the idle status the spinner depends on.

Changes:

  • sync.tsx: guard the legacy message.removed / message.part.removed handlers with the same missing-collection checks the .1 handlers already have, and handle session.idle by resetting session_status to idle.
  • sdk.tsx: isolate event dispatch per handler and per event so one throwing handler logs (tui event handler failed) instead of dropping the rest of the batch or killing the SSE loop.
  • Tests reproduce both symptoms on the existing sync fixture; both fail without the fix.

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