Repository navigation
Fix Orca Mobile agent tabs opening as a plain shell instead of launching the agent - #7837
Conversation
…d on activation When a mobile Claude tab was created while the desktop renderer was stalled, the tab could survive as a pending agent tab (launchAgent set, no PTY). Tapping it on the phone materialized it through activateMobileSessionTab, which passed identity/cwd/launchAgent to createHeadlessMobileSessionTerminal but no startup command - yielding a plain shell under the Claude icon. Resolve the agent launch plan like the create path does and thread it into the materialize; fall back to the plain shell when the agent is disabled or unresolvable. Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe runtime now resolves agent-specific startup details when activating a pending mobile session tab with a 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/runtime/orca-runtime.ts (1)
4004-4037: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winStale
launchAgenttag persists when the agent resolution fails (disabled/unresolvable agent).
launchAgent: tab.launchAgent(line 4035) is passed unconditionally, but whentab.launchAgentis set and resolution throws (disabled agent, unresolvable workspace, etc.),agentStartupstays{}— the PTY is materialized as a plain shell yet still taggedlaunchAgent: tab.launchAgent. This isn't just a cosmetic mismatch:pty.launchAgent = launchOpts.launchAgent ?? nullgets set from this value, andloadPtyForegroundAgentFromControllershort-circuits withif (pty.launchAgent) { return false }, so the runtime will never probe the real foreground process for this PTY again — agent-status detection is permanently wrong for that terminal, not just its icon.Use
agentStartup.launchAgentinstead oftab.launchAgent—resolveMobileSessionTerminalCommand's success path already echoeslaunchAgent: opts.agent(i.e.tab.launchAgent), and its failure path leaves itundefined, so this correctly clears the tag exactly when the plain-shell fallback kicks in, and is a no-op for the already-passing tests.🐛 Proposed fix
cwd: tab.startupCwd, command: agentStartup.command, env: agentStartup.env, startupCommandDelivery: agentStartup.startupCommandDelivery, launchConfig: agentStartup.launchConfig, - launchAgent: tab.launchAgent, + launchAgent: agentStartup.launchAgent, targetGroupId
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.test.ts (1)
16636-16680: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider reusing
makePendingAgentTabActivationRuntimeinstead of duplicating its setup.This test re-implements the full runtime/session/pty-controller setup already in the new helper just to omit
launchAgenton the persisted tab. Extending the helper with an optionallaunchAgentparameter (defaulting to'claude') would let this test reuse it and reduce duplication.♻️ Sketch
- function makePendingAgentTabActivationRuntime(opts: { disabledTuiAgents?: string[] } = {}): { + function makePendingAgentTabActivationRuntime( + opts: { disabledTuiAgents?: string[]; launchAgent?: string | null } = {} + ): { runtime: OrcaRuntimeService spawn: ReturnType<typeof vi.fn> } { const spawn = vi.fn().mockResolvedValue({ id: 'serve-materialized-pty' }) const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession( makeWorkspaceSessionWithHeadlessTerminal({ tabsByWorktree: { [TEST_WORKTREE_ID]: [ { id: 'host-tab', ptyId: 'serve-dead-pty', worktreeId: TEST_WORKTREE_ID, title: 'Terminal 1', customTitle: null, color: null, sortOrder: 0, createdAt: 1, - launchAgent: 'claude' + ...(opts.launchAgent !== null ? { launchAgent: opts.launchAgent ?? 'claude' } : {}) } ] },
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: dfd8937b-a130-4ad9-8fe1-e28341bd123f
📒 Files selected for processing (2)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
Co-authored-by: Orca <[email protected]>
…ver a bare renderer PTY (#12197) A mobile New Tab -> Codex create resolves the launch command and hands it to the renderer, but when the renderer's startup queue is lost (the #7587 stall class) the pane spawns a plain shell and the create still settles ready via PTY adoption - silently binding the phone to a bare terminal forever, since the ready status also disables the #7837 activation-time materialize recovery. Record the resolved launch command on the pending create and, at every renderer-backed settle point, deliver it to the adopted PTY when no spawn command was recorded for it. Spawn commands are noted per PTY by both spawn IPC handlers, so a missing record on the locally registered live PTY proves the launch never ran; delivery types the command exactly like the create would have, and the note prevents double delivery. Fixes STA-3214
…ing the agent (stablyai#7837) Co-authored-by: Orca <[email protected]>
…ver a bare renderer PTY (stablyai#12197) A mobile New Tab -> Codex create resolves the launch command and hands it to the renderer, but when the renderer's startup queue is lost (the stablyai#7587 stall class) the pane spawns a plain shell and the create still settles ready via PTY adoption - silently binding the phone to a bare terminal forever, since the ready status also disables the stablyai#7837 activation-time materialize recovery. Record the resolved launch command on the pending create and, at every renderer-backed settle point, deliver it to the adopted PTY when no spawn command was recorded for it. Spawn commands are noted per PTY by both spawn IPC handlers, so a missing record on the locally registered live PTY proves the launch never ran; delivery types the command exactly like the create would have, and the note prevents double delivery. Fixes STA-3214
Spawning a Claude (or any agent) tab from Orca Mobile could produce a tab that shows the agent icon but runs a plain shell — the agent never started. This PR makes the mobile activate path launch the tab's agent when it materializes a pending agent tab, so a tab labeled Claude actually runs Claude.
What changes:
activateMobileSessionTabmaterializes pending terminal tabs headlessly (phone taps sendsession.tabs.activatewithnotifyClients: false). That call site passedidentity/cwd/launchAgenttocreateHeadlessMobileSessionTerminalbut dropped the startup command, unlike every other agent-tab path. It now resolves the agent launch plan exactly like the mobile create path (resolveMobileSessionTerminalCommand: platform/remote-aware quoting, agent-enablement check, workspace trust marking) and threadscommand/env/startupCommandDelivery/launchConfiginto the materialize. If the agent is disabled or the plan can't be built, it falls back to the previous plain-shell behavior instead of failing the activation.What does not change: the create-side flows (renderer, headless, timeout-materialize, #7664 rescue) already delivered the command and are untouched. Live sessions cannot double-launch: every provider (local daemon
createOrAttach, degraded local provider, SSH relay attach) skips startup commands when attaching to an existing live session, and a live session means the tab isready, which skips the materialize branch entirely.Root cause / reproduction
Reproduced end-to-end on the reporter's machine and deterministically on a dev instance:
launchAgent: "claude",status: "pending-handle", no PTY, title reverted to "Terminal N".serve-*daemon session running a bare zsh under the Claude icon.Evidence from the affected machine: both broken sessions' terminal-history logs contain zero command bytes (prompt only), spawned 12s apart matching two taps after the create's 10s+1s timeout cadence; the tabs persist in
orca-data.jsonwithlaunchAgent: "claude"andserve-*bindings. Deterministic repro rig: seed a Claude tab → exit it → SIGSTOP the renderer →session.tabs.activatewithnotifyClients: false→ before the fix the daemon spawn receivedcommand: nulland produced a plain shell; after the fix the same steps relaunch Claude (validated live, plus on the Android emulator through the real mobile UI).Validation
src/main/runtime/orca-runtime.test.ts: pending agent tab activation spawns with the resolved claude command; pending tab withoutlaunchAgentstill spawns a plain shell (no command); disabled agent falls back to plain shell without failing activation. Fullorca-runtime.test.tssuite passes (580 tests).status: "pending-handle",launchAgent: "claude", no terminal handle, title "Terminal 10" with the Claude icon — the reporter's exact broken state) was tapped in the mobile tab bar and materialized with Claude running; server-side the tab flipped to"✳ Claude Code"/"ready"with a fresh terminal handle. Screenshot evidence captured for pairing, both scenarios, and the pre-tap pending state (kept locally under/tmp/mobile-claude-fix-evidence/; not committed per repo evidence policy).pnpm tcclean; oxlint/oxfmt clean.Risks / notes
--resume; resume-on-activate remains a separate feature.commandDelivery, attach paths never deliver); validated by code inspection and existing create-path coverage, not a live SSH rig.Made with Orca 🐋