Skip to content

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

fix: give a failed Quota Burn initial load a named cause and a Retry (#3930)

[._.]/ Adam Eivybf8474de5a64
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index bafd61c9dd..a8e8e06f2a 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -68,3 +68,4 @@
- A failed URL import in the SongBook importer no longer leaves the form looking untouched. The error had only a transient toast behind it, so once it faded the URL still sat in the input with no preview, no explanation, and a Save button that answered with the unrelated "Nothing to save — paste or fetch a tab first". The From URL tab now keeps an inline alert under the input naming the failure with a Retry button next to it, clears that alert as soon as the URL is edited, and drops any previously fetched draft (and the title/artist it auto-filled) so a failed fetch can't leave the earlier song previewed under a URL that never loaded. The disabled Save button now says why it's disabled instead of waiting for the click. A result that lands after the URL has been edited (or after the user has left the tab) is discarded rather than written under whatever is on screen now.
- The Digital Twin confidence gauge is now announced to screen readers. The circular SVG ring and the per-dimension bars beneath it were plain `<div>`s with a decorative SVG inside, so assistive tech either skipped them or read the loose "72%" text node with nothing to say what it measured. The overall gauge now carries `role="meter"` with `aria-label="Digital Twin overall confidence"`, the min/max/now values, and an `aria-valuetext` pairing the percentage with its Strong/Moderate/Needs Work band; each dimension bar carries the same meter semantics under its own dimension label, and the ring SVG is marked `aria-hidden` so its geometry isn't read twice.
- Pushing a series or music video project to a peer running an older PortOS no longer fires the same rejected request every sync cycle forever. When the older peer's strict schema rejects a newer bundled key (`manuscriptReview`, `reverseOutline`, `linkedTrack`), the sender strips it and retries — and deliberately withholds `lastPushedHash` so the stripped doc is re-sent once that peer upgrades. With nothing else recorded, the next cycle had no way to tell a settled record from a new edit, so every 60-second tick re-ran the same 400-plus-retry pair for content that had not moved. A second water-mark (`lastPushedLegacyHash`) now records what was actually delivered in stripped form, so an unchanged record short-circuits; any real edit still moves the hash and re-attempts the full push, and the `peer:online` re-probe still pushes unconditionally, which is where the stripped key finally lands after an upgrade. A pending doc the *receiver* reported (its bundled merge threw) is left un-water-marked, since that one is transient and must genuinely retry.
+- A failed first read on the Quota Burn page no longer strands you on a dead end. `load()` swallowed the error and left `config` null, and the unavailable branch returns before the header — so the only control that could re-read, "Refresh quota", was never rendered, and the one line on screen named neither the cause nor a way out short of reloading the browser tab. The read's failure is now kept in its own state (`null` = never failed, distinct from "the server answered and has no plan"), and the unavailable branch renders an error banner carrying that message with a Retry button that re-reads and clears it on success.
diff --git a/client/src/pages/QuotaBurn.jsx b/client/src/pages/QuotaBurn.jsx
index aa65b7c637..9a4be23c23 100644
--- a/client/src/pages/QuotaBurn.jsx
+++ b/client/src/pages/QuotaBurn.jsx
@@ -15,8 +15,9 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useNavigate, useParams } from 'react-router';
-import { Flame, RefreshCw } from 'lucide-react';
+import { AlertTriangle, Flame, RefreshCw } from 'lucide-react';
import toast from '../components/ui/Toast';
+import Banner from '../components/ui/Banner';
import BrailleSpinner from '../components/BrailleSpinner';
import FamilyCard from '../components/quotaBurn/FamilyCard';
import { NumberField } from '../components/quotaBurn/fields';
@@ -47,6 +48,11 @@ export default function QuotaBurn() {
const [status, setStatus] = useState(null);
const [catalog, setCatalog] = useState(EMPTY_CATALOG);
const [loading, setLoading] = useState(true);
+ // `null` = the read has never failed; a string = the message from the read
+ // that did. Collapsing the two into a boolean (or into `!config`) is what
+ // left a failed first load indistinguishable from "the server answered, and
+ // it has no plan" — one is retryable and names a cause, the other doesn't.
+ const [loadError, setLoadError] = useState(null);
// `unsaved` covers BOTH the debounce window and the in-flight PUT. Every "run"
// control reads server-side config, so it must stay disabled until the edit
// has actually landed — otherwise the user changes a model, clicks Burn, and
@@ -75,8 +81,14 @@ export default function QuotaBurn() {
const load = useCallback(async (refresh = false) => {
const seq = editSeqRef.current;
- const data = await api.getQuotaBurn(refresh, { silent: true }).catch(() => null);
+ // `silent: true` because the failure is rendered by this page's own banner
+ // rather than a toast — see client/src/CLAUDE.md's silent-vs-toasting rule.
+ const data = await api.getQuotaBurn(refresh, { silent: true })
+ .catch((err) => { setLoadError(err?.message || 'The request failed.'); return null; });
if (!data) return;
+ // Cleared on ANY successful read, including the polls: the last error no
+ // longer describes the page once the server has answered.
+ setLoadError(null);
// `status` is derived server-side and never edited here, so it is always
// safe to adopt; `config` is the form's own state and must not be rewound.
setStatus(data.status);
@@ -207,8 +219,37 @@ export default function QuotaBurn() {
setRunning(false);
};
+ const reload = (refresh = false) => {
+ setLoading(true);
+ load(refresh).finally(() => setLoading(false));
+ };
+
if (loading) return <div className="p-6 text-gray-400"><BrailleSpinner /> Loading burn plan…</div>;
- if (!config) return <div className="p-6 text-gray-400">Quota burn is unavailable — the server did not return a plan.</div>;
+ // A failed first read used to land here with no cause and no way out but a
+ // browser reload — the header (and its "Refresh quota") returns above.
+ if (!config) {
+ return (
+ <div className="p-6">
+ <Banner
+ tone="error"
+ icon={AlertTriangle}
+ size="md"
+ title="Quota burn is unavailable"
+ actions={(
+ <button
+ type="button"
+ className="text-xs px-3 py-1.5 rounded border border-port-error/40 hover:bg-port-error/10"
+ onClick={() => reload()}
+ >
+ Retry
+ </button>
+ )}
+ >
+ <p className="mt-0.5 break-words">{loadError || 'The server did not return a plan.'}</p>
+ </Banner>
+ </div>
+ );
+ }
const lastRun = status?.runs?.[0];
@@ -230,7 +271,7 @@ export default function QuotaBurn() {
<button
type="button"
className="inline-flex items-center gap-1 text-xs text-gray-300 hover:text-white"
- onClick={() => { setLoading(true); load(true).finally(() => setLoading(false)); }}
+ onClick={() => reload(true)}
>
<RefreshCw size={13} /> Refresh quota
</button>
diff --git a/client/src/pages/QuotaBurn.test.jsx b/client/src/pages/QuotaBurn.test.jsx
index 4ebce930b9..51402ba7f0 100644
--- a/client/src/pages/QuotaBurn.test.jsx
+++ b/client/src/pages/QuotaBurn.test.jsx
@@ -453,6 +453,33 @@ describe('QuotaBurn save races', () => {
expect(api.saveQuotaBurn.mock.calls[0][0].families.grok.jobs[0].label).toContain('Q');
});
+ it('names why the first load failed and recovers from the Retry button', async () => {
+ // A failed first read used to leave a bare "the server did not return a
+ // plan" with the header — and its Refresh — unrendered, so the only way
+ // out was reloading the browser tab.
+ const user = userEvent.setup();
+ api.getQuotaBurn.mockRejectedValueOnce(new Error('Network request failed'));
+ renderPage();
+
+ expect(await screen.findByText('Quota burn is unavailable')).toBeInTheDocument();
+ expect(screen.getByText('Network request failed')).toBeInTheDocument();
+
+ // Retry re-reads, and the success clears both the banner and the error.
+ await user.click(screen.getByRole('button', { name: 'Retry' }));
+ expect(await screen.findByText(/62% left/)).toBeInTheDocument();
+ expect(screen.queryByText('Quota burn is unavailable')).not.toBeInTheDocument();
+ expect(screen.queryByText('Network request failed')).not.toBeInTheDocument();
+ });
+
+ it('still offers a retry when the server answers without a plan', async () => {
+ // No error to name — but the page is just as stuck, so the way out has to
+ // be the same one.
+ api.getQuotaBurn.mockResolvedValueOnce({ config: null, status: null });
+ renderPage();
+ expect(await screen.findByText('The server did not return a plan.')).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument();
+ });
+
it('does not commit 0 when a number field is cleared to be retyped', async () => {
// Number('') === 0, which is below the server minimum for the interval and
// the dispatch cap — a 400 that also discards every co-pending edit.