Skip to content

fix(folder-workspaces): keep the broken-folder marker when a host sends a new reason - #15027

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/folder-status-guard
Aug 17, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/folder-status-guard

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​176 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​176
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​56 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​41

The defect

FolderWorkspacePathStatus reaches the renderer through a cast, not a decode. src/shared/runtime-rpc-envelope.ts:26 declares result: z.unknown() inside the zod-validated success envelope, so unwrapRuntimeRpcResult hands back whatever the host sent as TResult. Both fetch sites — src/renderer/src/store/slices/repos.ts:1658 and :2580 — do callRuntimeRpc<{ status: FolderWorkspacePathStatus }>(...). Clients and hosts update independently, so a newer host publishing a fifth reason reaching an older client is the normal state, not an edge case.

getFolderWorkspacePathStatusTitle and getFolderWorkspacePathStatusDescription switched on status.reason with no runtime guard. An unrecognized reason matched nothing and the functions returned undefined. FolderPathStatusIndicator.tsx:20 then hits if (!status || status.exists || !title) return null — the indicator does not render at all, and a broken folder workspace shows as healthy in the sidebar.

That is worse than the blank-toast bug #15002 just fixed: there the warning was empty, here it is gone. The red run for the new component test prints expected '' not to be '' — the marker renders as literally empty markup on main.

Two more consumers of the same two functions were silently degraded by this: worktree-activation.ts:95 (which has ?? fallbacks, so it degraded rather than vanished) and folder-workspace-composer-path-status.ts:128 (whose title && … guard nulled the whole composer error). Fixing the source repairs all three.

The fix

One shared guard, isHandledWireDiscriminant in src/shared/handled-wire-discriminant.ts, applied at all four switches — the two here, and the two #15002 landed. #15002 had to hand-write its guard twice; this change would have made it four bespoke copies. Extracting it makes the lesson structural instead of tribal.

export function isHandledWireDiscriminant<T extends string>(
  value: unknown,
  handled: Record<T, true>
): value is T {
  return typeof value === 'string' && Object.hasOwn(handled, value)
}

typeof first is load-bearing. Object.hasOwn coerces its key, so a guard typed (x: string) accepts ['missing'], whose toString() matches a handled key — and the value then falls straight back out of the switch, reintroducing the exact bug. That was the P1 found in review on #15002 after the author's own verification missed it. There is now one implementation of it that cannot drift.

A default: arm is not available, confirmed empirically here rather than assumed: injecting one into this file produces

src/renderer/src/lib/folder-workspace-path-status.ts:30:5: error typescript(switch-exhaustiveness-check):
The switch statement is exhaustive, so the default case is unnecessary.

because config/oxlint-code-quality-type-aware.json sets allowDefaultCaseForExhaustiveSwitch: false. A guard before the switch is the shape that satisfies both the lint rule and the wire.

A readonly Reason[] plus Array.includes is the other obvious shape, and it gets coercion-safety for free (includes uses SameValueZero, so an array is never equal to a string). It was rejected because it gives up the property that matters most here: const X: readonly Reason[] = ['missing', ...] compiles happily while missing a union member, so a fifth reason would land silently. The Record<Union, true> form makes a missing member a type error, and the explicit typeof check buys back the coercion safety the array form would have given.

Adding a fifth reason still fails typecheck in two places. Verified by temporarily widening the union:

folder-workspace-path-status.ts(11,7): error TS2741: Property '"permission-denied"' is missing in type
  '{ missing: true; 'not-directory': true; unavailable: true; 'ambiguous-connection': true; }'
  but required in type 'Record<FolderWorkspacePathStatusReason, true>'.
folder-workspace-path-status.ts(25,4): error TS2366: Function lacks ending return statement...
folder-workspace-path-status.ts(61,4): error TS2366: Function lacks ending return statement...
folder-workspace-path-status.ts:37:11: error typescript(switch-exhaustiveness-check): Switch is not exhaustive. Cases not matched: "permission-denied"
folder-workspace-path-status.ts:72:11: error typescript(switch-exhaustiveness-check): Switch is not exhaustive. Cases not matched: "permission-denied"

Why new copy instead of reusing unavailable

