Skip to content

[BUG][v0.0.7] Model picker (model_picker.rs): narrow-terminal footer overlap + search caret uses UTF-8 byte length #40176

@prinrevo

Description

@prinrevo

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 B

Screenshots

No response

Steps to Reproduce

A

  1. Open model picker (e.g. Ctrl+M where supported).
  2. Reduce terminal width (~50–60 columns).
  3. Observe bottom row: legend and hint string collide.

B

  1. Open model picker, focus search.
  2. Enter multi-byte characters (e.g. 你好, emoji).
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingideIssues related to IDEinvalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions