Fix SortPrompt display-width clipping - #3050
Conversation
📝 WalkthroughWalkthroughSortPrompt row rendering now uses display-width-aware truncation, and a test verifies wide Unicode content remains within the configured prompt width. ChangesSortPrompt width handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui/src/SortPrompt.test.ts`:
- Around line 158-170: Strengthen the SortPrompt rendering tests around
prompt.updateRect and prompt.render by adding mixed-width and combining-grapheme
boundary cases, not just repeated CJK characters. Assert each rendered row both
fits the configured width and preserves the expected complete grapheme/content,
preventing empty or over-truncated output from passing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b3a28f5c-7d55-4d60-a8f1-a04d7ce3be5a
📒 Files selected for processing (2)
packages/ui/src/SortPrompt.test.tspackages/ui/src/SortPrompt.ts
|
|
||
| it('renders wide-character rows within the prompt width', () => { | ||
| const prompt = new SortPrompt(['\u8868\u8868\u8868\u8868']); | ||
| const screen = new Screen(6, 2); | ||
| const writeSpy = vi.spyOn(screen, 'writeString'); | ||
|
|
||
| prompt.updateRect({ x: 0, y: 0, width: 5, height: 2 }); | ||
| prompt.render(screen); | ||
|
|
||
| const rendered = String(writeSpy.mock.calls[0][2]); | ||
| expect(stringWidth(rendered)).toBeLessThanOrEqual(5); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert content and grapheme preservation, not only width.
This test covers only repeated CJK characters and would pass for an empty or over-truncated row. Add mixed-width and combining-grapheme boundary cases, asserting the complete grapheme is present as well as fitting within the width.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/ui/src/SortPrompt.test.ts` around lines 158 - 170, Strengthen the
SortPrompt rendering tests around prompt.updateRect and prompt.render by adding
mixed-width and combining-grapheme boundary cases, not just repeated CJK
characters. Assert each rendered row both fits the configured width and
preserves the expected complete grapheme/content, preventing empty or
over-truncated output from passing.
Summary
Validation
Fixes #3040
Summary by CodeRabbit