Skip to content

fix: TUI drops visible partial assistant replies on stream error/cancel#826

Closed
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-eafe8542
Closed

fix: TUI drops visible partial assistant replies on stream error/cancel#826
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-eafe8542

Conversation

@sam-saffron-jarvis

Copy link
Copy Markdown
Contributor

What changed

  • salvage visible partial assistant output when a TUI stream ends with StreamEventError or cancellation
  • synthesize a fallback assistant message from the accumulated streamed text/reasoning, append it to in-memory m.messages, and invalidate history/context caches
  • best-effort persist that fallback with a short timeout, updating the existing pending assistant row when one already exists so interrupted streams do not create duplicate assistant rows
  • add regression tests covering both the fresh-fallback path and the pending-row update path

Why this is high-value

This fixes a real data-loss path in the main interactive TUI surface. Before this change, users could see partial assistant text on screen after an interrupted or failed stream, but that visible content was not added to conversation state and could be missing from persisted session history. That meant the next turn could lose context, and resuming the session later could lose the partial reply entirely.

Validation

  • gofmt -w internal/tui/chat/chat.go internal/tui/chat/streaming_test.go
  • go build ./...
  • go test ./...
  • added tests:
    • TestUpdate_StreamErrorSalvagesPartialAssistantReply
    • TestUpdate_StreamErrorUpdatesPendingAssistantFallbackRow
  • git diff --check

@SamSaffron

Copy link
Copy Markdown
Owner

Implemented directly in main working tree with the same fixes and regression coverage.

@SamSaffron SamSaffron closed this Jun 14, 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