Reusing the existing unavailable strings would have avoided two new keys, and that is a real cost. It loses on remedy accuracy, which matters more here:

  • unavailable's description is "Orca cannot verify this folder right now. Check the runtime or SSH connection and try again." But the host did verify — it returned exists: false with a definite reason. It is this client that cannot name it. Sending the user to inspect a healthy SSH connection and retry is a false lead that costs them time and does not fix anything.
  • The actual remedy is to update Orca, which is also the remedy fix(browser): keep cookie-import warnings readable from newer hosts #15002 chose for the same situation.
  • STYLEGUIDE.md requires displayed copy to be "concise and specific"; Cannot check folder is neither, applied to a folder the host checked.

New strings, following the #15002 precedent:

  • title unrecognized: Folder is not usable
  • description unrecognized: Orca cannot use {{path}}, and this version does not recognize the reason. Update Orca to see the details.

The indicator still renders, and isConfirmedStaleFolderPathStatus returning false keeps it on the neutral text-muted-foreground style rather than the destructive one — an imprecise visible warning, which beats a silently missing one.

isConfirmedStaleFolderPathStatus and blocksFolderWorkspaceActivation are safe, and here is why

Both consume the same cast value, but they are not the same class of exposure. The switches lost all output on a miss; these two have a well-defined false fallback that is exactly the behavior already chosen deliberately for unavailable.

  • isConfirmedStaleFolderPathStatus returns false for an unrecognized reason. That is literally correct by the function's own contract: an unknown reason is by definition not confirmed stale. The only effect is that the indicator renders muted rather than destructive — the correct call when we cannot tell.
  • blocksFolderWorkspaceActivation returns false, so activation stays permitted. This is deliberate fail-open, matching unavailable and absent-reason. Flipping it to fail-closed would lock a user out of a working folder workspace the moment a host adds a benign informational reason, and the operation would surface its own error anyway if the folder really is gone. Fail-open on activation plus fail-visible on the warning is the right split; this PR only had to repair the second half.

An explicit reason: null stays in the unrecognized bucket, deliberately

reason is optional, so null is a shape a differently-implemented host could put on the wire. It is tempting to fold null in with undefined, but that would reintroduce the bug: TypeScript sees reason as Reason | undefined, so case undefined: does not match null, and a null admitted by the guard would fall straight back out of the switch. Routing null to the unrecognized copy is the shape that cannot fall through.

Sweep for other switches on this wire

In this defect's blast radius (fixed here): the two switches in folder-workspace-path-status.ts. The other four readers of FolderWorkspacePathStatus.reason (SectionHeader.tsx:73, folder-row.tsx:67, folder-workspace-composer-path-status.ts:118,124, and the two shared predicates) are equality comparisons with a defined false branch, not switches — same fail-open reasoning as above.

Found, out of scope, filed for follow-up: sshHealth in src/shared/execution-host-registry.ts:113 is a genuine same-class exposure on a different wire field. SshConnectionState arrives cast from callRuntimeRpc<{ state: SshConnectionState | null }> at runtime-environment-ssh-state.ts:83 and :278. Its switch is exhaustive over eight SshConnectionStatus members plus undefined, with no guard, and its result is assigned straight into the non-nullable health: ExecutionHostHealth at :278. A ninth status from a newer host yields health: undefined, and setHost's if (existing.health !== 'disconnected') return then prevents any later registration from upgrading it. Not fixed here — different feature, different wire field.

runtimeControlHealth at :99 reads the same kind of wire value but is benign: its undefined is absorbed by controlHealth ?? runtimeHealth(...) at :167.

Checked and cleared — their discriminants are computed in the local main process or in-renderer, not published by a paired host: external-automation-display.ts:37,50 (ExternalAutomationRunStatus, produced by the local external manager over ipcRenderer.invoke), skill-install-result-label.ts:4, skill-freshness-scan-issues.tsx:5, project-skill-runtime.ts:66, and local-base-ref-refresh-toast.ts:9.

Tests

Each new wire test was proven red against main's version of the source file only, with the test files untouched:

× still titles a broken folder when a newer host sends an undeclared reason
    AssertionError: expected 'undefined' to be 'string'
× does not admit a non-string reason through the membership guard
    AssertionError: expected 'undefined' to be 'string'
× still describes a broken folder when a newer host sends an undeclared reason
    AssertionError: expected 'undefined' to be 'string'
× does not admit a non-string reason through the membership guard
    AssertionError: expected 'undefined' to be 'string'
× still renders the marker when a newer host sends an undeclared reason
    AssertionError: expected '' not to be ''
× still renders the marker when the wire carries a non-string reason
    AssertionError: expected '' not to be ''
