Skip to content

Fix Codex agent status in remote SSH workspaces - #18792

Merged
austinywang merged 6 commits into
mainfrom
task-remote-codex-status
Oct 10, 2026
Merged

austinywang merged 6 commits into
mainfrom
task-remote-codex-status

Conversation

@austinywang

@austinywang austinywang commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Remote Codex sessions now report status in the cmux-tui terminal that launched them, including when Codex runs hooks through a shared app-server daemon.

  • Add a Codex PATH shim and hidden wrapper that injects per-launch hook commands with explicit socket and terminal context.
  • Scope trust to generated session hooks, suppress only the installed cmux hook copies for that launch, and preserve user hooks and Claude behavior.
  • Keep Codex global config flags before session subcommands and document the separate ssh-tmux mirror boundary.

Testing

  • Hosted focused verification: ./scripts/verify-cmux-tui-hosted.sh --filter codex_wrapper_remote_hooks
    • Linux: passed
    • macOS: passed
    • Rust MSRV 1.91: passed
    • clippy and rustfmt on Linux/macOS: passed
  • python3 scripts/verify-local.py: passed applicable checks
  • ./scripts/localize-changes: passed; no localization keys changed
  • git diff --check: passed
  • Regression exercises generated hooks through a real Unix journal socket with cleared and stale daemon environments, terminal switching, scoped trust, duplicate suppression, management pass-through, and config hoisting.

Issues

Changelog

  • Fixed Codex agent status reporting for SSH workspaces and shared Codex daemons.

Impact map

  • Source of truth: cmux-tui Codex wrapper and the existing agent hook installer.
  • Direct callers and sibling entrypoints inspected: Claude wrapper, Codex app-server/config launch paths, SSH propagation, tmux fallback route, and journal ingress.
  • Cross-surface effects: cmux ssh remote journal status is covered; ssh-tmux mirrors remain on tmux control transport and have no agent-status subscription.
  • Residual risk: this carries hook context into Codex's generated hook processes; it does not change shared-daemon authorization for direct cmux notify calls.

Mergeability


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Changes how Codex is launched and which hook commands run, including per-session config/trust injection, but follows the established Claude wrapper pattern and scopes trust to cmux-generated session hooks only.

Overview
Fixes Codex agent status in remote SSH workspaces when Codex runs hooks through a shared app-server that no longer has the launching terminal’s CMUX_TUI_* environment.

Adds a Codex PATH shim and hidden cmux-tui agent codex-wrapper entrypoint (mirroring the existing Claude wrapper). On real session launches (exec, resume, fork), the wrapper injects Codex session -c flags that enable hooks whose commands embed the socket, terminal id, and cmux-tui helper path directly—so journal events still route to the correct pane after the original shell is gone. It trusts only those generated hooks, disables installed cmux hook copies for that invocation (avoiding duplicates), and hoists root-level -c/--enable/--disable ahead of subcommands so injected settings are not dropped. Management/help invocations and opt-out env vars pass through unchanged; pane startup prepends the shim directory on PATH when needed.

agent_hook_install gains codex_session_hook_settings and contextual hook command builders; session_route is exposed from the hook helper for the wrapper. Integration tests exercise multi-terminal routing under cleared/stale daemon env, trust scoping, and pass-through behavior; agent-hooks docs describe the Codex-without-install flow and the ssh-tmux mirror limitation.

Reviewed by Cursor Bugbot for commit 48bf4b4. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Fixes Codex agent status reporting in the cmux-tui terminal that launched the session, including when Codex runs hooks through a shared app-server daemon.

  • Adds a Codex PATH shim and hidden wrapper (cmux-tui agent codex-wrapper) that embeds the socket and terminal id in each generated hook command, so hooks keep reporting correctly even after the daemon outlives the launching shell.
  • Trusts only the generated session hooks for that launch, disables the installed cmux hook copies, and leaves user hooks, trust settings, and Claude behavior untouched.
  • Covers exec, resume, and fork sessions; management and informational commands pass through unchanged, and session config flags are hoisted before the subcommand.
  • ssh-tmux mirrors are unaffected — they run on tmux control transport and have no agent-status subscription.
  • Set CMUX_TUI_CODEX_HOOKS_DISABLED=1 to skip injection.

Related: #15473

