Skip to content

Route SM control socket messages as user turns#12

Merged
rajeshgoli merged 21 commits into
mainfrom
fix/sm-send-userturn-653
Apr 28, 2026
Merged

Route SM control socket messages as user turns#12
rajeshgoli merged 21 commits into
mainfrom
fix/sm-send-userturn-653

Conversation

@rajeshgoli

Copy link
Copy Markdown
Owner

Summary\n\n- Route control-socket submitted messages through the TUI literal external-message path instead of manually constructing deprecated UserInput ops.\n- Make literal external messages reuse normal UserTurn construction so current cwd/model/sandbox/approval context is attached.\n- Add regression coverage for thread-id control-socket submissions and external literal message submission.\n\n## Verification\n\n- cargo fmt\n- cargo test -p codex-tui control_socket --lib\n- cargo test -p codex-tui external_literal_message_submits_user_turn --lib\n- cargo build --release -p codex-cli\n- live Session Manager probe: spawned codex-fork 3510cb42, sent sm payload, observed SM_SEND_PROBE_OK and event stream op_submitted type=user_turn\n\nFixes rajeshgoli/session-manager#653\n

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23113e9c9d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/control_socket.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@rajeshgoli

Copy link
Copy Markdown
Owner Author

Addressed Codex P1 by preserving the control-socket thread_id contract. submit_message now carries target_thread_id through the external-message event and routes the generated UserTurn/AddToHistory to submit_thread_op(thread_id, ...) when supplied; active-thread submissions keep the existing direct TUI path.\n\nRe-verified:\n- cargo fmt\n- cargo test -p codex-tui control_socket --lib\n- cargo test -p codex-tui external_literal_message_submits_user_turn --lib\n- cargo build --release -p codex-cli\n- live SM probe 745a2b1b: sm send delivered, agent replied SM_SEND_PROBE2_OK, event stream shows sm payload as type=user_turn\n\n@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b7642742b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@rajeshgoli

Copy link
Copy Markdown
Owner Author

Addressed the second Codex P1 by keeping targeted control-socket messages out of the untargeted pre-configuration queue. For submit_message(thread_id=...), the event path now uses prepare_targeted_external_literal_user_message(...), which prepares the UserTurn immediately even before the active TUI session is configured, then routes it via submit_thread_op(thread_id, ...).\n\nRe-verified:\n- cargo fmt\n- cargo test -p codex-tui control_socket --lib\n- cargo test -p codex-tui external_literal_message --lib\n- cargo build --release -p codex-cli\n- restarted local Session Manager on rebuilt codex-fork binary\n\n@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ff758ef7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Addressed the third Codex P1 by preparing targeted control-socket turns from the target thread's stored session/input context instead of the active TUI thread. Targeted inactive-thread turns now use the target cwd, model, approval policy, sandbox policy, permission profile, reasoning effort, and collaboration mask.

Re-verified:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui control_socket --lib

@codex review

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@rajeshgoli

Copy link
Copy Markdown
Owner Author

Addressed the third Codex P1 by preparing targeted control-socket submit_message(thread_id=...) turns from the target thread's stored session/input context instead of the active TUI thread. Targeted inactive-thread turns now use the target cwd, model, approval policy, sandbox policy, permission profile, reasoning effort, and collaboration mask.

Re-verified:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui control_socket --lib

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18480c14c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Addressed the fourth Codex P1 by preserving literal semantics for untargeted external messages that arrive before session configuration. The pre-config queue now records those as QueuedInputAction::LiteralUserTurn and drains them through the existing shell-escape-disallowed submission path, so leading ! stays a literal user turn instead of becoming RunUserShellCommand.

Re-verified:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui control_socket --lib

@codex review

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 899b71db59

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/chatwidget.rs Outdated
Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Addressed the latest Codex review on 899b71db59:

  • P1: targeted external UserTurns now carry the target thread's approvals_reviewer instead of falling back to the active thread/global reviewer.
  • P2: pre-config queued external literal messages now use FIFO order (push_back + existing pop_front) instead of reversing multiple startup messages.

Re-verified:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui control_socket --lib

Fresh release build is running from 0115e65074.

@codex review

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0115e65074

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Addressed the P2 from the 0115e65074 review: startup-queued external literal messages now drain through the same literal UserTurn preparation path as non-queued external messages, so $skill / app mentions remain plain text and do not expand into structured UserInput::Skill or UserInput::Mention items.

Re-verified:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui control_socket --lib

@codex review

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

1 similar comment
@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b54187d4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6cb555ee44

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/bottom_pane/chat_composer.rs
Comment thread codex-rs/tui/src/chatwidget.rs Outdated
Comment thread codex-rs/tui/src/chatwidget.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6cb555ee44

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Fixed the current-head review followups in 00b47082fd.

Changes:

  • preserved PendingSteer.rejection_action in inactive-thread rejected-steer requeueing
  • kept queued external literal retries at the front when a session is still unconfigured/pending, preserving FIFO
  • documented LiteralUserTurn in the chat-composer module docs and narrative doc

Validation:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui control_socket --lib
  • cargo test -p codex-tui targeted_external_literal_input_state_records_rejected_steer --lib
  • cargo test -p codex-tui restore_thread_input_state_restores_pending_steers_without_downgrading_them --lib

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00b47082fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/app/event_dispatch.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Fixed the inactive-target pending-start P1 in 0d3697b44e.

Changes:

  • marks pending-start state on the target thread after an accepted non-steer targeted literal submit
  • queues follow-up external literal messages for inactive target threads while that target has a pending/running turn
  • added a focused ThreadInputState regression covering pending-start plus literal follow-up queueing

Validation:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui targeted_external_literal_input_state --lib
  • cargo test -p codex-tui control_socket --lib

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d3697b44e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/app/event_dispatch.rs Outdated
Comment thread codex-rs/tui/src/app/event_dispatch.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Fixed the active-thread targeted queue P1 in 301bb28b5f.

Changes:

  • targeted messages to the active thread now queue as literal user turns when a turn is pending/running
  • target channels with no loaded session now return an explicit not-ready error instead of silently dropping input
  • added the missing ChatWidget::queue_external_literal_user_message wrapper used by the active-thread path

Validation:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui targeted_external_literal_input_state --lib
  • cargo test -p codex-tui control_socket --lib

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 301bb28b5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/app/event_dispatch.rs Outdated
Comment thread codex-rs/tui/src/chatwidget.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Fixed the latest review followups in ecc355dc7f.

Changes:

  • moved external-literal ChatWidget and ThreadInputState helpers into tui/src/chatwidget/external_literal.rs
  • targeted external messages now submit AddToHistory after accepted submits even when the submit was handled as a steer

Validation:

  • cargo fmt
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui targeted_external_literal_input_state --lib
  • cargo test -p codex-tui control_socket --lib
  • cargo test -p codex-tui restore_thread_input_state_restores_pending_steers_without_downgrading_them --lib
  • just fix -p codex-tui (completed; clippy reported existing auto-fix warnings in control_socket.rs but made no unrelated file changes)

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ecc355dc7f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/app/event_dispatch.rs Outdated
Comment thread codex-rs/tui/src/app/event_dispatch.rs Outdated
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Review follow-up pushed at 40986a5.\n\nChanges:\n- Route omitted-thread external messages through the same active-thread-aware submit path instead of the legacy direct chat-widget submit.\n- Only queue active-thread external messages while a user turn is pending start; running turns now go through thread submit so they can steer.\n- Stop silently queueing inactive-thread messages when there is no active turn id; surface a not-ready error instead.\n- Synchronize cached inactive thread input state from background turn notifications/session refreshes so pending-start state does not go stale.\n\nValidation:\n- cargo fmt\n- cargo test -p codex-tui external_literal_message --lib\n- cargo test -p codex-tui targeted_external_literal_input_state --lib\n- cargo test -p codex-tui control_socket --lib

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40986a593f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/tui/src/app/thread_routing.rs
Comment thread codex-rs/tui/src/chatwidget.rs Outdated
Comment thread codex-rs/tui/src/chatwidget/external_literal.rs
@rajeshgoli

Copy link
Copy Markdown
Owner Author

Review follow-up pushed at baf3929.\n\nChanges:\n- Return rejection for inactive target threads when a turn is active but non-steerable, instead of acknowledging delivery into an inactive queue.\n- Preserve FIFO order when rejected external literal steers are requeued.\n- Preserve inactive target collaboration masks for model/effort instead of overwriting them with session defaults.\n- Clarify chat-composer docs for the external LiteralUserTurn queue action.\n\nValidation:\n- cargo fmt\n- cargo test -p codex-tui external_literal_message --lib\n- cargo test -p codex-tui targeted_external_literal_input_state --lib\n- cargo test -p codex-tui external_literal_rejected_steers_preserve_fifo_order --lib\n- cargo test -p codex-tui control_socket --lib\n- cargo test -p codex-tui active_turn_not_steerable --lib\n- cargo test -p codex-tui active_turn_steer_race --lib

@rajeshgoli

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@rajeshgoli

Copy link
Copy Markdown
Owner Author

Maintainer merge note for current head baf392977c:

Codex review is clean: #12 (comment)

Local verification on the reviewed head passed:

  • cargo fmt --check
  • cargo test -p codex-tui external_literal_message --lib
  • cargo test -p codex-tui targeted_external_literal_input_state --lib
  • cargo test -p codex-tui external_literal_rejected_steers_preserve_fifo_order --lib
  • cargo test -p codex-tui control_socket --lib
  • cargo test -p codex-tui active_turn_not_steerable --lib
  • cargo test -p codex-tui active_turn_steer_race --lib
  • cargo build --release -p codex-cli

CI is red for repo workflow/configuration issues outside this PR diff: Bazel exits before build because remote downloader is enabled without gRPC caching/BuildBuddy key, and npm staging is still hard-coded to CODEX_VERSION=0.115.0, whose rust-release workflow cannot be found. This PR only changes TUI/control-socket routing code and does not touch CI config.

The local Session Manager codex-fork runtime has been pinned to this reviewed binary via codex_fork.artifact_ref=baf392977c421e24ab1e350a702501f519df26c2 and restarted cleanly.

@rajeshgoli rajeshgoli merged commit e52bdb2 into main Apr 28, 2026
9 of 26 checks passed
@rajeshgoli rajeshgoli deleted the fix/sm-send-userturn-653 branch April 28, 2026 01:25
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