Skip to content

Drop write-only values and the casts that hid types - #364

Merged
byronwall merged 1 commit into
mainfrom
claude/drop-write-only-values
Nov 28, 2026
Merged

byronwall merged 1 commit into
mainfrom
claude/drop-write-only-values

Conversation

@byronwall

Copy link
Copy Markdown
Owner

This removes values that nothing reads, and the casts that kept the type checker from checking six status and role fields and one action result. Nothing changes on screen.

User impact: None.

Why

A srcly measurement on d59937fe found dead values and casts onto copied types. Each delete or cast removal:

Fix Proof
Delete fitToSpread from the canvas store No .fitToSpread access on base. The 4 hits left are the route's own function in routes/canvas.tsx
Delete requestedTokens 2 hits on base (declare, write), 0 now. The error regex still requires the "requested N tokens" text
Drop considered from the path-round and image-scan results, and readFailures from the image-scan result No property read in app/src, app/scripts or app/tests. The one UI caller reads updated, failed and matches. Both values stay in the server logs
Drop umapIndex from the positions store return No reader outside the store
ChatThreadStatus, ChatMessageRole, RunStatus Each is now Prisma's $Enums type, so the 6 casts are gone and a schema change reaches the query types
Drop the ProcessEmbeddingResult cast on the embedding run page processEmbeddingRun now declares its result type

One finding was wrong. The measurement said the server never sets umapProjection, so the page's "Auto-projected" line was dead. It does set it, on both returns that embed notes. The inferred return type had lost the field, and the cast hid that. This PR keeps the line and fixes the type.

Proof

Matching lines in app/src (git grep -P):

Pattern Base This branch
ProcessEmbeddingResult (local type and casts) 3 0
as ChatThreadStatus|ChatMessageRole|RunStatus 6 0
fitToSpread 6 4 (route's own)
requestedTokens 2 0
readFailures?: 1 0
umapIndex, in the store return 1 0

Removing only the cast, with no declared type, fails the type check. This is the hidden mismatch:

src/routes/embeddings/[id].tsx(241,48): error TS2339: Property 'umapProjection' does not exist
  on type '{ addedDocs: number; addedSections: number; remaining: number; }'.

A temporary test, not committed, ran processEmbeddingRun with one trained UMAP run and mocked database and embedding calls:

missing {"addedDocs":1,"addedSections":1,"remaining":0,"umapProjection":{"runsUpdated":1,"pointsProjected":1,"failedRuns":0}}
changed {"addedDocs":1,"addedSections":1,"remaining":0,"umapProjection":{"runsUpdated":1,"pointsProjected":1,"failedRuns":0}}

Checks:

  • pnpm type-check and pnpm lint pass. pnpm test: 924 passed, 86 skipped.
  • E2E on an isolated audit database with --workers 1 (route-hydration-smoke, which loads /canvas, /embeddings and /ai; canvas-note-panel; no-page-flash and note-safety-gaps, which open chat; homepage): 29 of 31 pass.
  • The 2 failures are in canvas-note-panel: "unsaved edits ask before the panel closes" and "a save in flight blocks closing until it finishes". Both also fail with origin/main's app/src on the same server.

Limits

🤖 Generated with Claude Code

Delete values nothing reads: canvas store fitToSpread, requestedTokens,
the considered/readFailures action result fields, and the umapIndex store
return. Derive the chat and run status types from Prisma and remove the
casts onto them. Declare processEmbeddingRun's result type so the route
can drop its cast; the inferred union hid umapProjection.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@byronwall
byronwall merged commit 966f707 into main Nov 28, 2026
2 checks passed
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.

1 participant