Tests  6 failed | 5 passed (11)

Green on this branch, together with #15002's unchanged tests — which is the proof that moving its two guards onto the shared helper kept behavior identical:

Test Files  6 passed (6)
     Tests  43 passed (43)

The ['missing'] cases are the P1 from #15002, now covered at both call sites and at the indicator.

src/shared/handled-wire-discriminant.test.ts pins the shared primitive's own contract, including the case none of the call-site tests reach: Object.hasOwn, not in, so 'toString' / 'constructor' / '__proto__' are not handled members.

The typeof check was mutation-tested rather than assumed. Replacing the helper body with Object.hasOwn(handled, value as string) fails six tests across all four call sites plus the helper's own:

× rejects a non-string the wire can carry
× still warns when a newer host sends the reason as an array
× still warns when a newer host sends the warning code as an array
× does not admit a non-string reason through the membership guard   (title)
× does not admit a non-string reason through the membership guard   (description)
× still renders the marker when the wire carries a non-string reason
Tests  6 failed | 19 passed (25)

Gates

$ node config/scripts/check-changed-code-quality.mjs
code quality: 0 new finding(s) across 5 changed file(s).
type-aware code quality: 0 new finding(s) across 5 changed file(s).
React Doctor: 0 new finding(s) across 5 changed file(s).
Changed-code quality gate passed since 81d7f9b24eb3.

$ pnpm run typecheck            # node_modules/.bin/tsc verified present first
REAL EXIT CODE: 0

$ npx vitest run --config config/vitest.config.ts <affected>
Test Files  12 passed (12)
     Tests  83 passed (83)

$ pnpm run verify:localization-catalog        EXIT 0
$ pnpm run verify:localization-extraction     EXIT 0
$ pnpm run verify:localization-coverage       EXIT 0
Localization coverage check passed with 12 allowlisted candidates.

A follow-up worth noting for the composer: with the fix, folder-workspace-composer-path-status.ts:128 now produces a non-null pathStatusProjectError for an unrecognized reason where it previously produced null. That surfaces as invalid styling plus a message on the project field (NewWorkspaceComposerCard.tsx:704,707) and does not newly block creation — createDisabled is driven by pathStatusBlocksCreate, which this PR does not touch. Verified by reading both consumers.

The first typecheck run caught a real error in the new .tsx test (TS6133: 'React' is declared but its value is never read), which is worth noting: src/**/*.test.tsx is typechecked, unlike tests/.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c8f9026f-98a1-4cb9-b19d-bbb9212a3e69

📥 Commits

Reviewing files that changed from the base of the PR and between 3d80a01ce3f1b4c86db73ae90b7bcd41203eda2a and 2e04374.

📒 Files selected for processing (2)
  • src/renderer/src/components/sidebar/worktree-list/rows/FolderPathStatusIndicator.test.tsx
  • src/shared/handled-wire-discriminant.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/sidebar/worktree-list/rows/FolderPathStatusIndicator.test.tsx

Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a shared type guard for validating string wire discriminants against handled records. Cookie import warning paths now use the shared guard. Folder workspace path-status handling adds fallbacks for unknown or non-string reasons. English localization adds unrecognized status text and expands unavailable status guidance. Tests cover status titles, descriptions, indicators, accessibility labels, styling, and healthy folders.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the defect, fix, scope, and tests, but omits required template sections including the linked issue, visual proof, and checklist. Add the required Fixes #... issue link, visual proof or an N/A rationale, and complete the remaining required template sections and checklist.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the fix for preserving broken-folder markers when hosts send new reasons.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

…ds a new reason

FolderWorkspacePathStatus is cast, not decoded, off the runtime RPC wire --
runtime-rpc-envelope declares result: z.unknown(), so unwrapRuntimeRpcResult hands
back whatever the host sent. Both title and description switch on status.reason with
no runtime guard, so a newer host publishing a fifth reason matched nothing and
returned undefined. FolderPathStatusIndicator's `!title` check then dropped the whole
indicator, and a broken folder workspace rendered as healthy -- worse than the blank
toast #15002 fixed, because there the warning was empty and here it is gone.

Guard before each switch, the shape #15002 landed. A default: arm is not available:
the type-aware config sets allowDefaultCaseForExhaustiveSwitch:false and rejects one
with switch-exhaustiveness-check.

