Symptom
After LeanerCloud/cloud-commitments-cli#1257 the Home savings-over-time tooltip shows a date instead of the raw 13-digit millisecond value (QA 3.2). However, the helper it reuses (formatTrendAxisTick in frontend/src/dashboard.ts:996) returns "Jun 15" for daily/weekly intervals with no year component. The hourly branch also omits the year.
For the 90d range (daily) and the new ~365-day All range (weekly), the tooltip can show two points labeled "Jun 15" -- one from this year and one from last year -- with no way to distinguish them. The same is true for any range straddling a year boundary (e.g. clicking 90d in February).
Root cause
The frontend reuses formatTrendAxisTick for both x-axis tick labels and the tooltip title (PR LeanerCloud/cloud-commitments-cli#1257). The axis-tick branch needs to be compact (limited horizontal space per label), but the tooltip has plenty of room and would benefit from including the year.
export function formatTrendAxisTick(tsMs: number, intervalHint: 'hourly' | 'daily' | 'weekly'): string {
const d = new Date(tsMs);
if (intervalHint === 'hourly') {
return d.toLocaleString('en-US', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false });
}
return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); // no year
}
Fix
Add a separate formatter formatTrendTooltipTitle(tsMs, interval) that includes the year. The axis-tick formatter stays as-is (compact). Wire the tooltip title callback to the new helper:
export function formatTrendTooltipTitle(tsMs: number, intervalHint: 'hourly' | 'daily' | 'weekly'): string {
const d = new Date(tsMs);
if (intervalHint === 'hourly') {
return d.toLocaleString('en-US', { year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hour12: false });
}
return d.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' });
}
Test parity: extend the existing tooltip-title test in dashboard.test.ts to assert the rendered string contains the year (/2024/).
Notes
Discovered via
Adversarial review of LeanerCloud/cloud-commitments-cli#1257.
Symptom
After LeanerCloud/cloud-commitments-cli#1257 the Home savings-over-time tooltip shows a date instead of the raw 13-digit millisecond value (QA 3.2). However, the helper it reuses (
formatTrendAxisTickinfrontend/src/dashboard.ts:996) returns"Jun 15"fordaily/weeklyintervals with no year component. Thehourlybranch also omits the year.For the
90drange (daily) and the new ~365-dayAllrange (weekly), the tooltip can show two points labeled"Jun 15"-- one from this year and one from last year -- with no way to distinguish them. The same is true for any range straddling a year boundary (e.g. clicking90din February).Root cause
The frontend reuses
formatTrendAxisTickfor both x-axis tick labels and the tooltip title (PR LeanerCloud/cloud-commitments-cli#1257). The axis-tick branch needs to be compact (limited horizontal space per label), but the tooltip has plenty of room and would benefit from including the year.Fix
Add a separate formatter
formatTrendTooltipTitle(tsMs, interval)that includes the year. The axis-tick formatter stays as-is (compact). Wire the tooltiptitlecallback to the new helper:Test parity: extend the existing tooltip-title test in
dashboard.test.tsto assert the rendered string contains the year (/2024/).Notes
en-US(consistent with the rest of the chart). A separate i18n issue can revisit if/when CUDly localizes.Discovered via
Adversarial review of LeanerCloud/cloud-commitments-cli#1257.