You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(startup): one agent-hook runtime binding set for every host - #27720
The Orca desktop app (and its headless orca serve mode) and the standalone server orcad each hand the same twelve "agent status" connections to the runtime when it starts. Each copied them by hand, and a third copy lived in the test helper. This PR writes them once and has all three use that one list. Nothing changes for users.
What Changed
New src/main/agent-hooks/agent-hook-runtime-deps.ts exports agentHookRuntimeDeps(server, observedPaneIdentities, getSettings). It returns the twelve bindings between the runtime and the agent-status store: terminal status and Claude evidence ingest, the two status snapshots (with the providerSessionOnly filter), the provider-session rows, the observed pane identity read, the structured-chat sink, presence check, ended-process reconcile, removed-worktree drop, and the hook PTY env. The env is gated on the hooks setting.
main-process-runtime-service.ts (desktop and orca serve) and orcad-entry.ts spread that result into the OrcaRuntimeService constructor in place of their copied blocks.
The test helper agent-status-store-wiring.test-fixture.ts, used by nine runtime specs, now builds its bindings with the same function. Those specs now run against the real host wiring, not a hand-kept copy.
What stays per host, unchanged:
How each host captures the observed pane identity. The desktop records it straight away. orcad buffers it until PTY recovery. Unifying the two is deferred.
The desktop's agent-hook compatibility-authority attest/retire bindings. orcad has never passed these, and adding them would change its behaviour.
The startup order in each host.
Net lines: production −9 (+55 / −64), tests −21 (+10 / −31), total −30.
Why
There were three copies of the same twelve bindings. A change to one, like a new filter or a new store method, had to be repeated by hand in the others, and the test copy had already drifted to a six-binding subset. With one list, a host that forgets a binding can no longer silently list no agents.
Alternative considered and dropped: one shared startHeadlessRuntime helper that would also own the startup order (register PTYs → refresh orchestration authority → reconcile legacy workers → publish the headless graph → start RPC). I built it with an order-assertion test and measured it at +33 production lines. Each host needs a step between recovery and graph publish (offscreen browser on serve; recovery cleanup plus identity-capture attach on orcad) and builds its RPC server differently. That makes the hooks bigger than the five calls they replace, so it was left out of this cleanup. The existing serve order test (main-process-runtime-launch-activation.test.ts) and the orcad startup tests still cover each order.
Linked Issue
Phase 3.99 cleanup, PR 2.3 (maintainer refactor, no issue).
Visual Proof
N/A: main-process wiring refactor with no UI or behaviour change.
Testing
pnpm tc passes.
pnpm test on the nine fixture-backed runtime specs (97 tests), plus orcad-push-startup, orcad-entry, orcad-launch-contract, main-preflight-order, orcad-forked-child-paths, main-process-runtime-launch-activation, the main-process-ready-* startup tests, codex-hook-startup-wiring and runtime-home-catalog-account-key: all pass.
build:electron-vite and build:orcad pass, so the bundlers resolve the new module on both hosts (orcad loads it through a dynamic import, like its other agent-hook modules).
oxlint, pnpm run check:code-quality:changed (0 new findings) and pnpm lint pass.
Dead-code proof: no symbol is removed. Only inline object literals were replaced, so there is nothing for the @ts-nocheck files to hide.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Self-review plus an independent read-only review (P0/P1 only).
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
SSH/remote: no change. orcad, which serves managed SSH hosts, keeps exactly the same bindings and capture timing.
Windows/Linux/macOS: no platform-dependent code touched.
Wire compatibility: nothing published changes.
Folder workspaces: unaffected.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
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)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
📝 Walkthrough
Walkthrough
The change adds agentHookRuntimeDeps to build agent-hook runtime dependencies. The Orcad and main-process runtime setup paths now use the factory instead of defining those bindings inline. The status-store test fixture also uses the factory with agent-status hooks disabled. The factory filters provider-session-only entries from general snapshots and supplies PTY environment values only when agent-status hooks are enabled.
Priority: ⬇️ Low
Merge Risk:⚪ Minimal · up to 57e73
No actionable behavior change was identified in the production runtime bindings. The PR is mergeable after normal checks.
Pre-merge checks | 4 | 1
❌ Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: consolidating agent-hook runtime bindings across all hosts.
Description check
The description follows the repository template and explains the change, rationale, scope, testing, compatibility considerations, and checklist status. It correctly marks visual proof as not applicabl…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
The Orca desktop app (and its headless
orca servemode) and the standalone serverorcadeach hand the same twelve "agent status" connections to the runtime when it starts. Each copied them by hand, and a third copy lived in the test helper. This PR writes them once and has all three use that one list. Nothing changes for users.What Changed
src/main/agent-hooks/agent-hook-runtime-deps.tsexportsagentHookRuntimeDeps(server, observedPaneIdentities, getSettings). It returns the twelve bindings between the runtime and the agent-status store: terminal status and Claude evidence ingest, the two status snapshots (with theproviderSessionOnlyfilter), the provider-session rows, the observed pane identity read, the structured-chat sink, presence check, ended-process reconcile, removed-worktree drop, and the hook PTY env. The env is gated on the hooks setting.main-process-runtime-service.ts(desktop andorca serve) andorcad-entry.tsspread that result into theOrcaRuntimeServiceconstructor in place of their copied blocks.agent-status-store-wiring.test-fixture.ts, used by nine runtime specs, now builds its bindings with the same function. Those specs now run against the real host wiring, not a hand-kept copy.What stays per host, unchanged:
Net lines: production −9 (+55 / −64), tests −21 (+10 / −31), total −30.
Why
There were three copies of the same twelve bindings. A change to one, like a new filter or a new store method, had to be repeated by hand in the others, and the test copy had already drifted to a six-binding subset. With one list, a host that forgets a binding can no longer silently list no agents.
Alternative considered and dropped: one shared
startHeadlessRuntimehelper that would also own the startup order (register PTYs → refresh orchestration authority → reconcile legacy workers → publish the headless graph → start RPC). I built it with an order-assertion test and measured it at +33 production lines. Each host needs a step between recovery and graph publish (offscreen browser on serve; recovery cleanup plus identity-capture attach on orcad) and builds its RPC server differently. That makes the hooks bigger than the five calls they replace, so it was left out of this cleanup. The existing serve order test (main-process-runtime-launch-activation.test.ts) and the orcad startup tests still cover each order.Linked Issue
Phase 3.99 cleanup, PR 2.3 (maintainer refactor, no issue).
Visual Proof
N/A: main-process wiring refactor with no UI or behaviour change.
Testing
pnpm tcpasses.pnpm teston the nine fixture-backed runtime specs (97 tests), plusorcad-push-startup,orcad-entry,orcad-launch-contract,main-preflight-order,orcad-forked-child-paths,main-process-runtime-launch-activation, themain-process-ready-*startup tests,codex-hook-startup-wiringandruntime-home-catalog-account-key: all pass.build:electron-viteandbuild:orcadpass, so the bundlers resolve the new module on both hosts (orcad loads it through a dynamic import, like its other agent-hook modules).oxlint,pnpm run check:code-quality:changed(0 new findings) andpnpm lintpass.Dead-code proof: no symbol is removed. Only inline object literals were replaced, so there is nothing for the
@ts-nocheckfiles to hide.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Self-review plus an independent read-only review (P0/P1 only).
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)