Repository navigation
Fix TUI duplicate top bar and crash with double-width (CJK) text at the right edge - #5500
Merged
Merged
Conversation
Copilot started reviewing on behalf of
Gabriel Dufresne (GabrielDuf)
October 9, 2026 17:29
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new width helper undercounts emoji rendered as double-width by Consolonia, leaving an edge-overflow path unresolved.
1 open finding
What changed in this PR
Fixes TUI edge rendering by measuring labels in terminal cells rather than UTF-16 length.
Changes:
- Adds shared terminal-cell measurement.
- Updates tab and function-bar fitting.
- Adds CJK width regression tests.
| File | Description |
|---|---|
src/UniGetUI.Tui/Views/MainWindow.cs |
Adds testable tab-density fitting. |
src/UniGetUI.Tui/Views/Controls/TuiFunctionBar.cs |
Measures hints, notifications, and badges by cells. |
src/UniGetUI.Tui/Infrastructure/TuiChrome.cs |
Adds shared cell-width calculation. |
src/UniGetUI.Tui.Tests/TuiTabStripTests.cs |
Tests CJK tab fitting. |
src/UniGetUI.Tui.Tests/TuiFunctionBarTests.cs |
Tests CJK function-bar fitting. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Copilot started reviewing on behalf of
Gabriel Dufresne (GabrielDuf)
October 9, 2026 17:48
View session
There was a problem hiding this comment.
🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉
Integration Details
{
"deliveryId": "d9888a70-c409-11f1-989f-19c35bf64653",
"headSha": "f886c53234a5d23c1974007d0c5765bbaec3d7a2",
"reviewer": "copilot-pull-request-reviewer[bot]"
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Cause
The TUI's page tab strip and bottom function bar sized their labels with
string.Length. CJK translations take two terminal cells per character (zh_CN "帮助" is 2 chars but 4 cells), so both rows believed they fit while the real text ran to the right edge and a double-width glyph could land in the terminal's last column.Consolonia 12.0.3.14 does not handle that:
DrawingContextImplkeeps a wide glyph whose first cell is inside the clip, andRenderTargetpasses it to the device unchanged.AnsiConsoleOutput.WritePixelwrites two spaces before a wide glyph. In the last column that wraps the cursor: the terminal scrolls a line (or spills onto the next row) that Consolonia never tracks, leaving a stale copy of the tab strip on screen. That is the duplicate, unresponsive top bar in the issue.RenderToDevicereads one cell past the buffer edge and the render loop dies withIndexOutOfRangeException.Changes
TuiChrome.Cells()measures text in terminal cells with Wcwidth, the same calculator Consolonia uses for glyph widths.MainWindow.FitTabsso it can be tested.TuiFunctionBarTests.DoubleWidthLabelsAreMeasuredInTerminalCellsand the newTuiTabStripTests. Both new test sets fail on the previous behaviour.Testing
dotnet format whitespaceandstyleare clean for both TUI projects.Not covered here
Other TUI layouts still measure with
string.Length(menu dropdown padding, the package page's actions panel width, dialog widths, chips). None of them sits at the right edge of the terminal, so at worst they misalign rather than crash; they can be moved toTuiChrome.Cellsin a follow-up.Closes #5490