Skip to content

refactor(startup): one agent-hook runtime binding set for every host - #27720

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/p399-2-3
Oct 12, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/p399-2-3

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 0 0 0 0
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65 $\color{#cf222e}{\Huge{\mathbf{−}}}$​95 $\color{#cf222e}{\Huge{\mathbf{−}}}$​30

ELI5

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)

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ec625d65-48be-473c-8153-0bc848810aa0

📥 Commits

Reviewing files that changed from the base of the PR and between 7e0e832 and 57e738e.


📒 Files selected for processing (4)
  • src/main/agent-hooks/agent-hook-runtime-deps.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/runtime/agent-status-store-wiring.test-fixture.ts
  • src/main/startup/main-process-runtime-service.ts

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 | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed The title clearly and concisely describes the main change: consolidating agent-hook runtime bindings across all hosts.
Description check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit c70ce74 into main Oct 12, 2026
45 checks passed
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.

1 participant