Written for commit 48bf4b4. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • New Features
    • Codex sessions launched through cmux can now send session activity to the correct terminal, including through SSH/tmux routing. Hook settings are applied for the session without changing persistent Codex configuration, and existing user hooks are preserved.
    • Codex management and informational commands, as well as sessions where hooks are disabled, continue to run without session hook injection.
  • Documentation
    • Added guidance on Codex hook behavior, setup conditions, opt-out, and known limitations.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9377eb22-0137-432f-8af4-32a2c166511b
📥 Commits

Reviewing files that changed from the base of the PR and between f6532b1 and 48bf4b4.

📒 Files selected for processing (6)
  • cmux-tui/crates/cmux-tui/src/agent_hook_install.rs
  • cmux-tui/crates/cmux-tui/src/bin/cmux-tui-hook.rs
  • cmux-tui/crates/cmux-tui/src/codex_wrapper.rs
  • cmux-tui/crates/cmux-tui/src/main.rs
  • cmux-tui/crates/cmux-tui/tests/codex_wrapper.rs
  • cmux-tui/docs/agent-hooks.md

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

Adds a Unix Codex wrapper that injects session-specific hook settings for eligible launches. Generated hook commands include the active socket and terminal identifiers. The wrapper passes through ineligible launches and adds a Codex shim to pane processes.

Changes

Codex session hooks

Layer / File(s) Summary
Generate session hook settings
cmux-tui/crates/cmux-tui/src/agent_hook_install.rs, cmux-tui/crates/cmux-tui/src/bin/cmux-tui-hook.rs
Generated commands set the socket and terminal identifiers, invoke the helper for each Codex event, and suppress helper errors. Session settings disable persisted cmux-owned hooks and add event-specific timeouts and trust hashes.
Route Codex launches through the wrapper
cmux-tui/crates/cmux-tui/src/codex_wrapper.rs, cmux-tui/crates/cmux-tui/src/main.rs, cmux-tui/docs/agent-hooks.md
The wrapper classifies launch commands, handles session options, locates the real Codex executable, and injects hook settings when eligible. Startup dispatches wrapper invocations and adds the shim path to child PATH. The documentation describes routing, opt-outs, and limitations.
Validate wrapper and event routing
cmux-tui/crates/cmux-tui/src/codex_wrapper.rs, cmux-tui/crates/cmux-tui/tests/codex_wrapper.rs
Tests cover launch classification, argument handling, pass-through cases, hook suppression and trust scope, and delivery of events to the matching terminal.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant CodexShim
  participant CmuxTuiWrapper
  participant Codex
  participant HookHelper
  participant JournalSocket
  CodexShim->>CmuxTuiWrapper: invoke codex-wrapper
  CmuxTuiWrapper->>Codex: exec with session hook settings
  Codex->>HookHelper: invoke contextual event command
  HookHelper->>JournalSocket: append event with terminal subject
Loading

Suggested reviewers: teamleaderleo, lawrencecchen

Merge Risk: ⚪ Minimal · up to 48bf4

This change makes Codex status reporting work in remote workspaces by injecting per-launch hooks, and it passes through launches that should not be modified. I found no concrete merge-blocking risk in the supplied material. Trust-key compatibility with Codex 0.162 was not independently confirmed.

