Skip to content

fix(mobile): bound pending-handle session-tab recovery polling (STA-4407) - #14916

Merged
brennanb2025 merged 20 commits into
mainfrom
brennanb2025/sta-4407-poll-bound
Aug 17, 2026
Merged

brennanb2025 merged 20 commits into
mainfrom
brennanb2025/sta-4407-poll-bound

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes STA-4407. Bounds the recovery poll that #14623 introduced, without reverting its STA-4256 fix.

The defect

#14623 fixed STA-4256 by adding hasPendingTerminalHandleRecoveryNeed() and OR-ing it into the mobile session route's hasSessionTabsRecoveryNeed. That predicate feeds MobileSessionTabsStreamHealth.poll(), whose park condition was:

health === 'live' && !hasRecoveryNeed() && requirementRevision <= satisfiedRevision

So while the active tab is a terminal whose terminal field is not a string (status: 'pending-handle'), poll() could never park. useFocusEffect in use-mobile-session-tabs-reconciliation.ts runs refresh(false) on a 2000 ms setInterval, so a focused, foregrounded mobile session issued session.tabs.list every 2 seconds indefinitely — no age cap, attempt cap, backoff, or failure state — while the pane sat on a spinner.

pending-handle is a valid and potentially indefinite host state (src/main/runtime/orca-runtime.ts), so this is not a rare crash path. The cost is battery, cellular data, and host RPC load for as long as the pane stays open.

Measured, before and after

A counting harness drove the real controller with the real predicate over a simulated hour:

session.tabs.list requests / hour
Before (main) 1800 — first at 2 s, last at 3,600,000 ms, every gap exactly 2000 ms, zero decay
After (this PR) 5 — at 2 s, 4 s, 6 s, 8 s, 10 s, then parked

Controls that rule out a vacuous measurement: an active tab whose terminal is already a string produces 0 requests/hour, and materializing the handle mid-run yields 1801 total then permanent silence.

Mechanism

PendingTerminalHandleRecoveryBudget grants five attempts per recovery context, keyed on the active pending-handle tab. When the budget is spent the poll parks and the pane swaps its indefinite spinner for an actionable Retry.

Two boundaries are deliberate and both are pinned by tests:

  • The budget applies only to a live stream. On a probing or degraded stream the 2-second poll is the only refresh path, so it keeps running indefinitely — matching pre-fix(mobile): keep polling session tabs while an active terminal is pending-handle (STA-4256) #14623 behaviour. Bounding it there would have stranded the pane harder than the bug this PR fixes.
  • The budget is consumed only when a pending-handle context exists. When another recovery source is active (closed-tab tombstones, pending browser focus, native chat) with no pending-handle tab, the poll proceeds without spending the budget; those sources keep their existing behaviour.

The budget resets on a new recovery context — terminal identity change, stream reconnect / subscription epoch, app foregrounding, focus, and explicit Retry — and never on the ordinary 2-second tick.

Validation

  • Focused recovery/session suites: 60 tests across 6 files
  • Full mobile suite: 3,546 tests
  • pnpm typecheck (tsc --noEmit) clean; targeted oxlint / oxfmt clean; React Doctor and changed-code-quality gates clean
  • Mutation battery over the review: 134/134 mutants killed, 2/2 controls
  • Spot-checked independently: replacing the health === 'live' gate with true — reintroducing the original over-bounding defect — fails 2 tests, confirming the non-live behaviour is genuinely pinned rather than incidentally passing

Scope

Deliberately narrow: 9 files, all under mobile/, confined to the session/recovery surface. No controller refactor, no route restructuring, no desktop or host changes, no RPC wire changes. Roughly 620 of the added lines are tests.

Reviewed across nine same-model review/mutation loops with readiness-checklist bookends, stopping only on a loop that returned clean with no changes. Rebased onto current main.

Does not merge or revert #14623.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4407-poll-bound branch from 95cf399 to f49cd86 Compare August 16, 2026 17:50
@coderabbitai

coderabbitai Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: bcf79a64-45bd-4317-b2a1-06a91a3d7615

📥 Commits

Reviewing files that changed from the base of the PR and between 6b10393 and bfce801.

