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: keep half-typed dates in the Usage page From/To pickers
[._.]/ Adam Eivyf931f393da6b
diff --git a/client/src/pages/UsagePage.jsx b/client/src/pages/UsagePage.jsxindex fe4877851d..1695f133d8 100644--- a/client/src/pages/UsagePage.jsx+++ b/client/src/pages/UsagePage.jsx@@ -402,6 +402,32 @@ function ProviderCostRows({ provider }) {// Time-filter pills + custom range, driven by URL search params so every// report view is shareable/bookmarkable (linkable-routes convention).+// A native date input reports "" while its mm/dd/yyyy segments are only+// partly typed, so binding it straight to the URL param wiped the field+// mid-keystroke. Hold the draft locally and commit only complete dates (or an+// explicit clear); re-sync when the committed value changes underneath.+function RangeDateInput({ id, value, onCommit }) {+ const [draft, setDraft] = useState(value);+ useEffect(() => { setDraft(value); }, [value]);+ const handleChange = (e) => {+ const next = e.target.value;+ setDraft(next);+ if (next === '' && e.target.validity.badInput) return;+ // Typing a year passes through 0002, 0020, 0202 — valid dates, not intent.+ if (next !== '' && Number(next.slice(0, 4)) < 1900) return;+ if (next !== value) onCommit(next);+ };+ return (+ <input+ id={id}+ type="date"+ value={draft}+ onChange={handleChange}+ className="bg-transparent text-xs text-white outline-none [color-scheme:dark]"+ />+ );+}+function CostReportFilters({ period, from, to, isCustom, onPeriod, onRange }) {return (<div className="flex flex-wrap items-center gap-2">@@ -418,21 +444,9 @@ function CostReportFilters({ period, from, to, isCustom, onPeriod, onRange }) {))}<div className={`flex items-center gap-1.5 rounded-full border px-2 py-0.5 ${isCustom ? 'border-port-accent bg-port-accent/10' : 'border-port-border'}`}><label htmlFor="usage-from" className="text-xs text-gray-400">From</label>- <input- id="usage-from"- type="date"- value={from}- onChange={(e) => onRange(e.target.value, to)}- className="bg-transparent text-xs text-white outline-none [color-scheme:dark]"- />+ <RangeDateInput id="usage-from" value={from} onCommit={(v) => onRange(v, to)} /><label htmlFor="usage-to" className="text-xs text-gray-400">To</label>- <input- id="usage-to"- type="date"- value={to}- onChange={(e) => onRange(from, e.target.value)}- className="bg-transparent text-xs text-white outline-none [color-scheme:dark]"- />+ <RangeDateInput id="usage-to" value={to} onCommit={(v) => onRange(from, v)} /></div></div>);diff --git a/client/src/pages/UsagePage.test.jsx b/client/src/pages/UsagePage.test.jsxindex 0f1b9545f0..2961c33246 100644--- a/client/src/pages/UsagePage.test.jsx+++ b/client/src/pages/UsagePage.test.jsx@@ -571,3 +571,22 @@ describe('UsagePage free-tier section (#7408)', () => {expect(await screen.findByText('No free-tier usage recorded in this period.')).toBeInTheDocument();});});++describe('UsagePage custom date range inputs', () => {+ it('keeps a half-typed date instead of resetting it, and commits once complete', async () => {+ api.getUsage.mockResolvedValue(usage);+ render(<MemoryRouter><UsagePage /></MemoryRouter>);+ const from = await screen.findByLabelText('From');+ const callsBefore = api.getUsage.mock.calls.length;++ // Partially typed segments surface as value "" (happy-dom lacks badInput, so+ // assert the complete-date path plus that a stray year-0002 date never commits).+ fireEvent.change(from, { target: { value: '0002-09-29' } });+ expect(from.value).toBe('0002-09-29');+ expect(api.getUsage.mock.calls.length).toBe(callsBefore);++ fireEvent.change(from, { target: { value: '2026-09-29' } });+ await waitFor(() => expect(api.getUsage.mock.calls.length).toBeGreaterThan(callsBefore));+ expect(from.value).toBe('2026-09-29');+ });+});