Consolidate the three-way reviews wire-type duplication - #971
Merged
Conversation
The reviews record tree was hand-copied three times: apps/server/src/agents/ reviews.ts declares it, apps/web/src/hooks/use-agent-reviews.ts restated all four types field-for-field, and apps/server/src/shared/mcp/server.ts restated the feedback-item tree inline in the listReviewFeedback callback signature. Both copies now derive from the server declarations. No field-level drift was found — all four web types were byte-equivalent to their server counterparts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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 freeto 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.
Tech-debt run: sub-item (b) of the server↔web wire-type cluster — the largest remaining pair from the 2026-08-14 duplicate-block audit (12 duplicated 7-line windows), and the only three-way one.
What was duplicated
apps/server/src/agents/reviews.tsdeclares the reviews record tree. It was hand-copied twice:apps/web/src/hooks/use-agent-reviews.tsrestated all four types field-for-field —ReviewThreadMessage(7 fields),ReviewFeedbackItem(14 +messages),Review(10),ReviewListItem(13).apps/server/src/shared/mcp/server.ts(thelistReviewFeedbackentry inMcpRequestContext) restated the 14-field feedback-item tree inline, plus a narrowed 4-field message shape.What changed
Both copies now derive from the server declarations. Web
import types directly from the leaf module and keeps every exported name as an alias, so all 13 importers are untouched:The MCP deps entry becomes
Array<ReviewFeedbackItemRecord & { messages: ReviewThreadMessageRecord[] }>— which is exactly whatlistFeedbackItemsForAgentreturns, so the declaration now matches its producer instead of approximating it. This widens the declared message shape from 4 fields to 7; the sole consumer (dispatch_review_list_feedbackinpersona-interaction-tools.ts) only readsmessages.lengthand rest-spreads the item, the tool has nooutputSchema, and the runtime objects are unchanged, so there is no behavior change.+17 / −69, 2 files.
Drift check: none
Diffed field by field against the server declarations. All four web types were byte-equivalent — same field names, same nullability, same inline
content: { body: string; resolution?: "fixed" | "dismissed" | null }. Unlike #863 (which found a missing field and over-broad unions) and #965 (one over-broad union), this copy had not diverged at all. Worth stating explicitly: the value here is preventing future drift, not fixing present drift.Deliberately excluded (near-misses, not duplication)
shared/mcp/server.ts— the other five review callbacks (resolveReviewFeedback,reopenReviewFeedback,submitReview,addReviewFeedback,addReviewThreadMessage). Each declares a deliberately tiny ad-hoc result ({ id, reviewId, status, resolution: null },{ review: { id, status, summary, items: Array<{ id }> } }), not a copy of the record tree. Aliasing them would widen narrow contracts for no gain.shared/mcp/server.ts:getReviewFeedbackItem— typedPromise<Record<string, unknown> | null>. That is a type gap, not a duplicate; tightening it changes what the consumer can do. Backlogged separately.apps/server/src/db/seed/reviews.ts:13FeedbackSeed— carriesresolutionNote/resolution/status, but it is a seed authoring input: noid/reviewId/baseRef/timestamps,statusandresolutionnarrowed to literals, andmessages: ThreadMsg[]usesminutesAgo. Same category as thedb/seed/jobs.tsexclusion in Derive the remaining within-server agent-type tables from shared #950.use-agent-reviews.tsSubmitReviewInput— resembles the server'sCreateReviewInputbut is genuinely the POST body shape: non-nullable optionals, nodiffSnapshot, noagentId/reviewerType.feedback-card-parts.tsx:200— a component prop namedresolutionNote: string | null, not a record copy.A repo-wide content grep for
resolutionNote(a middle field of the table) at the end of the job returns exactly one type declaration outside the seed fixture:reviews.ts:28. That is the completeness proof.Validation
pnpm run check✅pnpm run check:webwithapps/server/src/generated/deleted ✅ — rules out the Alias web release/assisted-update wire types to the server definitions #863 generated-file failure mode for the new cross-boundary importpnpm run finalize:web✅ — proves esbuild erases the type-only import (nothing fromagents/reviews.tsreaches the bundle)pnpm --filter @dispatch/server test✅ 2783 passed, 9 skippedcd apps/web && pnpm vitest run✅ 932 passedpnpm run test:e2e✅ 180 passed, 12 skippedLeaf check:
agents/reviews.tsimports onlypgtypes andshared/review-limits.js(itself import-free), so no service layer enters web's TS program.Queued next
Sub-item (c):
apps/server/src/brain/store.tsvsapps/web/src/hooks/use-brain.ts(6 windows).brain/store.tsis a class-bearing store, so probe the leaf test with a scratch import +check:webbefore committing to the shape.