📒 Files selected for processing (3)
  • mobile/src/session/mobile-session-startup-source.test.ts
  • mobile/src/session/pending-terminal-handle-recovery-context-cache.test.ts
  • mobile/src/session/pending-terminal-handle-recovery-poll.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • mobile/src/session/mobile-session-startup-source.test.ts
  • mobile/src/session/pending-terminal-handle-recovery-context-cache.test.ts
  • mobile/src/session/pending-terminal-handle-recovery-poll.test.ts

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


📝 Walkthrough

Walkthrough

Pending-terminal handle recovery uses a context key and a five-attempt budget for each terminal context. Reconciliation gates recovery polling and resets the budget after connection, foregrounding, stream updates, context changes, or explicit retry. Exhausted recovery contexts are reported to the session route. The pending-terminal UI displays a timeout message and Retry button when recovery is parked. Tests cover budget behavior, lifecycle resets, polling limits, retry behavior, and session wiring.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% 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, solution, scope, linked issue, and validation, but omits required template sections including visual proof and checklist confirmations. Use the repository template and add visual proof or an explicit reasoned N/A, testing checklist results, review notes, AI disclosure, boundary confirmation, and author details.
✅ 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 mobile recovery polling fix and includes the related issue identifier.
✨ 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 073cd8d4-bb7f-4115-8eea-d4984463fad2

📥 Commits

Reviewing files that changed from the base of the PR and between 516a269 and f49cd86.

📒 Files selected for processing (7)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/session/mobile-session-startup-source.test.ts
  • mobile/src/session/mobile-session-tabs-stream-health.ts
  • mobile/src/session/pending-terminal-handle-recovery-poll.test.ts
  • mobile/src/session/pending-terminal-handle-recovery.test.ts
  • mobile/src/session/pending-terminal-handle-recovery.ts
  • mobile/src/session/use-mobile-session-tabs-reconciliation.ts

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

@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: Pro Plus

Run ID: 50e14f8e-d430-4944-80c7-68f8a6bd8f84

📥 Commits

Reviewing files that changed from the base of the PR and between 61ea635 and 0f06685.

📒 Files selected for processing (4)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/session/mobile-session-startup-source.test.ts
  • mobile/src/session/mobile-session-tabs-stream-health.test.ts
  • mobile/src/session/pending-terminal-handle-recovery-poll.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • mobile/src/session/mobile-session-startup-source.test.ts
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/session/pending-terminal-handle-recovery-poll.test.ts

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

@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4407-poll-bound branch from 117ef01 to 259d7ea Compare August 16, 2026 20:48
@brennanb2025
brennanb2025 force-pushed the brennanb2025/sta-4407-poll-bound branch from 259d7ea to 32b8544 Compare August 16, 2026 21:00
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Mobile emulator QA — partial pass, parked/Retry state NOT reached

Platform: iOS Simulator, iPhone 17 Pro (iOS 26.5), UDID 50FD514C-96F6-446E-AC90-D07A24CAB3A0
Branch / head tested: brennanb2025/sta-4407-poll-bound @ 32b85447ea
Bundler: Metro from this worktree's mobile/ on 10.0.0.41:8090, Orca Mobile dev client (com.stably.orca.mobile)


✅ Verified: the app builds and loads cleanly on this branch

iOS Bundled 12888ms .../expo-router/entry.js (4748 modules) — no redbox, no "could not connect to development server", app renders its normal host list.

qa-14916-01-app-loaded.png

✅ Verified: the running bundle really is this PR's code

Rather than take the branch checkout on faith, I pulled the bundle Metro actually served to the simulator and grepped it. This PR's symbols and copy are compiled in:

Probe Result
PENDING_TERMINAL_HANDLE_RECOVERY_ATTEMPTS = 5 present (the new 5-attempt bound)
Terminal is taking longer than expected present (parked-state copy)
Retry loading terminal present (parked-state a11y label)

So the device was running the bounded-poll code, not main.

❌ NOT verified: session screen, terminal tab, and the parked/Retry state

