Skip to content

fix(tui): 修复mintty刷新残留问题#3829

Merged
esengine merged 2 commits into
esengine:main-v2from
taibai233:fix/mintty-rendering-ghost
Jun 12, 2026
Merged

fix(tui): 修复mintty刷新残留问题#3829
esengine merged 2 commits into
esengine:main-v2from
taibai233:fix/mintty-rendering-ghost

Conversation

@taibai233

@taibai233 taibai233 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

修复内容

修复 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.go
  • go test ./internal/cli -run 'TestCompletion|TestSlash|TestSkill|TestInputOwnedOverlaysKeepComposerBox|TestTranscriptViewportSizing' -count=1

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development tui Terminal UI / CLI (internal/cli, internal/control) labels Jun 10, 2026
@taibai233 taibai233 marked this pull request as draft June 10, 2026 09:43
…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.
@taibai233 taibai233 force-pushed the fix/mintty-rendering-ghost branch from 8c6ed48 to e985df6 Compare June 10, 2026 10:53
@zhaokai100

Copy link
Copy Markdown
image 修好了

@taibai233 taibai233 marked this pull request as ready for review June 12, 2026 09:39

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

@esengine esengine merged commit 939563a into esengine:main-v2 Jun 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tui Terminal UI / CLI (internal/cli, internal/control) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants