Skip to content

Prevent codex send from targeting a different displayed thread - #1

Draft
safal207 wants to merge 2 commits into
qol/ipc-sendfrom
fix/ipc-thread-routing
Draft

safal207 wants to merge 2 commits into
qol/ipc-sendfrom
fix/ipc-thread-routing

Conversation

@safal207

@safal207 safal207 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

When the primary thread A kept its IPC endpoint while the TUI displayed writable thread B, codex send --thread A submitted through B's widget. The endpoint's destination was lost in both the incoming event and the later unscoped CodexOp.

This change carries the primary thread ID and a fresh endpoint generation through IPC requests, queued input, automatic recovery, operation dispatch, and optimistic history events. Delivery is rejected if the endpoint has been replaced or its thread is not the active displayed thread. The second dispatch check prevents a thread switch after initial acceptance from redirecting the user turn. Ordinary manual input retains its existing path.

Validation on Linux with official Rust 1.95.0:

  • 9 send/widget tests passed, including 3 new queue/recovery regressions.
  • 6 new App dispatch/generation/history regressions passed.
  • 62 existing composer submission tests and 41 review/recovery tests passed.
  • cargo fmt -- --check and git diff --check passed. TUI test debug symbols were disabled to fit the environment's memory limit; assertions stayed enabled.

On the exact original head, the witness test passed: an IPC request for A was accepted and produced a user turn and ordinary message history through displayed thread B. The accompanying rejection regression failed at its intended assertion. The original production code was unchanged. See docs/repros/ipc-wrong-thread.md and docs/repros/ipc-wrong-thread.patch for the minimal reproduction and commands.

Removing only the second dispatch scope check made 2 of the 6 App tests fail at their stale-event/session-switch assertions (4 passed). After restoring the check, all 6 App tests and all 9 send/widget tests passed again. These tests exercise the real AppEvent dispatcher and widget submission with an in-process app-server fixture; they do not establish real socket or model execution.

Based on astral303/codex PR astral303#18 head 00ae96124babb37e25f77d568858c693ea9a2afd. This is a narrow routing fix. Same-account processes can still submit text as ordinary user input; sender authentication, socket ownership/cleanup races and transport denial-of-service remain unresolved. Actual socket lifecycle tests and Windows execution are not verified here. Acceptance and a user-message echo do not prove agent execution.

Use only in an isolated test environment. No main-environment installation, merge or release is part of this change.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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.

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