feat: "Ask your library" GraphRAG chat — schema + screen (P13d-2a)#145
Merged
Conversation
First user-facing slice of the P13d flagship: a persisted, multi-turn "Ask your library" chat reached from the Dashboard that drives the P13d-1 retrieval engine through on-device generation. - Schema v13→v14: `chats` + `chat_messages` (FK cascade), forward-included (title/archivedAt/citationsJson) so d-2b needs no further migration. - ChatRepository + providers; pure ask_chat helpers (history pairing, citation codec, citation-span parsing). - AskController: create-on-first-send → append question → re-retrieve with bounded history → stream a grounded answer → persist with citations; no-sources → graceful reply with no LLM call. - AskScreen: streamed transcript, inline `[n]` + Sources citations that deep-link items, generation-gated input (on-ramp via aiSummaryAction). - Dashboard AskEntryTile (auto-hides off the full-generation path) + /ask route. - Tests: v13→v14 migration (+ cascade), repo, pure helpers, controller (full/no-sources/error), entry-tile gating. Docs: P13-PLAN, VERIFICATION, SPEC (schema narrative caught up v11–v14), BACKLOG. https://claude.ai/code/session_013JoYmLCosYt5tQ8qwdbL1T
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.
P13d-2a — Chat schema + "Ask your library" screen (single conversation)
The first user-facing slice of the P13d flagship. P13d-1 (PR #144) shipped the pure-Dart retrieval engine; this wires it to on-device generation behind a real chat: paste a question, get a streamed, grounded answer that cites your library items, fully offline.
What's here
chats+chat_messagestables (FK cascade). Forward-included the d-2b columns (chats.title,chats.archivedAt, messagecitationsJson) so the conversation list/rename/archive/delete slice needs no second migration. New tables only — no data migration.ChatRepository(+chatRepositoryProvider/chatMessagesProvider) — create chat, append message (bumpsupdatedAt), watch/read the transcript.ask_chat.dart) —messagesToHistory(pair user→assistant turns), thecitationsJsoncodec, andparseCitationSpans(split an answer into tappable[n]spans).AskController— per turn: append the question → re-retrieve fresh RAG sources + a bounded slice of prior turns (reusing d-1) → stream a grounded answer → persist it with its citations. No sources → a graceful "couldn't find anything" reply with no LLM call.AskScreen— streamed transcript with inline[n]citations + a Sources row, both deep-linking the cited items; input is generation-gated viaaiSummaryAction(on-ramp to AI settings when no model).AskEntryTile+/askroute — auto-hides on low/ineligible tiers (the retrieval-only fallback is d-3).Decisions (confirmed at planning)
Tests (CI-verifiable; native generation is APK-verified)
ChatRepositoryround-trip + ordering +updatedAtbump.AskController: full path persists a streamed, cited answer; no-sources persists the graceful reply without calling generate; error sets state and persists no assistant row.AskEntryTilegating (eligible+graph+non-empty shows; otherwise hides).Full suite 858 passing;
dart format+flutter analyzeclean. No new deps.Docs
docs/design/P13-PLAN.md(d-2a →[~]with as-built status),docs/VERIFICATION.md(P13d-2a APK checklist),docs/SPEC.md(schema narrative caught up v11–v14 + the chat tables),docs/BACKLOG.md(cite-only-referenced sources; per-turn error UX).Verification owed (APK spot-check — native generation can't be CI-tested)
On a capable device with a model: open Ask from the Dashboard → ask → streamed, grounded, cited answer offline; citations navigate; the turn persists; on-ramp when no model; entry hidden on a low-end device.
Next: d-2b — conversation list + rename/archive/delete/continue (on this same schema).
https://claude.ai/code/session_013JoYmLCosYt5tQ8qwdbL1T
Generated by Claude Code