feat(ai): persist conversation across navigation + stop generation#95
Merged
Conversation
- Move chat state into a module-level zustand store (stores/ai-chat-store) so the thread survives leaving and returning to the assistant screen (was lost on unmount). `useAIChat` is now a thin selector over the store; the screen API is unchanged. - Stop generation: send() runs under an AbortController; a Stop button replaces Send while streaming and aborts the request, keeping whatever streamed so far (tagged "…(stopped)"). streamAiChat returns the partial accumulation on abort instead of throwing. Tests: new store suite (send/stream, persistence across instances, empty/ concurrent guard, error+retry, stop-keeps-partial, clear) + a Stop-button screen test. Suite 1230/1230, lint clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two more mainstream-chat affordances for the AI Assistant:
stores/ai-chat-store), so leaving/aiand coming back keeps the conversation (previously lost on unmount).useAIChatbecomes a thin selector over the store; the screen API is unchanged.send()runs under anAbortController; a Stop button replaces Send while streaming and aborts the request, keeping whatever streamed so far (tagged…(stopped)).streamAiChatreturns the partial accumulation on abort instead of throwing.Tests
stores/ai-chat-storesuite: send/stream +onUpdate, persistence across store instances, empty/concurrent-send guard, error + retry, stop keeps partial text, clear.stop().npm run lint0 errors;jest1230/1230 (151 suites).Note
Persistence is in-session (survives navigation). Disk persistence across app restarts is a possible follow-up (the store is ready for a persist middleware).
🤖 Generated with Claude Code