Extract that guard into isHandledWireDiscriminant instead of hand-writing a third and
fourth copy, and move #15002's two bespoke guards onto it. It takes unknown and checks
typeof before Object.hasOwn -- hasOwn coerces its key, so a host that widened the field
to an array sends ['missing'], which a hasOwn-only guard admits before the switch drops
it straight back out. That was the P1 found in review on #15002; one implementation
makes it structural instead of tribal.

An unrecognized reason gets its own copy rather than reusing 'unavailable'. The
unavailable remedy -- "Check the runtime or SSH connection and try again" -- is a false
lead here: the host did check and reported the folder unusable, so retrying and
inspecting a healthy connection wastes the user's time. Update Orca is the real remedy.

Adding a fifth reason still fails typecheck in two places: TS2741 on the Record and
TS2366 plus switch-exhaustiveness-check on both switches.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/folder-status-guard branch from 3d80a01 to 2e04374 Compare August 17, 2026 06:01
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Independent review loop — VERDICT: CLEAN

Covers head 2e04374aae061d7f18c13ac4a0bacefa9c7c9688. Reviewed as a fresh reviewer assuming nothing had been verified; 0 changes pushed, so this pass is clean-with-no-changes and the loop terminates here.

Every claim below was re-derived by mutation or differential execution rather than by reading the diff or trusting the existing tests.


1. The helper does not loosen the compile-time guarantee at any call site

The concern with extracting a generic guard is that inference could degrade T to string at some call sites and silently drop the "a new union member breaks the build" property. Verified by widening all three unions at once (FolderWorkspacePathStatusReason + both cookie unions) and running both gates:

src/renderer/src/lib/browser-cookie-import-toast.ts(13,7): error TS2741: Property '"quota-exceeded"' is missing in type '{ 'restart-fallback-unavailable': true; 'cookies-undecryptable': true; }' but required in type 'Record<...>'.
src/renderer/src/lib/browser-cookie-import-toast.ts(18,7): error TS2741: Property '"hardware-key"' is missing in type '{ 'app-bound-encryption': true; 'linux-keyring-unavailable': true; unknown: true; }' but required in type 'Record<...>'.
src/renderer/src/lib/browser-cookie-import-toast.ts(24,67): error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
src/renderer/src/lib/folder-workspace-path-status.ts(11,7): error TS2741: Property '"permission-denied"' is missing in type '{ missing: true; 'not-directory': true; unavailable: true; 'ambiguous-connection': true; }' but required in type 'Record<FolderWorkspacePathStatusReason, true>'.
src/renderer/src/lib/folder-workspace-path-status.ts(25,4): error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
src/renderer/src/lib/folder-workspace-path-status.ts(61,4): error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
src/renderer/src/lib/browser-cookie-import-toast.ts:32:11: error typescript(switch-exhaustiveness-check): Switch is not exhaustive. Cases not matched: "quota-exceeded"
src/renderer/src/lib/browser-cookie-import-toast.ts:57:15: error typescript(switch-exhaustiveness-check): Switch is not exhaustive. Cases not matched: "hardware-key"
src/renderer/src/lib/folder-workspace-path-status.ts:37:11: error typescript(switch-exhaustiveness-check): Switch is not exhaustive. Cases not matched: "permission-denied"
src/renderer/src/lib/folder-workspace-path-status.ts:72:11: error typescript(switch-exhaustiveness-check): Switch is not exhaustive. Cases not matched: "permission-denied"

All four switches and all three Records still fail. The guarantee is intact everywhere — no call site was traded away.

Worth recording why it holds, since it is not the obvious reason: the exhaustiveness enforcement does not depend on the helper's value is T predicate at all. The folder sites wrap it in isHandledPathStatusReason, which returns plain boolean, and the cookie sites switch on warning.code / warning.reason rather than on the narrowed local. So the enforcement rests entirely on the Record<Union, true> annotations, which the refactor left at the call sites rather than pulling into the helper. That is the right split, and it is what makes the extraction safe.

2. The typeof check is load-bearing at every call site

Mutated the helper body to Object.hasOwn(handled, value as string):