I could not reach a live paired host, so I never opened a session, never rendered a terminal tab, and never saw the parked/Retry affordance this PR adds. No part of the changed UI was exercised on-device. Treat the visual coverage here as "the app boots and its unpaired surfaces render" and nothing more.

Why it was unreachable — the machine had no usable pairing:

  1. All 63 stored hosts were stale. Their persisted endpoints point at previous runtime ports (e.g. 100.81.92.103:61677); the desktop runtime currently listens on :61312, and that port changes per app launch.
  2. I restored reachability for the newest host with a plain local TCP forwarder (61677 → 61312) so the app's own stored credentials could reach the real running runtime. It connected at the transport layer and then returned Authentication failed — the stored credential is no longer valid against the current runtime's device registry. Nothing was faked; this only fixed the network path.
  3. The app's re-pair flow offers "Paste code instead", so a single fresh pairing code would have unblocked the full capture — but there is no sanctioned way for me to mint one here. The pairing offer is minted by the desktop renderer (Settings → Mobile) over IPC; it is not exposed by the orca CLI. The running desktop app was not launched with a CDP debug port, and relaunching it with one would have disrupted a live session.
  4. A second runtime (orca serve --mobile-pairing) is not an option either: acquireSingleInstanceLock is keyed on the userData profile and packaged serve mode does not skip it, so it would exit with SINGLE_INSTANCE_ALREADY_RUNNING_EXIT_CODE.

qa-14916-02-host-auth-failed.png

⚠️ This screenshot is not evidence for this PR. The Retry / Re-pair / Remove row above is the host-level connection failure UI, which already exists on main. It is not the terminal-tab parked state this PR introduces. I'm including it only to document the blocker. Please don't read it as coverage of the change.

Independently of pairing, pending-handle is a narrow host-side race (a terminal published before its PTY handle materializes) and is not something I could induce on demand through ordinary use even with a healthy host.

Defects observed

None attributable to this PR. The app booted clean and every state I did reach rendered correctly and truthfully — after the auth failure, the host row correctly re-labelled itself Pairing invalid — re-pair with your desktop rather than sitting on a stale spinner.

What would close the gap

A host in pending-handle — either a live paired desktop plus a way to hold a published terminal's handle back for ~30s (5 attempts at 2s/4s/6s/8s/10s), or a dev-client build against a host stubbed to publish a handle-less terminal. The unit tests added here (pending-terminal-handle-recovery-poll.test.ts) cover the cadence and the park; this comment does not add on-device confirmation of it.

Interaction was driven entirely through orca emulator (tap / ax); Computer Use was used only for screenshot capture.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Mobile emulator QA — supersedes the earlier partial comment

This supersedes #14916 (comment). That run stopped at the unpaired host list because it could not mint a pairing code. This run launched an isolated Orca dev instance from this worktree, minted a LAN pairing offer from Settings → Mobile, paired the simulator, opened a session, and rendered a terminal tab.

Platform: iOS Simulator, iPhone 17 Pro (iOS 26.5), UDID 50FD514C-96F6-446E-AC90-D07A24CAB3A0
Branch / head tested: brennanb2025/sta-4407-poll-bound @ 32b85447ea
Desktop host: isolated electron-vite instance from this worktree (ORCA_DEV_USER_DATA_PATH=/tmp/orca-dev-sta4407-qa, CDP 9334, renderer 5175). Identity confirmed via CDP: Orca: brennanb2025/sta-4407-poll-bound / devRepoRoot=.../sta-4407-poll-bound. Not Brennan's packaged production app, and not the other worktrees already holding 9333 / 9451.
Bundler: Metro from this worktree's mobile/ on 10.0.0.41:8090 (iOS Bundled 697ms … expo-router/entry.js (4646 modules)). No redbox.


Pairing path

Settings → Mobile → LAN → advertise 10.0.0.41 (en0) → Generate QR code. The isolated runtime listened on :6769 (PID owned by this instance). I opened the mobile “Paste code instead” modal and typed the minted orca://pair?code=… URL with orca emulator type; the native field showed the payload, but the modal is a controlled React TextInput, so Save stayed disabled (canSubmit is React-state-backed). Pairing completed through the same URL the QR encodes via simctl openurl, which _layout.tsx documents as the same confirm flow as QR / paste / AirDrop. Confirmed on the “Pair with this desktop?” screen, then Pair.


