Skip to content

fix(ui): reset the event-stream state when the run id changes (gh #1325) - #1329

Closed
lb1192176991-lab wants to merge 1 commit into
jayminwest:mainfrom
lb1192176991-lab:fix/event-stream-run-isolation
Closed

lb1192176991-lab wants to merge 1 commit into
jayminwest:mainfrom
lb1192176991-lab:fix/event-stream-run-isolation

Conversation

@lb1192176991-lab

Copy link
Copy Markdown
Contributor

Summary

useEventStream kept the previous run's accumulated events when the run id changed without a remount, so a new run's tail showed the previous run's events and silently dropped the new run's (its seq restarts low). The stream state now carries the run id and resets to empty when it differs, while keeping history on a follow flip so the replay dedupe still works.

Changes

  • src/ui/src/hooks/use-event-stream.helpers.ts: add EventStreamState, emptyStreamState, and streamStateForRun (the keep-vs-reset decision, testable without a renderer).
  • src/ui/src/hooks/use-event-stream.ts: store runId in state, reset on change, and drop stale in-flight events from a previous run's stream.
  • src/ui/src/hooks/use-event-stream.helpers.test.ts: add streamStateForRun cases.

Test plan

  • tsc --noEmit passes
  • biome check on changed files passes
  • bun test src/ui/src/hooks/use-event-stream.helpers.test.ts passes (11 tests)

…minwest#1325)

useEventStream kept the previous run's accumulated events when the
run id changed without a remount, so a new run's tail showed stale
events and dropped the new run's (its seq numbers restart low). Store
the run id in the stream state and reset to empty when it differs,
keeping history on a follow flip. The run-isolation decision lives in
streamStateForRun so it is testable without a renderer.
@jayminwest

Copy link
Copy Markdown
Owner

Thanks for this! #1333 lands an equivalent change for #1325, so closing as a duplicate.

@jayminwest jayminwest closed this Oct 7, 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.

2 participants