Repository navigation
fix(agent-hooks): report hook status per host, and stop remote Codex reusing an env-less app-server (#8711, #11941) - #14621
brennanb2025 wants to merge 4 commits into
Conversation
📝 WalkthroughWalkthroughThe 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)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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: 6
🧹 Nitpick comments (1)
src/main/agent-hooks/agent-hook-host-reports.ts (1)
1-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueShorten 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
📒 Files selected for processing (25)
src/cli/handlers/agent-hooks-host-status.test.tssrc/cli/handlers/agent-hooks.tssrc/main/agent-hooks/agent-hook-host-reports.tssrc/main/agent-hooks/managed-hook-runtime.test.tssrc/main/agent-hooks/managed-hook-runtime.tssrc/main/agent-hooks/remote-hook-install-outcome.test.tssrc/main/agent-hooks/remote-hook-install-outcome.tssrc/main/ipc/ssh.tssrc/main/runtime/rpc/methods/agent-hooks.tssrc/main/runtime/rpc/methods/index.tssrc/main/ssh/ssh-relay-session-managed-hook-outcome.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/managed-hook-installer.tssrc/renderer/src/components/sidebar/folder-workspace-composer-submit.tssrc/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.tssrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/lib/launch-work-item-direct-agent.tssrc/shared/agent-hook-host-status.test.tssrc/shared/agent-hook-host-status.tssrc/shared/agent-status-hooks-for-agent.tssrc/shared/codex-remote-hook-launch.test.tssrc/shared/codex-remote-hook-launch.tssrc/shared/tui-agent-launch-command.codex-remote-hooks.test.tssrc/shared/tui-agent-launch-command.tssrc/shared/tui-agent-startup.ts
| 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 = [] | ||
| } |
There was a problem hiding this comment.
🎯 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 [].
| const reportedStatuses = Array.isArray(result.statuses) ? result.statuses : null | ||
| const statuses = (reportedStatuses ?? []).flatMap((entry) => { | ||
| const parsed = parseStatus(entry) | ||
| return parsed ? [parsed] : [] | ||
| }) |
There was a problem hiding this comment.
🗄️ 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
| if (statuses.every((status) => status.state === 'skipped')) { | ||
| return 'skipped' | ||
| } | ||
| if (statuses.some((status) => status.state === 'not_installed' || status.state === 'partial')) { | ||
| return 'partial' | ||
| } | ||
| return 'installed' |
There was a problem hiding this comment.
🎯 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.
| 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' |
fe8c06f to
c8437e2
Compare
|
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. |
There was a problem hiding this comment.
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
📒 Files selected for processing (27)
config/scripts/smoke-managed-hook-runtime-node18.mjssrc/cli/handlers/agent-hooks-host-status.test.tssrc/cli/handlers/agent-hooks.tssrc/main/agent-hooks/agent-hook-host-reports.tssrc/main/agent-hooks/managed-hook-runtime.test.tssrc/main/agent-hooks/managed-hook-runtime.tssrc/main/agent-hooks/remote-hook-install-outcome.test.tssrc/main/agent-hooks/remote-hook-install-outcome.tssrc/main/ipc/ssh.tssrc/main/runtime/rpc/methods/agent-hooks.tssrc/main/runtime/rpc/methods/index.tssrc/main/ssh/ssh-relay-session-managed-hook-outcome.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/managed-hook-installer.tssrc/renderer/src/components/sidebar/folder-workspace-composer-submit.tssrc/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.tssrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/lib/launch-work-item-direct-agent.tssrc/renderer/src/lib/launch-work-item-direct.test.tssrc/shared/agent-hook-host-status.test.tssrc/shared/agent-hook-host-status.tssrc/shared/agent-status-hooks-for-agent.tssrc/shared/codex-remote-hook-launch.test.tssrc/shared/codex-remote-hook-launch.tssrc/shared/tui-agent-launch-command.codex-remote-hooks.test.tssrc/shared/tui-agent-launch-command.tssrc/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.
| 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`) | ||
| } |
There was a problem hiding this comment.
🎯 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/scriptsRepository: 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 }))
}
JSRepository: 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
Review statusState: What the review loop established. Two independent defects behind #8711 and #11941, fixed at the layer that owns the fact.
The review loop's own framing is worth keeping: on current Validation — what was and was not done. Live, done: a throwaway Automated: 187 tests across 13 files green, plus Not verified — read before merging:
Wire compatibility. The relay's managed-hook install RPC gains an optional Supersedes #8848, which is still OPEN and One incidental refactor: |
…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
c8437e2 to
2225917
Compare
|
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.
There was a problem hiding this comment.
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 liftApply the hook override to older stored remote commands.
Line 218 bypasses
resolveAgentLaunchCommandwhenagentCommandexists. A sleeping record created before this change stores a remote Codex command without-c features.hooks=true. Its resume ignoresisRemoteandagentStatusHookSettings, so Orca hook events remain unavailable.When the stored command has no explicit
features.hooksargument, merge the managed override before appending the resume argv. Preserve explicit user hook settings. Add a regression test for a remote storedagentCommand: '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 valueRemove 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
📒 Files selected for processing (57)
config/scripts/smoke-managed-hook-runtime-node18.mjssrc/cli/handlers/agent-hooks-host-status.test.tssrc/cli/handlers/agent-hooks.tssrc/main/agent-hooks/agent-hook-host-reports.tssrc/main/agent-hooks/managed-hook-runtime.test.tssrc/main/agent-hooks/managed-hook-runtime.tssrc/main/agent-hooks/remote-hook-install-outcome.test.tssrc/main/agent-hooks/remote-hook-install-outcome.tssrc/main/ipc/ssh.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/agent-hooks.tssrc/main/runtime/rpc/methods/index.tssrc/main/ssh/ssh-relay-session-managed-hook-outcome.test.tssrc/main/ssh/ssh-relay-session.tssrc/relay/managed-hook-installer.tssrc/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsxsrc/renderer/src/components/right-sidebar/buildSourceControlAgentDeliveryPlan.tssrc/renderer/src/components/sidebar/folder-workspace-composer-submit.test.tssrc/renderer/src/components/sidebar/folder-workspace-composer-submit.tssrc/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.test.tssrc/renderer/src/components/sidebar/folder-workspace-linked-startup-plan.tssrc/renderer/src/components/terminal-pane/pty-connection-cold-restore-resume-command.test.tssrc/renderer/src/components/terminal-pane/pty-connection-remote-runtime-attach.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/hooks/useComposerState.tssrc/renderer/src/lib/agent-resume-launch-target.test.tssrc/renderer/src/lib/agent-resume-launch-target.tssrc/renderer/src/lib/ai-vault-omp-cold-resume.test.tssrc/renderer/src/lib/ai-vault-resume-command.test.tssrc/renderer/src/lib/ai-vault-resume-command.tssrc/renderer/src/lib/launch-agent-background-session-remote.test.tssrc/renderer/src/lib/launch-agent-background-session.tssrc/renderer/src/lib/launch-agent-in-new-tab-remote-codex-hooks.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-work-item-direct-agent.tssrc/renderer/src/lib/launch-work-item-direct.test.tssrc/renderer/src/lib/onboarding-folder-agent-startup.tssrc/renderer/src/lib/sleeping-agent-session-launch-windows-quoting.test.tssrc/renderer/src/lib/sleeping-agent-session-launch.tssrc/renderer/src/lib/source-control-agent-action-plan.test.tssrc/renderer/src/lib/source-control-agent-action-plan.tssrc/renderer/src/lib/tui-agent-startup.test.tssrc/shared/agent-hook-host-status.test.tssrc/shared/agent-hook-host-status.tssrc/shared/agent-resume-argv-drop.test.tssrc/shared/agent-resume-launch-command.test.tssrc/shared/agent-status-hooks-for-agent.tssrc/shared/codex-remote-hook-launch.test.tssrc/shared/codex-remote-hook-launch.tssrc/shared/tui-agent-launch-command.codex-remote-hooks.test.tssrc/shared/tui-agent-launch-command.tssrc/shared/tui-agent-startup-resume.test.tssrc/shared/tui-agent-startup-session-options.test.tssrc/shared/tui-agent-startup-shell.test.tssrc/shared/tui-agent-startup.test.tssrc/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.
| 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'), |
There was a problem hiding this comment.
🎯 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,| isRemote: !isLocalSession, | ||
| agentStatusHookSettings: args.state.settings ?? null, |
There was a problem hiding this comment.
🎯 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.
There was a problem hiding this comment.
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
📒 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.
| // 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 }) | ||
| ) | ||
| } | ||
| ) |
There was a problem hiding this comment.
🎯 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.
|
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). |
ELI5
orca agent hooks statusonly ever looked at your own Mac. Over SSH the agent runs on a different machine, so it happily saidcodex: installedwhile 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 saysunknowninstead 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)
SshRelaySessionkeeps its remote managed-hook result instead of discarding it after aconsole.warn. Every path records an outcome:skipped(hooks off, Windows remote, no agent CLI detected),installed/partial/errorfrom the relay, andunknownwhen the connection dropped mid-install. It defaults tounknown— a host that never reported is never silently absent.statusesalongside the existing counts. New optional field on an existing response, so an older relay simply omits it (wire Rule 1);readManagedHookInstallOutcomefalls back to the counts, and reportsunknown— neverinstalled— when the answer is unreadable.agentHooks.statusruntime RPC returns{ hosts: AgentHookHostReport[] }— the local host plus every live SSH host.orca agent hooks statusprints per host. When the runtime is unreachable it prints the local host and an explicitssh: 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
-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 hasORCA_AGENT_HOOK_*. Without it, hook commands run in a daemon environment that predates the pane and Orca's managed script exits silently.-crather than--enable hooks:--enableis 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-coverride is ignored.--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
agentStatusHooksEnabledas 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 sentcodex -c features.hooks=true …while the tab bar, same host and same binary minutes apart, sentcodex …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, andbuildAgentResumeStartupPlantakeagentStatusHookSettings: 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 — callsareAgentStatusHooksEnabledForAgentitself. 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 asagentStatusHooksEnabled ?? true, ignoring the per-agentdisabledTuiAgentsopt-out.orca-runtime.ts) now hand over the settings they already had in scope — every one was zero or one hop from asettingsobject, so nothing is threaded down a chain.Resume was missing the flag entirely.
buildAgentResumeStartupPlanhad no hooks parameter at all, and the three renderer resume paths (pty-connection.tscold restore,ai-vault-resume-command.ts,sleeping-agent-session-launch.ts) did not passisRemoteeither — so a resumed remote Codex re-attached to the very env-less app-server this PR exists to avoid. All three now pass both.resolveAgentResumeLaunchTargetgained anisRemotefield for this; note it deliberately does not reuse the expression the shell branch uses two lines below, because that one reads an absentexecutionHostIdas remote (null !== 'local'), which is fine for picking a shell but wrong for a launch decision.A resume that replays a stored
launchConfig.agentCommandskips 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.buildFolderWorkspaceLinkedStartupPlanandresolveFolderWorkspaceLaunchDraftmoved tofolder-workspace-linked-startup-plan.tsto 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
installedand ruled out the real cause. Currentmainalready installs file-scoped hooks into the remote~/.codex, so the originalCODEX_HOMEinjection 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: theunknowndefault 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.04Docker container as the SSH target (linux-arm64, key-based root login, build toolchain + node 22 installed, a real git repo at/work/demo-project,codexonPATH). The PR worktree ran as an isolated Electron dev instance (ORCA_DEV_USER_DATA_PATHunder the run's temp dir, own CDP port,getIdentity()verified asOrca: brennanb2025/codex-ssh-hooks-8711),pnpm build:relaybefore connecting, target registered and connected through the realssh.connectpath.Relay came up cleanly:
Remote host, with that connection live:
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
PATHat that point, and with the relay connected and no agent CLI detected the install correctly resolves toskipped: there is nothing to install hooks for. Once acodexbinary exists on the remote, the installer does run. The bug on display here is entirely the client-side one below — a greencodex: installedfor a host that was never asked. At the same moment, on the client:That is #8711's second half proven live: the diagnostic reports
installedfor a host where nothing is installed, and itsconfigPathis a local macOS path the remote agent will never read.After the fix, the same command against the same profile:
Every agent line is now scoped under a named host, and SSH status is explicitly
unknowninstead 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 detachedgit worktreeat HEAD): two interminal-ime-xterm-cancelled-preedit-visibility.test.ts(from #14982, already onmain) and one full-suite-only flake inmacos-computer-helper-owner-loss-processes.test.mjsthat passes in isolation.oxfmtandoxlintclean on all 39 changed files, with the lint gate proven live by injectingArray<string>and adebuggerstatement and confirming both were reported.tsc --noEmitclean 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=falsein Codex default args survives with exactly onefeatures.hookstoken on the line. Reverting the one-line fix inlaunch-agent-in-new-tab.tsturns the first case red.tui-agent-launch-command.codex-remote-hooks.test.ts— extended to 13 cases: the per-agentdisabledTuiAgentsopt-out suppresses the flag even with the global toggle on;nullsettings resolve to the shipped default (hooks on); remote Codex resume carries the override, local resume does not, and a resume whose CLI args sayfeatures.hooks=falseis not overruled. Dropping the derivation from the resume branch turns the resume case red; hardcodinghooksEnabled: trueturns the two opt-out cases red.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 inorca-runtime.test.tsnow 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.tsasserts the newisRemoteper case, including that an absentexecutionHostIdis not treated as remote.tui-agent-startup.test.tswas split (resume cases moved totui-agent-startup-resume.test.ts) and the composer-submit fixture duplication collapsed, to stay insidemax-lineswithout 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 realdemo-projectcloned from a local git bundle because the GitHub clone is auth-blocked, and an argv-recordingcodexshim onPATHso the exact remote command line could be captured).pnpm build:relayfirst; the PR worktree ran as an isolated Electron dev instance with its ownORCA_DEV_USER_DATA_PATHand CDP port,getIdentity()verified asOrca: brennanb2025/codex-ssh-hooks-8711before 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 --versionon 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
orcaCLI runtime socket shortly afterRelay started successfully, and did not recover within 3 minutes. Asampleof 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 reallaunchAgentInNewTabagainst 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.
Not verified live: the #11941 end-to-end callback (an authenticated interactive Codex TUI over SSH emitting
SessionStart/UserPromptSubmit/Stopwith 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) enumeratesactiveSessions, so a registered SSH host that is currently disconnected contributes no row at all. The report then shrinks back to justlocal, 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 asunknownrather than omitting them.Review
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
statusesfield — 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 byremote-hook-install-outcome.test.ts.skippedwith a reason. No hardcoded separators or platform assumptions added.isRemote: wiringisRemoteinto the three resume paths makes it reach two consumers —planCodexRemoteHookLaunchArgs(the intended hooks override) andgetTuiAgentLaunchCommand, which drops the local-onlyorca-iderename on Linux. The second is unreachable from resume:launchCmdByPlatformis declared by exactly one agent,claude-agent-teams, and that agent is not inRESUMABLE_TUI_AGENTS, sobuildAgentResumeStartupPlancannot be called with it. Every resumable agent resolves the same Linux binary withisRemotetrue or false, so no resumed pane changes process name and nothing inPROCESS_TO_AGENT/recognizeAgentProcessis affected. Pinned by anit.eachoverRESUMABLE_TUI_AGENTSintui-agent-startup-resume.test.ts, mutation-tested by givingcodexalaunchCmdByPlatform.linuxand confirming it fails — so if a resumable agent ever gains a platform-specific launch command, orclaude-agent-teamsbecomes resumable, this fails loudly instead of silently renaming a remote process.(For the record: an earlier revision of this description claimed the
orca-iderename did change for Linux-remote resumes. That was wrong — it is unreachable, as above.)agentStatusHookSettingsrequired 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.AgentHookCommandResult.statusesis retained (now explicitly the local host's) so existing--jsonconsumers keep working;hostsis additive.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) —oxlint(incl. React Doctor) andoxfmtclean on all 39 changed files,tsc --noEmitclean on web/node/cli, full vitest suite green apart from three documented pre-existing failures.Author