Skip to content

feat(ai): persist conversation across navigation + stop generation#95

Merged
os-zhuang merged 1 commit into
mainfrom
feat/ai-chat-persist-stop
Jun 10, 2026
Merged

feat(ai): persist conversation across navigation + stop generation#95
os-zhuang merged 1 commit into
mainfrom
feat/ai-chat-persist-stop

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

What

Two more mainstream-chat affordances for the AI Assistant:

  • Persistence across navigation — chat state moves into a module-level zustand store (stores/ai-chat-store), so leaving /ai and coming back keeps the conversation (previously lost on unmount). useAIChat becomes a thin selector over the store; the screen API is unchanged.
  • Stop generationsend() 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 stores/ai-chat-store suite: send/stream + onUpdate, persistence across store instances, empty/concurrent-send guard, error + retry, stop keeps partial text, clear.
  • Screen: Stop button shown while generating → calls stop().
  • npm run lint 0 errors; jest 1230/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

- 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>
@os-zhuang os-zhuang merged commit 2252af3 into main Jun 10, 2026
1 of 4 checks passed
@os-zhuang os-zhuang deleted the feat/ai-chat-persist-stop branch June 10, 2026 07:04
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