Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: show hour precision for usage quota resets
Adam Eivyf74b12b84aea
diff --git a/client/src/components/usage/UsageMeter.jsx b/client/src/components/usage/UsageMeter.jsxindex f7b7d3e1c9..98b9d09e6c 100644--- a/client/src/components/usage/UsageMeter.jsx+++ b/client/src/components/usage/UsageMeter.jsx@@ -2,6 +2,10 @@ import { Clock } from 'lucide-react';import ProgressBar from '../ui/ProgressBar';import { timeAgo, timeUntil } from '../../utils/formatters';+const HOUR_MS = 60 * 60 * 1000;+const DAY_MS = 24 * HOUR_MS;+const DETAILED_RESET_MAX_MS = 30 * DAY_MS;+/*** One quota window's meter — the shared rendering for a `limits[]` entry from* `GET /api/usage/providers`.@@ -20,12 +24,24 @@ import { timeAgo, timeUntil } from '../../utils/formatters';// this localizes and adds the relative "in 3h" that makes a reset time useful at// a glance. The raw-text fallback stays for a reading off an older peer that// still emits its CLI's own wording.+const formatResetCountdown = (date) => {+ const remainingMs = date.getTime() - Date.now();+ // Keep the existing compact buckets outside the multi-day window. Within it,+ // include the hour remainder so a 47-hour reset does not collapse to "1d".+ if (remainingMs < DAY_MS || remainingMs >= DETAILED_RESET_MAX_MS) return timeUntil(date, '');++ const totalHours = Math.floor(remainingMs / HOUR_MS);+ const days = Math.floor(totalHours / 24);+ const hours = totalHours % 24;+ return `in ${days}d${hours ? ` ${hours}h` : ''}`;+};+export const formatResetsAt = (resetsAt) => {if (!resetsAt || !/^\d{4}-\d{2}-\d{2}T/.test(resetsAt)) return resetsAt;const d = new Date(resetsAt);if (Number.isNaN(d.getTime())) return resetsAt;const local = d.toLocaleString(undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' });- const relative = timeUntil(d, '');+ const relative = formatResetCountdown(d);return relative ? `${local} (${relative})` : local;};diff --git a/client/src/components/usage/UsageMeter.test.jsx b/client/src/components/usage/UsageMeter.test.jsxindex 03991dbebd..1ab4470b5e 100644--- a/client/src/components/usage/UsageMeter.test.jsx+++ b/client/src/components/usage/UsageMeter.test.jsx@@ -1,7 +1,9 @@-import { describe, expect, it } from 'vitest';+import { afterEach, describe, expect, it, vi } from 'vitest';import { render, screen } from '@testing-library/react';import UsageMeter, { meterTone, formatResetsAt, readingAttribution } from './UsageMeter';+afterEach(() => vi.useRealTimers());+describe('meterTone', () => {// The thresholds are the whole reason this meter was extracted rather than// copied: a plan that reads "comfortable" on one page and "critical" on@@ -30,6 +32,13 @@ describe('formatResetsAt', () => {it('localizes an ISO reset', () => {expect(formatResetsAt('2026-03-01T12:00:00.000Z')).toMatch(/\d/);});++ it('keeps the remaining hours for a multi-day reset countdown', () => {+ vi.useFakeTimers();+ vi.setSystemTime(new Date('2026-09-21T00:00:00.000Z'));++ expect(formatResetsAt('2026-09-22T23:00:00.000Z')).toMatch(/\(in 1d 23h\)$/);+ });});describe('readingAttribution', () => {