Skip to content

fix(mobile): surface worktree catalog failures instead of silent 0 worktrees (STA-3123) - #12235

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/sta-3123-mobile-remote-worktrees
Aug 3, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/sta-3123-mobile-remote-worktrees

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

Fixes the "remote Orca server shows 0 worktrees" presentation from STA-3123 (synced GitHub issue #11869): a connected host whose worktree.ps request fails is no longer indistinguishable from a genuinely empty host.

  • Host page (/h/[hostId]): when the catalog RPC fails (RPC error, invalid payload, or transport throw) and there are no cached rows, the screen now shows "Could not load workspaces from this host — worktree.ps failed (<code>) — retrying automatically" instead of an eternal spinner or a "No worktrees" empty state. The existing 3s poll / reconnect / pull-to-refresh paths clear the state on the next success; cached rows still win when present.
  • Home screen host card: a failed worktree.ps no longer seeds a fabricated 0 worktrees count. With no prior data the card now says "Worktree list unavailable"; cached counts are still kept through transient failures.
  • WorktreeCatalogSnapshotClient.fetch now returns a discriminated result (response vs request_failed with the server error code) instead of collapsing failures to null, and preserves the snapshot token across failures.

Investigation notes: on current code the direct-pair catalog path is healthy end-to-end — verified via a fake mobile E2EE client (exact app params: {limit: 10000, afterSnapshotId: null}) against an isolated branch-built orca serve and against the installed production serve, plus a live iOS-sim pairing (screenshots below). The field "0 worktrees while CLI shows dozens" therefore reaches users through this silent-failure masking, which also made the original report undiagnosable — after this PR the failing host displays the actual RPC error code.

Screenshots

Host page, paired to a connected mock host whose worktree.ps returns an RPC error (previously rendered as an empty host):

host page failure state

Home screen: failing host (Host 4) says "Worktree list unavailable"; healthy host (Host 3) keeps real counts:

home card unavailable

Healthy path unchanged — iOS sim paired directly to an isolated orca serve built from this branch lists its catalog:

healthy direct pairing

Testing

  • pnpm lint (root, plus mobile oxlint — clean)
  • pnpm typecheck (root, plus mobile tsc --noEmit — clean)
  • pnpm test — targeted: mobile vitest src/worktree/ (113 tests passing, includes new failure-path and state-precedence tests); changed-code quality gate (check-changed-code-quality.mjs): 0 new findings incl. React Doctor
  • pnpm build — not run in full; build:cli + build:electron-vite were built and exercised for the QA serve rig (change is mobile-only)
  • Added or updated high-quality tests that would catch regressions: worktree-catalog-snapshot-client.test.ts (error-code surfacing, token preservation across failures) and new host-workspace-list-state.test.ts (loading/failure/empty precedence — a failed fetch can never render as "No worktrees")

AI Review Report

Reviewed for: (1) failure-state vs cached-rows interplay — cached rows always win; the failure state only replaces the empty presentation; (2) snapshot-token semantics — a request_failed fetch does not clear the admitted token (server never answered), while an invalid success payload still resets it, covered by tests; (3) staleness — error state is guarded by the same client/host staleness checks as row application and is reset when the route re-seeds for a new hostId; (4) live QA on the iOS simulator confirmed both the failure state and the untouched healthy path. Cross-platform: the change is React Native (iOS/Android) only — no desktop/Electron, shortcut, path, or shell behavior touched; no metaKey/path separators involved; text-only UI additions render identically on both mobile platforms.

Security Audit

The only new input surface is the RPC error code string rendered into the failure caption. It is rendered via React Native Text (no HTML/markup interpretation) and is only ever produced by an already-authenticated paired host; non-string/empty codes are normalized to request_failed. No command execution, path handling, secret handling, IPC, or dependency changes. Device tokens and pairing payloads are never logged by the new code.

Notes

  • STA-3123 also reports that the Mac host list does not aggregate remote Runtime Environment worktrees (parity with the desktop sidebar). That is a separate feature-sized data path (worktree.ps never merges environment runtimes; sessions for such rows would also need proxying) and is intentionally not attempted here — this PR makes the failing-catalog case visible and diagnosable, which is the P0 observable, and gives field users the actual error code to report.
  • Server-side follow-up worth a look (matches STA-1730): computeResolvedWorktrees caches a scan-timeout-degraded (possibly empty) snapshot for the TTL without distinguishing it from an authoritative result.

References: STA-3123, #11869

…orktrees (STA-3123)

A connected host whose worktree.ps request fails now shows an explicit
catalog-failure state (with the RPC error code) on the host page, and
'Worktree list unavailable' on the home host card, instead of silently
rendering as a healthy host with zero workspaces.
@coderabbitai

coderabbitai Bot commented Aug 3, 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: 1fefafc3-eb56-49ce-9a01-ee1c52f57498

📥 Commits

Reviewing files that changed from the base of the PR and between f05587f and 9dbbb57.

📒 Files selected for processing (3)
  • mobile/app/index.tsx
  • mobile/src/worktree/home-worktree-info.test.ts
  • mobile/src/worktree/home-worktree-info.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • mobile/app/index.tsx

📝 Walkthrough

Walkthrough

The mobile worktree catalog client now returns structured response or failure results and preserves error codes. Shared host metadata marks unavailable catalog data separately from valid zero counts. Host workspace screens track catalog errors and use centralized loading, error, and empty-state rendering. Connected host cards display “Worktree list unavailable” when worktree retrieval fails. Tests cover catalog failures, cached data, loading, empty results, connection transitions, and snapshot token behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 states that mobile worktree catalog failures are surfaced instead of appearing as zero worktrees.
Description check ✅ Passed The description covers the required summary, screenshots, testing, AI review, security audit, and notes, while documenting that the full build was not run.
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.
✨ 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.

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

🧹 Nitpick comments (1)
mobile/src/worktree/host-workspace-list-states.tsx (1)

15-21: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Consider adding an accessibility role to the loading indicator.

ActivityIndicator has no accessibilityRole or accessibilityLabel. Screen reader users get no signal that the host workspace list is loading.

♿ Optional accessibility improvement
-      <View style={styles.centered}>
+      <View style={styles.centered} accessibilityRole="progressbar" accessibilityLabel="Loading workspaces">
         <ActivityIndicator size="small" color={colors.textSecondary} />
       </View>

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e93b009-2c7d-47bc-9be4-dcc844933a9f

📥 Commits

Reviewing files that changed from the base of the PR and between db53252 and f05587f.

📒 Files selected for processing (8)
  • mobile/app/h/[hostId]/index.tsx
  • mobile/app/index.tsx
  • mobile/src/components/MobileHostCard.tsx
  • mobile/src/worktree/host-workspace-list-state.test.ts
  • mobile/src/worktree/host-workspace-list-state.ts
  • mobile/src/worktree/host-workspace-list-states.tsx
  • mobile/src/worktree/worktree-catalog-snapshot-client.test.ts
  • mobile/src/worktree/worktree-catalog-snapshot-client.ts

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Post-review QA on commit 9dbbb574a8 (iOS Simulator, owned iPhone 17 Pro 50FD514C-96F6-446E-AC90-D07A24CAB3A0):

  • Isolated branch-built orca serve paired directly over LAN and listed the registered STA-3123 worktree.
  • An isolated authenticated mock returned worktree.ps error code catalog_unavailable; the host page showed the explicit retrying failure state and the home card showed Worktree list unavailable.
  • Restoring successful catalog responses brought the same host back to its two worktrees.
  • Isolated Electron dev instance attached over CDP to the intended worktree with the visible app loaded and 0 renderer console errors.
  • Gates: mobile typecheck, oxlint, and targeted mobile Vitest (23 tests) passed.

Host-page RPC failure:

Host page RPC failure

Home-card unavailable state beside a healthy direct host:

Home card unavailable

Healthy direct orca serve catalog:

Healthy direct server catalog

Recovered catalog after successful responses resumed:

Recovered catalog

@brennanb2025
brennanb2025 merged commit 3d68212 into main Aug 3, 2026
43 checks passed
Jinwoo-H pushed a commit that referenced this pull request Aug 4, 2026
Completes the 0.0.37 release attempted on 2026-08-03 (run 30791649691
failed on the version assertion). Ships the post-0.0.36 transport fixes:
relay session recovery when the LAN endpoint is unreachable (#12344,
#11368, #11465, #11690) and honest worktree-catalog failure states
(#12235) — the released-app defect class verified live tonight.

Co-authored-by: OrcaWin <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…rktrees (STA-3123) (stablyai#12235)

* fix(mobile): surface worktree catalog failures instead of showing 0 worktrees (STA-3123)

A connected host whose worktree.ps request fails now shows an explicit
catalog-failure state (with the RPC error code) on the host page, and
'Worktree list unavailable' on the home host card, instead of silently
rendering as a healthy host with zero workspaces.

* fix(mobile): mark cached worktree catalogs unavailable
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Completes the 0.0.37 release attempted on 2026-08-03 (run 30791649691
failed on the version assertion). Ships the post-0.0.36 transport fixes:
relay session recovery when the LAN endpoint is unreachable (stablyai#12344,
stablyai#11368, stablyai#11465, stablyai#11690) and honest worktree-catalog failure states
(stablyai#12235) — the released-app defect class verified live tonight.

Co-authored-by: OrcaWin <[email protected]>
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