Skip to content

fix(widgets): truncate label and dots in LoadingDots to prevent layout overflow #3083#3064

Open
itssagarK wants to merge 2 commits into
Karanjot786:mainfrom
itssagarK:fix/loadingdots-layout-overflow
Open

fix(widgets): truncate label and dots in LoadingDots to prevent layout overflow #3083#3064
itssagarK wants to merge 2 commits into
Karanjot786:mainfrom
itssagarK:fix/loadingdots-layout-overflow

Conversation

@itssagarK

@itssagarK itssagarK commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Pull Request Description

### Title
fix(widgets): truncate label and dots in LoadingDots to prevent layout overflow

### Summary of Changes
- Bounded label and dot animation string rendering with `truncate()` in

packages/widgets/src/feedback/LoadingDots.ts.
- Added unit test in packages/widgets/src/feedback/LoadingDots.test.ts.

Closes #3063 

Type of Change

  • 🐛 Bug fix (type:bug)
  • ✨ Feature (type:feature)
  • 📝 Docs (type:docs)
  • 🧪 Tests (type:testing)
  • ♻️ Refactor (type:refactor)
  • 🎨 Design / UX (type:design)
  • ♿ Accessibility (type:accessibility)
  • ⚡ Performance (type:performance)
  • 🔧 DevOps / CI (type:devops)
  • 🔒 Security (type:security)

Checklist

  • ⭐ You starred the repo. The needs-star check blocks your merge otherwise.
  • Tests pass locally: bun vitest run
  • Build passes: bun run build
  • Typecheck passes: bun run typecheck
  • You read CONTRIBUTING.md.
  • Your PR title follows type: short description.
  • Widget state mutators call markDirty() (if your change affects rendering).
  • No new any types without an inline comment explaining why.
  • No unrelated refactors bundled into this PR.

GSSoC 2026 Participation

  • You are a GSSoC 2026 contributor.
  • Your GSSoC profile: https://gssoc.girlscript.org/profile/____

Screenshots / Recordings (UI changes)

Notes for the Reviewer

Summary by CodeRabbit

  • Bug Fixes

    • Prevented loading indicators from overflowing narrow display areas.
    • Long labels and dot sequences are now truncated to fit the available width.
  • Tests

    • Added coverage confirming loading indicators render safely within very narrow areas.

@itssagarK
itssagarK requested a review from Karanjot786 as a code owner July 25, 2026 15:49
@github-actions github-actions Bot added area:widgets @termuijs/widgets type:testing +10 pts. Tests. labels Jul 25, 2026
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

LoadingDots 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.

Changes

LoadingDots width handling

Layer / File(s) Summary
Width-aware rendering and coverage
packages/widgets/src/feedback/LoadingDots.ts, packages/widgets/src/feedback/LoadingDots.test.ts
LoadingDots truncates the label and remaining dots/padding using available width, with a test covering a five-column screen.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: quality:clean, type:bug, level:beginner

Suggested reviewers: karanjot786, varshinigurram

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing required template sections like Description, Related Issue heading, and Which package(s). Add the missing template sections with a 1-3 sentence Description, a Related Issue entry, and the affected package(s), then complete the required checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change truncates the label and dot string as required by #3063, and the added test covers narrow-width rendering.
Out of Scope Changes check ✅ Passed Only the widget implementation and its test were changed, and both align with the linked overflow fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is specific, concise, and accurately summarizes the main LoadingDots overflow fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 46503a5 and 3263ec9.

📒 Files selected for processing (2)
  • packages/widgets/src/feedback/LoadingDots.test.ts
  • packages/widgets/src/feedback/LoadingDots.ts

Comment on lines +151 to 158
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);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:widgets @termuijs/widgets type:testing +10 pts. Tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant