fix(widgets): truncate label and dots in LoadingDots to prevent layout overflow #3083#3064
fix(widgets): truncate label and dots in LoadingDots to prevent layout overflow #3083#3064itssagarK wants to merge 2 commits into
Conversation
📝 WalkthroughWalkthroughLoadingDots now truncates its label and dot output to fit the available rectangle width. A narrow-screen test verifies rendering does not throw and stays within bounds. ChangesLoadingDots width handling
Estimated code review effort: 2 (Simple) | ~10 minutes 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/widgets/src/feedback/LoadingDots.test.ts`:
- Around line 151-158: Strengthen the LoadingDots.render test to assert the
exact truncated row content rather than only screen width. For the existing
Unicode configuration, verify the rendered row matches the expected label
truncation, such as “Long…”, and add a separate ASCII-mode assertion if
LoadingDots supports an ASCII fallback.
🪄 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: eb1599a6-57d6-4f61-9ab6-582df5979ad7
📒 Files selected for processing (2)
packages/widgets/src/feedback/LoadingDots.test.tspackages/widgets/src/feedback/LoadingDots.ts
| it('truncates label and dots to fit narrow rect width without overflowing', () => { | ||
| const screen = new Screen(5, 1); | ||
| const ld = new LoadingDots({}, { label: 'LongLoadingText', maxDots: 5 }); | ||
| ld.updateRect({ x: 0, y: 0, width: 5, height: 1 }); | ||
| expect(() => ld.render(screen)).not.toThrow(); | ||
| const row = screen.back[0].map(c => c.char).join(''); | ||
| expect(row).toBe('Thinki'); | ||
| expect(row.length).toBeLessThanOrEqual(5); | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert the actual truncated output.
screen.back[0] is initialized with five cells, so row.length <= 5 passes even if LoadingDots writes an overlong string and Screen clips it. Assert the expected row content—such as Long… in Unicode mode—and add an ASCII-mode case if fallback behavior is required.
As per coding guidelines, tests must assert observable behavior or rendered output.
🤖 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/widgets/src/feedback/LoadingDots.test.ts` around lines 151 - 158,
Strengthen the LoadingDots.render test to assert the exact truncated row content
rather than only screen width. For the existing Unicode configuration, verify
the rendered row matches the expected label truncation, such as “Long…”, and add
a separate ASCII-mode assertion if LoadingDots supports an ASCII fallback.
Source: Coding guidelines
Pull Request Description
packages/widgets/src/feedback/LoadingDots.ts.- Added unit test in
packages/widgets/src/feedback/LoadingDots.test.ts.Type of Change
type:bug)type:feature)type:docs)type:testing)type:refactor)type:design)type:accessibility)type:performance)type:devops)type:security)Checklist
needs-starcheck blocks your merge otherwise.bun vitest runbun run buildbun run typecheckCONTRIBUTING.md.type: short description.markDirty()(if your change affects rendering).anytypes without an inline comment explaining why.GSSoC 2026 Participation
https://gssoc.girlscript.org/profile/____Screenshots / Recordings (UI changes)
Notes for the Reviewer
Summary by CodeRabbit
Bug Fixes
Tests