Skip to content

TUI slash command popup keeps stale selection after filtering #25295

@cauldron26

Description

@cauldron26

Summary

The TUI slash-command popup keeps its previous selection and scroll state when the typed slash-command filter changes. If the user first scrolls the full / command list, then types a prefix such as /s or /st, the filtered list can start from the stale scroll position and highlight the wrong command.

This is visible in Codex rust-v0.135.0.

Reproduction

  1. Start the TUI.
  2. Type / to open the slash-command popup.
  3. Press Down repeatedly until the popup scrolls away from the top of the command list.
  4. Type s or st.

Expected behavior

Changing the filter text should reset the popup selection/viewport to the first filtered match. For example, /st should select /status.

Actual behavior

The popup preserves the old selected index and scroll position, then clamps that stale index into the new filtered result set. Depending on where the unfiltered list had been scrolled, /s can show only a lower match such as /subagents, and /st can highlight /stop instead of /status.

Likely cause

CommandPopup::on_composer_text_change() updates command_filter, then calls ScrollState::clamp_selection() and ensure_visible(). That preserves the previous selected index and scroll state across a new filter token instead of treating the filtered result set as a fresh list.

Relevant area:

  • codex-rs/tui/src/bottom_pane/command_popup.rs
  • CommandPopup::on_composer_text_change()
  • ScrollState::{clamp_selection, ensure_visible}

Proof-of-concept fix

I tested a small patch that resets the popup ScrollState only when the slash filter token changes, preserving normal arrow navigation when the filter is unchanged.

Public fork branch:

https://github.com/cauldron26/codex/tree/codex/fix-slash-command-filter-scroll

Commit:

cauldron26@d271558

Validation

cargo test -p codex-tui bottom_pane::command_popup::tests::changing_filter_resets_selection_after_scrolling --lib
cargo test -p codex-tui bottom_pane::command_popup::tests --lib
cargo fmt --package codex-tui
git diff --check

The focused command-popup test group passed locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions