Skip to content

Handle Codex steer requests during turn finalization - #331

Open
germanescobar wants to merge 1 commit into
mainfrom
issue-330
Open

Handle Codex steer requests during turn finalization#331
germanescobar wants to merge 1 commit into
mainfrom
issue-330

Conversation

@germanescobar

Copy link
Copy Markdown
Owner

Summary

  • distinguish accepted native Codex steers from turns that completed while the request was in flight
  • preserve late composer submissions as durable queued follow-ups
  • delay draft clearing and optimistic user-message UI until the server accepts responsibility
  • stop offering native steering as soon as a terminal Codex event is observed
  • serialize queue advancement and keep promoted queue messages exactly once

Root cause

Codex clears its active turn when run.completed or run.failed arrives, while the client remains in streaming mode until the later SSE done event. A steer submitted during that interval was rejected after the client had already cleared the composer and rendered an unpersisted user message.

Validation

  • focused Codex steer and session queue tests: 11 passed
  • server TypeScript check: passed
  • client production build: passed
  • full test suite: 728/729 passed; the unrelated PTY environment timing test passed on an isolated rerun
  • git diff --check: passed

Closes #330

@germanescobar
germanescobar marked this pull request as ready for review August 8, 2026 21:07
@germanescobar

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: e2ecb4a37c

ℹ️ 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 on lines +5180 to +5182
if (!nativeSteerAvailableRef.current) {
await handleEnqueue();
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve steering for Codex turns observed through polling

When this view is opened during an already-running Codex turn, or when the server starts a queued turn headlessly, the component receives activity through the runtime/event pollers rather than its own SSE, so nativeSteerAvailableRef never becomes true. Cmd/Ctrl+Enter therefore calls handleEnqueue() here and silently converts the requested steer into a later follow-up; with an empty composer and a queued item, it does nothing at all. The server already determines whether turn/steer raced finalization, so the client should still send the steer request for these active polled turns.

Useful? React with 👍 / 👎.

Comment thread server/lib/codex-steer.ts
Comment on lines +25 to +27
if (outcome === "steered") {
if (options.queuedMessageId) {
await options.removeQueuedMessage(options.queuedMessageId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Serialize promoted-message removal with queue advancement

When turn/steer succeeds just as the current turn completes, finalization can dequeue the promoted item before this separate removal acquires the queue lock. The promoted text is then both accepted as a steer and started as the next queued turn, while removeQueuedMessage silently reports no removal and this function still returns steered. The ownership transfer needs to be atomic with dequeue/advancement, or at least verify that the item was actually removed before claiming it was steered.

Useful? React with 👍 / 👎.

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.

Handle Codex steer requests during turn finalization without losing the message

1 participant