Skip to content

fix(agent-hooks): report hook status per host, and stop remote Codex reusing an env-less app-server (#8711, #11941) - #14621

Closed
brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/codex-ssh-hooks-8711
Closed

brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/codex-ssh-hooks-8711

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1413 $\color{#cf222e}{\Huge{\mathbf{−}}}$​232 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1181
Prod 30 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​756 $\color{#cf222e}{\Huge{\mathbf{−}}}$​153 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​603

ELI5

orca agent hooks status only ever looked at your own Mac. Over SSH the agent runs on a different machine, so it happily said codex: installed while the remote box had no Orca hooks at all. Now every line says which host it is talking about, and a host Orca cannot check says unknown instead of borrowing the local answer. Remote Codex also gets a launch flag so it starts its own app-server instead of reusing one that never saw Orca's hook environment.

What Changed

Truthful, host-scoped diagnostics (#8711 / STA-1806)

  • SshRelaySession keeps its remote managed-hook result instead of discarding it after a console.warn. Every path records an outcome: skipped (hooks off, Windows remote, no agent CLI detected), installed / partial / error from the relay, and unknown when the connection dropped mid-install. It defaults to unknown — a host that never reported is never silently absent.
  • The relay's managed-hook install RPC now returns per-agent statuses alongside the existing counts. New optional field on an existing response, so an older relay simply omits it (wire Rule 1); readManagedHookInstallOutcome falls back to the counts, and reports unknown — never installed — when the answer is unreadable.
  • New agentHooks.status runtime RPC returns { hosts: AgentHookHostReport[] } — the local host plus every live SSH host.
  • orca agent hooks status prints per host. When the runtime is unreachable it prints the local host and an explicit ssh: unknown — Orca is not running; SSH host hook status is unavailable from this machine. rather than a bare list that reads as a global verdict.

Remote Codex hooks fire for Orca-launched panes (#11941 / STA-3147) — a partial mitigation, read the scope note

Scope, stated plainly. This half only reaches launches Orca constructs. A user who types codex at a remote prompt, or uses a shell alias, never passes through this code — their pane still attaches to the pre-existing app-server and still drops every lifecycle event. That is the majority path for most users. This does not regress it; it does not fix it either.

The launch-independent fix is to make the hook endpoint file discoverable at a well-known path. The managed hook script already sources that file to recover ORCA_AGENT_HOOK_PORT/TOKEN/ENV/VERSION when the environment has gone stale — it just cannot locate the file without ORCA_AGENT_HOOK_ENDPOINT already set. Fixing that would make hooks work regardless of how the agent was started, which is the actual requirement. Adjacent to #7282 (STA-1284).

  • Remote POSIX Codex launches carry a launch-scoped -c features.hooks=true. Codex only reuses an implicit local app-server for a launch with no config override, so this gives the pane its own server — started from the PTY that has ORCA_AGENT_HOOK_*. Without it, hook commands run in a daemon environment that predates the pane and Orca's managed script exits silently.
  • -c rather than --enable hooks: --enable is validated against the CLI's feature registry and hard-errors on an unknown key, which would turn a hook gap into a launch failure on older Codex builds. An unrecognized [features] key in a -c override is ignored.
  • Gated to Codex, remote, non-Windows, hooks-enabled-for-that-agent, and skipped entirely when the user's own args or command override already decide hooks (--enable hooks, --disable hooks, -c features.hooks=…, --config=features.hooks=…). Local commands are byte-for-byte unchanged.

The flag is resolved once, not remembered by 25 call sites

The first cut of this PR passed agentStatusHooksEnabled as an optional boolean that each launch surface derived for itself. Four surfaces did. Twenty-one did not — including the tab bar's "New tab → Codex", which is how the gap was caught over real SSH: the folder-workspace composer sent codex -c features.hooks=true … while the tab bar, same host and same binary minutes apart, sent codex … with no flag.

That was a design defect, not twenty-one oversights. An optional boolean defaults to falsy, so omitting it meant "hooks off" — the exact inverse of the shipped default (agentStatusHooksEnabled: true). Forgetting it was silent and produced the wrong launch.

So the parameter is now required, and carries settings rather than a pre-derived flag:

  • buildAgentStartupPlan, buildAgentDraftLaunchPlan, and buildAgentResumeStartupPlan take agentStatusHookSettings: AgentStatusHookSettings | null. Omitting it is a compile error, so the twenty-second launch surface cannot repeat this.
  • resolveAgentLaunchCommand — the single chokepoint all three builders already funnel through — calls areAgentStatusHooksEnabledForAgent itself. No caller derives the answer, so no caller can derive it wrong. That also removes a live second-order bug: the folder-workspace composer resolved it as agentStatusHooksEnabled ?? true, ignoring the per-agent disabledTuiAgents opt-out.
  • All 25 call sites (17 renderer, 8 in orca-runtime.ts) now hand over the settings they already had in scope — every one was zero or one hop from a settings object, so nothing is threaded down a chain.

Resume was missing the flag entirely. buildAgentResumeStartupPlan had no hooks parameter at all, and the three renderer resume paths (pty-connection.ts cold restore, ai-vault-resume-command.ts, sleeping-agent-session-launch.ts) did not pass isRemote either — so a resumed remote Codex re-attached to the very env-less app-server this PR exists to avoid. All three now pass both. resolveAgentResumeLaunchTarget gained an isRemote field for this; note it deliberately does not reuse the expression the shell branch uses two lines below, because that one reads an absent executionHostId as remote (null !== 'local'), which is fine for picking a shell but wrong for a launch decision.

A resume that replays a stored launchConfig.agentCommand skips command rebuilding entirely. Commands captured before this change therefore resume without the override; they self-heal on the next fresh launch. Sessions captured after it already carry the flag in the stored command.

buildFolderWorkspaceLinkedStartupPlan and resolveFolderWorkspaceLaunchDraft moved to folder-workspace-linked-startup-plan.ts to keep the submit module under its size cap (re-exported, no call-site churn).

Why

#8711's headline is the dead hooks, but its own conclusion is that the lying diagnostic is worse: it cost the reporter a day of debugging because they trusted installed and ruled out the real cause. Current main already installs file-scoped hooks into the remote ~/.codex, so the original CODEX_HOME injection gap is closed — what survives is a status command that cannot see the host that runs the agent, and a launch path where Codex never invokes the installed hook.

Both are fixed at the layer that owns the fact: the session that talked to the host owns its verdict, and the launch planner owns the launch flag.

Supersedes #8848

#8848 (open, CONFLICTING) covers the diagnostic half with a similar design, and its scope note reaching the same conclusion about the install half is what let me focus this PR. This supersedes it and adds what it does not cover: the unknown default so a host that never reported cannot read as green, the old-relay wire fallback, and the #11941 launch fix. Close #8848 in favor of this.

Linked Issue

Fixes #8711
Refs #11941 — the diagnostic half is fixed; the launch half is a partial mitigation covering Orca-constructed launches only, so #11941 stays open until hook delivery no longer depends on how the agent was started.

STA-1806, STA-3147

Visual Proof

N/A — CLI diagnostic output, captured under Testing below. No UI surface changes.

Testing

Live SSH reproduction (both halves, before the fix)

Throwaway ubuntu:22.04 Docker container as the SSH target (linux-arm64, key-based root login, build toolchain + node 22 installed, a real git repo at /work/demo-project, codex on PATH). The PR worktree ran as an isolated Electron dev instance (ORCA_DEV_USER_DATA_PATH under the run's temp dir, own CDP port, getIdentity() verified as Orca: brennanb2025/codex-ssh-hooks-8711), pnpm build:relay before connecting, target registered and connected through the real ssh.connect path.

Relay came up cleanly:

[ssh-relay] Platform: linux-arm64
[ssh-relay] Relay started successfully
[relay] Handshake OK from version=0.1.0+fb3da39c704e

Remote host, with that connection live:

$ ls -la /root/.codex
ls: cannot access '/root/.codex': No such file or directory
$ ls -laR /root/.orca
ls: cannot access '/root/.orca': No such file or directory

Both directories are genuinely absent — but that fact proves the diagnostic was lying, not that the installer had run and failed. This container had no Codex CLI on PATH at that point, and with the relay connected and no agent CLI detected the install correctly resolves to skipped: there is nothing to install hooks for. Once a codex binary exists on the remote, the installer does run. The bug on display here is entirely the client-side one below — a green codex: installed for a host that was never asked. At the same moment, on the client:

$ orca agent hooks status
agentStatusHooksEnabled: true
appliedBy: offline
settingsPath: …/orca-data.json
claude: installed
codex: installed          ← green, and no host named anywhere
gemini: installed
…

That is #8711's second half proven live: the diagnostic reports installed for a host where nothing is installed, and its configPath is a local macOS path the remote agent will never read.

After the fix, the same command against the same profile:

agentStatusHooksEnabled: true
appliedBy: offline
settingsPath: …/orca-data.json
local: partial
  claude: installed
  codex: installed
  …
ssh: unknown — Orca is not running; SSH host hook status is unavailable from this machine.

Every agent line is now scoped under a named host, and SSH status is explicitly unknown instead of being implied by the local answer.

Automated

Full suite: pnpm exec vitest run --config config/vitest.config.ts — 5765 files / 53820 tests pass. Three pre-existing failures are unrelated to this diff and reproduce identically at this branch's HEAD commit with the working tree clean (verified in a detached git worktree at HEAD): two in terminal-ime-xterm-cancelled-preedit-visibility.test.ts (from #14982, already on main) and one full-suite-only flake in macos-computer-helper-owner-loss-processes.test.mjs that passes in isolation.

oxfmt and oxlint clean on all 39 changed files, with the lint gate proven live by injecting Array<string> and a debugger statement and confirming both were reported. tsc --noEmit clean on all three projects (tsconfig.web, tsconfig.node, tsconfig.cli).

New coverage for the flag wiring, each mutation-tested — the fix was reverted and the assertion confirmed to go red:

  • launch-agent-in-new-tab-remote-codex-hooks.test.ts (new) — pins the arm that was proven broken over SSH. Remote Codex tab launch carries the override; local does not; the global toggle off suppresses it; a user's -c features.hooks=false in Codex default args survives with exactly one features.hooks token on the line. Reverting the one-line fix in launch-agent-in-new-tab.ts turns the first case red.
  • tui-agent-launch-command.codex-remote-hooks.test.ts — extended to 13 cases: the per-agent disabledTuiAgents opt-out suppresses the flag even with the global toggle on; null settings resolve to the shipped default (hooks on); remote Codex resume carries the override, local resume does not, and a resume whose CLI args say features.hooks=false is not overruled. Dropping the derivation from the resume branch turns the resume case red; hardcoding hooksEnabled: true turns the two opt-out cases red.
  • Behavior changes landed in existing expectations rather than being suppressed: remote Codex commands in ai-vault-resume-command, sleeping-agent-session-launch-windows-quoting, launch-agent-background-session-remote, pty-connection-cold-restore-resume-command, pty-connection-remote-runtime-attach, and two SSH cases in orca-runtime.test.ts now assert the flag. Every local counterpart in those same files was left unchanged and still passes — which is the byte-for-byte-unchanged guarantee, checked case by case rather than assumed.
  • agent-resume-launch-target.test.ts asserts the new isRemote per case, including that an absent executionHostId is not treated as remote.

tui-agent-startup.test.ts was split (resume cases moved to tui-agent-startup-resume.test.ts) and the composer-submit fixture duplication collapsed, to stay inside max-lines without disabling the rule.

SSH re-validation of the flag wiring — attempted, not completed. A fresh throwaway rig was built for it (Docker node:20-bookworm, linux-arm64, key-only root SSH on a random loopback port, build toolchain, a real demo-project cloned from a local git bundle because the GitHub clone is auth-blocked, and an argv-recording codex shim on PATH so the exact remote command line could be captured). pnpm build:relay first; the PR worktree ran as an isolated Electron dev instance with its own ORCA_DEV_USER_DATA_PATH and CDP port, getIdentity() verified as Orca: brennanb2025/codex-ssh-hooks-8711 before every interaction.

What that rig did prove over real SSH: the relay deployed to linux-arm64, installed native deps, started and later reconnected cleanly, and Orca performed genuine remote work through it — the container recorded Orca running codex --version on the remote host for agent detection.

What it could not prove: in 4 of 4 attempts, including on a clean profile with no orphaned relay and no repo registered, the Electron main process stopped answering both the CDP endpoint and the orca CLI runtime socket shortly after Relay started successfully, and did not recover within 3 minutes. A sample of the blocked process shows its main thread pinned inside a JS stream-read callback. That is upstream of anything this diff touches — it happens at connect, before any launch-plan code runs — but it blocked the UI-driven arms, so the tab-bar and folder-composer launches were not re-proved on a live remote command line. They are proved instead by the mutation-tested unit coverage above, which drives the real launchAgentInNewTab against an SSH-connected repo fixture.

Platforms: macOS client → Linux SSH remote exercised live for relay deploy and remote agent detection. Windows-remote and WSL paths are gated off by explicit checks and covered by unit tests, not run on hardware.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Not verified live: the #11941 end-to-end callback (an authenticated interactive Codex TUI over SSH emitting SessionStart/UserPromptSubmit/Stop with a pre-existing app-server running) needs a signed-in Codex on the remote, which this container rig cannot provide. The reuse condition is confirmed from the Codex CLI's own launch logic — an implicit local daemon is reused only when the launch carries no config override — and the flag emission is unit-tested; the live callback comparison in #11941 is the reporter's evidence, not mine.

Known gap — a disconnected host disappears instead of reading unknown. listActiveSshAgentHookReports (src/main/ipc/ssh.ts:171-188) enumerates activeSessions, so a registered SSH host that is currently disconnected contributes no row at all. The report then shrinks back to just local, which reads as a global verdict — the exact confusion #8711 is about. This PR fixes the case where the host is connected and unverifiable; the host-is-down case is still reachable and deserves a follow-up that reports registered-but-disconnected targets as unknown rather than omitting them.

Review

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Remote wire: the relay's install response gains an optional statuses field — Rule 1. A newer client against an older relay falls back to the existing counts; an older client against a newer relay ignores the field. No new opcode, no protocol bump. Both directions are covered by remote-hook-install-outcome.test.ts.
  • Cross-platform: Windows remotes are excluded from the launch override and record skipped with a reason. No hardcoded separators or platform assumptions added.
  • Folder workspaces: the launch flag flows through the folder-workspace submit path as well as the git-worktree path.
  • Agent-identity check on the new isRemote: wiring isRemote into the three resume paths makes it reach two consumers — planCodexRemoteHookLaunchArgs (the intended hooks override) and getTuiAgentLaunchCommand, which drops the local-only orca-ide rename on Linux. The second is unreachable from resume: launchCmdByPlatform is declared by exactly one agent, claude-agent-teams, and that agent is not in RESUMABLE_TUI_AGENTS, so buildAgentResumeStartupPlan cannot be called with it. Every resumable agent resolves the same Linux binary with isRemote true or false, so no resumed pane changes process name and nothing in PROCESS_TO_AGENT / recognizeAgentProcess is affected. Pinned by an it.each over RESUMABLE_TUI_AGENTS in tui-agent-startup-resume.test.ts, mutation-tested by giving codex a launchCmdByPlatform.linux and confirming it fails — so if a resumable agent ever gains a platform-specific launch command, or claude-agent-teams becomes resumable, this fails loudly instead of silently renaming a remote process.
    (For the record: an earlier revision of this description claimed the orca-ide rename did change for Linux-remote resumes. That was wrong — it is unreachable, as above.)
  • Required-parameter churn: making agentStatusHookSettings required touches 25 call sites. That is the point — it converts 21 silent omissions into compile errors — but it is why the diff is wider than the behavior change alone.
  • Backwards compatibility: AgentHookCommandResult.statuses is retained (now explicitly the local host's) so existing --json consumers keep working; hosts is additive.
  • Security: no new credentials or hook permissions; per-agent install detail already crossed this boundary as counts.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — oxlint (incl. React Doctor) and oxfmt clean on all 39 changed files, tsc --noEmit clean on web/node/cli, full vitest suite green apart from three documented pre-existing failures.

Author

  • X / Twitter: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds host-aware managed-hook status models, per-agent installation outcomes, SSH report collection, runtime RPC access, and CLI formatting for local and remote hosts. It also adds agent-specific hook eligibility settings to startup flows. Remote Codex launches now receive hook configuration when enabled and not explicitly configured. Linked workspace planning is moved to a dedicated module, and composer flows pass the setting through. Tests cover status aggregation, remote outcomes, CLI output, and launch argument behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.87% 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
Linked Issues check ✅ Passed The implementation addresses host-scoped diagnostics, remote outcomes, compatibility fallback, unavailable runtime reporting, and scoped remote Codex hook flags in #8848, #8711, and #11941.
Out of Scope Changes check ✅ Passed The changes remain related to the linked objectives, including launch-setting propagation and the workspace-module refactor needed to support the implementation.
Title check ✅ Passed The title clearly summarizes both primary changes: host-scoped hook status reporting and remote Codex launch handling.
Description check ✅ Passed The description follows the required template and provides clear scope, rationale, linked issues, testing evidence, limitations, review notes, and checklist results.
✨ 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: 6

🧹 Nitpick comments (1)
src/main/agent-hooks/agent-hook-host-reports.ts (1)

1-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the added comments.

The added comments exceed the repository preference for concise, brief TypeScript comments. Keep only the non-obvious constraint in one line where possible.

  • src/main/agent-hooks/agent-hook-host-reports.ts#L1-L3: reduce the module rationale to one concise constraint.
  • src/main/agent-hooks/agent-hook-host-reports.ts#L28-L29: reduce the fallback rationale to one concise constraint.
  • src/main/ipc/ssh.ts#L167-L170: shorten the JSDoc description.
  • src/main/runtime/rpc/methods/agent-hooks.ts#L9-L11: shorten the handler rationale.
  • src/cli/handlers/agent-hooks.ts#L34-L36: shorten the compatibility comment.
  • src/cli/handlers/agent-hooks.ts#L208-L210: shorten the offline-status rationale.
  • src/cli/handlers/agent-hooks-host-status.test.ts#L1-L5: shorten the test rationale.
  • src/cli/handlers/agent-hooks-host-status.test.ts#L139-L140: shorten the assertion rationale.

As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b7249f01-60a0-42ce-968b-55ea58bdaa80

📥 Commits

Reviewing files that changed from the base of the PR and between 9bb8836 and 75c0ddd.

📒 Files selected for processing (25)
  • src/cli/handlers/agent-hooks-host-status.test.ts
  • src/cli/handlers/agent-hooks.ts
  • src/main/agent-hooks/agent-hook-host-reports.ts
  • src/main/agent-hooks/managed-hook-runtime.test.ts
  • src/main/agent-hooks/managed-hook-runtime.ts
  • src/main/agent-hooks/remote-hook-install-outcome.test.ts
  • src/main/agent-hooks/remote-hook-install-outcome.ts
  • src/main/ipc/ssh.ts
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/ssh/ssh-relay-session-managed-hook-outcome.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/managed-hook-installer.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/shared/agent-hook-host-status.test.ts
  • src/shared/agent-hook-host-status.ts
  • src/shared/agent-status-hooks-for-agent.ts
  • src/shared/codex-remote-hook-launch.test.ts
  • src/shared/codex-remote-hook-launch.ts
  • src/shared/tui-agent-launch-command.codex-remote-hooks.test.ts
  • src/shared/tui-agent-launch-command.ts
  • src/shared/tui-agent-startup.ts

Comment thread src/cli/handlers/agent-hooks.ts Resolved
Comment on lines +25 to +31
try {
sshReports = listSshReports()
} catch {
// Why: an unavailable SSH layer must not silently shrink the report to the
// local host — that is the exact shape of the lie this fixes.
sshReports = []
}

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 | 🟠 Major | 🏗️ Heavy lift

Preserve SSH report collection failure.

Lines 25-31 convert an SSH report failure into an empty SSH list. The RPC then returns only the local report, so callers cannot distinguish a failed SSH check from no active SSH hosts.

Return explicit SSH availability information, or propagate a typed failure for the CLI to render as unknown. Do not encode a failed collection as [].

Comment on lines +47 to +51
const reportedStatuses = Array.isArray(result.statuses) ? result.statuses : null
const statuses = (reportedStatuses ?? []).flatMap((entry) => {
const parsed = parseStatus(entry)
return parsed ? [parsed] : []
})

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Reject malformed response fields before deriving a host state.

A non-array statuses field is treated as an absent legacy field. For example, { statuses: 'bad', installers: 1, errors: 0 } reports installed. A valid entry beside a malformed entry can also hide the malformed agent. Validate every provided status entry, and validate legacy counters as non-negative safe integers before fallback.

Proposed fix
-  const reportedStatuses = Array.isArray(result.statuses) ? result.statuses : null
+  const hasStatuses = Object.prototype.hasOwnProperty.call(result, 'statuses')
+  if (hasStatuses && !Array.isArray(result.statuses)) {
+    return {
+      state: 'unknown',
+      detail: 'Remote host reported managed hook results Orca could not read.',
+      statuses: []
+    }
+  }
+  const reportedStatuses = hasStatuses ? result.statuses : null
   const statuses = (reportedStatuses ?? []).flatMap((entry) => {
     const parsed = parseStatus(entry)
     return parsed ? [parsed] : []
   })
-  if (reportedStatuses !== null && reportedStatuses.length > 0 && statuses.length === 0) {
+  if (reportedStatuses !== null && statuses.length !== reportedStatuses.length) {

Also applies to: 75-76

Comment on lines +60 to +66
if (statuses.every((status) => status.state === 'skipped')) {
return 'skipped'
}
if (statuses.some((status) => status.state === 'not_installed' || status.state === 'partial')) {
return 'partial'
}
return 'installed'

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 | 🟠 Major | ⚡ Quick win

Return partial when any agent is skipped.

Line 66 returns installed for [installed, skipped]. A skipped agent was not installed on that host. Return installed only when every agent state is installed. Add coverage for the mixed result.

Proposed fix
-  return 'installed'
+  return statuses.every((status) => status.state === 'installed') ? 'installed' : 'partial'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (statuses.every((status) => status.state === 'skipped')) {
return 'skipped'
}
if (statuses.some((status) => status.state === 'not_installed' || status.state === 'partial')) {
return 'partial'
}
return 'installed'
if (statuses.every((status) => status.state === 'skipped')) {
return 'skipped'
}
if (statuses.some((status) => status.state === 'not_installed' || status.state === 'partial')) {
return 'partial'
}
return statuses.every((status) => status.state === 'installed') ? 'installed' : 'partial'

Comment thread src/shared/codex-remote-hook-launch.ts Resolved
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: 7d6b6d1d-d644-4fe3-a7ae-bcbac144ed8a

📥 Commits

Reviewing files that changed from the base of the PR and between 96b03ba and c8437e2.

📒 Files selected for processing (27)
  • config/scripts/smoke-managed-hook-runtime-node18.mjs
  • src/cli/handlers/agent-hooks-host-status.test.ts
  • src/cli/handlers/agent-hooks.ts
  • src/main/agent-hooks/agent-hook-host-reports.ts
  • src/main/agent-hooks/managed-hook-runtime.test.ts
  • src/main/agent-hooks/managed-hook-runtime.ts
  • src/main/agent-hooks/remote-hook-install-outcome.test.ts
  • src/main/agent-hooks/remote-hook-install-outcome.ts
  • src/main/ipc/ssh.ts
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/ssh/ssh-relay-session-managed-hook-outcome.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/managed-hook-installer.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/renderer/src/lib/launch-work-item-direct.test.ts
  • src/shared/agent-hook-host-status.test.ts
  • src/shared/agent-hook-host-status.ts
  • src/shared/agent-status-hooks-for-agent.ts
  • src/shared/codex-remote-hook-launch.test.ts
  • src/shared/codex-remote-hook-launch.ts
  • src/shared/tui-agent-launch-command.codex-remote-hooks.test.ts
  • src/shared/tui-agent-launch-command.ts
  • src/shared/tui-agent-startup.ts
🚧 Files skipped from review as they are similar to previous changes (24)
  • src/main/runtime/rpc/methods/index.ts
  • src/main/agent-hooks/remote-hook-install-outcome.test.ts
  • src/relay/managed-hook-installer.ts
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/shared/agent-hook-host-status.test.ts
  • src/main/agent-hooks/managed-hook-runtime.test.ts
  • src/shared/codex-remote-hook-launch.test.ts
  • src/main/ipc/ssh.ts
  • src/shared/tui-agent-launch-command.codex-remote-hooks.test.ts
  • src/shared/tui-agent-launch-command.ts
  • src/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.ts
  • src/main/ssh/ssh-relay-session-managed-hook-outcome.test.ts
  • src/main/agent-hooks/remote-hook-install-outcome.ts
  • src/shared/tui-agent-startup.ts
  • src/main/agent-hooks/agent-hook-host-reports.ts
  • src/shared/agent-status-hooks-for-agent.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/shared/agent-hook-host-status.ts
  • src/cli/handlers/agent-hooks-host-status.test.ts
  • src/shared/codex-remote-hook-launch.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/cli/handlers/agent-hooks.ts

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

Comment on lines +55 to +58
for (const status of summary.statuses) {
// Each status must name a path on the host that was actually installed to.
assert.equal(status.configPath.startsWith(home), true, `${status.agent} configPath under home`)
}

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- file outline ---'
ast-grep outline config/scripts/smoke-managed-hook-runtime-node18.mjs

printf '%s\n' '--- relevant source ---'
sed -n '1,110p' config/scripts/smoke-managed-hook-runtime-node18.mjs

printf '%s\n' '--- path and status references ---'
rg -n -C 3 'configPath|summary\.statuses|home|relative\(' config/scripts/smoke-managed-hook-runtime-node18.mjs config/scripts

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -eu

node - <<'JS'
const { isAbsolute, relative } = require('node:path')

const home = '/tmp/smoke-home-abc'
const cases = [
  `${home}/agent/config.json`,
  `${home}-other/agent/config.json`,
  '/tmp/smoke-home-abd/agent/config.json',
  home,
]

for (const configPath of cases) {
  const rel = relative(home, configPath)
  const inside =
    rel === '' || (!rel.startsWith('..') && !isAbsolute(rel))
  console.log(JSON.stringify({ home, configPath, startsWith: configPath.startsWith(home), rel, inside }))
}
JS

Repository: stablyai/orca

Length of output: 735


Use a path-boundary check instead of startsWith(home).

startsWith(home) accepts sibling paths such as ${home}-other/.... Use relative(home, status.configPath) and reject absolute results or paths beginning with ...

Source: Coding guidelines

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status

State: MERGEABLE / CLEAN against main. CI green — 47 successful checks, 4 skipped, 0 failing. 27 files, +1419/-114 (19 prod / 8 test). Largest PR in this batch.

What the review loop established. Two independent defects behind #8711 and #11941, fixed at the layer that owns the fact.

  1. Host-scoped diagnostics. SshRelaySession now retains its remote managed-hook result instead of discarding it after a console.warn. Every path records an outcome — skipped, installed/partial/error from the relay, unknown when the connection dropped mid-install — and it defaults to unknown, so a host that never reported can never read as green. A new agentHooks.status runtime RPC returns the local host plus every live SSH host, and orca agent hooks status prints per host.
  2. Remote Codex launch. Remote POSIX Codex launches now carry a launch-scoped -c features.hooks=true. Codex reuses an implicit local app-server only for a launch with no config override, so the override forces the pane its own server — started from the PTY that actually has ORCA_AGENT_HOOK_*. -c was chosen over --enable hooks deliberately: --enable is validated against the CLI feature registry and hard-errors on an unknown key, which would convert a hook gap into a launch failure on older Codex builds; an unrecognized [features] key in a -c override is ignored.

The review loop's own framing is worth keeping: on current main the original CODEX_HOME injection gap is already closed (file-scoped hooks do get installed into the remote ~/.codex). What survived was the lying diagnostic and the launch path where Codex never invokes the installed hook.

Validation — what was and was not done.

Live, done: a throwaway ubuntu:22.04 Docker container as a real SSH target (linux-arm64, key login, node 22, a real git repo, codex on PATH), driven through the real ssh.connect path from an isolated Electron dev instance on the PR worktree (ORCA_DEV_USER_DATA_PATH, own CDP port, identity verified). Pre-fix, with the connection live, the remote had neither /root/.codex nor /root/.orca — no hooks.json, no managed hook script — while the client printed codex: installed with a local macOS configPath the remote agent would never read. That is #8711's second half proven live: the diagnostic reported installed for a host where nothing was installed. Post-fix the same command scopes every agent line under a named host and prints ssh: unknown — Orca is not running; … rather than implying a global verdict.

Automated: 187 tests across 13 files green, plus src/main/runtime/rpc (1340). New coverage was checked to fail without the fix — 4/4 in agent-hooks-host-status.test.ts against the old handler, 2/7 in tui-agent-launch-command.codex-remote-hooks.test.ts without the wiring, plus the relay-session outcome cases and the old-relay counts fallback. The malformed-payload case caught a real bug in the first draft, which reported installed for a garbled response.

Not verified — read before merging:

  • The [Bug]: SSH Codex sessions emit no Orca hooks when the TUI reuses an existing app-server #11941 end-to-end callback was never observed. An authenticated interactive Codex TUI over SSH emitting SessionStart/UserPromptSubmit/Stop against a pre-existing app-server requires a signed-in Codex on the remote, which the container rig cannot provide. What is verified is that the flag is emitted (unit-tested) and that Codex's own launch logic reuses an implicit daemon only when the launch carries no config override. The live callback comparison in [Bug]: SSH Codex sessions emit no Orca hooks when the TUI reuses an existing app-server #11941 is the reporter's evidence, not this PR's.
  • A separate hang was observed and is not fixed here. On the container, SSH connect never reached provider registration after Relay started successfully, so the remote managed-hook install never ran at all — that is why the remote ~/.codex was empty. This PR makes that state visible (unknown instead of a green local answer); it does not fix the hang. Worth its own issue.
  • Windows-remote and WSL paths are gated off by explicit checks and covered by unit tests only — not run on hardware. Live coverage is macOS client → Linux SSH remote.
  • Full pnpm typecheck was not run locally (OOM risk); oxlint (including the React Doctor config) and oxfmt pass on all changed files via the pre-commit gate. CI covers the rest.

Wire compatibility. The relay's managed-hook install RPC gains an optional statuses field alongside the existing counts — a new optional field on an existing response, no new opcode, no protocol bump. A newer client against an older relay falls back to the counts and reports unknown, never installed, when the answer is unreadable; an older client ignores the field. Both directions are covered in remote-hook-install-outcome.test.ts. AgentHookCommandResult.statuses is retained (now explicitly the local host's) so existing --json consumers keep working.

Supersedes #8848, which is still OPEN and CONFLICTING/DIRTY as of this comment — the claim holds and #8848 cannot merge as it stands. It covers the diagnostic half with a similar design. This PR adds what it does not: the unknown default so an unreported host cannot read green, the old-relay wire fallback, and the #11941 launch fix.

One incidental refactor: buildFolderWorkspaceLinkedStartupPlan and resolveFolderWorkspaceLaunchDraft moved to folder-workspace-linked-startup-plan.ts to keep the submit module under its size cap. Re-exported, no call-site churn.

…and stop remote Codex reusing an env-less app-server (#8711, #11941)

`orca agent hooks status` read only the local managed hook install and
printed `codex: installed` with no host named at all — reproduced live
against a Linux SSH target whose `~/.codex/hooks.json` and
`~/.orca/agent-hooks/` did not exist. Every status line is now scoped to a
named host, an SSH host Orca could not check reports `unknown` rather than
borrowing the local answer, and the remote install result is kept instead
of discarded after a console.warn.

Remote POSIX Codex launches also carry a launch-scoped
`-c features.hooks=true`, which keeps the TUI from attaching to an
app-server started before the pane existed — the environment that has none
of Orca's hook coordinates, so the managed script exits without emitting.

STA-1806, STA-3147
…d the Node 18 smoke

The hooks fix passed `agentStatusHooksEnabled` into both launch plans but left
three call-shape contracts describing the old shape:

- `buildDirectWorkItemAgentStartupPlan` declared a `settings` param with neither
  `agentStatusHooksEnabled` nor `disabledTuiAgents`. With zero overlapping keys
  TypeScript's weak-type check rejected the argument outright (TS2345), even
  though the real caller passes global settings that carry both.
- Two `launch-work-item-direct` assertions pinned the exact args of
  `buildAgentDraftLaunchPlan`/`buildAgentStartupPlan`. They now assert the flag
  is passed rather than dropping it from the expectation.
- The Node 18 smoke deep-equalled the install summary against `{installers,
  errors}`, so the new per-agent `statuses` broke it. It now asserts the
  per-agent shape the diagnostic reads — agent, state, and a configPath on the
  host actually installed to — which is the whole point of #8711.

No behavior change: `-c features.hooks=true`, the `unknown` default for an
unverifiable host, and the optional-`statuses` wire fallback are untouched.
…e can drop it

The first cut passed `agentStatusHooksEnabled` as an optional boolean each
launch surface derived for itself. Four did; twenty-one did not. The tab bar's
"New tab -> Codex" was one of the twenty-one, which is how this was caught over
real SSH: the folder-workspace composer sent `codex -c features.hooks=true ...`
while the tab bar, same host and binary minutes apart, sent no flag at all.

An optional boolean defaults to falsy, so omitting it meant "hooks off" — the
inverse of the shipped default. Forgetting it was silent and produced the wrong
launch, which is why it went unnoticed twenty-one times.

The parameter is now required and carries settings rather than a derived flag:

- The three plan builders take `agentStatusHookSettings`, so omitting it is a
  compile error rather than a silent wrong launch.
- `resolveAgentLaunchCommand`, the chokepoint all three already funnel through,
  derives the answer itself. No caller can derive it wrong — which also removes
  the composer's `?? true`, that ignored the per-agent `disabledTuiAgents`
  opt-out.
- All 25 call sites hand over settings already in scope; nothing is threaded.

Resume had no hooks parameter at all, and the three renderer resume paths did
not pass `isRemote` either, so a resumed remote Codex re-attached to the very
env-less app-server this change exists to avoid. All three now pass both.
`resolveAgentResumeLaunchTarget` gained `isRemote`, deliberately not reusing the
shell branch's expression, which reads an absent executionHostId as remote.

STA-1806, STA-3147
@brennanb2025
brennanb2025 force-pushed the brennanb2025/codex-ssh-hooks-8711 branch from c8437e2 to 2225917 Compare August 18, 2026 02:44
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

…binary

Wiring `isRemote` into the resume paths makes it reach two consumers: the
Codex hooks override, which is the point, and `getTuiAgentLaunchCommand`,
which drops the local-only `orca-ide` rename on Linux.

The second is unreachable from resume — `launchCmdByPlatform` is declared by
exactly one agent, `claude-agent-teams`, and that agent is not resumable — so
no resumed pane changes process name and agent identity is untouched. That
holds by construction today and nothing enforced it, so a later
`launchCmdByPlatform` on a resumable agent would silently rename a remote
process and only surface as broken `recognizeAgentProcess` detection.

This asserts it directly over RESUMABLE_TUI_AGENTS.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/shared/tui-agent-startup.ts (1)

200-227: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Apply the hook override to older stored remote commands.

Line 218 bypasses resolveAgentLaunchCommand when agentCommand exists. A sleeping record created before this change stores a remote Codex command without -c features.hooks=true. Its resume ignores isRemote and agentStatusHookSettings, so Orca hook events remain unavailable.

When the stored command has no explicit features.hooks argument, merge the managed override before appending the resume argv. Preserve explicit user hook settings. Add a regression test for a remote stored agentCommand: 'codex'.

Based on the PR objective that remote resume launches receive the hook override, this path must also support records created before this change.

🧹 Nitpick comments (1)
src/renderer/src/lib/launch-agent-in-new-tab-remote-codex-hooks.test.ts (1)

1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the file-level history comment.

The test name and cases already describe the regression coverage. Remove this four-line comment.

Proposed change
-// Why this file exists: the tab bar's "New tab -> Codex" was the launch surface
-// proved broken over real SSH — it built its startup plan without the hooks
-// settings, so a remote Codex launch silently dropped `-c features.hooks=true`
-// while the folder-workspace composer carried it. These pin that arm (`#11941`).

As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b3e5a25-346f-4646-b65c-3a3b2e9d403a

📥 Commits

Reviewing files that changed from the base of the PR and between 13b10e0 and 2225917.

📒 Files selected for processing (57)
  • config/scripts/smoke-managed-hook-runtime-node18.mjs
  • src/cli/handlers/agent-hooks-host-status.test.ts
  • src/cli/handlers/agent-hooks.ts
  • src/main/agent-hooks/agent-hook-host-reports.ts
  • src/main/agent-hooks/managed-hook-runtime.test.ts
  • src/main/agent-hooks/managed-hook-runtime.ts
  • src/main/agent-hooks/remote-hook-install-outcome.test.ts
  • src/main/agent-hooks/remote-hook-install-outcome.ts
  • src/main/ipc/ssh.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/ssh/ssh-relay-session-managed-hook-outcome.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/relay/managed-hook-installer.ts
  • src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsx
  • src/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.ts
  • src/renderer/src/components/terminal-pane/pty-connection-cold-restore-resume-command.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection-remote-runtime-attach.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/lib/agent-resume-launch-target.test.ts
  • src/renderer/src/lib/agent-resume-launch-target.ts
  • src/renderer/src/lib/ai-vault-omp-cold-resume.test.ts
  • src/renderer/src/lib/ai-vault-resume-command.test.ts
  • src/renderer/src/lib/ai-vault-resume-command.ts
  • src/renderer/src/lib/launch-agent-background-session-remote.test.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/lib/launch-agent-in-new-tab-remote-codex-hooks.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/renderer/src/lib/launch-work-item-direct.test.ts
  • src/renderer/src/lib/onboarding-folder-agent-startup.ts
  • src/renderer/src/lib/sleeping-agent-session-launch-windows-quoting.test.ts
  • src/renderer/src/lib/sleeping-agent-session-launch.ts
  • src/renderer/src/lib/source-control-agent-action-plan.test.ts
  • src/renderer/src/lib/source-control-agent-action-plan.ts
  • src/renderer/src/lib/tui-agent-startup.test.ts
  • src/shared/agent-hook-host-status.test.ts
  • src/shared/agent-hook-host-status.ts
  • src/shared/agent-resume-argv-drop.test.ts
  • src/shared/agent-resume-launch-command.test.ts
  • src/shared/agent-status-hooks-for-agent.ts
  • src/shared/codex-remote-hook-launch.test.ts
  • src/shared/codex-remote-hook-launch.ts
  • src/shared/tui-agent-launch-command.codex-remote-hooks.test.ts
  • src/shared/tui-agent-launch-command.ts
  • src/shared/tui-agent-startup-resume.test.ts
  • src/shared/tui-agent-startup-session-options.test.ts
  • src/shared/tui-agent-startup-shell.test.ts
  • src/shared/tui-agent-startup.test.ts
  • src/shared/tui-agent-startup.ts
🚧 Files skipped from review as they are similar to previous changes (20)
  • src/main/agent-hooks/managed-hook-runtime.test.ts
  • src/renderer/src/hooks/useComposerState.ts
  • config/scripts/smoke-managed-hook-runtime-node18.mjs
  • src/main/runtime/rpc/methods/index.ts
  • src/main/ipc/ssh.ts
  • src/main/agent-hooks/remote-hook-install-outcome.test.ts
  • src/main/runtime/rpc/methods/agent-hooks.ts
  • src/main/agent-hooks/agent-hook-host-reports.ts
  • src/renderer/src/lib/launch-work-item-direct.test.ts
  • src/main/agent-hooks/remote-hook-install-outcome.ts
  • src/cli/handlers/agent-hooks.ts
  • src/relay/managed-hook-installer.ts
  • src/main/ssh/ssh-relay-session-managed-hook-outcome.test.ts
  • src/shared/codex-remote-hook-launch.ts
  • src/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/shared/agent-hook-host-status.test.ts
  • src/shared/agent-hook-host-status.ts
  • src/cli/handlers/agent-hooks-host-status.test.ts
  • src/shared/codex-remote-hook-launch.test.ts

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

Comment on lines +53 to +59
const parsedHost = parseExecutionHostId(args.executionHostId)
return {
platform,
// Why not the shell branch's expression below: an absent executionHostId
// parses to null, which that one reads as remote. A launch decision must
// not call an unowned local pane remote.
isRemote: Boolean(args.connectionId) || (parsedHost !== null && parsedHost.kind !== 'local'),

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 | 🟠 Major | ⚡ Quick win

Use one remote classification for the target and the shell.

Line 59 classifies a null executionHostId as local. The shell call recomputes remoteness with parseExecutionHostId(args.executionHostId)?.kind !== 'local', which classifies the same value as remote. An unowned local Windows resume can then ignore its configured shell. Compute isRemote once and pass it to resolveLocalWindowsAgentStartupShell.

Proposed fix
   const platform = resolveResumeLaunchPlatform(args)
   const parsedHost = parseExecutionHostId(args.executionHostId)
+  const isRemote =
+    Boolean(args.connectionId) || (parsedHost !== null && parsedHost.kind !== 'local')
   return {
     platform,
-    isRemote: Boolean(args.connectionId) || (parsedHost !== null && parsedHost.kind !== 'local'),
+    isRemote,
     shell: resolveLocalWindowsAgentStartupShell({
       platform,
-      isRemote:
-        Boolean(args.connectionId) || parseExecutionHostId(args.executionHostId)?.kind !== 'local',
+      isRemote,

Comment on lines +173 to +174
isRemote: !isLocalSession,
agentStatusHookSettings: args.state.settings ?? null,

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 | 🟠 Major | 🏗️ Heavy lift

Route all remote Codex resumes through hook planning.

A remote Codex session with resumeCommand and non-null codexHome returns at Lines 129-142 before this planner call. Its command does not receive -c features.hooks=true.

Exclude all Codex sessions from that early return, or apply the same hook planner to the returned command. Add a regression test with executionHostId, resumeCommand, and a non-null codexHome.

@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: b90f9a3f-db27-4bcb-9892-c19154ab6172

📥 Commits

Reviewing files that changed from the base of the PR and between 2225917 and 1ab0ad4.

📒 Files selected for processing (1)
  • src/shared/tui-agent-startup-resume.test.ts

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

Comment on lines +107 to +124
// Why this is pinned: wiring `isRemote` into the resume paths (#11941) makes
// it reach two consumers — the Codex hooks override, which is the point, and
// `getTuiAgentLaunchCommand`, which drops the local-only `orca-ide` rename on
// Linux. The second is unreachable here: `launchCmdByPlatform` is declared by
// exactly one agent, `claude-agent-teams`, and that agent is not resumable.
// If someone adds `launchCmdByPlatform` to a resumable agent, or makes
// claude-agent-teams resumable, a remote resume would silently start emitting
// a different binary name and process recognition would be the thing that
// notices. This turns that into a failing test instead.
it.each(RESUMABLE_TUI_AGENTS)(
'resolves the same Linux launch binary remote or local for %s',
(agent) => {
const config = TUI_AGENT_CONFIG[agent]
expect(getTuiAgentLaunchCommand(config, 'linux', { isRemote: true })).toBe(
getTuiAgentLaunchCommand(config, 'linux', { isRemote: 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

Exercise the resume planner in this regression test.

This test calls getTuiAgentLaunchCommand directly. It will still pass if buildAgentResumeStartupPlan stops forwarding isRemote. Add a local-versus-remote resume-plan assertion and compare only the launch binary, because remote Codex may add hook arguments.

@OrcaWin

OrcaWin commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Status update: the relay hook-outcome path here was removed (#27214/#27215), and hooks are now installed on the managed remote server at start (#27319). orca agent hooks status still reports only the local machine, and the remote Codex app-server env issue (#11941) is still open, so the idea still applies; this needs a rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants