Skip to content

fix(agent-hooks): install Droid & Copilot managed hooks over SSH (#7253) - #7744

Merged
Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/bug-7253-ssh-agent-status
Jul 7, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
Jinwoo-H/bug-7253-ssh-agent-status

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7253 — Codex, Amp & Droid agent status rows missing in the task tree over SSH (Claude/Hermes work).

Root cause (structural, one bug class, two agents): Agent status over SSH depends on installRemoteManagedAgentHooks SFTP-ing each agent's hook config + managed script onto the remote host. It only iterates the REMOTE_MANAGED_HOOK_INSTALLERS registry. Droid had no installRemote method and wasn't in the registry; Copilot shipped a full installRemote (and its own remote-install test) but was also never added to the registry. So for both agents, no hook config ever reached the remote → the CLI never fired the managed hook → no status row. Claude/Hermes/Codex/Amp were registered, which is why they worked over SSH.

Note on Codex/Amp from the report: on the reporter's 1.4.120.0 and current main, Codex and Amp are registered with working remote installers, and I verified both install + round-trip correctly over real SSH. The still-reproducible structural miss is Droid (and, found during review, Copilot).

Changes

  • src/main/droid/hook-service.ts — add DroidHookService.installRemote (mirrors the grok/command-code sibling pattern). Extract buildInstalledDroidConfig so local install() and installRemote produce byte-identical ~/.factory/settings.json hook trees. getManagedScript('posix') always emits POSIX script/paths even from a Windows host; local default ('local') preserves existing Windows behavior.
  • src/main/agent-hooks/remote-managed-hook-installers.ts — register droid and copilot; export REMOTE_MANAGED_HOOK_INSTALLER_AGENTS for the invariant test.
  • src/main/agent-hooks/remote-hook-service-installers.test.ts — add a class-level invariant test: every locally-managed hook service that implements installRemote must be registered in the remote installer. This guards the whole bug class, not just these two agents. Plus a Droid config-shape test, a malformed-settings.json safety test, an aggregate droid+copilot install test, and Droid added to the POSIX-from-Windows loop.

Testing

  • Reproduced over a real Docker SSH target (throwaway Ubuntu container, demo-project cloned in): the production installRemoteManagedAgentHooks installed hook scripts/configs for claude/codex/amp/hermes + 10 others but wrote nothing for droid — no ~/.factory/settings.json, no droid-hook.sh.
  • Proved the round-trip: with the managed script staged, firing it (payload on stdin, endpoint env injected) POSTed to /hook/droid with the auth token and URL-encoded payload — confirming the only gap was the missing install.
  • Verified the fix over the same real SSH path: the aggregate install now writes a well-formed ~/.factory/settings.json (all 8 events, if [ -x ] guard, timeout: 10) plus an executable droid-hook.sh.
  • Invariant test proven to catch the bug: temporarily un-registering copilot makes the new test fail with expected [ 'copilot' ] to deeply equal [].
  • pnpm tsgo (node project) + oxlint clean; 62 tests pass across the touched suites.

Cross-platform / scope notes

  • Remote install is POSIX-only, matching every other agent (Windows-remote is out of scope for the relay's managed-hook path and is guarded upstream in installManagedHooksOnRemote). Local Windows/macOS/Linux behavior is unchanged.
  • No GitLab-specific surface; mobile unaffected (this is desktop main-process ↔ remote relay).

🤖 Generated with Claude Code

Made with Orca 🐋

Droid and Copilot each shipped a working `installRemote` (and, for
Copilot, its own remote-install test) but were never registered in
`REMOTE_MANAGED_HOOK_INSTALLERS`. Over SSH, `installRemoteManagedAgentHooks`
only iterates that list, so neither agent's hook config or managed script
ever reached the remote host — the CLI never fired the hook and no agent
status row appeared in the task tree. Claude/Hermes/Codex/Amp were
registered, which is why they worked over SSH.

- Add `DroidHookService.installRemote` (mirrors the grok/command-code
  sibling pattern; extracts `buildInstalledDroidConfig` so local and
  remote produce identical Factory settings.json; always emits POSIX
  script/paths even from a Windows host).
- Register `droid` and `copilot` in `REMOTE_MANAGED_HOOK_INSTALLERS`.
- Add a class-level invariant test: every locally-managed hook service
  that implements `installRemote` must be registered in the remote
  installer. This guards the whole bug class, not just these two agents.

Verified end-to-end over a real Docker SSH target: the aggregate install
now writes ~/.factory/settings.json + droid-hook.sh, and the managed hook
POSTs to /hook/droid with the auth token and payload.

Fixes #7253

Co-authored-by: Orca <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

This change adds Copilot and Droid to the remote-managed hook installer registry, exporting a new REMOTE_MANAGED_HOOK_INSTALLER_AGENTS constant. The Droid hook service is refactored around a shared buildInstalledDroidConfig helper used by both local install() and rewritten installRemote(), and getManagedScript() now accepts a target parameter to force POSIX script generation on remote hosts regardless of server OS. Regression tests covering issue #7253 verify installer registration coverage, aggregate remote installation, Droid settings.json hook writing, and error handling for malformed remote configuration files.

Sequence Diagram(s)

Included in hidden artifact.

Related Issues: #7253

Estimated code review effort: High

Suggested labels: area:agent-hooks, droid, testing

Suggested reviewers: (none identified)

Poem
A rabbit hops through settings.json's maze,
Wiring Droid and Copilot hooks in new ways,
POSIX scripts written, remote and true,
Regression tests guard what the config can do,
Hop, commit, and merge — another burrow anew. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the SSH managed-hook install fix for Droid and Copilot.
Description check ✅ Passed The description includes a clear summary, changes, testing, and platform notes, so it is mostly complete despite missing some template sections.
Linked Issues check ✅ Passed The changes add remote installation support, registry wiring, and regression tests for the SSH agent-status bug class.
Out of Scope Changes check ✅ Passed The added Copilot wiring and tests stay within the same remote-managed hook installation scope and are directly related to the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 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.

🧹 Nitpick comments (3)
src/main/droid/hook-service.ts (1)

250-269: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the remote script filename to avoid literal drift.

'droid-hook.sh' is hardcoded twice: once embedded in remoteScriptPath (Line 252) and once passed directly to buildInstalledDroidConfig (Line 265). If either literal is edited without the other, createManagedCommandMatcher silently stops matching managed entries, defeating the sweep/cleanup logic — exactly the kind of quiet drift this PR is meant to prevent.

♻️ Proposed fix
   async installRemote(sftp: SFTPWrapper, remoteHome: string): Promise<AgentHookInstallStatus> {
     const home = remoteHome.replace(/\/$/, '')
     const remoteConfigPath = `${home}/.factory/settings.json`
-    const remoteScriptPath = `${home}/.orca/agent-hooks/droid-hook.sh`
+    const REMOTE_SCRIPT_FILE_NAME = 'droid-hook.sh'
+    const remoteScriptPath = `${home}/.orca/agent-hooks/${REMOTE_SCRIPT_FILE_NAME}`
     try {
       const config = await readHooksJsonRemote(sftp, remoteConfigPath)
       ...
-      buildInstalledDroidConfig(config, wrapPosixHookCommand(remoteScriptPath), 'droid-hook.sh')
+      buildInstalledDroidConfig(config, wrapPosixHookCommand(remoteScriptPath), REMOTE_SCRIPT_FILE_NAME)
src/main/agent-hooks/remote-hook-service-installers.test.ts (2)

661-663: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicate hooks property in type cast.

The inline type annotation repeats the identical hooks: Record<...> member four times. TypeScript accepts identical duplicate members silently, but this is clearly a copy-paste artifact and should be collapsed to a single declaration.

🧹 Proposed fix
     const config = JSON.parse(fs.files.get('/home/dev/.factory/settings.json')!) as {
       hooks: Record<string, { matcher?: string; hooks?: { command: string }[] }[]>
-      hooks: Record<string, { matcher?: string; hooks?: { command: string }[] }[]>
-      hooks: Record<string, { matcher?: string; hooks?: { command: string }[] }[]>
-      hooks: Record<string, { matcher?: string; hooks?: { command: string }[] }[]>
     }

646-708: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a local/remote parity test.

buildInstalledDroidConfig's own doc comment states its purpose is to keep install() and installRemote() "byte-identical" hook trees, but no test here directly asserts that parity — only installRemote()'s output is checked. A test comparing install()'s and installRemote()'s resulting hook structures (normalizing the platform-specific command string) would directly validate the PR's stated invariant and catch future divergence between the two code paths.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c4d7ff0b-c53b-4183-9e51-554cca06df01

📥 Commits

Reviewing files that changed from the base of the PR and between bea9b38 and f7f827b.

📒 Files selected for processing (3)
  • src/main/agent-hooks/remote-hook-service-installers.test.ts
  • src/main/agent-hooks/remote-managed-hook-installers.ts
  • src/main/droid/hook-service.ts

@Jinwoo-H
Jinwoo-H merged commit 5790793 into main Jul 7, 2026
2 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/bug-7253-ssh-agent-status branch July 7, 2026 21:21
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex, Amp & Droid agent status not shown in task tree over SSH remote (works locally; Claude/Hermes OK over SSH)

1 participant