codex - 💡(How to fix) Fix TUI slash command popup keeps stale selection after filtering

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Root Cause

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.

Fix Action

Fix / Workaround

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.

Code Example

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
RAW_BUFFERClick to expand / collapse

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:

https://github.com/cauldron26/codex/commit/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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

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

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix TUI slash command popup keeps stale selection after filtering