-
Notifications
You must be signed in to change notification settings - Fork 27
[BUG][v0.0.7] Model picker (model_picker.rs): narrow-terminal footer overlap + search caret uses UTF-8 byte length #40176
Description
Project
cortex
Description
A — Help / legend row overlap
ModelPicker::render_help_bar in src/cortex-tui/src/widgets/model_picker.rs draws the legend (* current , + popular at fixed columns) and the shortcut string ([Enter] select [Esc] cancel [Ctrl+L] clear search) on the same row. The right block uses help_x = area.right().saturating_sub(help.len() as u16 + 1) with no guard that help_x stays strictly to the right of the legend’s last column. For small area.width, help_x moves left and overwrites the legend → garbled footer.
B — Search caret
render_search_bar sets
cursor_x = x + 3 + self.state.search_query.len() as u16.
str::len() is UTF-8 byte count, not terminal display width or grapheme count → caret misaligns for CJK, emoji, etc.
Code verification (local tree): Both behaviors are present exactly as above at the cited lines.
Error Message
Debug Logs
System Information
Cortex TUI / cortex-cli: v0.0.7 (per bounty title)
OS: Any
Terminal: width ~50–70 cols to reproduce A; UTF-8 locale for BScreenshots
No response
Steps to Reproduce
A
- Open model picker (e.g. Ctrl+M where supported).
- Reduce terminal width (~50–60 columns).
- Observe bottom row: legend and hint string collide.
B
- Open model picker, focus search.
- Enter multi-byte characters (e.g.
你好, emoji). - Observe caret vs visible glyphs.
Expected Behavior
A: Legend and hints do not overlap (wrap, truncate, hide one side, or two-line footer when width insufficient).
B: Caret position follows display width / grapheme-aware indexing (e.g. unicode-width or shared TUI helpers).
Actual Behavior
A: Single-line layout without collision detection → overlap when narrow.
B: Caret uses byte length → misalignment for non-ASCII.
Additional Context
No response