Repository navigation
perf(mobile): build the two projected git enums once, not per parse - #21311
Conversation
`readProjectedConflictOperation` and `readProjectedCompareStatus` constructed a `z.enum` on every call, so every `git.status` and `git.branchCompare` reply paid the constructor. Hoisted to module constants; the git-status payload schema reuses the same instance. Behaviour is unchanged: same arms, same fallbacks, identical reader output on all eleven recorded matrix cases. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe change creates module-level Zod enum schemas for branch compare status and conflict operation. The schemas are reused by payload validation and projected-value parsing. Successful parse results and fallback values remain unchanged. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The PR reuses equivalent enum schema instances while preserving parsing and fallback behavior, so it is mergeable with normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description clearly explains the change, rationale, performance results, and validation. However, it omits the required template sections for ELI5, Linked Issue, Visual Proof, Testing checklist, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. It also does not provide the required issue link or explicitly state N/A for visual proof. Resolution Add the missing template sections. Include a linked issue after “Fixes #”, write
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This PR hoists two z.enum(...) constructions out of the functions that run on every reply and into module-level constants.
diff-review-reply-schema.ts— addsgitBranchCompareStatusSchema(line 31) and pointsreadProjectedCompareStatusat it.git-status-reply-schema.ts— addsgitConflictOperationSchema(line 28), used by bothreadProjectedConflictOperationand theconflictOperationfield ofgitStatusHostPayloadSchema, replacing a second, separatez.enuminstance.
The change is behavior-identical. z.enum schemas are stateless and safeParse does not mutate them, and salvagedOptional wraps the schema it is handed in a transform rather than calling .optional() on it in place, so sharing a single instance between the payload schema and the projection reader cannot couple the two parse paths. Both readers are already pinned by tests (session-reply-schema.test.ts, source-control-reply-schema.test.ts), so no new coverage is needed for a pure construction hoist.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…tablyai#21311) `readProjectedConflictOperation` and `readProjectedCompareStatus` constructed a `z.enum` on every call, so every `git.status` and `git.branchCompare` reply paid the constructor. Hoisted to module constants; the git-status payload schema reuses the same instance. Behaviour is unchanged: same arms, same fallbacks, identical reader output on all eleven recorded matrix cases. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

What this is
Two reply-schema helpers built a
z.enum(...)inside the function that runs on every reply:readProjectedConflictOperationingit-status-reply-schema.tsandreadProjectedCompareStatusindiff-review-reply-schema.ts. Everygit.statusandgit.branchComparereply paid to construct a schema before using it. The enums are now module constants, and the git-status payload schema reuses the same instance instead of a second copy. Nine lines, two files, behaviour-identical; the comments explaining the coercion fallbacks are kept.Numbers
Median ns per parse, twenty timed rounds of two thousand parses after five warm-up rounds, same reader result digests on both legs:
git.status(branchContextStatusRead, 11 recorded cases, median)git.branchCompare(reviewBranchCompareRead, median)How it was found
A trial of zod's
z.compile(not adopted: 0.89x net across all recorded readers, and Hermes has nonew Functionso nothing JITs on device) showed these two readers regressing 2.2x under global compile, because compile shims every schema construction and these constructed one per parse. Removing the per-parse construction is the fix regardless of compile.Gates
Recording suites 23 files, 986 passed; zero goldens moved; source-control + session suites 196 files, 1875 passed; mobile
tsc0; oxfmt and oxlint clean; changed-code quality 0 findings. Lead re-verified in a clean tree under the pinned zod 4.4.3: tsc 0, 52 files / 1210 tests, zero goldens.