feat: add treasury-balance-derived at-risk health state to StreamDetail sidebar (Closes #1280) - #1376
Open
waterWang wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1280
Description
Add a treasury-balance-derived "At risk" funding health state to the
StreamDetailsidebar. The existing health pill reflects the stream's own status (active/paused/completed); this adds a distinct, layered indicator that surfaces when the remaining balance only covers under 48 hours of accrual at the stream's monthly rate.Changes
src/pages/StreamDetail.tsxAT_RISK_RUNWAY_HOURS = 48named constant (single, tunable threshold).HOURS_PER_MONTH = 720(30-day month) for the runway calculation.computeFundingRunwayHours(remainingAmount, monthlyRate)— returnsInfinitywhen the monthly rate is zero (no accrual → no funding risk) and0when the remaining balance is exhausted.isFundingAtRisk(stream)— true when the computed runway is below the 48-hour threshold, and excludes completed streams (already settled).isFundingAtRiskis true. It uses design tokens (--color-error-subtle,--color-error,--color-error-border), isrole="alert"for screen readers, and is responsive (inline-flex, wraps alongside the pill).src/pages/__tests__/StreamDetail.edgeCases.test.tsxcomputeFundingRunwayHours(happy path, zero/negative rate, zero/negative balance).isFundingAtRisk(below/above threshold, completed streams, zero rate).Verification
vitest run ... -t "Funding").tsc --noEmitreports no new errors inStreamDetail.tsx/ its tests.role="alert"and relies on an icon + label (not color alone).Screenshots / a11y notes