fix(codex): preserve hook-driven agent status#8292
Conversation
📝 WalkthroughWalkthroughCodex hook support now includes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
490086a to
600e536
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/relay/agent-hook-server.ts (1)
317-334: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winPrevent duplicate Codex
SessionStartclears on the relay path. Insrc/relay/agent-hook-server.ts:317-334,normalizeHookPayload(..., 'codex', ...)deletes the cached status forSessionStart, so a second identical POST can re-enterforwardSessionStartClearafter the tombstone is written and broadcast a second clear. Skip this branch whenpreviousStatus.hookEventName === 'SessionStart'.
🧹 Nitpick comments (1)
src/main/agent-hooks/server.ts (1)
1310-1330: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the delete-side-effect inference used to detect a Codex SessionStart clear.
previousStatus && !this.state.lastStatusByPaneKey.has(paneKey)only works becausenormalizeHookPayload's Codex branch deletes the cache entry as a side effect of returningnullforSessionStart. Nothing here checkshookEventName/hook_event_namedirectly, so this reads as an accidental correlation rather than an intentional contract, and any future Codex event that also nulls-and-deletes for an unrelated reason would silently route through this same "clear" path (with its listener/telemetry side effects).A one-line comment stating this dependency (and ideally an explicit
hookEventName === 'SessionStart'check inclearStatusForSessionStartitself, mirroring the relay'singestRemoteexplicit check) would make the contract self-evident.Based on coding guidelines: "When code is driven by a design document or non-obvious constraint, add a brief one- or two-line comment explaining why it behaves that way."
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: be012b83-a822-4745-a4d4-09e9d1be5457
📒 Files selected for processing (16)
src/main/agent-hooks/server.test.tssrc/main/agent-hooks/server.tssrc/main/codex/codex-hook-identity.tssrc/main/codex/config-toml-trust.tssrc/main/codex/hook-service-wsl-runtime.test.tssrc/main/codex/hook-service.test.tssrc/main/codex/hook-service.tssrc/relay/agent-hook-server.test.tssrc/relay/agent-hook-server.tssrc/renderer/src/components/terminal-pane/codex-auto-approval-notification-suppression.test.tssrc/renderer/src/components/terminal-pane/codex-auto-approval-notification-suppression.tssrc/renderer/src/lib/agent-status.test.tssrc/shared/agent-detection.tssrc/shared/agent-hook-listener.test.tssrc/shared/agent-hook-listener.tssrc/shared/agent-title-status.ts
✅ Files skipped from review due to trivial changes (1)
- src/main/codex/hook-service-wsl-runtime.test.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- src/shared/agent-detection.ts
- src/main/codex/codex-hook-identity.ts
- src/renderer/src/lib/agent-status.test.ts
- src/renderer/src/components/terminal-pane/codex-auto-approval-notification-suppression.test.ts
- src/renderer/src/components/terminal-pane/codex-auto-approval-notification-suppression.ts
- src/shared/agent-title-status.ts
- src/main/codex/hook-service.ts
- src/main/codex/hook-service.test.ts
- src/shared/agent-hook-listener.ts
- src/main/codex/config-toml-trust.ts
600e536 to
1512f04
Compare
|
Addressed the latest CodeRabbit outside-diff finding in The relay now recognizes a prior Post-rebase verification: 3 focused files / 345 tests, full Node/CLI/Web typecheck, targeted lint/format, max-lines, diff check, and independent PASS / APPROVED review. |
1512f04 to
7582f64
Compare
Summary
SessionStartas an active turn while retaining its provider session identity for the next real status eventSessionStartclears while retaining the tombstone required for reconnect replaySubagentStartandSubagentStopwithout letting a child stop mark the root turn doneThis is the focused hooks/status replacement extracted from #7950. It intentionally excludes startup delivery, session bridging/native chat, auth/config, and rate-limit changes.
Refs #7950
Screenshots
No visual redesign.
Testing
oxlintoxfmt --checkpnpm check:max-lines-ratchetgit diff --check origin/main...HEADAI Review Report
The first independent gate found three blockers: remote prepend shifted user trust indices, SessionStart discarded the only session ID, and old server/WSL expectations contradicted the new event set. All three were reproduced with failing tests and fixed before submission.
A later CodeRabbit review found that a second relayed
SessionStartcould delete the cached tombstone and broadcast a duplicate clear. The final fix restores the prior tombstone after the shared normalizer's synchronous delete and returns without forwarding. Tests prove one clear, retained reconnect replay, and later working-state replacement. An independent second gate ended spec PASS / quality APPROVED.Final behavior separates session identity from visible status: SessionStart resets prior turn state and caches the new provider session, but only a later real prompt/tool/stop event reaches the UI.
Security Audit
Compatibility
The same normalizer serves local and relay hook traffic. Windows/WSL managed event lists include the new subagent events; no path separator, keyboard, UI label, or Git-provider behavior changes.
The branch was rebased onto current
origin/mainat667e04e72; range-diff preserved the two existing commits and added only the duplicate-SessionStart fix.Notes
Validation used the repository-declared Node 24 toolchain. Electron/E2E and physical SSH/WSL verification were intentionally not run in this review cycle.