fix(tui): 修复mintty刷新残留问题#3829
Merged
Merged
Conversation
…ells bubbletea's delta renderer uses \033[K (erase-to-end-of-line) when a changed line is shorter than the previous frame. The completion menu (slash commands, @-references) wrote lines of varying width — one candidate might be "/review" while the next is "/clear · start fresh", so delta updates routinely changed widths and \033[K had work to do. On mintty (MSYS2/MinGW), \033[K is unreliable and can leave trailing characters from the previous frame — ghost cells. Fix: pad every completion line (items and footer) to m.width with padRight(), matching the transcript viewport and status line which already enforce fixed-width lines. delta renderer now never sees a width change for completion lines, and \033[K has nothing to clear. No terminal detection needed — this is strictly a layout correctness fix.
8c6ed48 to
e985df6
Compare
esengine
approved these changes
Jun 12, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Thanks — solid, well-targeted fix. The diagnosis holds: ultraviolet collapses trailing ASCII-space runs into EL/ECH erases, and mintty leaves stale CJK half-cells after them; padding with NBSP forces real overwrites instead. The two regression tests (ASCII + CJK at fixed width, asserting the NBSP suffix and the absence of a trailing ASCII space) lock the behaviour in nicely.
One heads-up for whoever touches this next: NBSP is unicode.IsSpace-true, so if any later frame-composition step ever TrimSpaces these overlay lines, the padding silently vanishes and the ghosting comes back. Fine as-is today — just don't add trailing-whitespace trimming to this path. Merging.
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.

修复内容
修复 Git Bash/mintty 中输入
/触发技能补全列表后,刷新时可能留下旧字符的问题。这个问题在技能描述包含中文等双宽字符时更容易出现。根因是补全菜单虽然已经按固定宽度补齐,但尾部使用普通 ASCII 空格时,终端渲染器可能把这些尾随空格优化成清行/清字符控制序列。mintty 在中文双宽字符附近处理这些 erase 序列时,仍可能保留旧单元格内容。
本次改动让补全菜单行和 footer 使用 NBSP 作为不可清除式 padding:视觉上仍是空白,但会强制渲染器实际覆盖到固定宽度,而不是依赖 erase 优化。
主要改动
padCompletionLine,统一按 TUI 宽度补齐。completionPadCell = "\u00a0"避免尾部普通空格被优化成 erase 序列。验证
gofmt -w internal/cli/complete.go internal/cli/chat_tui_test.gogo test ./internal/cli -run 'TestCompletion|TestSlash|TestSkill|TestInputOwnedOverlaysKeepComposerBox|TestTranscriptViewportSizing' -count=1