feat: integrate Codex hooks into cmux

Closed
AD
1mo ago
+1130-5

Summary

  • add first-class codex-hook command to cmux CLI with session mapping, notification routing, and workspace status updates
  • add bundled Resources/bin/codex wrapper that auto-injects Codex notify/TUI runtime config inside cmux
  • add Codex integration toggle in Settings and env wiring to disable wrapper hooks when needed
  • include Codex docs and regression coverage (test_codex_hook_session_mapping.py)
  • harden existing Claude mapping regression test to resolve surfaces from the created workspace

Linked Issue

Validation

  • xcodebuild -project GhosttyTabs.xcodeproj -scheme cmux -configuration Debug -destination 'platform=macOS' build
  • python3 tests/test_codex_hook_session_mapping.py
  • python3 tests/test_claude_hook_session_mapping.py
  • xcodebuild -project GhosttyTabs.xcodeproj -scheme cmux-unit -configuration Debug -destination 'platform=macOS' -only-testing:cmuxTests/GhosttyConfigTests test

Summary by cubic

Add first-class OpenAI Codex integration to cmux with a codex-hook CLI and a bundled codex wrapper to route notifications, track sessions, and update sidebar status (implements #854). This wires Codex events into the right workspace/surface and keeps status accurate.

  • New Features

    • New cmux codex-hook: session-start, stop, notification, approval, prompt-submit. Routes notifications and sets status (Running, Needs input, Approval requested, Error, Completed).
    • Session store with locking and 7‑day pruning maps session_id → workspace/surface/cwd; consumed on stop; avoids false “Error” on negated-failure outputs.
    • Bundled Resources/bin/codex wrapper auto-injects notify/TUI config (including approval events), generates session IDs, and sends start/stop. Falls back to real codex; disable via CMUX_CODEX_HOOKS_DISABLED=1.
    • Settings: “Codex Integration” toggle (default on) with env wiring in terminal view. Docs updated. Tests: E2E Codex session mapping; settings defaults; small Claude test fix.
  • Migration

    • No setup needed when running codex inside cmux; the wrapper handles hooks.
    • To opt out: Settings → Codex Integration off, or set CMUX_CODEX_HOOKS_DISABLED=1.
    • If managing Codex config manually, add notify=["cmux","codex-hook","notification"] and enable approval events in TUI as shown in docs.

Summary by CodeRabbit

  • New Features

    • Added Codex integration with cmux, including a codex-hook CLI and a fallback wrapper script for automatic event routing and lifecycle notifications.
    • Settings toggle for Codex hooks (enabled by default) exposed in the app settings.
  • Documentation

    • Updated Codex integration docs with configuration, notify/tui examples, and routing details.
  • Tests

    • Added end-to-end regression tests and unit tests validating Codex hook session mapping and settings.