✅ Verified: paired host, session screen, live terminal tab

Host 64 (the isolated instance) listed this worktree. Opening it reached the session route (0 tabs / Create Tab), then a created Terminal tab rendered a live PTY prompt in sta-4407-poll-bound.

Paired isolated host showing this worktree

Session screen before creating a tab

Live terminal tab after Create Tab → Terminal

✅ Verified: the running bundle is this PR's code

Pulled the Metro-served iOS bundle (expo-router/entry.bundle?platform=ios&dev=true) and grepped it:

Probe Result
PENDING_TERMINAL_HANDLE_RECOVERY_ATTEMPTS = 5 present
Terminal is taking longer than expected present
Retry loading terminal present

❌ NOT verified: pending-handle spinner and parked / Retry

I created a fresh terminal on the live host and watched the first ~15s (AX + screenshots at ~1.2s intervals). The host published a ready handle immediately. Metro diagnostics for every tabs-applied / tabs-fetch-success in that window reported pendingTerminalCount: 0. The first screenshot after create already shows the materialized “Terminal 1” prompt, not a spinner.

pending-handle is a host-side race (tab published before the PTY handle exists). On this local isolated instance the PTY is ready before mobile can observe the pending state, so the 5-attempt budget (2s/4s/6s/8s/10s) never starts and the parked copy / “Retry loading terminal” button never appears. I did not use the e2e-only __remoteTerminalMultiplexAckGate / parkHostTerminal fixture to fake it.

This is not a host-level connection failure. The session stayed connected (green “1 tab”) the whole time.

Defects observed

None attributable to this PR on the surfaces I reached. Pairing, session open, tab create, and the live terminal pane all rendered correctly.

Remaining gap

On-device visual of the parked/Retry affordance still needs a host that actually publishes status: 'pending-handle' long enough for the five-attempt budget to exhaust. Ordinary “create a terminal” on a healthy local host did not do that.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Mobile emulator QA — supersedes the previous two comments

This supersedes #14916 (comment) and #14916 (comment).

Platform: iOS Simulator, iPhone 17 Pro (iOS 26.5), UDID 50FD514C-96F6-446E-AC90-D07A24CAB3A0
Branch / head tested: brennanb2025/sta-4407-poll-bound @ 32b85447ea
Desktop host: isolated electron-vite from this worktree (ORCA_DEV_USER_DATA_PATH=/tmp/orca-dev-sta4407-ph-36787, VITE_EXPOSE_STORE=true, CDP 9334, renderer 5178). CDP identity: Orca: brennanb2025/sta-4407-poll-bound / devRepoRoot=.../sta-4407-poll-bound. Not Brennan's packaged production app; 9333 and 9451 were left alone.
Bundler: Metro from this worktree's mobile/ on 10.0.0.41:8090. Bundle grep:

Probe Result
PENDING_TERMINAL_HANDLE_RECOVERY_ATTEMPTS = 5 present
Terminal is taking longer than expected present
Retry loading terminal present

How pending-handle was induced (not organic)

This was host-side fault injection, not a natural race. A reader should not treat the captures below as an organic reproduction.

I launched the isolated host with VITE_EXPOSE_STORE=true. Renderer window.api.e2e.getConfig() reported { enabled: true, exposeStore: true, userDataDir: null }. __remoteTerminalMultiplexAckGate was not on window. That hook lives in remote-runtime-terminal-multiplexer.ts and is only installed when that module loads; this instance is a local host, so the remote multiplexer never mounts. Dynamic import() of that module also failed (Vite 5178 404). hold() therefore could not be armed.

I used the same host-side park the e2e suite uses in parkHostTerminal (tests/e2e/paired-remote-terminal-materialization-reconnect.spec.ts): session.tabs.createTerminal then terminal.stopExact({ keepHistory: true, targetOnly: true }). After that, session.tabs.list on the isolated host returned:

[{ "title": "Terminal 2", "status": "pending-handle", "isActive": true, "terminal": null }]

