Repository navigation
fix(agent-hooks): preserve Antigravity ownership across nested hooks - #37955
Conversation
…ubagents
- Capture ORCA_HOOK_AGENT_PID/PPID and agentProcess in POSIX antigravity-hook.sh and admit antigravity in readHookAgentProcess so idle Antigravity process owners block nested CLI hooks
- Propagate paneOwner ({ agent, session }) on AgentStatusEntry and mobile status projections when a session-bound root owner is active
- Suppress nested guest CLI hooks (e.g. background grok subagent) in renderer status routing and live entry builder while paneOwner or foreground process remains on the parent owner
- Resolve effectiveAgentStatusOwnerType (paneOwner.agent ?? agentType) in desktop/mobile tab selectors and native-chat eligibility so an Antigravity terminal never flips to Grok Chat View
Fixes #37505
…capture - Capture ORCA_HOOK_AGENT_PID before launching the POSIX antigravity-hook.sh wrapper shell in getPosixManagedCommand - Drop stale incoming paneOwner when foregroundLeftExistingOwner transitions to a new foreground agent - Preserve paneOwner.session and matching remembered transcript metadata when a supported Native Chat owner has a nested guest status
Keep ownership at execution-host admission and preserve existing handoffs. Refs #37505
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
Carries over #37507 by @zhangxaochen.
ELI5
An Antigravity tab stays an Antigravity terminal when its background Grok task reports progress, including after Antigravity finishes a turn.
What Changed
Capture Antigravity's process before the managed hook shell and carry that proof through HTTP, startup replay and host relays. The existing host owner admits the status consumed by both desktop and mobile. Its turn boundary can retry root admission when it becomes foreground.
Why
Antigravity lacked process-backed ownership, so nested hooks could replace its identity after a done or stale turn. Reusing the existing process lifecycle rules also permits genuine exit, suspension and foreground handoffs without permanent session-based vetoes.
Linked Issue
Fixes #37505
STA-13500
Visual Proof
The same real foreground process and hook HTTP sequence on main
ab6f6a78807and this branch, in hidden Electron at 1440×900. Main switches identity to Grok; the fix retains Antigravity. A Node fixture supplies process proof; no liveagyexecutable is installed.Testing
On macOS, 277 focused tests pass across 24 files, with five platform skips. Failing-before/passing-after regressions cover done/stale ownership and foreground recovery. Suites cover HTTP/spool capture, relay root/exit/suspension and desktop consumers; 59 additional mobile identity/chat eligibility tests passed. The installed POSIX command was executed against a real process and HTTP receiver. Hidden Electron checks on both main and the fix assert rendered identity and terminal continuity through real HTTP ingestion, using disposable profiles and homes.
Local Linux, Windows, SSH/WSL and live Antigravity sessions were not exercised. Exact-head CI passed: PR checks passed and Mobile verify on
cca29c419c0371628d31dfe06a9d7c24e2172530. All twelve unit shards and both packaging jobs passed. The local excessive-selection limitation below remains unchanged.The required
ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2ran after the final rebase. All 28 non-unit checks passed, including node/web/CLI typechecks. Its broad related unit stage was canceled after 1207.5 seconds under the documented excessive-selection fallback; the full gate did not pass. Every selected input has named focused coverage.Exact commands, selected inputs and scoped fallback evidence
HEAD
cca29c419c0371628d31dfe06a9d7c24e2172530, baseab6f6a78807f985b9b7b993679e96fb4952f74c3. No tracked edit or rebase followed the required invocation.ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2selected 29 checks. All 28 non-unit checks passed, including full node, web and CLI typechecks. The broadrelated --rununit stage was canceled with SIGTERM after 1207.5 seconds because selection fanned out excessively. The gate returned 1 after 1208.3 seconds. This is an incomplete gate, not a pass. No pass cache was fabricated or base changed.landing-check-changed.logpreserves its buffered output.The coordinator explicitly approved the user-provided AGENTS.md fallback. Only this worktree's verified unit wrapper PID 25235 was signaled. Its Vitest PID 25429, worker children, and gate PID 25049 all exited; process group 25039 was empty afterward. No other session was signaled.
Every selected input
Paths in this table are relative to
src/.main/agent-hooks/hook-process-capture.tshook-process-capture.test.ts; actual installed command inmain/antigravity/posix-hook-invocation.test.tsmain/agent-hooks/hook-stdin-contract.tsspool.test.ts,managed-hook-stdin-lifecycle.test.ts,hook-script-outside-orca.test.ts,posix-hook-json-stdin-reader.test.tsmain/agent-hooks/runtime-home-hook-command.tshook-process-capture.test.ts,installer-utils.test.ts,managed-hook-stdin-lifecycle.test.ts,main/claude/post-compact-hook-command.test.tsmain/agent-hooks/server-antigravity-status-admission.test.tsmain/agent-hooks/server-hook-root-provenance.test.tsmain/agent-hooks/server-idle-process-owner.test.tsmain/agent-hooks/spool.test.tsmain/antigravity/hook-script.tsposix-hook-invocation.test.ts,hook-service.test.ts, shared stdin lifecycle and outside-Orca testsmain/antigravity/hook-service.tshook-service.test.ts,posix-hook-invocation.test.ts,main/agent-hooks/remote-hook-service-installers.test.tsmain/antigravity/posix-hook-invocation.test.tsshared/agent-hook-spool.tsagent-hook-spool-read.test.ts,agent-hook-spool-drain.test.ts,main/agent-hooks/spool.test.ts, installed POSIX startup spool testshared/agent-process-presence.tsagent-process-presence-probe.test.ts,agent-hook-owner-presence.test.tsshared/hook-root-attempts.tsmain/agent-hooks/server-hook-root-provenance.test.ts; server and relay root acquisition/replay suiteswsl-guest/agent-hook-envelope-build.tsagent-hook-server.test.ts,agent-hook-integration.test.ts,relay-idle-process-owner.test.ts,relay-hook-root-acquisition.test.ts, hook session bindingEvidence and exact commands
landing-rebase-tests.log: 277 passed, five platform skips across 24 named files on current HEAD. The exact command is recorded below.landing-dependents.txt: regenerated withbash /Users/kelvinamoaba/.agents/skills/orca-issue/scripts/test-dependents.sh --base origin/main. All listed tests are covered by the prior direct-dependent run or the current 24-file run. Compared with the prior inventory, onlyspool.test.tsmoved into the changed-test set; it passed in the current run. No missing named suite was found.implementation-dependent-tests.log: exact 30-file command at its first line, 306 passed and 28 skipped. Its sole failure was the obsolete spool source-fragment assertion, removed in the final patch and covered by the current passing spool run. All four rebased patches compare equal undergit range-diff; none of these direct-dependent test files changed in the nine main commits used for the rebase.implementation-mobile.log:cd mobile && ORCA_BACKGROUND_LAUNCH=1 pnpm test src/session/mobile-terminal-tab-agent.test.ts src/session/native-chat/mobile-native-chat-eligibility.test.ts --maxWorkers=2, 59 passed. These files and the ownership patch are unchanged through the rebase. No mobile ownership implementation was added.landing-main-render.log/landing-fixed-render.log: the ignored harness passed separately on exact main and fixed source, with real process/root reads and HTTP ingestion, 1440×900 rendered identity assertions and hidden-window assertions. Build commands and provenance are inrendered-proof-instructions.md.Current-HEAD focused command:
Excluded evidence: completion of the broad transitive related selection. No full-gate pass is claimed. Exact-head aggregate PR checks and Mobile verify remain mandatory before merge.
Prior direct-dependent command, with the obsolete spool assertion subsequently removed and its file passing on current HEAD:
Risk
Level: Medium
Process proof and relay serialization cross execution-host boundaries. Incorrect evidence could retain or retire the wrong owner. Existing root, exit and suspension admission remains shared; remote PIDs are never probed on desktop. Windows and older hook commands retain their unverified fallback, and older peers keep the existing wire fields. Revert the change to restore prior behavior; no saved-data migration is involved.
AI Disclosure
Review
Codex and Claude completed two consecutive clean review rounds. The rebased patches are unchanged according to
git range-diff.Agent skill upstream boundary
Notes
Desktop status listeners and the mobile status builder consume the same host-admitted agent/session pair. No mobile ownership logic is added. Folder and connection scoping use existing shared comparisons. Existing background-survivor lifecycle architecture remains outside this issue.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)