Skip to content

Fix background task auto-resume invisible in UI#15

Open
pufit wants to merge 1 commit intomainfrom
pufit/fix-background-task-streaming
Open

Fix background task auto-resume invisible in UI#15
pufit wants to merge 1 commit intomainfrom
pufit/fix-background-task-streaming

Conversation

@pufit
Copy link
Copy Markdown
Member

@pufit pufit commented Mar 27, 2026

Summary

  • Fix auto-resume response after background tasks being invisible to the user
  • Add auto_resume_start WebSocket event broadcast before auto-resume to reliably enter streaming mode
  • Remove !isStreaming guard from session_running handler (now idempotent)
  • Track background watcher tasks for proper cancellation on stop/shutdown
  • Touch session during polling to prevent idle sweep killing the client
  • Await auto-resume instead of fire-and-forget create_task for error propagation

Test plan

  • Trigger a background task — verify thinking cursor appears when task completes and response streams visibly
  • Type during background task polling — verify no token loss or duplicate responses
  • Stop session while background task runs — verify watcher is cancelled cleanly
  • Wait >5min with background task — verify idle sweep doesn't kill client
  • All 326 existing tests pass
  • Frontend builds clean

Generated by Nerve

The StreamingMessage component only renders when isStreaming is true.
During auto-resume after background tasks complete, session_running
was the only signal to enter streaming mode, but its !isStreaming
guard caused race conditions where tokens accumulated invisibly.

- Add auto_resume_start event broadcast before auto-resume run
- Remove !isStreaming guard from session_running handler (idempotent)
- Track background watchers for cancellation on stop/shutdown
- Touch session during polling to prevent idle sweep killing client
- Await auto-resume instead of fire-and-forget create_task
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