Phase 3: guide content, deep dives and analytics tables #4
main fromphase-3-guide·merged by fuko Phase 3 of the V2 brief: the guide, rewritten against the working app, plus a deep-dive page.
Guide sections#
Every section says what to do in the app and what to look for. Section ids stay the same.
- Introduction: what the app is. This is the only copy that depends on the layout (
ByGuideLayout): "next to this guide" on wide screens, "tap Try it" on phones. - Collections: quotes the real
notesCollection. One copy of each note feeds the list, the editor and the counts. The text says what theschemachecks: the app's own inserts and updates. Rows loaded byqueryFnskip it. - Live queries: quotes
noteListQueryandinFolder(smart folders are justwhereclauses), and says why they're fast (incremental updates). - Optimistic updates: quotes
renameFolderand the per-note paced mutation (noteChanges/changeNote). Includes a short "Why one paced mutation per note?" part on concurrent optimistic transactions, linking to the TanStack docs. - Rollbacks: quotes the server's duplicate-name check and the client's throw on non-2xx. Tells readers how to trigger a rollback today: rename Work to "Personal", or type a title over 100 characters. Steps are given for both the sidebar and the iPhone layout.
- How collections sync: one-way data flow, query collections writing back confirmed rows (
saveNoteUpdates,inOrder,saveEach), other collection types, and a link to the deep dive. - Aggregations: quotes
noteCountsQuery, plus a new two-stage query.noteStatsCollectionusesfn.selectto count words per note, andfolderStatsQuerygroups it. Words are counted from the parsed note (countWordsinsrc/lib/notes/note-body.ts), so block markers like#,-,[ ]and[x]don't count. - What's next: the deep dive and docs links.
Every section now has typed appStates: AppState[] (src/lib/app-state.ts): a screen from APP_SCREENS, which is checked against the route tree with satisfies, optional params, and an optional last-action matcher. These are for phase 4; nothing reads them yet.
Analytics#
/analytics shows two plain tables from live groupBy queries: notes and words per folder, and notes by day of last edit. There are no charts (phase 4).
Deep dive (new route)#
/deep-dives/query-driven-sync: a realsyncMode: "on-demand"collection (src/db/on-demand-notes.ts) that sends the live query's folder filter toqueryFnthroughparseLoadSubsetOptions. There's a small live demo against the fake API (it shows the result and the requests made), plus pitfalls checked against the installed package source. The fake API gainedGET /api/notes?folderId=….
Rollback toasts and progress on every page#
Rollback toasts, section-progress tracking and the Toaster are mounted once, in the root route (src/components/shell/app-notifications.tsx). They used to live in the Notes app and the workspace. So a change that settles after the reader has gone to the deep dive still shows its toast, and still ticks off its section.
How snippets stay in sync with the code#
Quotable code is wrapped in // #region name … // #endregion name comments. src/guide/snippets.ts imports the files with ?raw and pulls out the regions (src/guide/source-regions.ts), so the guide always shows the current code. Tests check that:
- every snippet's region exists and its lines are in the file;
- every region marker in
src/is quoted, so no marker goes stale.
The notes collection now uses named handlers so it reads cleanly when quoted.
Unverified / TODO#
- Rollbacks use server validation, not "fail next". The Network panel's latency and fail-next controls exist but are disabled until phase 4. The
?failNext/?latencyURL switches are dev-only, so the guide doesn't mention them. - "Notes by day of last edit" stands in for "edits per day". Notes only store
updatedAt; there is no edit history.
Checks#
vp check, vp test (21 files, 143 tests) and vp build pass.
🤖 Generated with Claude Code
- 1
fuko merged thise6b0611
fuko closed this
Sign in to join this conversation.