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([issue-3153]): field-level errors for cleared bounds and stale edit links
[._.]/ Adam Eivy0f8836958f4e
diff --git a/client/src/components/sprites/AnimationTypesDrawer.jsx b/client/src/components/sprites/AnimationTypesDrawer.jsxindex 57ec47c520..d6b681a747 100644--- a/client/src/components/sprites/AnimationTypesDrawer.jsx+++ b/client/src/components/sprites/AnimationTypesDrawer.jsx@@ -45,9 +45,10 @@ const TABS = [];const TAB_IDS = TABS.map((t) => t.id);-// `NEW_SPRITE_KINDS` is the shared "kinds a user may pick" list (already excluding-// the legacy import-only `props`, for the same reason). A hand-edited store row may-// still claim `props` and renders fine in the list — this only governs the FORM.+// A new type's starting point. The kind options come from the shared+// `NEW_SPRITE_KINDS` (which already excludes the legacy import-only `props`); a+// hand-edited store row may still claim `props` and lists fine — that list and this+// default only govern the FORM.const BLANK = {id: '',label: '',@@ -88,14 +89,20 @@ const toForm = (row) => ({});/**- * The first bounds violation, or `null`.+ * The first bounds problem, or `null`.*- * Deliberately only the ordering rule: it's the one the user hits by typing a- * default outside the range they just narrowed, and the only one whose message is- * more useful before the round-trip than after.+ * Two rules, both chosen because the message is more useful before the round-trip+ * than after: a cleared field (the number inputs hold `''`, and `Number('')` is `0`,+ * so an emptied minimum would sail through the ordering check and come back as a raw+ * "expected number" from Zod), and the ordering the user breaks by typing a default+ * outside the range they just narrowed.*/function boundsError(form) {for (const [min, def, max, label] of BOUND_TRIPLES) {+ const values = [form[min], form[def], form[max]];+ if (values.some((v) => v === '' || v === null || !Number.isFinite(Number(v)))) {+ return `${label}: fill in the minimum, default and maximum.`;+ }if (!(Number(form[min]) <= Number(form[def]) && Number(form[def]) <= Number(form[max]))) {return `${label}: minimum ≤ default ≤ maximum is required.`;}@@ -486,6 +493,28 @@ export default function AnimationTypesDrawer({ open, onClose }) {}if (tracks === null) return <p className="text-sm text-gray-500">Loading…</p>;+ // A stale `?editTrack=` (a shared link to a type since deleted, or a typo) must+ // say so rather than silently falling through to the blank create form, which+ // would read as "your link worked" while offering a different action — the+ // not-found fallback every id-addressed view here owes a stale id.+ if (editingId && !editing) {+ return (+ <div className="space-y-3">+ <Banner tone="warning" icon={AlertTriangle} size="sm">+ No animation type called <span className="font-mono">{editingId}</span> — it may have been deleted+ or renamed.+ </Banner>+ <button+ type="button"+ onClick={() => setEditingId(null)}+ className="flex items-center gap-2 px-3 py-1.5 bg-port-bg border border-port-border hover:border-port-accent text-gray-300 rounded text-sm"+ >+ <RotateCcw className="w-4 h-4" /> Back to the list+ </button>+ </div>+ );+ }+if (activeTab === 'new' || editing) {return (// Remount per edit target rather than re-seeding through an effect — samediff --git a/client/src/components/sprites/AnimationTypesDrawer.test.jsx b/client/src/components/sprites/AnimationTypesDrawer.test.jsxindex 9908179f04..4c66a6ba68 100644--- a/client/src/components/sprites/AnimationTypesDrawer.test.jsx+++ b/client/src/components/sprites/AnimationTypesDrawer.test.jsx@@ -51,8 +51,8 @@ const CHEST = {promptTemplate: 'Animate the {{kind}} {{name}} opening once.',};-const renderDrawer = () => render(- <MemoryRouter>+const renderDrawer = (initialEntry = '/sprites') => render(+ <MemoryRouter initialEntries={[initialEntry]}><AnimationTypesDrawer open onClose={vi.fn()} /></MemoryRouter>,);@@ -174,6 +174,19 @@ describe('AnimationTypesDrawer create', () => {expect(createSpriteAnimationTrack).not.toHaveBeenCalled();});+ it('blocks a CLEARED bound rather than letting Number("") pass as 0', async () => {+ // The number inputs hold `''` when emptied, and `Number('') === 0` would satisfy+ // the ordering check — so without an explicit empty check the user gets a raw+ // "expected number" from Zod instead of a message naming the knob.+ renderDrawer();+ await screen.findByText('Chest opening');+ await fillNewType();+ fireEvent.change(screen.getByLabelText(/^Min frames/), { target: { value: '' } });+ fireEvent.click(screen.getByRole('button', { name: /create type/i }));+ expect(await screen.findByText(/fill in the minimum, default and maximum/i)).toBeInTheDocument();+ expect(createSpriteAnimationTrack).not.toHaveBeenCalled();+ });+it('blocks a duplicate id, a blank label, and a blank prompt locally', async () => {renderDrawer();await screen.findByText('Chest opening');@@ -216,6 +229,21 @@ describe('AnimationTypesDrawer create', () => {});describe('AnimationTypesDrawer edit', () => {+ it('deep-links to a type via ?editTrack and opens its form', async () => {+ renderDrawer('/sprites?editTrack=chest-opening');+ expect(await screen.findByDisplayValue('Chest opening')).toBeInTheDocument();+ expect(screen.getByText(/id is fixed/i)).toBeInTheDocument();+ });++ it('says so on a STALE ?editTrack instead of silently offering the create form', async () => {+ // A shared link to a since-deleted type must not read as "your link worked" while+ // presenting a different action.+ renderDrawer('/sprites?editTrack=long-gone');+ expect(await screen.findByText(/No animation type called/)).toBeInTheDocument();+ expect(screen.getByText('long-gone')).toBeInTheDocument();+ expect(screen.queryByRole('button', { name: /create type/i })).not.toBeInTheDocument();+ });+it('loads the row, hides the id as immutable, and shows the derived fields', async () => {renderDrawer();await screen.findByText('Chest opening');diff --git a/server/services/sprites/animationTrackCrud.js b/server/services/sprites/animationTrackCrud.jsindex a6425fd7d3..6ff5885138 100644--- a/server/services/sprites/animationTrackCrud.js+++ b/server/services/sprites/animationTrackCrud.js@@ -124,12 +124,12 @@ const authoredFields = (row) => ({* first.*/function withDerivedBaselines(rows, builtins) {+ // Seed from the BUILTINS only: their claim is compiled in and fixed, while every+ // stored row's answer is what this function decides below (a row arrives from+ // `composeRow` with no `standaloneContract` at all).const claimed = new Set();- for (const row of [...builtins, ...rows]) {- if (!row.standaloneContract) continue;- // A builtin's claim is fixed; a stored row's is being decided below, so only- // seed from rows whose answer is already settled.- if (row.builtin) for (const kind of row.kinds) claimed.add(kind);+ for (const row of builtins) {+ if (row.standaloneContract) for (const kind of row.kinds) claimed.add(kind);}return rows.map((row) => {const standaloneContract = row.kinds.every((kind) => !claimed.has(kind));diff --git a/server/services/sprites/animationTracks.js b/server/services/sprites/animationTracks.jsindex fbdc355973..82f9c735e7 100644--- a/server/services/sprites/animationTracks.js+++ b/server/services/sprites/animationTracks.js@@ -181,21 +181,6 @@ export const ANIMATION_TRACKS = Object.freeze({// `animationTrackStore.js`. Iterate `Object.keys(ANIMATION_TRACKS)` inline when you// genuinely mean the compiled rows only.-/**- * Validate a registry's rows, throwing on the first violation.- *- * Called at module load below (the navManifest.js / catalogTypes.js idiom): a- * row missing a bound would otherwise boot clean and surface much later as- * `NaN` out of a Math.min, or as `z.number().min(undefined)` throwing at the- * first sprite render. A bad row should block boot with a message naming the- * field, not corrupt a render hours later.- *- * Exported and pure — taking the table as an argument — so the guard can be- * proven against a synthetic multi-row fixture. Asserting set-uniqueness over- * the real (currently single-row) table would only re-derive the- * implementation: the whole guard could be deleted and such a test would stay- * green, which is exactly the regression it exists to prevent.- *//*** The min/default/max triples every row must keep in order.*@@ -255,6 +240,21 @@ export function deriveTrackFields(id) {};}+/**+ * Validate a registry's rows, throwing on the first violation.+ *+ * Called at module load below (the navManifest.js / catalogTypes.js idiom): a+ * row missing a bound would otherwise boot clean and surface much later as+ * `NaN` out of a Math.min, or as `z.number().min(undefined)` throwing at the+ * first sprite render. A bad row should block boot with a message naming the+ * field, not corrupt a render hours later.+ *+ * Exported and pure — taking the table as an argument — so the guard can be+ * proven against a synthetic multi-row fixture. Asserting set-uniqueness over+ * the real (currently single-row) table would only re-derive the+ * implementation: the whole guard could be deleted and such a test would stay+ * green, which is exactly the regression it exists to prevent.+ */export function assertAnimationTrackRows(tracks) {const claimedContractFields = new Map();const claimedOnDiskKinds = new Map();