Skip to content

fix: preserve assistant responses in chat history#8

Open
akdenizemirhan wants to merge 1 commit intoryanstephen:mainfrom
akdenizemirhan:fix/preserve-streaming-history
Open

fix: preserve assistant responses in chat history#8
akdenizemirhan wants to merge 1 commit intoryanstephen:mainfrom
akdenizemirhan:fix/preserve-streaming-history

Conversation

@akdenizemirhan
Copy link
Copy Markdown

Summary

  • Assistant responses from Claude CLI were lost when the chat popover closed and reopened
  • Streaming text was displayed in real-time but never saved to session history
  • replayHistory() only showed user messages, not Claude's responses

Root Cause

Claude CLI sends responses as streaming "assistant" type messages, but the final "result" type message has an empty "result" field. The history was only populated from result.result, so responses were never persisted.

Fix

  • Accumulate streaming text in currentStreamingResponse during assistant messages
  • Save accumulated text to history when the turn completes ("result" event)
  • Reset accumulator for the next turn

Test plan

  • Send a message, receive response
  • Close popover by clicking elsewhere
  • Reopen popover - both user message and assistant response are preserved
  • Send multiple messages - all history entries persist correctly

🤖 Generated with Claude Code

Streaming text from Claude's responses was not being saved to the
session history. When the popover closed and reopened, only user
messages appeared - assistant responses were lost.

The root cause: Claude CLI returns streaming text via "assistant" type
messages, but the "result" type message has an empty "result" field.
The history was only populated from the "result" field, so responses
were never saved.

Fix: accumulate streaming text during the assistant response and save
it to history when the turn completes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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