fix(desktop): ignore Codex subagent completion notifications

Merged
JU
3mo ago
+19-24

Context

Codex subagents trigger Superset completion notifications while the root agent is still working. Superset's wrapper injects Codex's legacy notify callback, which emits the same agent-turn-complete payload for root and child threads without ancestry metadata. This is the Codex form of #1785; OpenAI tracks the missing distinction in codex#16226.

Changes

  1. Notify only for the root Codex turn. Stops overriding notify; Superset's existing native Stop hook handles root completion while Codex routes child completion to the unregistered SubagentStop event.
  2. Keep active-state signals unchanged. Retains the process-scoped session-log watcher for Start and permission events and the wrapper-owned SessionEnd signal.
  3. Preserve user Codex configuration. Removing the command-line override lets any user-owned notify setting resolve normally.

Verification

A live Codex 0.147 run with one delegated child produced two indistinguishable legacy callbacks, but native hooks produced exactly one root Stop and one separate SubagentStop. The focused regression assertion failed before removing the override and passed after.

  • bun test src/main/lib/agent-setup/agent-wrappers.test.ts src/main/lib/agent-setup/notify-hook.test.ts — 74 pass
  • bunx biome check apps/desktop/src/main/lib/agent-setup/agent-wrappers.test.ts apps/desktop/src/main/lib/agent-setup/agent-wrappers-claude-codex-opencode.ts — pass
  • git diff --check — pass

Summary by cubic

Stops emitting completion notifications from Codex subagents by removing the wrapper’s legacy notify injection and relying on native hooks. Previously root and subagent turns both surfaced as agent-turn-complete; now only the root turn triggers Stop, while subagents emit unregistered SubagentStop to prevent duplicate or early completions.

  • Codex wrapper runs with --enable hooks only; it no longer adds -c 'notify=…'.
  • Session-log watcher still handles Start and permission events; no behavior change.
  • User ~/.codex/hooks.json and any existing notify config are left intact.
  • Tests assert no notify override and correct hook enablement; docs describe native hooks and session-log signals.

Summary by CodeRabbit

  • Bug Fixes

    • Improved Codex event handling through native hook support.
    • Reduced inaccurate completion notifications caused by subagent activity.
    • Preserved compatibility for Start and permission events on older Codex versions.
    • Improved workspace trust handling while maintaining support for custom Codex arguments.
  • Documentation

    • Updated Codex integration guidance to reflect the revised event-handling behavior and compatibility support.