Skip to content

Conversation

@448523760
Copy link
Contributor

Slash Command popup issue

#7659

When recalling history, the composer(codex_tui::bottom_pane::chat_composer) restores the previous prompt text (which may start with /) and then calls sync_command_popup. The logic in sync_command_popup treats any first line that starts with / and has the caret inside the initial /name token as an active slash command name:

let is_editing_slash_command_name = if first_line.starts_with('/') && caret_on_first_line {
    let token_end = first_line
        .char_indices()
        .find(|(_, c)| c.is_whitespace())
        .map(|(i, _)| i)
        .unwrap_or(first_line.len());
    cursor <= token_end
} else {
    false
};

This detection does not distinguish between an actual interactive slash command being typed and a normal historical prompt that happens to begin with /. As a result, after history recall, the restored prompt like / test is interpreted as an "editing command name" context and the slash-command popup is (re)activated. Once active_popup is ActivePopup::Command, subsequent Up key presses are handled by handle_key_event_with_slash_popup instead of handle_key_event_without_popup, so they no longer trigger history.navigate_up(...) and the session prompt history cannot be scrolled.

…ke "/ test"

- Updated `sync_command_popup` logic to ensure that the slash command popup only activates when:
  - The input starts with `/` and has no non-whitespace content after `/` (e.g., `/`).
  - The input starts with `/` and the command name is a valid prefix of a built-in command (e.g., `/re` for `/review`).
- Prevents recalled history inputs like `/ test` from incorrectly triggering the command popup.
- Ensures that `/` alone still activates the popup to display all available commands.
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.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@@ -0,0 +1,40 @@
# Recall Prompt History Issue
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this file from the PR.

assert_eq!(composer.textarea.text(), "z".repeat(count));
assert!(composer.pending_pastes.is_empty());
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think a test is needed in this case because there's little chance of a regression. We're trying to keep our CI test times from exploding, so we want to add tests only when they matter. Please remove.

@etraut-openai
Copy link
Collaborator

Thanks for the contribution. I'm not that familiar with the code you're changing here, so I will ask a colleague to review the change. Before I pass it along for review, please address the comments I added.

@etraut-openai etraut-openai added the needs-response Additional information is requested label Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-response Additional information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants