Skip to content

feat(cli): add Unicode width support for input composer#54

Open
titan wants to merge 1 commit intomadebyaris:mainfrom
titan:main
Open

feat(cli): add Unicode width support for input composer#54
titan wants to merge 1 commit intomadebyaris:mainfrom
titan:main

Conversation

@titan
Copy link
Copy Markdown

@titan titan commented Apr 29, 2026

Summary by cubic

Adds proper Unicode display width handling and horizontal scrolling to the CLI input composer, fixing misaligned cursors with CJK and emoji. Also simplifies key handling across pickers for clearer behavior.

  • New Features

    • Use unicode-width to compute display width (CJK=2, ASCII=1, zero-width=0).
    • Composer windows input to available columns and keeps the cursor visible; shows "… " when the start is truncated, otherwise "❯ ".
    • Width calculation accounts for borders to prevent overflow.
  • Refactors

    • Simplified Up/Down/Esc handling using match guards across palette, model/provider/branch/session pickers, and onboarding connect menu.
    • composer_line now accepts max_cols; tests updated.

Written for commit a738e47. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/cli/src/tui/app.rs">

<violation number="1" location="crates/cli/src/tui/app.rs:357">
P2: Inclusive iteration over a half-open visible window renders one extra cell beyond the width budget.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread crates/cli/src/tui/app.rs
let mut run_style: Option<Style> = None;

for idx in 0..=chars.len() {
for idx in win_start..=win_end {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Inclusive iteration over a half-open visible window renders one extra cell beyond the width budget.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At crates/cli/src/tui/app.rs, line 357:

<comment>Inclusive iteration over a half-open visible window renders one extra cell beyond the width budget.</comment>

<file context>
@@ -292,16 +292,69 @@ fn push_styled_run(
     let mut run_style: Option<Style> = None;
 
-    for idx in 0..=chars.len() {
+    for idx in win_start..=win_end {
         if idx == cursor_char_idx {
             let cursor_char = chars.get(idx).copied().unwrap_or(' ');
</file context>

@madebyaris madebyaris self-assigned this Apr 29, 2026
@madebyaris
Copy link
Copy Markdown
Owner

Hi @titan That's look good, and thanks for your contribution.

Can you make it to merge DEV instead of main?

That would be great, thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants