Skip to content

web(StreamProgressBar): clamp progress percentage between 0 and 100 - #583

Open
Abdul-dev-creator wants to merge 2 commits into
Fundable-Protocol:mainfrom
Abdul-dev-creator:fix/413-stream-progress-bar-clamp-percentage
Open

web(StreamProgressBar): clamp progress percentage between 0 and 100#583
Abdul-dev-creator wants to merge 2 commits into
Fundable-Protocol:mainfrom
Abdul-dev-creator:fix/413-stream-progress-bar-clamp-percentage

Conversation

@Abdul-dev-creator

@Abdul-dev-creator Abdul-dev-creator commented Jul 29, 2026

Copy link
Copy Markdown

Overview

This PR clamps the progress percentage values in StreamProgressBar to [0, 100] to prevent the bar from displaying > 100% for completed streams or under edge cases.

Related Issue

Closes #413

Changes

  • [FIX] Added Math.min(100, Math.max(0, val)) clamping to remainingPercent for consistency
  • [FIX] Added Math.min(100, Math.max(0, val)) clamping to the vested percentage display label to prevent values exceeding 100%

Verification

npm run lint ✅ completed (existing repo warnings only)
npm run typecheck ✅ passed
npm test -- src/config/__tests__/config.test.ts --runInBand ✅ passed (9/9)
npm run build ✅ passed

Summary by CodeRabbit

  • Bug Fixes
    • Improved payment stream countdown accuracy by resetting the displayed time immediately when the countdown refreshes.
    • Prevented stream progress indicators from displaying values below 0% or above 100%.
    • Corrected the vested percentage display to remain within the valid 0–100% range, providing more reliable progress information.

…ssBar

- Ensured all percentage calculations are clamped with Math.min(100, Math.max(0, val))
  to prevent values exceeding 100% for completed streams
- Applied clamping consistently to remainingPercent and the vested display label

Closes Fundable-Protocol#413
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Abdul-dev-creator, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 24d9332d-01fa-425d-89ae-b2dc73dfdbdb

📥 Commits

Reviewing files that changed from the base of the PR and between b48348e and ec45835.

📒 Files selected for processing (1)
  • apps/web/src/components/modules/payment-stream/StreamCountdown.tsx
📝 Walkthrough

Walkthrough

Payment stream UI updates refresh countdown time immediately and clamp remaining and vested percentages to prevent values outside the 0–100 range.

Changes

Payment stream display corrections

Layer / File(s) Summary
Countdown time refresh
apps/web/src/components/modules/payment-stream/StreamCountdown.tsx
The countdown refreshes currentTime immediately before starting its active-state interval.
Progress percentage clamping
apps/web/src/components/modules/payment-stream/StreamProgressBar.tsx
Remaining progress and the displayed vested percentage are clamped between 0 and 100.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The StreamCountdown currentTime refresh is unrelated to issue #413 and appears outside the requested StreamProgressBar fix. Remove or split the StreamCountdown change into a separate PR unless it is required by a linked issue.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: clamping StreamProgressBar percentages to 0–100.
Linked Issues check ✅ Passed The StreamProgressBar fix clamps values as requested and matches the issue's acceptance criteria.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Abdul-dev-creator Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@apps/web/src/components/modules/payment-stream/StreamProgressBar.tsx`:
- Line 145: Update the vested percentage expression in StreamProgressBar so
zero, non-finite, or otherwise invalid stats.total values are handled before
division and formatting. Ensure the label always renders a valid clamped
percentage, including the invalid-input fallback, while preserving the existing
one-decimal format.
🪄 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: 00f783fe-71be-4177-bf12-45e4c02e3c07

📥 Commits

Reviewing files that changed from the base of the PR and between 375c936 and b48348e.

📒 Files selected for processing (2)
  • apps/web/src/components/modules/payment-stream/StreamCountdown.tsx
  • apps/web/src/components/modules/payment-stream/StreamProgressBar.tsx

<div className="flex justify-between items-center text-[10px] text-zinc-400 font-mono">
<span>{stats.withdrawnPercent.toFixed(1)}% withdrawn</span>
<span>{((stats.vestedSize / stats.total) * 100).toFixed(1)}% vested</span>
<span>{Math.min(100, Math.max(0, (stats.vestedSize / stats.total) * 100)).toFixed(1)}% vested</span>

Copy link
Copy Markdown
Contributor

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

Handle invalid totals before formatting the vested label.

The invalid-input fallback returns total: 0 and vestedSize: 0, so this expression evaluates to NaN. Math.min/Math.max preserve NaN, causing the UI to render NaN% vested instead of a clamped value.

Proposed fix
-                <span>{Math.min(100, Math.max(0, (stats.vestedSize / stats.total) * 100)).toFixed(1)}% vested</span>
+                <span>{(stats.total > 0
+                    ? Math.min(100, Math.max(0, (stats.vestedSize / stats.total) * 100))
+                    : 0
+                ).toFixed(1)}% vested</span>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<span>{Math.min(100, Math.max(0, (stats.vestedSize / stats.total) * 100)).toFixed(1)}% vested</span>
<span>{(stats.total > 0
? Math.min(100, Math.max(0, (stats.vestedSize / stats.total) * 100))
: 0
).toFixed(1)}% vested</span>
🤖 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 `@apps/web/src/components/modules/payment-stream/StreamProgressBar.tsx` at line
145, Update the vested percentage expression in StreamProgressBar so zero,
non-finite, or otherwise invalid stats.total values are handled before division
and formatting. Ensure the label always renders a valid clamped percentage,
including the invalid-input fallback, while preserving the existing one-decimal
format.

@Abdul-dev-creator
Abdul-dev-creator force-pushed the fix/413-stream-progress-bar-clamp-percentage branch from b48348e to ec45835 Compare July 30, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web(StreamProgressBar): clamp progress percentage between 0 and 100

1 participant