FAIL src/shared/handled-wire-discriminant.test.ts > rejects a non-string the wire can carry
FAIL src/renderer/src/lib/browser-cookie-import-toast.test.ts > still warns when a newer host sends the warning code as an array
FAIL src/renderer/src/lib/browser-cookie-import-toast.test.ts > still warns when a newer host sends the reason as an array
FAIL src/renderer/src/lib/folder-workspace-path-status.test.ts > getFolderWorkspacePathStatusTitle > does not admit a non-string reason through the membership guard
FAIL src/renderer/src/lib/folder-workspace-path-status.test.ts > getFolderWorkspacePathStatusDescription > does not admit a non-string reason through the membership guard
FAIL src/renderer/src/components/.../FolderPathStatusIndicator.test.tsx > still renders the marker when the wire carries a non-string reason
Tests  6 failed | 19 passed (25)

Six failures across four distinct files and five distinct call sites plus the helper's own contract test — not six failures from one site. Confirmed.

3. Behavioural equivalence at the merged #15002 sites — byte-identical

Did not rely on the existing tests to cover this. Built a differential harness driving emitBrowserCookieImportToast over the cross-product of 18 code values × 15 reason values × 3 loadedCookies × 3 otherFailedCookies × 3 googleCookiesSkipped (including arrays, null, numbers, symbols, toString, __proto__, constructor, hasOwnProperty), captured every emitted toast string, then reverted only browser-cookie-import-toast.ts to main and re-ran:

BYTE-IDENTICAL across 7293 cookie shapes

Zero drift. The refactor of the two live #15002 guards is behaviour-preserving.

4. The undefined case is correct in both switches

Same differential method on the folder side, reverting only folder-workspace-path-status.ts. 14 of 40 status shapes changed, and every one of them previously returned undefined. An absent reason is untouched in both functions:

BEFORE {"k":"folder|false|undefined:undefined","title":"Cannot check folder","description":"Orca cannot verify this folder right now. ..."}
AFTER  {"k":"folder|false|undefined:undefined","title":"Cannot check folder","description":"Orca cannot verify this folder right now. ..."}

Also confirms an explicit reason: null routes to the unrecognized copy rather than falling out of the switch, as the description claims.

5. Regression risk in the indicator — none

From the same 40-shape matrix, every case that correctly rendered nothing before still renders nothing:

{"k":"folder|null","title":null,"description":null}
{"k":"folder|undefined","title":null,"description":null}
{"k":"folder|true|string:missing","title":null,"description":null}
{"k":"folder|true|array([\"missing\"])","title":null,"description":null}

The !title arm of !status || status.exists || !title becomes unreachable, which is the intent; the !status and status.exists arms are unchanged.

6. Test quality — new tests proven red against main's source only

Reverted src/renderer/src/lib/folder-workspace-path-status.ts to origin/main with both test files untouched (no git stash, no test edits):

FAIL ... > still titles a broken folder when a newer host sends an undeclared reason      expected 'undefined' to be 'string'
FAIL ... > does not admit a non-string reason through the membership guard                 expected 'undefined' to be 'string'
FAIL ... > still describes a broken folder when a newer host sends an undeclared reason    expected 'undefined' to be 'string'
FAIL ... > does not admit a non-string reason through the membership guard                 expected 'undefined' to be 'string'
FAIL ... > still renders the marker when a newer host sends an undeclared reason           expected '' not to be ''
FAIL ... > still renders the marker when the wire carries a non-string reason              expected '' not to be ''
Test Files  2 failed (2)
     Tests  6 failed | 5 passed (11)

On the expected '' not to be '' question: it is a genuine assertion on rendered output, not an empty harness. In that same red run the sibling test marks a folder missing for a declared reason passes, asserting aria-label="Folder not found" and text-destructive are present in the markup. The harness renders real markup; the '' is the component genuinely returning null.

7. Copy and localization

Catalog is consistent — the two new keys sit alongside the four existing ones under the same title/description groups, and no stale unrecognized keys exist in es/ja/ko/zh. All three localization gates pass.

On the copy choice itself I reach the same conclusion as the description, with one caveat worth recording. The argument against reusing unavailable is sound: it is the stronger of the two options, because Cannot check folder sends the user to inspect a healthy connection when the host in fact returned a definite verdict.

The caveat is that Folder is not usable is very slightly stronger than what we know. Checking the producer, pathStatErrorReason (src/main/project-groups/folder-workspace-path-status.ts:102) maps any non-ENOENT/ENOTDIR error to unavailable, and a missing SSH provider also yields exists: false, reason: 'unavailable'. So exists: false already does not uniformly mean "broken" — the union contains an undeterminable-class member, and a future host's new reason could well be another one. Folder is not usable asserts a verdict in that case.

