Skip to content

feat: "Ask your library" GraphRAG chat — schema + screen (P13d-2a)#145

Merged
blokzdev merged 1 commit into
mainfrom
claude/p13d2a-ask-chat
Jun 3, 2026
Merged

feat: "Ask your library" GraphRAG chat — schema + screen (P13d-2a)#145
blokzdev merged 1 commit into
mainfrom
claude/p13d2a-ask-chat

Conversation

@blokzdev
Copy link
Copy Markdown
Owner

@blokzdev blokzdev commented Jun 3, 2026

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

  • Schema v13→v14 — new Drift chats + chat_messages tables (FK cascade). Forward-included the d-2b columns (chats.title, chats.archivedAt, message citationsJson) 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 (bumps updatedAt), watch/read the transcript.
  • Pure helpers (ask_chat.dart) — messagesToHistory (pair user→assistant turns), the citationsJson codec, and parseCitationSpans (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 via aiSummaryAction (on-ramp to AI settings when no model).
  • Dashboard AskEntryTile + /ask route — auto-hides on low/ineligible tiers (the retrieval-only fallback is d-3).

Decisions (confirmed at planning)

  • Forward-include the v14 schema (one migration covers d-2a + d-2b).
  • Hide the Dashboard entry on low/ineligible tiers in d-2a; d-3 lights it up for the retrieval-only fallback.

Tests (CI-verifiable; native generation is APK-verified)

  • v13→v14 migration incl. cascade delete; bumped the schema-version assertion.
  • ChatRepository round-trip + ordering + updatedAt bump.
  • Pure helpers: history pairing (incl. trailing unanswered drop), citation codec round-trip/tolerance, citation-span parsing (in/out-of-range).
  • 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.
  • AskEntryTile gating (eligible+graph+non-empty shows; otherwise hides).

Full suite 858 passing; dart format + flutter analyze clean. 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

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
@blokzdev blokzdev merged commit b8d38f4 into main Jun 3, 2026
1 check passed
@blokzdev blokzdev deleted the claude/p13d2a-ask-chat branch June 3, 2026 06:05
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.

2 participants