Repository navigation
Use one DocDetail type and stop casting fetch* query results - #361
Merged
Merged
Conversation
This was referenced Nov 28, 2026
This was referenced Nov 28, 2026
The note page and side panel each kept a hand-copied DocDetail, and the editor a DocData, read through `fetchDoc(id) as Promise<...>`. The casts hid the copies from tsc. All three now read the type that fetchDoc and fetchDocLatest return. A new lint rule, vn/no-query-result-cast, fails on a cast of a fetch* result; six files with older casts are listed as exceptions until they are cleaned up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
byronwall
force-pushed
the
claude/doc-detail-one-type
branch
from
November 28, 2026 06:07
3b320b5 to
028f585
Compare
Owner
Author
|
Code review (medium, inline) before merge: nothing blocking.
🤖 Generated with Claude Code |
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.
The note page, the note side panel and the editor now read the note type that
fetchDocreturns, so a change to that type reaches all three. A new lint rule stops the old pattern from coming back.User impact: None. Types and lint only.
Why
The note page and side panel each kept a hand-copied
DocDetail, and the editor kept aDocData. Each read the query throughfetchDoc(id) as Promise<…>. The cast hid the copies from tsc: a field added to or removed from the real type inservices/docs.queries.tswould not reach those files, and nothing would fail. The side panel's copy had already drifted (optional dates, noarchive).This is the first probe of a cleanup loop where one batch moves every caller, deletes the old copy, and adds a check, all in one PR (planning TASK-0017,
srcly-cleanup-loop.md). srcly's symbol index found the copies and their callers.Proof
Callers found by srcly's symbol index before the change:
After the change, one declaration and no casts are left:
The new rule fails on the old code. With
routes/docs/[id].tsxput back frommain:Without its exceptions the rule finds exactly the 8 older casts that
grep -rnE "\) as Promise<|\(await [^)]*\)\) as "finds (minus the.json()boundary casts), and no other hits.Checks on this branch:
pnpm type-checkpassed,pnpm lintpassed (warnings only, all from before), andpnpm testpassed (924 passed, 86 skipped). Against an isolated audit DB I ran the e2e specs that cover the note page, the side panel and live sync:live-note-updates,note-title-hydration,canvas-note-panel,late-note-share-responses,collection-peek-guard,note-session-recovery,inline-title-failed-save. On a warm server, 15 passed, 4 skipped and 2 failed when run in parallel. Those two passed 6 of 6 with--repeat-each 3 --workers 1. A run ofmainon the same server passed all 17.Product scope: srcly's same-named-type scan over all of
app/dropped from 23 groups to 22.DocDetailis gone and no group was added.Limits
fetch*result:LLMSidebar.tsx,routes/embeddings/[id].tsx,routes/umap/[id]/index.tsx,routes/ai/prompts/[id].tsx,routes/ai/index.tsx,routes/ai/runs/[id].tsx..oxlintrc.jsonlists them as exceptions. Remove a file from that list when its local copy goes.fetch+ an uppercase letter, which is the query naming here. A query with another name is not covered.Stack: type cleanup
What splits: Removing hand-copied query types, in two batches:
DocDetailhere, then every other copy that srcly and lint found.Why it splits: This layer can merge alone. It sets the pattern and the cast rule on one type.
Why this split: Each layer is one closed batch with its own callers, deletions and check. One PR per type was rejected, because the exceptions list would stay open across many PRs.
DocDetailand thevn/no-query-result-castrule.vn/no-query-type-redeclarerule.🤖 Generated with Claude Code