Skip to content

test(mobile): typecheck the test files on a ratchet, and pin the reply enums where tsc looks - #21298

Merged
Jinwoo-H merged 15 commits into
mainfrom
mobile-tests-tsc
Sep 17, 2026
Merged

Jinwoo-H merged 15 commits into
mainfrom
mobile-tests-tsc

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​517 $\color{#cf222e}{\Huge{\mathbf{−}}}$​125 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​392
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​603 $\color{#cf222e}{\Huge{\mathbf{−}}}$​60 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​543

What this is

Two wrap-up items of the mobile RPC-foundation series, both about the same blind spot: mobile/tsconfig.json excludes *.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 introduced hostUnionArms<Union>({ arm: true, … }) in src/shared/zod-salvage.ts and 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. openEnum widens from a non-empty tuple to readonly string[] so a pinned list can feed it (z.enum already accepted that). Twelve mutations, a dropped key and an added key for each of the six, each fail mobile tsc. Zero goldens moved: the schemas' runtime behaviour is unchanged.

Part 2: typecheck the tests, on a ratchet

mobile/tsconfig.test.json extends the main config and includes the test files; pnpm run typecheck:tests runs it. Run raw before any fixing it reported 869 errors. 281 sit in desktop files under src/main and src/shared, dragged in by four Node-side tests, and are a lib conflict (React Native's setTimeout answers a number, Node's a Timeout), not defects; those four are excluded from the test program. That leaves 587 errors in 144 of 630 test files, by class:

class count
react-test-renderer ElementType for components located by string name 180
mock / fixture assignment (TS2345, TS2322), mostly vi.fn into typed slots 182
act() overload (callback returning VitestUtils) 67
nullable renderer holders; component-prop fixtures; missing property 24 / 24 / 20
mock-not-callable, tuple indexing, createElement children, implicit any, missing fixture member, unrelated casts 15 / 12 / 11 / 9 / 9 / 9

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 ElementType class 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.mjs fails when a file that checks today stops checking, and when a grandfathered entry in mobile/tests-typecheck-baseline.txt starts 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 in TESTS_OUTSIDE_PROGRAM with its reason, so excluding a clean test cannot hide it. The census caught one on its first run: MobileHostCard.test.tsx was in no tsc program at all because a wildcard include keeps only one of two files sharing a basename, and MobileHostCard.test.ts sat beside it; it is renamed MobileHostCard-truthful-status.test.tsx and joins the baseline. The script spawns typescript/lib/tsc.js on process.execPath (no .bin shim, so it runs on Windows) and normalises paths to POSIX. The parser and census are pinned by check-tests-typecheck-ratchet.test.ts (13 tests). CI: one step in mobile.yml after 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 tsc 0 · root tsconfig.node.json 0 · ratchet OK at 126 · full mobile vitest run 632 files, 6228 passed, 6 skipped · oxfmt --check clean · oxlint clean on src, scripts and the shared salvage module · zero goldens changed against origin/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 rewritten await 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 inside act's microtask flush today, so nothing was red, but the ordering was incidental rather than guaranteed. All 27 now await inside 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: openEnum takes const T so a bare literal keeps its arms, and hostUnionArms refuses a call without an explicit union (NoInfer plus a conditional parameter; the never default alone did nothing because Record<never, true> is {}). Nits: the grouped-question advance read is non-optional again behind an expect(advance).toBeDefined(); the push-notification fixture is built as a real Notification with 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/tsc shim 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, openEnum with a non-arm fallback all fail; arms survive into z.output), re-parsed raw tsc output with an independent pipeline (511 errors, exactly the 127 baselined files, zero non-test files), and drove main() 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 the hostUnionArms comment's rationale.

Ticket, not here: mobile.yml's paths filter 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).

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
@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The 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 75de0

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: ratcheted mobile test typechecking and reply-enum pinning.
Description check ✅ Passed The description is detailed and covers the changes, rationale, testing, review findings, cross-platform behavior, and unchanged runtime behavior. It does not use all template headings and does not inc…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8f16f4eb-31c1-44c1-b406-7215d6a76047

📥 Commits

Reviewing files that changed from the base of the PR and between eabfbaa and 141665e.

📒 Files selected for processing (38)
  • .github/workflows/mobile.yml
  • mobile/README.md
  • mobile/package.json
  • mobile/scripts/check-tests-typecheck-ratchet.mjs
  • mobile/scripts/check-tests-typecheck-ratchet.test.ts
  • mobile/src/components/new-workspace-reply-schema.test.ts
  • mobile/src/components/new-workspace-reply-schema.ts
  • mobile/src/components/use-new-worktree-drawer-navigation.test.ts
  • mobile/src/hooks/use-now.test.ts
  • mobile/src/notifications/NotificationDeliverySection.test.tsx
  • mobile/src/notifications/android-foreground-push.test.ts
  • mobile/src/notifications/notification-reply-schema.test.ts
  • mobile/src/notifications/notification-reply-schema.ts
  • mobile/src/session/MobileNativeChatView.test.ts
  • mobile/src/session/mobile-structured-grouped-question.test.ts
  • mobile/src/session/mobile-terminal-records.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.test.ts
  • mobile/src/session/use-mobile-native-chat-controller.test.ts
  • mobile/src/session/use-mobile-native-chat-drafts.test.ts
  • mobile/src/session/use-mobile-native-chat-file-search.test.ts
  • mobile/src/session/use-mobile-native-chat-input-lease.test.ts
  • mobile/src/session/use-mobile-native-chat-stop.test.ts
  • mobile/src/session/use-throttled-latest-value.test.ts
  • mobile/src/source-control/mobile-pr-chip-summary.test.ts
  • mobile/src/source-control/mobile-source-control-primary-action.test.ts
  • mobile/src/tasks/task-project-board-reply-schema.test.ts
  • mobile/src/tasks/task-project-board-reply-schema.ts
  • mobile/src/tasks/task-provider-entity-reply-schema.test.ts
  • mobile/src/tasks/task-provider-entity-reply-schema.ts
  • mobile/src/tasks/workspace-source-reply-schema.test.ts
  • mobile/src/tasks/workspace-source-reply-schema.ts
  • mobile/src/terminal/use-buffered-terminal-drafts.test.tsx
  • mobile/src/test-support/rpc-recording/README.md
  • mobile/src/transport/mobile-endpoint-supervisor-test-fakes.ts
  • mobile/src/worktree/workspace-view-settings.test.ts
  • mobile/tests-typecheck-baseline.txt
  • mobile/tsconfig.test.json
  • src/shared/zod-salvage.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

Comment on lines +121 to +123
const baseline = parseBaseline(fs.readFileSync(baselineFile, 'utf8'))
const current = collectCurrentFailingFiles(root)
const { added, stale } = diffBaseline(current, baseline)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 mobile

Repository: 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) become hostUnionArms<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.
  • openEnum widens to readonly string[] — type-only change so a hostUnionArms list can feed it; verified against the installed zod v4 (z.enum<const T extends readonly string[]>) that this is what z.enum already 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/Node setTimeout lib conflict in.
  • Tests typecheck ratchet — mobile/scripts/check-tests-typecheck-ratchet.mjs freezes the 126 currently-failing test files in mobile/tests-typecheck-baseline.txt; fails on a newly-failing file and on a baseline entry that starts checking. Parser pinned by check-tests-typecheck-ratchet.test.ts, wired into mobile.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-salvage goldens, matching the new text.

ℹ️ Nitpicks

  • check-tests-typecheck-ratchet.mjs is now the third near-verbatim copy of the parseBaseline / 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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
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
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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.mjs resolves typescript/lib/tsc.js and spawns it on process.execPath with shell: false (mobile pins TS 6.0.3, which has no exports map), instead of the POSIX .bin/tsc shim, and normalises tsc's separators to POSIX before the baseline diff. Both prior review threads are retired.
  • Program census added — collectTestFilesOnDisk / collectProgramTestFiles / diffCensus require every *.test.ts(x) on disk to be in the program or named in TESTS_OUTSIDE_PROGRAM, and flag a stale allowance; a test pins the allow-list against tsconfig.test.json's exclude list entry for entry.
  • Shadowed suite unshadowed — MobileHostCard.test.tsx was in no tsc program (a wildcard include drops a .tsx beside a same-basename .test.ts); renamed MobileHostCard-truthful-status.test.tsx and added to the baseline (126 → 127).
  • Enum helpers refuse vacuous calls — openEnum takes const T so a bare literal keeps its arms, and hostUnionArms uses NoInfer plus 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 now await vi.advanceTimersByTimeAsync(...) inside the body, and the grouped-question advance read is non-optional behind an explicit toBeDefined().
  • Push fixtures typed — android-foreground-push.test.ts builds real Notification / FirebaseRemoteMessageNotification values 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.

Pullfrog  | View workflow run | Using 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: ab36befc-ca76-49b3-a61e-33f72feddf13

📥 Commits

Reviewing files that changed from the base of the PR and between 1e73a6a and 75de009.

📒 Files selected for processing (4)
  • .github/workflows/mobile.yml
  • mobile/scripts/check-tests-typecheck-ratchet.mjs
  • mobile/scripts/check-tests-typecheck-ratchet.test.ts
  • src/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.

Comment on lines +101 to +102
if (!text.startsWith('//') && !text.startsWith('/*') && !text.startsWith('*')) {
return false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 -80

Repository: 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"' sh

Repository: 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 tsc pass — collectTypecheckPass runs tsc --noEmit --listFiles -p tsconfig.test.json once and splits the stream: parseProgramTestFiles takes the absolute --listFiles paths (prefix-stripped, POSIX-normalised, de-duped) as the census, parseFailingFiles takes the relative (line,col): error diagnostics as the failing set. collectProgramTestFiles is gone; collectCurrentFailingFiles reuses the pass.
  • @ts-nocheck guard — hasTsNocheckDirective scans each program test file's leading comment block (stopping at the first non-comment line) for @ts-nocheck, and findTsNocheckFiles fails 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-nocheck scanner's line/block/code-after cases.
  • Counts and rationale — mobile.yml and the script header now say 127 of 632 (was 126 of 630), and the hostUnionArms JSDoc 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 40b2230 into main Sep 17, 2026
30 checks passed
@Jinwoo-H
Jinwoo-H deleted the mobile-tests-tsc branch September 17, 2026 22:58
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
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