Skip to content

fix(tui): align skill descriptions with wide characters - #42262

Open
liujianbo2013 wants to merge 2 commits into
anomalyco:devfrom
liujianbo2013:dev
Open

fix(tui): align skill descriptions with wide characters#42262
liujianbo2013 wants to merge 2 commits into
anomalyco:devfrom
liujianbo2013:dev

Conversation

@liujianbo2013

@liujianbo2013 liujianbo2013 commented Aug 13, 2026

Copy link
Copy Markdown

fix(tui): align skill descriptions with wide characters

Issue for this PR

#40605
Closes #40605

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a skill's name contains wide characters (e.g. CJK), the /skillsdialog padded titles with String.prototype.padEnd based on UTF-16 codeunit length (s.name.length). Chinese characters count as 1 code unit butoccupy 2 terminal cells, so titles with the same code-unit length ended atdifferent screen columns and the descriptions below them misaligned.

The fix measures the column width with Bun.stringWidth (already usedelsewhere in the TUI, e.g. src/prompt/display.ts) and pads each title upto the maximum display width instead of the maximum code-unit length:

const maxWidth = Math.max(0, ...list.map((s) => Bun.stringWidth(s.name)))
title: skill.name.padEnd(skill.name.length + maxWidth - Bun.stringWidth(skill.name))

How did you verify your code works?

I created a Chinese title skill that describes normal alignment

Screenshots / recordings

屏幕截图 2026-08-13 145422

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

Update maxWidth calculation to use Bun.stringWidth for accurate width measurement.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

在使用较宽字符作为技能名时,技能描述不对齐

1 participant