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: surface a failed Quota Burn catalog read instead of silently emptying the job form (#3932)

[._.]/ Adam Eivy444c01a19d45
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 46937604d7..5d0119be08 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -72,3 +72,4 @@
- Deleting a prompt variable now asks first. The 14px trash icon on each row in the Prompt Manager's Variables list fired `DELETE /api/prompts/variables/:key` on the first click, so a mis-click — easy on a touch screen or with tight cursor tracking — destroyed the variable and its template content with no warning and no undo. The trash button now arms an inline confirm row in place of that row ("Delete "Tone Guide"?" with Delete / Cancel), using the shared `useConfirmDelete` + `InlineConfirmRow` pattern, so only one row is armed at a time and cancelling leaves the variable untouched. The trash button's accessible name now also names the variable it deletes instead of the generic "Delete variable".
- Media-library sweeps from two or more full-sync peers no longer race on the same asset file. The in-flight pull guard is keyed by `(peer, kind, filename)` on purpose — a re-render pushed by one peer should still be able to overwrite an older copy another peer served — but that also meant two peers advertising the same filename, which is exactly what a mirrored library looks like, both passed the guard and downloaded and wrote `data/{images,videos,audio,music}/<name>` at the same time. Pulls now serialize on a queue keyed by the destination alone, so the later peer waits its turn rather than writing alongside the first, and the local file is re-checked against the advertised hash once the turn arrives: for every asset kind, not just images, matching bytes mean a hash instead of a second download. The all-peers sweep also picked up a global re-entrancy guard, since a sweep that outran the 60-second tick let the next tick start peer B while peer A was still mid-pull, and the derived `media_assets` reconcile now runs on a single tail with concurrent requests collapsed into one pass instead of stacking overlapping full-table rebuilds.
- "Refresh quota" on the Quota Burn page no longer blanks the page or hides a failed re-scrape. The handler flipped the same `loading` flag as the first read, so every family card, control, and status number was replaced by a full-page "Loading burn plan…" spinner for the length of a 10–20s PTY quota scrape — and because the read's error was swallowed, a scrape that timed out simply put the stale numbers back with nothing saying they were stale. The refresh now reports itself on the button that asked for it (spinning icon, "Refreshing…", disabled) while the plan stays on screen, and a failure raises a toast naming the cause. The unavailable-state Retry button shares the same path; it stays banner-only there, since the banner already names the error.
+- A failed job-catalog read on the Quota Burn page no longer empties the config form silently. The fetch was `.catch(() => {})`, so a 500 or a network blip left the catalog at its empty default: the "Add a preset job" picker returned null and vanished, "Add job" sat disabled, and every job row's Job Type / Apps / Universes / Image Modes dropdown rendered blank — with nothing on screen naming a cause, and editing a step in that state saving `jobType: ""` into a 400 that stalls the whole save. The catalog read now keeps its failure in its own state (with a 200 carrying zero job types reported as its own distinct cause rather than as a successful load), and an expanded family card renders an inline warning banner naming it with a "Retry catalog load" button that re-reads the catalog in place — no browser reload, and the plan itself stays on screen throughout.
diff --git a/client/src/components/quotaBurn/FamilyCard.jsx b/client/src/components/quotaBurn/FamilyCard.jsx
index 71d65bd953..4700ac819a 100644
--- a/client/src/components/quotaBurn/FamilyCard.jsx
+++ b/client/src/components/quotaBurn/FamilyCard.jsx
@@ -7,7 +7,8 @@
* runner evaluates, so the card can't disagree with what actually happens.
*/
-import { Ban, ChevronDown, ChevronRight, Flame, Plus, RotateCcw } from 'lucide-react';
+import { AlertTriangle, Ban, ChevronDown, ChevronRight, Flame, Plus, RotateCcw } from 'lucide-react';
+import Banner from '../ui/Banner';
import BrailleSpinner from '../BrailleSpinner';
import JobRow from './JobRow';
import PresetPicker from './PresetPicker';
@@ -16,8 +17,8 @@ import { formatDateTime } from '../../utils/formatters';
import { NumberField } from './fields';
export default function FamilyCard({
- familyId, config, status, catalog, expanded, actionsBusy,
- onToggleExpand, onPatch, onRunFamily, onRunJob, onRearm,
+ familyId, config, status, catalog, catalogError, catalogRetrying, expanded, actionsBusy,
+ onToggleExpand, onPatch, onRunFamily, onRunJob, onRearm, onRetryCatalog,
}) {
const jobs = config.jobs || [];
// Pending counts and `run once` completions stay on the STATUS side and are
@@ -160,6 +161,33 @@ export default function FamilyCard({
{expanded && (
<div className="border-t border-port-border/60 p-3 space-y-4">
+ {/* Every choice this section offers — job type, app, universe, image
+ mode, and the preset picker — comes from the catalog, so a failed
+ catalog read empties them all and hides the picker outright. Say
+ so where the empty controls are, and offer the re-read here rather
+ than making a browser reload the only way back. */}
+ {catalogError && (
+ <Banner
+ tone="warning"
+ icon={AlertTriangle}
+ title="Job choices could not be loaded"
+ actions={(
+ <button
+ type="button"
+ className="text-xs px-3 py-1.5 rounded border border-port-warning/40 hover:bg-port-warning/10 disabled:opacity-40"
+ disabled={catalogRetrying}
+ onClick={onRetryCatalog}
+ >
+ {catalogRetrying ? 'Retrying…' : 'Retry catalog load'}
+ </button>
+ )}
+ >
+ <p className="mt-0.5 break-words">
+ {catalogError} Job types, apps, universes, and presets are unavailable — editing a step now would save an
+ empty job type and be rejected.
+ </p>
+ </Banner>
+ )}
<div className="grid grid-cols-2 lg:grid-cols-4 gap-3">
<NumberField id={`burn-${familyId}-window`} label="Burn within (hours of reset)" value={config.resetWithinHours} onChange={(v) => onPatch({ resetWithinHours: v })} min={0} max={168} hint="Measured against the broadest window (the weekly one) — the allowance that expires unused." />
<NumberField id={`burn-${familyId}-reserve`} label="Reserve (%)" value={config.reservePercent} onChange={(v) => onPatch({ reservePercent: v })} min={0} max={100} hint="Never spend below this much headroom." />
@@ -191,7 +219,7 @@ export default function FamilyCard({
type="button"
className="inline-flex items-center gap-1 text-xs text-port-accent hover:underline disabled:opacity-40"
disabled={!canAddJob}
- title={canAddJob ? 'Add a job to this plan' : 'Job catalog unavailable — reload the page'}
+ title={canAddJob ? 'Add a job to this plan' : 'Job catalog unavailable — retry the catalog load above'}
onClick={addJob}
>
<Plus size={13} /> Add job
diff --git a/client/src/pages/QuotaBurn.jsx b/client/src/pages/QuotaBurn.jsx
index dc5e340de6..aa438dc9e0 100644
--- a/client/src/pages/QuotaBurn.jsx
+++ b/client/src/pages/QuotaBurn.jsx
@@ -42,6 +42,12 @@ const EMPTY_CATALOG = { jobTypes: [], apps: [], universes: [], imageModes: [] };
// two need opposite handling of the error state, and both are falsy.
const READ_FAILED = Symbol('quota-burn-read-failed');
+// A catalog the server answered with, but which is missing the job types the
+// form needs, is indistinguishable from a failed fetch as far as the page is
+// concerned — both leave every dropdown empty — so normalize to the same shape
+// and let the caller decide which message to show.
+const normalizeCatalog = (data) => ({ ...EMPTY_CATALOG, ...(data || {}) });
+
export default function QuotaBurn() {
// Which family is expanded lives in the URL, not local state, so a specific
// family's plan is linkable and survives a reload.
@@ -60,6 +66,15 @@ export default function QuotaBurn() {
// 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);
+ // Same `null` = never failed / string = the cause convention as `loadError`,
+ // for the SECOND read this page makes. The catalog fetch used to be swallowed
+ // outright, which is what left the preset picker missing, "Add job" disabled,
+ // and every job row's dropdown empty with nothing on screen saying why — and
+ // editing a step against an empty job-type list submits `jobType: ""`, which
+ // the strict PUT schema 400s into a stalled save.
+ const [catalogError, setCatalogError] = useState(null);
+ // Reported ON the retry button, like `refreshing` — the plan stays rendered.
+ const [catalogRetrying, setCatalogRetrying] = useState(false);
// `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
@@ -126,12 +141,37 @@ export default function QuotaBurn() {
return null;
}, []);
+ // The catalog is the page's second read and fails independently of the plan:
+ // the plan can render perfectly while every choice the form offers is empty.
+ // `silent: true` for the same reason as `load` — the failure is rendered by
+ // the family card's own banner, not the request helper's toast.
+ const loadCatalog = useCallback(async () => {
+ let failure = null;
+ const data = await api.getQuotaBurnCatalog({ silent: true })
+ .catch((err) => {
+ failure = err?.message || 'The request failed.';
+ return READ_FAILED;
+ });
+ if (data === READ_FAILED) {
+ setCatalogError(failure);
+ return;
+ }
+ const next = normalizeCatalog(data);
+ setCatalog(next);
+ // A 200 carrying no job types is a different failure with the same symptom
+ // — say so rather than reporting success into an empty form.
+ setCatalogError(next.jobTypes.length ? null : 'The server returned no job types.');
+ }, []);
+
useEffect(() => {
- Promise.all([
- load(),
- api.getQuotaBurnCatalog({ silent: true }).then(setCatalog).catch(() => {}),
- ]).finally(() => setLoading(false));
- }, [load]);
+ Promise.all([load(), loadCatalog()]).finally(() => setLoading(false));
+ }, [load, loadCatalog]);
+
+ const retryCatalog = async () => {
+ setCatalogRetrying(true);
+ await loadCatalog();
+ setCatalogRetrying(false);
+ };
// A cold quota cache comes back as `pending` families rather than holding the
// response open for a 20s-per-family PTY scrape, so the page renders its plan
@@ -370,6 +410,9 @@ export default function QuotaBurn() {
config={family}
status={(status?.families || []).find((row) => row.id === familyId)}
catalog={catalog}
+ catalogError={catalogError}
+ catalogRetrying={catalogRetrying}
+ onRetryCatalog={retryCatalog}
expanded={expanded === familyId}
actionsBusy={unsaved || running}
onToggleExpand={(id) => navigate(expanded === id ? '/devtools/quota-burn' : `/devtools/quota-burn/${id}`)}
diff --git a/client/src/pages/QuotaBurn.test.jsx b/client/src/pages/QuotaBurn.test.jsx
index 11db0d19aa..ed515ae62b 100644
--- a/client/src/pages/QuotaBurn.test.jsx
+++ b/client/src/pages/QuotaBurn.test.jsx
@@ -355,6 +355,56 @@ describe('QuotaBurn run-once steps', () => {
});
});
+/**
+ * The catalog is the page's second read, and it fails independently of the
+ * plan: the plan renders perfectly while every choice the form offers is empty.
+ * Swallowing that failure left the preset picker gone, "Add job" disabled, and
+ * every dropdown blank with nothing saying why — and editing a step against an
+ * empty job-type list saves `jobType: ""`, which the strict PUT rejects.
+ */
+describe('QuotaBurn catalog failure', () => {
+ it('names a failed catalog read instead of silently emptying the form', async () => {
+ api.getQuotaBurnCatalog.mockRejectedValueOnce(new Error('Catalog request failed'));
+ renderPage('/devtools/quota-burn/grok');
+
+ expect(await screen.findByText('Job choices could not be loaded')).toBeInTheDocument();
+ expect(screen.getByText(/Catalog request failed/)).toBeInTheDocument();
+ // The controls the catalog feeds are gone or inert — the banner is the only
+ // thing on screen that explains either.
+ expect(screen.queryByLabelText(/Add a preset job/)).not.toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /Add job/ })).toBeDisabled();
+ // The plan itself still rendered: a catalog failure is not a page failure.
+ expect(screen.getByText(/62% left/)).toBeInTheDocument();
+ });
+
+ it('re-fetches the catalog from the banner without a page reload', async () => {
+ const user = userEvent.setup();
+ api.getQuotaBurnCatalog.mockRejectedValueOnce(new Error('Catalog request failed'));
+ renderPage('/devtools/quota-burn/grok');
+
+ await user.click(await screen.findByRole('button', { name: 'Retry catalog load' }));
+ await waitFor(() => expect(api.getQuotaBurnCatalog).toHaveBeenCalledTimes(2));
+ // The success clears the banner AND restores the controls it was standing in for.
+ await waitFor(() => expect(screen.queryByText('Job choices could not be loaded')).not.toBeInTheDocument());
+ expect(screen.getByLabelText(/Add a preset job/)).toBeInTheDocument();
+ expect(screen.getByRole('button', { name: /Add job/ })).toBeEnabled();
+ });
+
+ it('treats a catalog that answered with no job types as its own failure', async () => {
+ // Same symptom as a thrown read — every dropdown empty — but a different
+ // cause, so it must not be reported as a successful load.
+ api.getQuotaBurnCatalog.mockResolvedValueOnce({ ...catalog, jobTypes: [] });
+ renderPage('/devtools/quota-burn/grok');
+ expect(await screen.findByText(/The server returned no job types\./)).toBeInTheDocument();
+ });
+
+ it('says nothing about the catalog when it loaded', async () => {
+ renderPage('/devtools/quota-burn/grok');
+ await screen.findByLabelText(/Add a preset job/);
+ expect(screen.queryByText('Job choices could not be loaded')).not.toBeInTheDocument();
+ });
+});
+
describe('QuotaBurn save debounce', () => {
it('folds a burst of edits into ONE PUT and blocks runs until it lands', async () => {
// Per-keystroke saving also re-read the status, and a universe-bible-images