73 lines
4.0 KiB
Markdown
73 lines
4.0 KiB
Markdown
---
|
|
id: TASK-9
|
|
title: Add Convex-synced savings chat history
|
|
status: Done
|
|
assignee: []
|
|
created_date: '2026-06-16 07:58'
|
|
updated_date: '2026-06-16 08:23'
|
|
labels: []
|
|
dependencies: []
|
|
priority: high
|
|
ordinal: 9000
|
|
---
|
|
|
|
## Description
|
|
|
|
<!-- SECTION:DESCRIPTION:BEGIN -->
|
|
Persist savings chat sessions and messages in Convex per authenticated user so chat history syncs across devices, with automatic one-time import of existing localStorage chats.
|
|
<!-- SECTION:DESCRIPTION:END -->
|
|
|
|
## Acceptance Criteria
|
|
<!-- AC:BEGIN -->
|
|
- [x] #1 Chat sessions and messages are stored in Convex per authenticated user and synchronize across devices
|
|
- [x] #2 Existing localStorage savings chats are imported once, deduplicated by legacy local id, and old local data is not deleted
|
|
- [x] #3 Sending a chat message stores both user and assistant messages, including assistant tool traces
|
|
- [x] #4 Deleting a chat hides it account-wide and unauthorized users cannot read or mutate another user's chats
|
|
- [x] #5 Focused Convex tests, focused ESLint, and build verification are run and recorded
|
|
<!-- AC:END -->
|
|
|
|
## Implementation Plan
|
|
|
|
<!-- SECTION:PLAN:BEGIN -->
|
|
1. Add failing Convex tests for user-scoped chat history, legacy import, sendMessage persistence, and deletion
|
|
2. Add chatSessions/chatMessages schema tables
|
|
3. Implement savingsChatHistory queries and mutations
|
|
4. Refactor savingsChat AI generation helper and add sendMessage action
|
|
5. Move SavingsChatPage to Convex-backed state and automatic legacy import
|
|
6. Run focused tests, focused lint, build, and record verification notes
|
|
<!-- SECTION:PLAN:END -->
|
|
|
|
## Implementation Notes
|
|
|
|
<!-- SECTION:NOTES:BEGIN -->
|
|
Implementation completed on branch codex/convex-chat-history-sync.
|
|
|
|
Verification:
|
|
- RED verified first: npx vitest convex/savingsChat.test.ts --run failed with 3 missing chat-history/sendMessage tests.
|
|
- PASS npx vitest convex/savingsChat.test.ts --run (25 tests).
|
|
- PASS npx eslint convex/schema.ts convex/savingsChat.ts convex/savingsChatHistory.ts convex/savingsChat.test.ts src/pages/SavingsChatPage.tsx src/components/chat/ChatHistory.tsx.
|
|
- PASS npm run build (Vite chunk-size warning remains).
|
|
- FULL LINT npm run lint still fails on pre-existing unrelated files: convex/bank/comdirectProvider.ts, convex/bank/config.ts, src/components/import/TanAwaitDialog.tsx, layout/ui fast-refresh exports, src/main.tsx, src/pages/SettingsPage.tsx, plus existing React Compiler warnings. No changed feature file appears in the full-lint error list.
|
|
|
|
Notes:
|
|
- Ran npx convex codegen; first sandboxed attempt failed on DNS/fetch to Sentry, rerun outside sandbox succeeded and updated convex/_generated/api.d.ts.
|
|
- Backlog task remains In Progress pending explicit user confirmation after manual testing.
|
|
|
|
Review follow-up:
|
|
- Addressed code-review finding: legacy import marker is now scoped by current Convex user id instead of only browser-global.
|
|
- Addressed code-review finding: sendMessage now persists an assistant failure message if AI generation fails after saving the user message.
|
|
- Added regression coverage for unauthorized listMessages, unauthorized sendMessage, and failed-generation persistence.
|
|
|
|
Final verification after review fixes:
|
|
- PASS npx vitest convex/savingsChat.test.ts --run (26 tests).
|
|
- PASS npx eslint convex/schema.ts convex/savingsChat.ts convex/savingsChatHistory.ts convex/savingsChat.test.ts src/pages/SavingsChatPage.tsx src/components/chat/ChatHistory.tsx.
|
|
- PASS npm run build (Vite chunk-size warning remains).
|
|
- FULL LINT npm run lint still fails only on pre-existing unrelated files and generated-file warnings; no changed feature file is in the full-lint error list.
|
|
<!-- SECTION:NOTES:END -->
|
|
|
|
## Final Summary
|
|
|
|
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
|
|
Shipped Convex-backed savings chat history sync with user-scoped sessions/messages, automatic per-user legacy localStorage import, server-persisted sendMessage flow, account-wide delete behavior, authorization coverage, and focused verification. Full lint still has unrelated pre-existing failures documented in notes.
|
|
<!-- SECTION:FINAL_SUMMARY:END -->
|