I am not treating this as a finding and made no change, because the paired description explicitly disclaims the cause ("this version does not recognize the reason"), the marker renders muted rather than destructive, and the remedy offered is "Update Orca" rather than anything destructive like remove-and-re-import. The residual imprecision is bounded and strictly better than the marker vanishing. Recording it so the trade-off is on the record rather than implicit.

8. Two notes on the description (no code impact)

  • worktree-activation.ts:95 was not actually degraded. That call is gated behind folderWorkspaceActivationBlocked, which is true only for missing / not-directory / ambiguous-connection — all recognized. Its ?? fallbacks were already unreachable both before and after. The description lists it as a silently-degraded consumer; it wasn't. Harmless overstatement.
  • A fifth consumer the description does not list is also repaired. project-group-header-actions.tsx:127 renders getFolderWorkspacePathStatusDescription(pathStatus) directly into a TooltipContent, so on main an unrecognized reason produced an empty tooltip on the project-group create button. The fix repairs that too. Unclaimed benefit.

I separately verified the description's own claim about the composer: pathStatusBlocksCreate is computed from isConfirmedStaleFolderPathStatus and an === 'ambiguous-connection' comparison, neither of which touches the switches, so an unrecognized reason does not newly block creation. Confirmed by reading both branches.


Sweep for other cast-then-switch exposures

Enumerated all 204 default:-less (therefore exhaustive-by-type, therefore undefined-on-miss) switches across src/renderer/src, src/shared, and src/preload, then filtered to those whose discriminant originates in a callRuntimeRpc<…> cast. Beyond the already-filed sshHealth case, two further same-class exposures, both confirmed by execution rather than by reading:

A. ProjectHostSetup.setupState — the closest analogue to this bug, and it reaches a non-nullable field.
Origin store/slices/repos.ts:529, callRuntimeRpc<{ setups: ProjectHostSetup[] }>('projectHostSetup.list') — cast, not decoded, same wire.

  • repository-host-setup-options.ts:18 getSetupStateLabel(...): string returns undefined for an unrecognized state, rendered at RepositoryHostSetupsSection.tsx:282 → blank status chip.
  • project-host-setup-options.ts:304 getPendingSetupDetail(...): string returns undefined, which is then assigned to detail, declared non-nullable string, at :187. Executed probe:
SWEEP getSetupStateLabel => undefined
AssertionError: detail for needs-setup:ssh:builder: expected 'undefined' to be 'string'

There is a further latent throw at compareProjectHostSetupOptions:334 — aDetail.localeCompare(bDetail) on an undefined detail — but I could not make it fire reliably: it is short-circuited by a.label.localeCompare(b.label) ||, so it needs two non-local hosts with identical labels and the undefined-detail option in the a position. Reporting it as order-dependent rather than claiming a reproducible crash.

B. AutomationRun.status. Origin automations/automation-host-client.ts:117,178, callRuntimeRpc<{ runs: AutomationRun[] }> / <{ run: AutomationRun }>. automation-page-parts.tsx:71 getAutomationRunStatusLabel(...): string has an exhaustive default:-less switch; a newer host's run status yields undefined into three render sites (AutomationRunHistory.tsx:139, AutomationsDetailPane.tsx:240, automation-list-last-run.ts:79) → blank status label in run history.

Both are out of scope for this PR and I have not changed them; flagging for follow-up. Now that isHandledWireDiscriminant exists, both are a two-line application of it.


Gates (verbatim, run at 2e04374aae)

$ node config/scripts/check-changed-code-quality.mjs
code quality: 0 new finding(s) across 6 changed file(s).
type-aware code quality: 0 new finding(s) across 6 changed file(s).
React Doctor: 0 new finding(s) across 6 changed file(s).
Changed-code quality gate passed since 81d7f9b24eb3.

A clean lint gate is indistinguishable from a dead one, so all three scans were proven live by injecting violations into changed files:

code quality:       eslint(no-unused-vars) + eslint(no-debugger)  -> "2 new finding(s)"
type-aware:         typescript(await-thenable)                    -> "1 new finding(s)"
React Doctor:       react-doctor(no-array-index-as-key)           -> "1 new finding(s)"
$ pnpm run typecheck
REAL EXIT: 0

Not a false pass: node_modules/.bin/tsc verified present before the run, and the run consumed 62s of CPU across all three projects — tsc genuinely executed rather than exiting 0 through a pipe on command not found.