That pending-handle snapshot stayed on the host for the full ~12s budget window (re-listed at t=0 and t=12s). It did not occur naturally; a healthy local create still publishes ready immediately (pendingTerminalCount: 0).


✅ Verified: pairing, session, live terminal

LAN pairing via window.api.mobile.getPairingQR({ address: '10.0.0.41', connectionMode: 'local-only' }) → simctl openurl of the orca://pair?code=… URL. Host 66 connected. Opened brennanb2025/sta-4407-poll-bound and created a Terminal tab. A live PTY prompt rendered in this worktree:

Live terminal tab on the paired isolated host

Host list after pairing (Host 66 = this isolated instance)


❌ NOT verified: pending-handle spinner and parked / “Retry loading terminal”

I never photographed the spinner, the “Terminal is taking longer than expected” copy, or the “Retry loading terminal” control. Those strings are in the bundle; they did not appear on-device.

What I saw instead, while the host was still publishing status: 'pending-handle', terminal: null for Terminal 2:

Client on Terminal 2 after ~12s with host still pending-handle — blank chrome, no parked copy, no Retry

AX at that moment: tab “Terminal 2”, “Type a command…”, no “Loading terminal”, no “taking longer than expected”, no “Retry”. The parked empty-state in session/[worktreeId].tsx was not the surface on screen.

Metro [terminal-diagnostic] for this injection:

  1. An earlier park-while-viewing cycle did apply pendingTerminalCount: 1 / activeHandle: null, then the route’s intent: 'user' session.tabs.activate effect ran and the next tabs-applied was pendingTerminalCount: 0 with a new handle (serve-owned rematerialize).
  2. The 12s hold above applied the pre-park handle (activeHandle: "770589d1", suffix of term_67c1dc9d-…) with pendingTerminalCount: 0 and never flipped to pending. The client kept the stale handle, so activePendingTerminalTab (typeof terminal !== 'string') stayed false and the recovery budget never started.

Opening a parked desktop-owned tab from the worktree list rematerializes synchronously (next session.tabs.list is already ready). Parking a serve-owned tab while mobile is looking at it also rematerializes before a screenshot can land. worktree.sleep cleared the tab list (tabCount: 0) rather than leaving a pending-handle surface.

I did not get a Metro trace of session.tabs.list stopping after the 5th attempt, because the five-attempt poll never started on this client.


Defects observed

  • Client may not enter the pending-handle UI after a host-side park of a tab it already has a handle for. Host listed pending-handle / terminal: null for 12s; mobile kept pendingTerminalCount: 0 and rendered empty live chrome + command dock. That is the opposite of the spinner → park → Retry path this PR adds. I did not patch the client to confirm a fix; reporting as observed.
  • The route always fires session.tabs.activate with intent: 'user' when it does see a pending tab. On this local host that rematerializes a serve-owned PTY immediately, so the 5-attempt budget cannot run even when pendingTerminalCount briefly hits 1.
  • No other visual defects on the unpaired/paired/live-terminal surfaces I reached.

What this does not prove

On-device visual of the parked/Retry affordance is still missing. The unit tests cover cadence and park. This run proves the host can publish pending-handle via terminal.stopExact, and that this mobile client did not show the new UI under that induced host state.

Interaction via orca emulator (tap / ax). Computer Use used only for Simulator screenshots. __remoteTerminalMultiplexAckGate.hold was not used — the gate is not mounted on a local-host renderer.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Mobile emulator QA — closing pass (supersedes the previous three)

This supersedes #14916 (comment), #14916 (comment), and #14916 (comment).

Platform: iOS Simulator, iPhone 17 Pro (iOS 26.5), UDID 50FD514C-96F6-446E-AC90-D07A24CAB3A0 (left Booted)
Branch / head tested: brennanb2025/sta-4407-poll-bound @ 32b85447ea
Desktop host: isolated electron-vite from this worktree (ORCA_DEV_USER_DATA_PATH=/tmp/orca-dev-sta4407-qa-closing, VITE_EXPOSE_STORE=true, CDP 9334, renderer 5176). CDP identity: e2e.enabled=true, exposeStore=true, devRepoRoot this worktree. Not Brennan's packaged production app; 9333 / 9451 were left alone.
Bundler: Metro from this worktree's mobile/ on 10.0.0.41:8090 (iOS Bundled 1546ms … expo-router/entry.js (4656 modules)). Pulled the served iOS bundle and grepped it:

Probe Result
PENDING_TERMINAL_HANDLE_RECOVERY_ATTEMPTS = 5 present
Terminal is taking longer than expected present
Retry loading terminal present

How the pending-handle state was induced (not organic)

This was host-side fault injection plus a first-observation ordering fix. Do not treat the captures as a natural race.

Route A (preferred, remote ACK gate) did not land:

  • Isolated instance window.__remoteTerminalMultiplexAckGate was absent (expected on a local host).
  • I added Brennan's openclaw SSH config host via CDP (configHost: openclaw, SOCKS 127.0.0.1:1055). ssh.connect failed with Relay package for linux-x64 not found locally — the isolated dev profile does not ship the packaged linux-x64 relay. No SSH worktree was opened; /home/brennan/orca on that box was not used. A throwaway /tmp/orca-sta4407-qa-pending was mkdir'd over SSH and left empty.
  • Windows-low-spec remote was left disconnected.

Route B is what produced the UI:

  1. Added a new local folder workspace /tmp/orca-sta4407-qa-local-pending on the isolated host (not this git worktree).
  2. session.tabs.createTerminal then terminal.stopExact({ keepHistory: true, targetOnly: true }). Host listed status: 'pending-handle', terminal: null for Terminal 1.
  3. chmod 000 on that folder so session.tabs.activate with intent: 'user' could not rematerialize a PTY (the failure mode of the previous comment). Host session.tabs.list stayed pending-handle / terminal: null for the whole capture window.
  4. simctl terminate + relaunch of com.stably.orca.mobile so the client had no cached handle. LAN pairing via window.api.mobile.getPairingQR({ address: '10.0.0.41', connectionMode: 'local-only' }) → simctl openurl of the orca://pair?code=… URL → Pair. Host 67.
  5. Opened the folder workspace. First tabs-applied was pendingTerminalCount: 1, activeHandle: null.

The last run's stale-handle / rematerialize-on-activate problems were avoided by (3) + (4). intent: 'user' still fired (it is the route's pending-tab effect); chmod made spawn fail so activate did not flip the tab to ready.


✅ Verified: spinner / Loading while pending

Immediately after opening the parked tab, AX showed ActivityIndicator (In progress) plus the tab title Terminal 1 (the pending empty-state uses activePendingTerminalTab.title || 'Loading terminal'). After tapping Retry, the same spinner state was photographed:

Spinner after Retry — ActivityIndicator + Terminal 1

Paired host / worktree list before opening the session:

Host 67 showing the induced folder workspace


✅ Verified: parked copy + “Retry loading terminal”

After the 5-attempt budget (~2s/4s/6s/8s/10s), AX and screenshot showed “Terminal is taking longer than expected” and a button with a11y label “Retry loading terminal” (visible label: Retry). Session stayed connected (green “1 tab”). This is the new parked empty-state, not the host-level reconnect row.

Parked state — taking longer than expected + Retry


✅ Verified: tapping Retry

Tap on Retry loading terminal reset the budget: spinner returned (shot above). ~11s later the same parked copy / Retry control came back. Host was still pending-handle / terminal: null (chmod still blocking rematerialize).

Re-parked after Retry


Metro / host diagnostics

While the session was on the pending tab, Metro [terminal-diagnostic] reported pendingTerminalCount: 1 and activeHandle: null on every successful tabs-applied / tabs-fetch-success (apart from two transient tabCount: 0 snapshots that immediately republished the pending tab). tabs-fetch-start logged four times during the first budget window; I did not get a clean five-line session.tabs.list stop-after-5th-attempt trace (live tabs-applied snapshots outnumber explicit fetch-start lines). The on-device park after the budget, and the same park after Retry, is the user-visible bound.

Host session.tabs.list stayed:

[{ "title": "Terminal 1", "status": "pending-handle", "terminal": null, "isActive": true }]