🚥 Pre-merge checks | ✅ 24 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (24 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: fixing Codex agent status reporting in remote SSH workspaces.
Description check Passed The description is detailed and covers the problem, resulting behavior, implementation scope, testing, changelog entry, impact, and residual risk. The Proof and Checklist sections from the template ar…
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.
Cmux Cloud Persistent Session And Early Input Passed PASS. The diff adds Codex hook routing, a PATH shim, tests, and documentation. It does not change Cloud terminal creation, manual renderer admission, attachment readiness, input ownership, or persiste…
Cmux Swift Actor Isolation Passed The pull request changes only Rust source, Rust tests, and Markdown documentation. It introduces no Swift files or Swift production changes, so it cannot introduce or worsen Swift 6 actor isolation mi…
Cmux Swift Blocking Runtime Passed PASS: The pull request changes only Rust and Markdown files. It introduces no production Swift changes, so it cannot introduce or expand the Swift blocking or timing primitives covered by this check.
Cmux Browser Automation Off-Main Passed PASS: The pull request changes only cmux-tui Rust code, tests, and documentation. It does not modify the rule-scoped Swift files, add a browser.* socket command, or change socket-worker/main-actor bro…
Cmux Expensive Synchronous Load Passed PASS: The reviewed diff changes five Rust files and one Markdown file. It adds no Swift files or Swift code, so it cannot introduce an expensive synchronous Swift agent-history load onto the main acto…
Cmux Cache Substitution Correctness Passed PASS: The pull request changes only Rust source/tests and Markdown documentation. It contains no production Swift, TypeScript, or JavaScript changes, so the cache-substitution correctness rule does no…
Cmux No Hacky Sleeps Passed PASS. The pull request changes only Rust source/tests and Markdown documentation; it does not change TypeScript, JavaScript, shell, or build/runtime scripts covered by this check. The only fixed sleep…
Cmux Algorithmic Complexity Passed The changed production runtime code does not introduce a prohibited scalable nested scan or repeated batch rescan. The new Codex wrapper performs linear scans over PATH entries and argv, and it iterat…
Cmux Swift Concurrency Passed PASS: The pull request changes only Rust source/tests and Markdown documentation. The authoritative diff contains no Swift, Objective-C, or Objective-C++ files, so it does not introduce or expand Swif…
Cmux Swift @Concurrent Passed The pull-request diff contains no Swift files or Swift code. It changes only Rust source, Rust tests, and Markdown documentation, so the Swift @concurrent check is not applicable.
Cmux Swift Package Boundaries Passed The pull request changes only Rust source/tests and Markdown documentation under cmux-tui. It adds or modifies no Swift files or SwiftPM package manifests, so the Swift package boundary rule does not …
Cmux Swiftpm Lockfiles Passed The pull request changes only Rust source/tests and documentation. The authoritative diff contains no Package.swift, Package.resolved, Xcode project/workspace, .gitignore, workflow, or dependenc…
Cmux Swift Logging Passed The pull request changes only Rust and Markdown files. It adds no Swift code or logging statements, so the Swift logging rule is not triggered.
Cmux User-Facing Error Privacy Passed The production diff adds only generic wrapper stderr messages already present in the base localization: “the agent executable was not found,” “starting the agent without cmux status updates,” and “the…
Cmux Full Internationalization Passed PASS: The PR changes only Unix Rust implementation/tests and cmux-tui/docs/agent-hooks.md; it adds no Swift UI text, app string-catalog/Info.plist entries, web UI/API/metadata, locale files, or `web…
Cmux Swiftui State Layout Passed The pull request changes only Rust source/tests and Markdown documentation. It introduces no SwiftUI files or SwiftUI state/layout changes, so none of the specified failure conditions apply.
Cmux Architecture Rethink Passed The pull request does not change Swift code or Swift architecture. The reviewed diff contains only Rust sources/tests and Markdown documentation, so the Swift architectural-rethink failure conditions …
Cmux Swift Auxiliary Window Close Shortcuts Passed The pull request changes only Rust source, Rust tests, and documentation. It adds no Swift NSWindow, NSPanel, NSWindowController, SwiftUI Window, or WindowGroup code. The auxiliary-window close-shortc…
Cmux Source Artifacts Passed All six changed paths are intentional Rust source, Rust tests, or product documentation under cmux-tui/crates/cmux-tui/src, cmux-tui/crates/cmux-tui/tests, and cmux-tui/docs. The authoritative d…
Cmux No Test Or Debug Seam In Production Source Passed PASS: The pull request changes only Rust, Rust tests, and Markdown files. The authoritative diff contains no Swift file under a production Sources/ path, so this check does not apply.
Full details: Docstring Coverage

Explanation

Docstring coverage is 45.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 5 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • 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.

@austinywang
austinywang merged commit cf5bbe8 into main Oct 10, 2026
113 checks passed
@austinywang
austinywang deleted the task-remote-codex-status branch October 10, 2026 19:29
@github-actions

Copy link
Copy Markdown
Contributor

Merge receipt for 48bf4b4cbd: every check was green at merge (11 verified; 19 skipped by policy). Full suite runs on main after merge.

rustybret pushed a commit to rustybret/bmux that referenced this pull request Oct 10, 2026
812c971 fix: make local-tmux detached recovery reliable (manaflow-ai#18654)
592952f fix(cloud): isolate sidebar row hover targets (manaflow-ai#18693)
aece34e fix: repair Cloud VM canary and Claude managed defaults (manaflow-ai#18982)
071dbed fix(ui): reduce workspace layout follow-up amplification (manaflow-ai#18879)
ca14fdd fix(cloud): fence WireGuard activation preparation lifecycle (manaflow-ai#18672)
cf5bbe8 Fix Codex agent status in remote SSH workspaces (manaflow-ai#18792)
f7095c9 ⌘⌥F finds open agent sessions by what was said in them (manaflow-ai#18962)
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