Skip to content

Dashboard post-merge fixes: counter, ex-div day, dividend mini#174

Merged
fleveque merged 1 commit into
mainfrom
fix/dashboard-counter-and-day-mismatch
May 25, 2026
Merged

Dashboard post-merge fixes: counter, ex-div day, dividend mini#174
fleveque merged 1 commit into
mainfrom
fix/dashboard-counter-and-day-mismatch

Conversation

@fleveque

@fleveque fleveque commented May 25, 2026

Copy link
Copy Markdown
Owner

Three bugs reported in prod after #173 merged.

1. Quick-stat counters stuck at 0

AnimatedCounter (in DashboardGreeting) rendered 0 holdings / 0 on radar even when the user had data.

Root cause. useCountUp only animated on the first viewport intersect. Sequence on a real account:

  1. Mount → useHoldings() loading → holdings.length === 0 → target = 0.
  2. IntersectionObserver fires → startedRef.current = true → animate 0 → 0.
  3. Data arrives → holdings.length === N → effect re-runs with new target.
  4. Re-run sees startedRef.current === true → skips → counter sticks at 0.

Fix. Rewrote useCountUp so it animates from the previous value to the new target on every change, with visibility tracked separately (once) but not gating subsequent updates. Reduced-motion still short-circuits.

2. "SBUX in 5d" greeting vs "in 4d" in upcoming list

DashboardGreeting and UpcomingExDividends disagreed by 1 day for the same stock.

Root cause. Greeting used Math.ceil, UpcomingExDividends uses Math.round. Server ships date-only strings (parsed as UTC midnight); compared against local midnight, that's a fractional diff (e.g. 4.08 days). ceil → 5, round → 4.

Fix. One-line change in Greeting to use Math.round.

3. DividendIncomeMini hidden despite recorded dividends

User had several dividends, mini didn't render.

Root cause. /dividends/chart_data returns 24 buckets per currency: 12 past + 12 future. Past months carry actual (paid), future ones carry projected. My slice(-12) grabbed the last 12 (= current month + 11 future), where actual is mostly null — so the "sum of actual values" sat at 0 unless the current month had a payment, and the card hid itself.

Fix. Filter to past-only entries (actual !== null) and take the last 12 of those. Robust to wider server windows (range=full).

Test plan

  • npx tsc --noEmit — clean
  • Manual: logged in with a populated account → holdings/radar counters animate up to real values, next ex-div day matches the list below
  • Manual: account with historical dividends → DividendIncomeMini renders with this-month total + 12-bar sparkline
  • Manual: empty account → counters animate to 0, mini stays hidden
  • Reduced motion: counts jump to final immediately

🤖 Generated with Claude Code

Two bugs reported from a populated prod account:

**Counters stuck at 0.** `useCountUp` only animated on the first
visibility intersect; when the data hooks loaded async (target
flipping 0 → N a tick later), the re-run of the effect saw
`startedRef.current = true` and skipped. Rewrote the hook so it
animates from the *previous* value to the new target on every
target change, with visibility tracked once but not gating
subsequent updates. Reduced-motion still short-circuits to the
final value immediately.

**"SBUX in 5d" vs "in 4d" mismatch.** DashboardGreeting used
`Math.ceil` while UpcomingExDividends uses `Math.round`. Server
ships date-only strings (parsed as UTC midnight) and we compare
against local midnight — for UTC+N users that's a fractional
diff (e.g. 4.08 days), and ceil produces 5 while round produces
4. Aligned Greeting to `round` so both surfaces agree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fleveque fleveque merged commit a48a258 into main May 25, 2026
5 checks passed
@fleveque fleveque deleted the fix/dashboard-counter-and-day-mismatch branch May 25, 2026 13:52
@fleveque fleveque changed the title Fix dashboard counter stuck at 0 + ex-div day mismatch Dashboard post-merge fixes: counter, ex-div day, dividend mini May 25, 2026
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.

1 participant