Repository navigation
fix(agent-hooks): make agent hooks status report the SSH hosts that run the agents - #8848
xianjianlf2 wants to merge 17 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds structured remote agent hook installation reports to SSH relay sessions, covering installed, partial, skipped, and error states. Exposes local and remote hook statuses through a new runtime RPC method. Updates the CLI status command to display remote host reports and distinguish runtime-backed results from offline fallback results. Adds tests covering SSH installation outcomes, RPC responses, and CLI runtime availability paths. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 67a64825-0e56-4c8a-af0d-f2d05af7b4df
📥 Commits
Reviewing files that changed from the base of the PR and between 9e2c63e and 842dc964e345185b5db20c45b2b79ec0dad965fa.
📒 Files selected for processing (9)
src/cli/handlers/agent-hooks.test.tssrc/cli/handlers/agent-hooks.tssrc/main/ipc/ssh.tssrc/main/runtime/rpc/methods/agent-hooks.test.tssrc/main/runtime/rpc/methods/agent-hooks.tssrc/main/runtime/rpc/methods/index.tssrc/main/ssh/ssh-relay-session-agent-hook-report.test.tssrc/main/ssh/ssh-relay-session.tssrc/shared/agent-hook-types.ts
|
Addressed both review points in the latest push:
|
|
Taking a look! |
0180edd to
63a23b3
Compare
|
Thanks for the contribution — I rebased this onto current main and adapted the implementation to the newer relay-local hook installer, so SSH setup still uses one control-channel round trip while returning the detailed per-agent results needed for truthful host-aware status. I also kept reachable-runtime failures from falling back to a misleading local green, made offline text explicitly say SSH status is unavailable, and fenced late reconnect results so they cannot overwrite the current session report. Focused coverage now includes success/partial/error/skip paths, RPC and CLI behavior, and overlapping reconnects; the targeted suite (57 tests), node/CLI typechecks, touched-file lint, max-lines ratchet, and relay builds all pass. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/cli/handlers/agent-hooks.test.ts (1)
224-225: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider consolidating output assertions for consistency.
This test only checks
console.logfor the error message, whereas the similar test above (lines 175-179) checks bothconsole.errorandconsole.log. For consistency and robustness against potential changes inreportCliError, consider using the same combined check here.♻️ Proposed refactor
expect(process.exitCode).toBe(1) - expect(vi.mocked(console.log).mock.calls.flat().join('\n')).toContain('status transport failed') + const printed = [ + ...vi.mocked(console.error).mock.calls.flat(), + ...vi.mocked(console.log).mock.calls.flat() + ].join('\n') + expect(printed).toContain('status transport failed')
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b5d38b75-fc45-44bf-bcb1-39c1b9c3c8c1
📥 Commits
Reviewing files that changed from the base of the PR and between 0180edd212932618489ffab048ef921779030417 and 63a23b3974961ce7cc53f42c8400a042b9d85cfb.
📒 Files selected for processing (2)
src/cli/handlers/agent-hooks.test.tssrc/cli/handlers/agent-hooks.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/cli/handlers/agent-hooks.ts
63a23b3 to
2f96e6c
Compare
|
Rebased this onto current Local validation:
|
2f96e6c to
96f7a54
Compare
|
Rebased this onto current
Validation after the rebase:
|
|
Also picked up the remaining low-priority test nit: the runtime transport failure assertion now checks combined stderr/stdout output, matching the nearby test style. Validation:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
…un the agents Codex hooks on an SSH worktree live on the remote host, but `orca agent hooks status` only inspected the local managed install and reported `codex: installed` even when the remote install had failed — the exact configuration where status hooks go dead (stablyai#8711). - Record each relay session's remote managed-hook install outcome (installed/partial/skipped/error plus per-agent statuses) instead of discarding the results after a console.warn. - Expose the reports through a new `agentHooks.status` runtime RPC. - `orca agent hooks status` now asks the running runtime and prints a per-SSH-host section; when the runtime is unreachable (so no SSH agents can be running either) it falls back to the local-only report. Fixes stablyai#8711 Co-Authored-By: Claude Fable 5 <[email protected]>
…port writes by reconnect ownership Review feedback: - A reachable runtime whose agentHooks.status RPC fails was silently converted into a local-only report — which can read `installed` while SSH host state is unknown, the exact misleading green this command exists to prevent. Only an unreachable runtime falls back to local-only now; RPC failures surface with a nonzero exit. - Thread registerProviders' shouldContinue into the remote hook install so an aborted reconnect that resolves late cannot overwrite a newer attempt's install report with stale data. Co-Authored-By: Claude Fable 5 <[email protected]>
ab682ac to
25f51ca
Compare
|
Rebased all five existing commits onto the latest The updated branch preserves current-main behavior for:
It layers the host-aware reporting on top: the relay returns per-agent install statuses, each active SSH session records its current report with reconnect ownership protection, the runtime exposes local + remote reports, and the CLI distinguishes offline/unavailable SSH state from a clean remote result. Validation:
Current head: |
Greptile SummaryThe PR adds host-aware managed-hook diagnostics by retaining per-session SSH installation reports and exposing them through a runtime RPC to the CLI.
Confidence Score: 4/5The active-host omission should be fixed before merging because it can leave the status command green while an SSH host remains unchecked or pending. The new collector drops active sessions with null reports, and reachable installation paths can retain null long enough—or indefinitely after empty agent detection—for the CLI to omit the host whose status it is intended to diagnose. Files Needing Attention: src/main/ipc/ssh.ts and src/main/ssh/ssh-relay-session.ts
|
| Filename | Overview |
|---|---|
| src/main/ipc/ssh.ts | Adds active-session report collection, but silently excludes active hosts whose report is not yet available. |
| src/main/ssh/ssh-relay-session.ts | Records detailed installation outcomes with reconnect ownership fencing, while some reachable branches still leave the report null. |
| src/cli/handlers/agent-hooks.ts | Adds runtime-backed host-aware output and correctly surfaces reachable-runtime RPC failures. |
| src/main/runtime/rpc/methods/agent-hooks.ts | Adds a straightforward RPC returning local and collected active SSH installation reports. |
| src/main/agent-hooks/managed-hook-runtime.ts | Extends the managed-hook result contract with the resolved home and detailed installer statuses. |
| src/shared/agent-hook-relay.ts | Defines the expanded relay result shape consumed by the SSH session. |
| src/shared/agent-hook-types.ts | Defines remote host report states but does not include a pending or unknown state. |
Sequence Diagram
sequenceDiagram
participant CLI as agent hooks status
participant Runtime as Runtime RPC
participant Main as SSH session registry
participant Session as SshRelaySession
participant Relay as Remote relay
CLI->>Runtime: agentHooks.status
Runtime->>Main: list active SSH reports
Main->>Session: getAgentHookInstallReport()
Session-->>Main: report or null
Main-->>Runtime: local and remote reports
Runtime-->>CLI: host-aware status
Session->>Relay: installManagedHooks
Relay-->>Session: per-agent statuses
Session->>Session: record latest report
Reviews (1): Last reviewed commit: "fix(agent-hooks): align status RPC with ..." | Re-trigger Greptile
Assisted-by: OpenAI Codex (GPT-6 Astra, autonomous) Signed-off-by: MarkXian <[email protected]>
Remove unrelated formatting introduced by the merge commit hook. Assisted-by: OpenAI Codex (GPT-6 Astra, autonomous) Signed-off-by: MarkXian <[email protected]>
|
Thank you for this thorough work, @xianjianlf2! The legacy SSH relay it built on (relay sessions and the relay hook installer) has been removed; SSH hosts now run Orca's managed remote server, which installs hooks when it starts (#27319). The diagnostic idea still applies, so I've carried it over to #27399 with credit to you. |
ELI5
When an agent runs over SSH, hook status should describe that remote computer. An old successful check must not make a reconnecting host look healthy before its new check finishes.
What Changed
agentHooks.statusmethod andorca agent hooks status.unavailable, and report an empty supported-agent detection asskipped.method_not_foundfallback with explicit remote unavailability. Other reachable-runtime errors are not converted into a successful local-only result.Why
Local hook installation cannot establish the state of remote hooks. Reconnect also releases its attempt token before background installation necessarily finishes, which previously dropped valid late results and could leave stale status visible.
Linked Issue
Fixes #8711 (the diagnostic portion; remote installation itself already exists).
Visual Proof
N/A — CLI diagnostics and runtime state plumbing; no rendered UI change. No live SSH or Windows proof is claimed.
Testing
On macOS with
ORCA_BACKGROUND_LAUNCH=1(also verified on the required Node 24 runtime):pnpm test src/main/ssh/ssh-relay-session.test.ts src/main/ssh/ssh-relay-session-agent-hook-report.test.ts src/main/ssh/ssh-relay-session-managed-hooks.test.ts src/main/ipc/ssh.test.ts src/main/runtime/rpc/methods/agent-hooks.test.ts src/cli/handlers/agent-hooks.test.ts: 138 tests passed across 10 files, including the adjacent CLI load-boundary, isolated Codex-home, managed-hook-runtime, and relay-installer suites.pnpm tc:node,pnpm tc:cli, formatting, changed-code quality checks, andgit diff --checkpassed.AI Disclosure
Originally developed with Claude Code; this follow-up used OpenAI Codex for diagnosis, code, regression tests, and self-review.
Review
Reviewed report ownership across reconnect/disconnect, disabled and unsupported hosts, empty detection, and mixed-version fallback. The follow-up reuses the existing
unavailablestate without adding required wire fields or changing hook installation permissions. Host state remains owned by its execution host; the guards add constant-time identity checks.Agent skill upstream boundary
Checklist
N/Awith reasonAuthor
X: @mark86202384100
October 8 upstream refresh
Merged current upstream main and regenerated the RPC parameter catalog. The hook visibility regression now lives in a separate IPC test file to stay within the existing file-size limit. The initial 102 tests across 7 suites pass; after the test split, both affected IPC suites were rerun successfully. Full type checking, the follow-up node type check, formatting, and focused lint pass. Validation used ORCA_BACKGROUND_LAUNCH=1; live SSH validation was not repeated. This refresh was AI-assisted.