Repository navigation
test(mobile): typecheck the test files on a ratchet, and pin the reply enums where tsc looks - #21298
Conversation
mobile/tsconfig.json excludes *.test.ts, so a `Record<HostUnion, true>` coverage record in a schema test is never typechecked: the two that existed (SshConnectionStatus, GitHubProjectOwnerType) checked nothing, and the four closed enums beside them had only a doc citation of the host type. Each arm list moves into its schema module as hostUnionArms<Union>(), which #21269 introduced for the same reason, and each test iterates the exported list instead of holding its own copy: - SSH_CONNECTION_STATUS to SshConnectionStatus - PROJECT_OWNER_TYPE to GitHubProjectOwnerType - DETAIL_FILE_STATUS to GitHubPRFile['status'] - PUSH_TEST_REFUSAL_REASONS and PUSH_REGISTER_REFUSAL_REASONS to the refusal arms of MobilePushTestResult and MobilePushRegisterResult - SETUP_RUN_POLICIES to SetupRunPolicy openEnum's parameter widens from a non-empty tuple to `readonly string[]` so a hostUnionArms list can feed it. z.enum already accepts the same, so the tuple constraint only excluded callers zod itself takes; behaviour unchanged. Twelve mutations prove the pins: dropping one arm and adding a bogus one each fail mobile tsc in all six places. Zero goldens move, the schemas' behaviour being unchanged, and the 21 recording suites pass at the existing baseline. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Found by typechecking the tests for the first time (see the config that follows). All mechanical, none weakens a product type: - 67 `act(() => vi.advanceTimersByTime(...))` callbacks return VitestUtils where act wants void, so each becomes a block. The async ones await only a genuinely promise-returning call, so no extra microtask tick is introduced. - Four fixtures were stale against a product type that gained a required member: MobileViewState.alwaysShowDefaultBranch, PrSidebarData.checksError, the branch-compare summary's errorMessage, and SessionOptionDescriptor's transport, which #20884 added precisely so a producer could not inherit the wrong lane's rendering by omission. - `getLastConnectedAt` on the shared relay fake was typed `() => null`, which refused the timestamp two escalation suites assign to it. - Two holders used before assignment take `!`, one `advance!.kind === ...` becomes `advance?.kind`, one widened status arm takes `as const`, and the Expo notification fixture keeps `data` required because the dismissal cases assign through it. 631 test files pass, 6222 tests, unchanged. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
mobile/tsconfig.json excludes *.test.ts so Metro never compiles tests into the release bundle, and vitest transpiles without checking types. Nothing had ever typechecked a mobile test, which is why a `Record<HostUnion, true>` pin written in one proved nothing and why 144 of the 630 test files had drifted. tsconfig.test.json is that program with the tests put back, behind `typecheck:tests`. Four files stay out: they import the desktop main process or src/shared/child-process, which are written against @types/node, and this program's libs are React Native's, where setTimeout answers a number rather than a NodeJS.Timeout. Pulling that graph in reports ~280 errors about the desktop rather than about mobile; vitest runs those four under Node, which is where they belong. The CI gate is a ratchet rather than the raw typecheck, modelled on check-ts-nocheck-ratchet.mjs: 126 files still fail, so the gate freezes that set and fails when a file that checks today stops checking, or when a baseline entry starts checking and was not pruned. The list may only shrink. Why not zero: 180 of the remaining 510 errors are one seam — tests locate mocked react-native components by string name, which `ElementType` does not admit — and closing it means either 180 casts or a global JSX declaration for the mocked names. That is a design decision, not a mechanical fix, so it is left for a follow-up rather than made here. The rest are smaller clusters of the same kind: vi.fn mocks assigned into typed slots, call-arg tuple indexing, and createElement props fixtures. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The oracle section still quoted the corpus as 368 scenarios and 727 goldens; it is 393 and 778, and the three replay suites report 781 tests. Each number now names the command that measures it. "No golden carries one" was the load-bearing error: 44 goldens carry a recorded `reply-salvage` today, starting with the push-test unknown-reason scenario #21176 added for exactly that purpose. The paragraph claimed the observation pins an absence when on those families it pins a recorded drop. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The gate reads tsc's output, and tsc indents the "Overload 1 of 2, ..." detail under an error. Counting those as filenames would write unparseable entries into the baseline and leave the gate unprunable, so the parser is pinned on that shape as well as on the added/stale diff. Written against the gate itself: it flagged this file before the directive it carried was removed, which is the end-to-end proof the spawn half works. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
📝 WalkthroughWalkthroughThe mobile project adds a test TypeScript configuration and a ratchet command that compares current test failures with a 130-file baseline. CI and validation documentation run this check. Several mobile schemas now derive enum values from shared host contracts. Tests update timer handling, fixtures, snapshots, and type annotations. The RPC recording README updates corpus metrics and salvage statistics. Priority: ➖ Normal Merge Risk: 🔵 Low · up to A specific header style can let an unchecked test pass the typecheck ratchet. The localized fix should be made, but runtime behavior is unaffected. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 26.09% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 32 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 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.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8f16f4eb-31c1-44c1-b406-7215d6a76047
📒 Files selected for processing (38)
.github/workflows/mobile.ymlmobile/README.mdmobile/package.jsonmobile/scripts/check-tests-typecheck-ratchet.mjsmobile/scripts/check-tests-typecheck-ratchet.test.tsmobile/src/components/new-workspace-reply-schema.test.tsmobile/src/components/new-workspace-reply-schema.tsmobile/src/components/use-new-worktree-drawer-navigation.test.tsmobile/src/hooks/use-now.test.tsmobile/src/notifications/NotificationDeliverySection.test.tsxmobile/src/notifications/android-foreground-push.test.tsmobile/src/notifications/notification-reply-schema.test.tsmobile/src/notifications/notification-reply-schema.tsmobile/src/session/MobileNativeChatView.test.tsmobile/src/session/mobile-structured-grouped-question.test.tsmobile/src/session/mobile-terminal-records.test.tsmobile/src/session/use-mobile-native-chat-answer-send.test.tsmobile/src/session/use-mobile-native-chat-controller.test.tsmobile/src/session/use-mobile-native-chat-drafts.test.tsmobile/src/session/use-mobile-native-chat-file-search.test.tsmobile/src/session/use-mobile-native-chat-input-lease.test.tsmobile/src/session/use-mobile-native-chat-stop.test.tsmobile/src/session/use-throttled-latest-value.test.tsmobile/src/source-control/mobile-pr-chip-summary.test.tsmobile/src/source-control/mobile-source-control-primary-action.test.tsmobile/src/tasks/task-project-board-reply-schema.test.tsmobile/src/tasks/task-project-board-reply-schema.tsmobile/src/tasks/task-provider-entity-reply-schema.test.tsmobile/src/tasks/task-provider-entity-reply-schema.tsmobile/src/tasks/workspace-source-reply-schema.test.tsmobile/src/tasks/workspace-source-reply-schema.tsmobile/src/terminal/use-buffered-terminal-drafts.test.tsxmobile/src/test-support/rpc-recording/README.mdmobile/src/transport/mobile-endpoint-supervisor-test-fakes.tsmobile/src/worktree/workspace-view-settings.test.tsmobile/tests-typecheck-baseline.txtmobile/tsconfig.test.jsonsrc/shared/zod-salvage.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| const baseline = parseBaseline(fs.readFileSync(baselineFile, 'utf8')) | ||
| const current = collectCurrentFailingFiles(root) | ||
| const { added, stale } = diffBaseline(current, baseline) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- target script ---'
cat -n mobile/scripts/check-tests-typecheck-ratchet.mjs
printf '%s\n' '--- matching files ---'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
'check-tests-typecheck-ratchet|tests-typecheck-baseline|typecheck-ratchet|merge-base' .Repository: stablyai/orca
Length of output: 50369
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 28693
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- workflow references ---'
rg -n -C 8 'tests-typecheck|check:tests|typecheck' .github/workflows/mobile.yml .github/workflows/pr.yml
printf '%s\n' '--- package and README references ---'
rg -n -C 6 'tests-typecheck|typecheck:tests|ratchet|baseline' mobile/package.json mobile/README.md
printf '%s\n' '--- ratchet tests ---'
cat -n mobile/scripts/check-tests-typecheck-ratchet.test.ts
printf '%s\n' '--- targeted CI/config references ---'
rg -n -C 4 --glob '!mobile/rpc-foundation/**' \
'tests-typecheck-baseline|check:tests-typecheck|typecheck:tests|baseline.*shrink|shrink.*baseline' \
.github config mobileRepository: stablyai/orca
Length of output: 30620
Reject baseline additions against the PR base. The CI workflow runs only pnpm run check:tests-typecheck. The script compares current failures with the checked-out baseline, so adding a newly failing file to tests-typecheck-baseline.txt makes the sets match and returns success. Add a CI check that compares the PR baseline with the merge-base baseline and fails when the PR adds entries.
Rewriting `await act(async () => vi.advanceTimersByTimeAsync(n))` into a braced body left the returned promise floating at 27 sites, so the advance was no longer ordered before the assertions that follow it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Important
The new gate does not run on Windows. check-tests-typecheck-ratchet.mjs spawns node_modules/.bin/tsc directly (the extensionless shim is not spawnable there) and compares tsc's backslash paths against a forward-slash baseline, so pnpm run check:tests-typecheck crashes or fails for Windows developers even though ubuntu CI stays green. Two inline comments.
Reviewed changes
- Reply-enum pins move where tsc looks — six closed-enum arm lists (
SSH_CONNECTION_STATUS,PROJECT_OWNER_TYPE,DETAIL_FILE_STATUS,PUSH_TEST_REFUSAL_REASONS,PUSH_REGISTER_REFUSAL_REASONS,SETUP_RUN_POLICIES) becomehostUnionArms<HostUnion>({ ... })exports in their schema modules, checked by the main (non-test) program; the tests now iterate the exported list instead of holding the exhaustiveness pin. openEnumwidens toreadonly string[]— type-only change so ahostUnionArmslist can feed it; verified against the installed zod v4 (z.enum<const T extends readonly string[]>) that this is whatz.enumalready accepts.mobile/tsconfig.test.json+typecheck:tests— puts*.test.ts(x)back into a tsc program, excluding four Node-side tests that would drag the desktop/NodesetTimeoutlib conflict in.- Tests typecheck ratchet —
mobile/scripts/check-tests-typecheck-ratchet.mjsfreezes the 126 currently-failing test files inmobile/tests-typecheck-baseline.txt; fails on a newly-failing file and on a baseline entry that starts checking. Parser pinned bycheck-tests-typecheck-ratchet.test.ts, wired intomobile.yml. I reproduced it:mobile tests typecheck ratchet OK — 126 grandfathered file(s). - Eighteen test files fixed —
act()overloads wrapped in blocks, stale fixtures updated, nullable holders given definite-assignment assertions. - Recorder README counts corrected — I re-measured the tree and got 393 scenarios, 778 goldens, and 44
reply-salvagegoldens, matching the new text.
ℹ️ Nitpicks
check-tests-typecheck-ratchet.mjsis now the third near-verbatim copy of theparseBaseline/diffBaseline/printAddedFailure/printStaleFailure/writeBaseline/ CLI scaffold (config/scripts/check-ts-nocheck-ratchet.mjs,config/scripts/check-max-lines-ratchet.mjs). Extracting that scaffold into a shared module would keep the three in step; AGENTS.md's reuse rule points the same way.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
A wildcard `include` keeps only the higher-priority extension, so MobileHostCard.test.tsx sat outside every tsc program while MobileHostCard.test.ts existed beside it. Its one error is the same react-test-renderer seam its sibling is baselined for. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The ratchet diffs only files that error, so a test excluded from tsconfig.test.json or shadowed by a sibling extension left the gate silently. Every *.test.ts(x) on disk must now be in the program or named in TESTS_OUTSIDE_PROGRAM with its reason. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…hing openEnum takes a `const` T so a bare literal keeps its arms rather than widening to string. hostUnionArms blocks inference of U with NoInfer and defaults it to never, so a call that omits the host union — where the record would only pin itself — no longer compiles. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Widening the pre-existing cast made the changed-code gate attribute it as a new finding. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Replaces the `as unknown as` cast with Expo's own types, filling FirebaseRemoteMessage and its notification once in two builders, and passes the data payload in rather than mutating through an optional member. Typing the fixture showed one assertion comparing the scheduled content against the whole arriving content, which only held while the cast let the fixture omit the two members the presenter drops; it now names the four members the presenter forwards. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`advance?.kind` let an absent advance take the null-draft branch instead of failing. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Spawns tsc's JS entry on this Node instead of the node_modules/.bin shim, which is a POSIX shell script that Windows resolves to tsc.CMD and then appends .exe to. Parsed paths are normalised to POSIX so a Windows run does not read every baseline entry as both stale and added. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The nine commits since the prior pullfrog review (141665e) close out the mobile test-typecheck gate and harden the reply-enum pins.
- Ratchet runs on Windows —
check-tests-typecheck-ratchet.mjsresolvestypescript/lib/tsc.jsand spawns it onprocess.execPathwithshell: false(mobile pins TS 6.0.3, which has noexportsmap), instead of the POSIX.bin/tscshim, and normalises tsc's separators to POSIX before the baseline diff. Both prior review threads are retired. - Program census added —
collectTestFilesOnDisk/collectProgramTestFiles/diffCensusrequire every*.test.ts(x)on disk to be in the program or named inTESTS_OUTSIDE_PROGRAM, and flag a stale allowance; a test pins the allow-list againsttsconfig.test.json's exclude list entry for entry. - Shadowed suite unshadowed —
MobileHostCard.test.tsxwas in no tsc program (a wildcardincludedrops a.tsxbeside a same-basename.test.ts); renamedMobileHostCard-truthful-status.test.tsxand added to the baseline (126 → 127). - Enum helpers refuse vacuous calls —
openEnumtakesconst Tso a bare literal keeps its arms, andhostUnionArmsusesNoInferplus a conditional parameter so a call without an explicit union fails to compile. - Timer-advance order restored — the 27 sites where the
act()rewrite dropped the returned promise nowawait vi.advanceTimersByTimeAsync(...)inside the body, and the grouped-questionadvanceread is non-optional behind an explicittoBeDefined(). - Push fixtures typed —
android-foreground-push.test.tsbuilds realNotification/FirebaseRemoteMessageNotificationvalues instead of casts, and the scheduling assertion names the four members the presenter rebuilds. - Docs corrected — the recorder README describes the census and the 127-entry baseline.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
tsc exits 0 on a @ts-nocheck file, so a baselined test could be "fixed" with one line, pruned, and never checked again; the census now names any program test file whose leading comment carries the directive. `--noEmit --listFiles` answers both questions in one pass, so the gate spawns tsc once rather than twice. Corrects the two stale counts, and states hostUnionArms' real reason for living in the schema module now that tests are typechecked. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: ab36befc-ca76-49b3-a61e-33f72feddf13
📒 Files selected for processing (4)
.github/workflows/mobile.ymlmobile/scripts/check-tests-typecheck-ratchet.mjsmobile/scripts/check-tests-typecheck-ratchet.test.tssrc/shared/zod-salvage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- .github/workflows/mobile.yml
- src/shared/zod-salvage.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| if (!text.startsWith('//') && !text.startsWith('/*') && !text.startsWith('*')) { | ||
| return false |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '90,120p' mobile/scripts/check-tests-typecheck-ratchet.mjs
sed -n '155,180p' mobile/scripts/check-tests-typecheck-ratchet.test.ts
sed -n '270,310p' mobile/scripts/check-tests-typecheck-ratchet.mjs
rg -n 'ts-nocheck|commentDirective|processCommentPragmas' node_modules/typescript mobile/node_modules/typescript 2>/dev/null | head -80Repository: stablyai/orca
Length of output: 3380
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- package/version references ---'
rg -n -S --glob 'package.json' --glob 'package-lock.json' --glob 'yarn.lock' --glob 'pnpm-lock.yaml' 'typescript' . | head -80
printf '%s\n' '--- ratchet compiler flow ---'
rg -n -A12 -B8 'function collectTypecheckPass|collectTypecheckPass\\(|hasTsNocheckDirective|diffBaseline|tsc|typescript' mobile/scripts/check-tests-typecheck-ratchet.mjs mobile/scripts/check-tests-typecheck-ratchet.test.ts
printf '%s\n' '--- directive-related repository evidence ---'
rg -n -S --glob '*.ts' --glob '*.tsx' --glob '*.mjs' --glob '*.js' '`@ts-nocheck`|hasTsNocheckDirective' mobile | head -120
printf '%s\n' '--- relevant TypeScript configuration ---'
fd -i 'tsconfig*.json' mobile | head -40 | xargs -r -n1 sh -c 'echo "--- $0"; cat "$0"'Repository: stablyai/orca
Length of output: 6132
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- ratchet definitions and calls ---'
rg -n -F -e 'collectTypecheckPass' -e 'hasTsNocheckDirective' -e 'diffBaseline' -e 'typescript' mobile/scripts/check-tests-typecheck-ratchet.mjs mobile/scripts/check-tests-typecheck-ratchet.test.ts
printf '%s\n' '--- ratchet implementation ---'
sed -n '1,125p' mobile/scripts/check-tests-typecheck-ratchet.mjs
sed -n '250,305p' mobile/scripts/check-tests-typecheck-ratchet.mjs
printf '%s\n' '--- TypeScript configuration paths ---'
fd -i 'tsconfig*.json' mobile -x sh -c 'echo "--- $1"; cat "$1"' shRepository: stablyai/orca
Length of output: 9930
Handle unstarred lines in leading block comments.
The closing */ does not trigger this guard because it starts with *. However, a header such as:
/*
Header text.
*/
// `@ts-nocheck`returns false on Header text. before reading the directive. TypeScript still treats the directive as leading file trivia. findTsNocheckFiles then misses the file, so removing its baseline entry can let the ratchet accept an unchecked test. Track block-comment state or parse leading trivia, and add this case to the guard tests. Doc-style headers whose content lines start with * are already handled.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The one commit since the prior pullfrog review (1e73a6a), 75de009, closes the @ts-nocheck evasion hole and folds the ratchet's two tsc invocations into one.
- Single
tscpass —collectTypecheckPassrunstsc --noEmit --listFiles -p tsconfig.test.jsononce and splits the stream:parseProgramTestFilestakes the absolute--listFilespaths (prefix-stripped, POSIX-normalised, de-duped) as the census,parseFailingFilestakes the relative(line,col): errordiagnostics as the failing set.collectProgramTestFilesis gone;collectCurrentFailingFilesreuses the pass. @ts-nocheckguard —hasTsNocheckDirectivescans each program test file's leading comment block (stopping at the first non-comment line) for@ts-nocheck, andfindTsNocheckFilesfails the census when any is found, so a baselined test cannot be silenced with one line, pruned, and left unchecked. Verified against the repo's own TS 6.0.3 and 7.0.2: both honour only// @ts-nocheck, so the guard is conservative rather than leaky.- New pins — a mixed-stream test asserts the two parsers split one
--listFiles-plus-diagnostics stream correctly (including a Windows root), and four tests cover the@ts-nocheckscanner's line/block/code-after cases. - Counts and rationale —
mobile.ymland the script header now say 127 of 632 (was 126 of 630), and thehostUnionArmsJSDoc explains why the arm list lives in the schema module rather than its test.
No inline comments; the two prior Windows threads are resolved and the earlier approval stands.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…y enums where tsc looks (stablyai#21298) * fix(mobile): move the last six reply-enum pins where tsc looks mobile/tsconfig.json excludes *.test.ts, so a `Record<HostUnion, true>` coverage record in a schema test is never typechecked: the two that existed (SshConnectionStatus, GitHubProjectOwnerType) checked nothing, and the four closed enums beside them had only a doc citation of the host type. Each arm list moves into its schema module as hostUnionArms<Union>(), which stablyai#21269 introduced for the same reason, and each test iterates the exported list instead of holding its own copy: - SSH_CONNECTION_STATUS to SshConnectionStatus - PROJECT_OWNER_TYPE to GitHubProjectOwnerType - DETAIL_FILE_STATUS to GitHubPRFile['status'] - PUSH_TEST_REFUSAL_REASONS and PUSH_REGISTER_REFUSAL_REASONS to the refusal arms of MobilePushTestResult and MobilePushRegisterResult - SETUP_RUN_POLICIES to SetupRunPolicy openEnum's parameter widens from a non-empty tuple to `readonly string[]` so a hostUnionArms list can feed it. z.enum already accepts the same, so the tuple constraint only excluded callers zod itself takes; behaviour unchanged. Twelve mutations prove the pins: dropping one arm and adding a bogus one each fail mobile tsc in all six places. Zero goldens move, the schemas' behaviour being unchanged, and the 21 recording suites pass at the existing baseline. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): fix the type errors in eighteen test files Found by typechecking the tests for the first time (see the config that follows). All mechanical, none weakens a product type: - 67 `act(() => vi.advanceTimersByTime(...))` callbacks return VitestUtils where act wants void, so each becomes a block. The async ones await only a genuinely promise-returning call, so no extra microtask tick is introduced. - Four fixtures were stale against a product type that gained a required member: MobileViewState.alwaysShowDefaultBranch, PrSidebarData.checksError, the branch-compare summary's errorMessage, and SessionOptionDescriptor's transport, which stablyai#20884 added precisely so a producer could not inherit the wrong lane's rendering by omission. - `getLastConnectedAt` on the shared relay fake was typed `() => null`, which refused the timestamp two escalation suites assign to it. - Two holders used before assignment take `!`, one `advance!.kind === ...` becomes `advance?.kind`, one widened status arm takes `as const`, and the Expo notification fixture keeps `data` required because the dismissal cases assign through it. 631 test files pass, 6222 tests, unchanged. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): typecheck the test files, on a ratchet mobile/tsconfig.json excludes *.test.ts so Metro never compiles tests into the release bundle, and vitest transpiles without checking types. Nothing had ever typechecked a mobile test, which is why a `Record<HostUnion, true>` pin written in one proved nothing and why 144 of the 630 test files had drifted. tsconfig.test.json is that program with the tests put back, behind `typecheck:tests`. Four files stay out: they import the desktop main process or src/shared/child-process, which are written against @types/node, and this program's libs are React Native's, where setTimeout answers a number rather than a NodeJS.Timeout. Pulling that graph in reports ~280 errors about the desktop rather than about mobile; vitest runs those four under Node, which is where they belong. The CI gate is a ratchet rather than the raw typecheck, modelled on check-ts-nocheck-ratchet.mjs: 126 files still fail, so the gate freezes that set and fails when a file that checks today stops checking, or when a baseline entry starts checking and was not pruned. The list may only shrink. Why not zero: 180 of the remaining 510 errors are one seam — tests locate mocked react-native components by string name, which `ElementType` does not admit — and closing it means either 180 casts or a global JSX declaration for the mocked names. That is a design decision, not a mechanical fix, so it is left for a follow-up rather than made here. The rest are smaller clusters of the same kind: vi.fn mocks assigned into typed slots, call-arg tuple indexing, and createElement props fixtures. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * docs(mobile-recorder): correct the corpus counts and the salvage claim The oracle section still quoted the corpus as 368 scenarios and 727 goldens; it is 393 and 778, and the three replay suites report 781 tests. Each number now names the command that measures it. "No golden carries one" was the load-bearing error: 44 goldens carry a recorded `reply-salvage` today, starting with the push-test unknown-reason scenario stablyai#21176 added for exactly that purpose. The paragraph claimed the observation pins an absence when on those families it pins a recorded drop. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): pin the tests-typecheck ratchet's parser The gate reads tsc's output, and tsc indents the "Overload 1 of 2, ..." detail under an error. Counting those as filenames would write unparseable entries into the baseline and leave the gate unprunable, so the parser is pinned on that shape as well as on the added/stale diff. Written against the gate itself: it flagged this file before the directive it carried was removed, which is the end-to-end proof the spawn half works. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): await the timer advances the act() rewrite dropped Rewriting `await act(async () => vi.advanceTimersByTimeAsync(n))` into a braced body left the returned promise floating at 27 sites, so the advance was no longer ordered before the assertions that follow it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): unshadow MobileHostCard's .tsx suite A wildcard `include` keeps only the higher-priority extension, so MobileHostCard.test.tsx sat outside every tsc program while MobileHostCard.test.ts existed beside it. Its one error is the same react-test-renderer seam its sibling is baselined for. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): census every test file into the typecheck program The ratchet diffs only files that error, so a test excluded from tsconfig.test.json or shadowed by a sibling extension left the gate silently. Every *.test.ts(x) on disk must now be in the program or named in TESTS_OUTSIDE_PROGRAM with its reason. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(shared): make the enum helpers refuse the ways they can prove nothing openEnum takes a `const` T so a bare literal keeps its arms rather than widening to string. hostUnionArms blocks inference of U with NoInfer and defaults it to never, so a call that omits the host union — where the record would only pin itself — no longer compiles. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * docs(mobile): describe the census and correct the baseline count Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): give the push fixture cast its SAFETY rationale Widening the pre-existing cast made the changed-code gate attribute it as a new finding. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): build the push fixtures as typed notifications Replaces the `as unknown as` cast with Expo's own types, filling FirebaseRemoteMessage and its notification once in two builders, and passes the data payload in rather than mutating through an optional member. Typing the fixture showed one assertion comparing the scheduled content against the whole arriving content, which only held while the cast let the fixture omit the two members the presenter drops; it now names the four members the presenter forwards. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): keep the grouped-question advance read non-optional `advance?.kind` let an absent advance take the null-draft branch instead of failing. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(mobile): run the tests-typecheck ratchet on Windows Spawns tsc's JS entry on this Node instead of the node_modules/.bin shim, which is a POSIX shell script that Windows resolves to tsc.CMD and then appends .exe to. Parsed paths are normalised to POSIX so a Windows run does not read every baseline entry as both stale and added. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): close the ratchet's @ts-nocheck hole and read tsc once tsc exits 0 on a @ts-nocheck file, so a baselined test could be "fixed" with one line, pruned, and never checked again; the census now names any program test file whose leading comment carries the directive. `--noEmit --listFiles` answers both questions in one pass, so the gate spawns tsc once rather than twice. Corrects the two stale counts, and states hostUnionArms' real reason for living in the schema module now that tests are typechecked. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

What this is
Two wrap-up items of the mobile RPC-foundation series, both about the same blind spot:
mobile/tsconfig.jsonexcludes*.test.ts, so nothing has ever typechecked mobile's tests, and vitest does not either.Part 1: the enum pins move to where tsc looks
The step-7 lanes put
Record<HostUnion, true>coverage pins in schema tests to prove each closed reply enum matched the host's union. Those pins were never typechecked; a mutation that dropped a key stayed green. #21269 introducedhostUnionArms<Union>({ arm: true, … })insrc/shared/zod-salvage.tsand used it for its own batch. This PR moves the remaining six into their schema modules: SSH connection status, project owner type, PR file status, both push refusal-reason vocabularies, and the New Workspace setup run policy.openEnumwidens from a non-empty tuple toreadonly string[]so a pinned list can feed it (z.enumalready accepted that). Twelve mutations, a dropped key and an added key for each of the six, each fail mobiletsc. Zero goldens moved: the schemas' runtime behaviour is unchanged.Part 2: typecheck the tests, on a ratchet
mobile/tsconfig.test.jsonextends the main config and includes the test files;pnpm run typecheck:testsruns it. Run raw before any fixing it reported 869 errors. 281 sit in desktop files undersrc/mainandsrc/shared, dragged in by four Node-side tests, and are a lib conflict (React Native'ssetTimeoutanswers a number, Node's aTimeout), not defects; those four are excluded from the test program. That leaves 587 errors in 144 of 630 test files, by class:ElementTypefor components located by string nameTS2345,TS2322), mostlyvi.fninto typed slotsact()overload (callback returningVitestUtils)18 files are fixed outright here, including four fixtures that had gone stale against a product type that gained a required member. The 180-error
ElementTypeclass needs either 180 casts or a global JSX declaration for the mocked component names, which is a design decision, so the gate is a ratchet:scripts/check-tests-typecheck-ratchet.mjsfails when a file that checks today stops checking, and when a grandfathered entry inmobile/tests-typecheck-baseline.txtstarts checking without being pruned. Both directions are proved (breaking a clean test fires it; it caught this PR's own new test file before it was fixed). Post-fix: 510 errors in 127 grandfathered files. The gate also takes a census before diffing: every*.test.ts(x)on disk must be in the program or named inTESTS_OUTSIDE_PROGRAMwith its reason, so excluding a clean test cannot hide it. The census caught one on its first run:MobileHostCard.test.tsxwas in no tsc program at all because a wildcard include keeps only one of two files sharing a basename, andMobileHostCard.test.tssat beside it; it is renamedMobileHostCard-truthful-status.test.tsxand joins the baseline. The script spawnstypescript/lib/tsc.jsonprocess.execPath(no.binshim, so it runs on Windows) and normalises paths to POSIX. The parser and census are pinned bycheck-tests-typecheck-ratchet.test.ts(13 tests). CI: one step inmobile.ymlafter the existing typecheck.Also
The recorder README's counts are corrected with the command that measures each (368 → 393 scenarios, 727 → 778 goldens), and its claim that no golden carries a recorded salvage drop is replaced: 44 do, starting with the unknown-reason push scenario #21176 recorded for that purpose. One figure ("19,384 checked reads") could not be recounted from the tree, so the sentence is replaced rather than restated.
Gates
Mobile
tsc0 · roottsconfig.node.json0 · ratchet OK at 126 · full mobilevitest run632 files, 6228 passed, 6 skipped ·oxfmt --checkclean ·oxlintclean onsrc,scriptsand the shared salvage module · zero goldens changed againstorigin/main. Lead reproduced the ratchet, the parser test, tsc, and one dropped-key mutation.Review
Round 1 (adversarial): ship after fixes, all applied. F1, the real one: the
act()overload fix had rewrittenawait act(async () => vi.advanceTimersByTimeAsync(n))into a braced body that dropped the returned promise at 27 sites in three native-chat suites; the advance still completed insideact's microtask flush today, so nothing was red, but the ordering was incidental rather than guaranteed. All 27 nowawaitinside the body, and the debounce boundary test is proved to bite (advancing 119 then 0 instead of 119 then 1 fails it). F2: the ratchet had no census, so an excluded clean test would vanish silently; added, and it found the shadowed suite above. F4/F5:openEnumtakesconst Tso a bare literal keeps its arms, andhostUnionArmsrefuses a call without an explicit union (NoInferplus a conditional parameter; theneverdefault alone did nothing becauseRecord<never, true>is{}). Nits: the grouped-questionadvanceread is non-optional again behind anexpect(advance).toBeDefined(); the push-notification fixture is built as a realNotificationwith no cast, which exposed an assertion that only passed because the cast let the fixture omit two members (it now names the four members the presenter rebuilds). pullfrog: the ratchet spawned the POSIX.bin/tscshim and kept tsc's\paths, both fixed as above with a Windows-style parser sample.Round 2 (fresh reviewer): ship as-is. Re-derived the six host unions (each a closed literal union in
src/shared/), compiled twelve probes outside the repo with the repo's tsc (dropped key, added key, omitted type argument, wrong value,openEnumwith a non-arm fallback all fail; arms survive intoz.output), re-parsed raw tsc output with an independent pipeline (511 errors, exactly the 127 baselined files, zero non-test files), and drovemain()on synthetic roots to prove it fails closed on a missing baseline and an unloadable project. Five nits folded: two stale counts in comments, a census guard against// @ts-nocheck(which would have let a baselined test be "fixed" with one line and never checked again), one tsc spawn instead of two, and thehostUnionArmscomment's rationale.Ticket, not here:
mobile.yml'spathsfilter omits the host modules the pins import, so a desktop-only PR adding an arm does not trigger the mobile typecheck (pre-existing: mobile prod code already imported all five).