$ npx vitest run --config config/vitest.config.ts <8 affected files>
Test Files  8 passed (8)
     Tests  78 passed (78)
$ pnpm run verify:localization-catalog     REAL EXIT: 0
$ pnpm run verify:localization-extraction  REAL EXIT: 0
$ pnpm run verify:localization-coverage    REAL EXIT: 0
Localization coverage check passed with 12 allowlisted candidates.

Determination

CLEAN at 2e04374aae061d7f18c13ac4a0bacefa9c7c9688. No blocking or non-blocking defects found in the change itself; nothing pushed. The fix is correct, the extraction preserves the compile-time guarantee at all four call sites, the two live #15002 guards are byte-for-byte behaviour-preserving across 7,293 shapes, and the new tests genuinely fail against main's source alone.

Note the branch is 1 commit behind main (merge-base 81d7f9b24eb3); a merged-tree run is still worth having before merge, since a clean merge-base does not guarantee a green merged tree. Not merging.

@brennanb2025
brennanb2025 merged commit 6387e5b into main Aug 17, 2026
45 checks passed
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 21, 2026
…ds a new reason (stablyai#15027)

FolderWorkspacePathStatus is cast, not decoded, off the runtime RPC wire --
runtime-rpc-envelope declares result: z.unknown(), so unwrapRuntimeRpcResult hands
back whatever the host sent. Both title and description switch on status.reason with
no runtime guard, so a newer host publishing a fifth reason matched nothing and
returned undefined. FolderPathStatusIndicator's `!title` check then dropped the whole
indicator, and a broken folder workspace rendered as healthy -- worse than the blank
toast stablyai#15002 fixed, because there the warning was empty and here it is gone.

Guard before each switch, the shape stablyai#15002 landed. A default: arm is not available:
the type-aware config sets allowDefaultCaseForExhaustiveSwitch:false and rejects one
with switch-exhaustiveness-check.

Extract that guard into isHandledWireDiscriminant instead of hand-writing a third and
fourth copy, and move stablyai#15002's two bespoke guards onto it. It takes unknown and checks
typeof before Object.hasOwn -- hasOwn coerces its key, so a host that widened the field
to an array sends ['missing'], which a hasOwn-only guard admits before the switch drops
it straight back out. That was the P1 found in review on stablyai#15002; one implementation
makes it structural instead of tribal.

An unrecognized reason gets its own copy rather than reusing 'unavailable'. The
unavailable remedy -- "Check the runtime or SSH connection and try again" -- is a false
lead here: the host did check and reported the folder unusable, so retrying and
inspecting a healthy connection wastes the user's time. Update Orca is the real remedy.

Adding a fifth reason still fails typecheck in two places: TS2741 on the Record and
TS2366 plus switch-exhaustiveness-check on both switches.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ds a new reason (stablyai#15027)

FolderWorkspacePathStatus is cast, not decoded, off the runtime RPC wire --
runtime-rpc-envelope declares result: z.unknown(), so unwrapRuntimeRpcResult hands
back whatever the host sent. Both title and description switch on status.reason with
no runtime guard, so a newer host publishing a fifth reason matched nothing and
returned undefined. FolderPathStatusIndicator's `!title` check then dropped the whole
indicator, and a broken folder workspace rendered as healthy -- worse than the blank
toast stablyai#15002 fixed, because there the warning was empty and here it is gone.

Guard before each switch, the shape stablyai#15002 landed. A default: arm is not available:
the type-aware config sets allowDefaultCaseForExhaustiveSwitch:false and rejects one
with switch-exhaustiveness-check.

Extract that guard into isHandledWireDiscriminant instead of hand-writing a third and
fourth copy, and move stablyai#15002's two bespoke guards onto it. It takes unknown and checks
typeof before Object.hasOwn -- hasOwn coerces its key, so a host that widened the field
to an array sends ['missing'], which a hasOwn-only guard admits before the switch drops
it straight back out. That was the P1 found in review on stablyai#15002; one implementation
makes it structural instead of tribal.

An unrecognized reason gets its own copy rather than reusing 'unavailable'. The
unavailable remedy -- "Check the runtime or SSH connection and try again" -- is a false
lead here: the host did check and reported the folder unusable, so retrying and
inspecting a healthy connection wastes the user's time. Update Orca is the real remedy.

Adding a fifth reason still fails typecheck in two places: TS2741 on the Record and
TS2366 plus switch-exhaustiveness-check on both switches.
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