Skip to content

queue slash commands in tui#14170

Closed
charley-oai wants to merge 67 commits intomainfrom
cc/queue-tui-slash-commands
Closed

queue slash commands in tui#14170
charley-oai wants to merge 67 commits intomainfrom
cc/queue-tui-slash-commands

Conversation

@charley-oai
Copy link
Contributor

Summary

  • make slash commands entered during a running turn queue instead of failing immediately
  • cover queued /review behavior and inline slash-command variants in the TUI tests
  • update the queued-command snapshot to reflect the new pending state

Testing

  • just fmt
  • cargo test -p codex-tui

@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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: 30106e2b31

ℹ️ 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".

@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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

ℹ️ 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".

@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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: 5c0d86ad38

ℹ️ 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".

if key_event.code == KeyCode::Esc
&& matches!(key_event.kind, KeyEventKind::Press | KeyEventKind::Repeat)
&& self.is_task_running
&& !is_agent_command
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The old && !is_agent_command guard was a heuristic workaround, not the real correctness condition.

Why it was added:

  • In 2a5bcc053f (fix: esc in /agent), /agent was a special case because typing past the command name hid the slash popup, so popup_active() was no longer protecting that flow.
  • At that point, Esc only interrupted in a narrower set of cases, and the guard was used to keep /agent draft editing from getting treated like a global interrupt.

Why it is safe to remove now:

  • The rule we want now is simpler and more correct: if a task is running and no popup/modal is active, Esc should interrupt.
  • That means the thing we should key off is actual UI state (popup_active() / modal stack), not the current text prefix.
  • Once the /agent popup is gone, there is no longer any agent-specific local UI to dismiss. At that point /agent is just ordinary composer text, and it should behave the same as any other nonempty draft.

Why the text-prefix check was the wrong abstraction:

  • It special-cased one command name instead of checking the actual thing that matters: whether the user is inside a local picker/dialog flow.
  • It was inconsistent with the newer behavior for other nonempty drafts, where Esc is intentionally allowed to interrupt.
  • It would have kept /agent as a one-off exception even after we explicitly changed the product behavior to allow interrupt with nonempty composer text.

Why this does not lose user state:

  • The interrupt path preserves the draft text; it does not clear the composer.
  • We also have coverage for the non-destructive behavior higher up in ChatWidget, so this is not “drop the command and interrupt”, it is “interrupt, while keeping the draft available”.

So the short version is: removing !is_agent_command is safe because popup/modal state is the real guard. /agent text by itself is not a meaningful interaction mode once its picker is gone.

AppEvent::HandleSlashCommandDraft(draft) => {
self.chat_widget.handle_serialized_slash_command(draft);
self.refresh_status_line();
}
Copy link
Contributor Author

@charley-oai charley-oai Mar 11, 2026

Choose a reason for hiding this comment

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

Allows a slash command popup (e.g. model picker popup) to then submit a text slash command that can be queued or submitted

self.restore_user_message_to_composer(combined);
}
self.refresh_pending_input_preview();
if !started_turn_after_interrupt {
self.maybe_send_next_queued_input();
}
Copy link
Contributor Author

@charley-oai charley-oai Mar 11, 2026

Choose a reason for hiding this comment

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

  • we changed interrupt behavior so queued slash actions were no longer merged back into the composer
  • instead, they stayed queued and were replayed after interrupt
  • to make that work, we added drain_queued_inputs_until_blocked() at the end of on_interrupted_turn()

That new replay step created the race:

  • in the submit_pending_steers_after_interrupt path, on_interrupted_turn() calls submit_user_message(...)
  • but submit_user_message(...) does not synchronously mark the task as running
  • so the new post-interrupt replay could immediately start draining queued items before the replacement steer turn had actually started

started_turn_after_interrupt was added to block exactly that case.

@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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: 16ce18e9e5

ℹ️ 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".

{
if self.reject_slash_command_if_unavailable(cmd) {
return Some(InputResult::None);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was "'/{}' is disabled while a task is in progress.", which we no longer emit


if !cmd.supports_inline_args() {
return None;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Every command supports inline args now

@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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: 5e8a7454ea

ℹ️ 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".

@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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

ℹ️ 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".

charley-oai added a commit that referenced this pull request Mar 13, 2026
Co-authored-by: Codex <noreply@openai.com>
charley-oai added a commit that referenced this pull request Mar 13, 2026
Co-authored-by: Codex <noreply@openai.com>
@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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: 6178ba4cb3

ℹ️ 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".

@charley-oai
Copy link
Contributor Author

@codex review this

Copy link
Contributor

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

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

ℹ️ 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".

@charley-oai
Copy link
Contributor Author

@codex review this

charley-oai and others added 25 commits March 15, 2026 23:32
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Centralize slash command metadata, dedupe runtime builtin gating, and make popup-driven queued replay resume explicit.

Co-authored-by: Codex <noreply@openai.com>
Remove the extra app-side popup completion latch so queued replay resumes
whenever app events fully drain and ChatWidget is waiting to continue.
Add an app-level regression for queued /personality followed by a
queued user draft.

Co-authored-by: Codex <noreply@openai.com>
Include builtin aliases when filtering the slash popup so valid
commands like /multi-agents still surface the canonical /subagents
entry. Reuse a shared command-name iterator for alias-aware builtin
lookup and reserved-name filtering.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@charley-oai charley-oai force-pushed the cc/queue-tui-slash-commands branch from b237ca7 to 6c9bac8 Compare March 16, 2026 06:36
@charley-oai
Copy link
Contributor Author

@codex review this

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ 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".

@charley-oai
Copy link
Contributor Author

Superseded by a stacked split:

Closing this draft to avoid duplicate review traffic.

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