Defects observed

None attributable to this PR on the surfaces I reached. Spinner, parked copy, Retry, and the Retry → spinner → re-park loop all rendered correctly.

The previous comment's observation still stands as a product constraint, not a regression in this PR: if the client already holds a handle, or if intent: 'user' activate rematerializes a serve-owned PTY, this UI never appears. This pass only reached it by making the first observation handle-less and preventing rematerialize.


What this does not prove

  • Organic pending-handle (healthy local create is still instantly ready).
  • Remote ACK-gate hold() on a remote-backed host (__remoteTerminalMultiplexAckGate never mounted; SSH relay package missing in the isolated dev instance).
  • An exact Metro count of five session.tabs.list RPCs then silence.

Interaction via orca emulator (tap / ax). Computer Use used only for Simulator screenshots. Isolated host quit after this comment; simulator left Booted.

@brennanb2025
brennanb2025 merged commit c73e5a2 into main Aug 17, 2026
46 checks passed
AmethystLiang pushed a commit that referenced this pull request Aug 17, 2026
…407) (#14916)

* fix(mobile): bound pending terminal recovery polls

* wip(mobile): partial STA-4407 bound pending-handle poll

* fix(mobile): finish bounded pending-handle recovery

* fix(mobile): preserve pending-handle recovery attempts on slow links

* fix(mobile): retain pending-handle cadence budget semantics

* test(mobile): pin pending recovery parked state resets

* chore(mobile): drop the STA-4407 worker status logbook

* fix(mobile): preserve pending recovery liveness

* fix(mobile): coalesce repeated recovery retries

* fix(mobile): memoize pending recovery context

* fix(mobile): type the pending recovery poll test renderer explicitly

* fix(mobile): type the poll test renderer without an any union

* fix(mobile): keep recovery context refs current

* test(mobile): tighten pending recovery coverage

* test(mobile): preserve recovery-source liveness

* fix(mobile): keep the poll test renderer union free of any

* test(mobile): prove parked recovery isolation

* fix(mobile): write the parked-recovery callback ref after commit

* test(mobile): isolate recovery identity changes

* test(mobile): prove recovery publication boundaries
brennanb2025 added a commit that referenced this pull request Aug 19, 2026
The host has no timer and must not acquire one. These pin that the publication
is driven by the addressability transition, at each position relative to the
client's 5-attempt ~2s recovery budget (#14916):

- before: PTY addressable first, so the tab publishes ready and nothing is owed
  — asserts no spurious materialization push
- during: registration inside the window still publishes
- after: registration 30s later still publishes, and beats the newest frame the
  client took rather than the first one, because intervening title/status churn
  bumps the version meanwhile

Also covers reconnect — `paneWasAddressable` must not latch, so a pane that dies
and comes back is owed the same publication — and old-client compatibility, via
the same-epoch monotonic freshness gate every mirrored client applies. A push an
old client cannot accept is a push that never happened.

3 of the 4 go RED against pre-fix source; the `before` case is a guard.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…407) (stablyai#14916)

* fix(mobile): bound pending terminal recovery polls

* wip(mobile): partial STA-4407 bound pending-handle poll

* fix(mobile): finish bounded pending-handle recovery

* fix(mobile): preserve pending-handle recovery attempts on slow links

* fix(mobile): retain pending-handle cadence budget semantics

* test(mobile): pin pending recovery parked state resets

* chore(mobile): drop the STA-4407 worker status logbook

* fix(mobile): preserve pending recovery liveness

* fix(mobile): coalesce repeated recovery retries

* fix(mobile): memoize pending recovery context

* fix(mobile): type the pending recovery poll test renderer explicitly

* fix(mobile): type the poll test renderer without an any union

* fix(mobile): keep recovery context refs current

* test(mobile): tighten pending recovery coverage

* test(mobile): preserve recovery-source liveness

* fix(mobile): keep the poll test renderer union free of any

* test(mobile): prove parked recovery isolation

* fix(mobile): write the parked-recovery callback ref after commit

* test(mobile): isolate recovery identity changes

* test(mobile): prove recovery publication boundaries
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