feat(ai-partner): Amicus conversation persistence (#1457)#1483
Merged
CraigBuckmaster merged 1 commit intoApr 17, 2026
Conversation
Adds user.db migration v16 with amicus_threads + amicus_messages + amicus_usage tables, plus typed read queries, write mutations, and a useAmicusThreads hook. New migration v16 (stacked on v15 from #1452): - amicus_threads (pinned-first index) - amicus_messages (CASCADE on thread delete) - amicus_usage (day-keyed upsert table) New types: AmicusThread, AmicusMessage, AmicusCitation. New queries (app/src/db/userQueries.ts): - listAmicusThreads(limit, offset) - getAmicusThread(threadId) - listAmicusMessages(threadId) - getAmicusUsageToday / getAmicusUsageThisMonth New mutations (app/src/db/userMutations.ts): - createAmicusThread - appendAmicusMessage (tx: insert + touch parent last_message_at) - updateThreadTitle - toggleThreadPin (returns new state) - deleteAmicusThread (CASCADE handles messages) - clearAllAmicusData (tx-wrapped wipe of all three tables) - incrementAmicusUsage (upsert today row) New hook useAmicusThreads — refresh + optimistic pin/unpin/remove/rename. Citations + follow-ups are JSON-hydrated in the query layer so callers receive typed objects. All IDs are caller-generated UUIDs (not autoincrement) for future sync. Tests: 19 new tests for queries + mutations; migration-count tests bumped 15 → 16. All 3,218 app tests pass; tsc clean. https://claude.ai/code/session_01Pht3kzgdvkn81DDfL9SnFe
Test Results✅ All tests passed
Coverage
⏱️ Duration: 75.1s |
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.
Closes #1457. Phase 2 of epic #1446. Stacked on #1452.
Summary
Persistence foundation for Amicus — threads, messages, usage. Local-only to
user.db; never synced (Supabase phase 14 may revisit).Migration v16
New API surface
Queries —
listAmicusThreads,getAmicusThread,listAmicusMessages,getAmicusUsageToday,getAmicusUsageThisMonth.Mutations —
createAmicusThread,appendAmicusMessage(tx: insert + touch parent),updateThreadTitle,toggleThreadPin,deleteAmicusThread,clearAllAmicusData,incrementAmicusUsage.Types —
AmicusThread,AmicusMessage,AmicusCitation.Hook —
useAmicusThreads()with optimistic pin/unpin/remove/rename.Test plan
npx tsc --noEmitcleannpx jest— 3,218 tests passOut of scope
getAmicusUsageThisMonth.https://claude.ai/code/session_01Pht3kzgdvkn81DDfL9SnFe