fix: remove trailing space padding from TUI chat lines - #3730
Conversation
🦋 Changeset detectedLatest commit: 0999f92 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48fec0e00c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // No background - keep margins but do not pad to width. Padding | ||
| // would fill copied text with trailing spaces and break tokens | ||
| // (e.g. shell backslash line continuations). | ||
| contentLines.push(lineWithMargins); |
There was a problem hiding this comment.
Register the new vendored divergence
When packages/pi-tui is next synchronized from upstream, this copy-friendly rendering change can be overwritten because the package guide says every remaining local divergence must be listed and re-verified, but this new text.ts/markdown.ts behavior and its guarding tests were not added to that list. Add a divergence entry covering both components and the new tests so the fix is preserved during re-vendoring.
AGENTS.md reference: packages/pi-tui/AGENTS.md:L3-L7
Useful? React with 👍 / 👎.
48fec0e to
0999f92
Compare
Related Issue
No linked issue — this PR addresses a direct bug report: copied lines from the TUI chat end with trailing spaces, which breaks shell backslash line continuations.
Problem
In the TUI chat, every rendered line was padded with spaces to the full terminal width. When users copied multi-line shell commands such as:
bash script.sh \ --flag1 \ --flag2the copied lines ended with spaces after the
\, so the shell did not treat\as a line continuation marker.What changed
packages/pi-tui/src/components/text.tsandpackages/pi-tui/src/components/markdown.tswhen no background color is applied. Left/right margins requested by the component are preserved.packages/pi-tui/test/tui-render.test.ts,packages/pi-tui/test/markdown.test.ts, andapps/kimi-code/test/tui/components/messages/assistant-message.test.tsto ensure code block lines (including backslash continuations) no longer have trailing spaces.@moonshot-ai/kimi-code.The main-screen and alt-screen renderers already clear each line with
\x1b[2Kbefore drawing, so the padding was not needed for display correctness.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.