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
address review (claude): fence soft-deleted PATCH, branch description field per kind, validate cursor-object values
[._.]/ Adam Eivy0f9b882a80c5
diff --git a/client/src/pages/Catalog.jsx b/client/src/pages/Catalog.jsxindex 8c22bfb135..88dbdce89d 100644--- a/client/src/pages/Catalog.jsx+++ b/client/src/pages/Catalog.jsx@@ -132,10 +132,18 @@ export default function Catalog() {const confirmDelete = async (it) => {setArmedId(null);+ // Capture the original index so a failed delete restores in place rather+ // than jumping the row to the top of the list.+ const originalIdx = items.findIndex((x) => x.id === it.id);setItems((prev) => prev.filter((x) => x.id !== it.id));await deleteCatalogIngredient(it.id, { silent: true }).catch((err) => {toast.error(err?.message || 'Delete failed');- setItems((prev) => (prev.some((x) => x.id === it.id) ? prev : [it, ...prev]));+ setItems((prev) => {+ if (prev.some((x) => x.id === it.id)) return prev;+ const next = [...prev];+ next.splice(Math.max(0, originalIdx), 0, it);+ return next;+ });});loadStats();};diff --git a/client/src/pages/CatalogIngest.jsx b/client/src/pages/CatalogIngest.jsxindex 1d931a86d2..f4cd807770 100644--- a/client/src/pages/CatalogIngest.jsx+++ b/client/src/pages/CatalogIngest.jsx@@ -330,6 +330,12 @@ function ReviewSection({ section, items, selected, onToggle, onSelectAll, onPatc<ul className="space-y-2">{items.map((c, idx) => {const baseId = `${section.key}-${idx}`;+ // Characters use `physicalDescription` (matches the canon shape from+ // sanitizeCharacter); places/objects use `description`. Without this+ // a character's LLM-extracted physicalDescription would render as an+ // empty textarea and edits would land in a sibling `description` key+ // that the canon shape doesn't read.+ const descField = section.type === 'character' ? 'physicalDescription' : 'description';return (<li key={baseId} className="border border-port-border rounded p-3 bg-port-bg/40 flex items-start gap-2"><input id={`${baseId}-check`} type="checkbox" checked={selected.has(idx)} onChange={() => onToggle(idx)}@@ -340,8 +346,8 @@ function ReviewSection({ section, items, selected, onToggle, onSelectAll, onPatcplaceholder="Name" maxLength={200}className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-sm text-white focus:outline-none focus:border-port-accent" /><label htmlFor={`${baseId}-desc`} className="sr-only">Description</label>- <textarea id={`${baseId}-desc`} rows={2} value={c.description ?? ''}- onChange={(e) => onPatch(idx, { description: e.target.value })} placeholder="Short description"+ <textarea id={`${baseId}-desc`} rows={2} value={c[descField] ?? ''}+ onChange={(e) => onPatch(idx, { [descField]: e.target.value })} placeholder="Short description"className="w-full px-2 py-1 bg-port-bg border border-port-border rounded text-xs text-gray-200 focus:outline-none focus:border-port-accent" /></div></li>diff --git a/server/lib/storyBible.test.js b/server/lib/storyBible.test.jsindex 45305916c4..4fc0a09700 100644--- a/server/lib/storyBible.test.js+++ b/server/lib/storyBible.test.js@@ -267,7 +267,6 @@ describe('storyBible — sanitizeCharacter', () => {it('caps the list at BIBLE_LIMITS.WARDROBES_PER_CHARACTER_MAX', () => {const tooMany = Array.from({ length: BIBLE_LIMITS.WARDROBES_PER_CHARACTER_MAX + 5 }, (_, i) => ({-tryReadFile: vi.fn().mockResolvedValue(null),name: `Outfit ${i}`,}));const out = sanitizeCharacter({ name: 'A', wardrobes: tooMany });diff --git a/server/routes/catalog.js b/server/routes/catalog.jsindex dd49425c17..3dedddcc69 100644--- a/server/routes/catalog.js+++ b/server/routes/catalog.js@@ -111,13 +111,13 @@ router.post('/scraps/:id/commit', asyncHandler(async (req, res) => {}));router.get('/ingredients', asyncHandler(async (req, res) => {- const q = validateRequest(catalogIngredientQuerySchema, req.query);+ const params = validateRequest(catalogIngredientQuerySchema, req.query);res.json(await catalogDB.listIngredients({- type: q.type,- tag: q.tag,- query: q.q,- limit: q.limit ?? 50,- offset: q.offset ?? 0,+ type: params.type,+ tag: params.tag,+ query: params.q,+ limit: params.limit ?? 50,+ offset: params.offset ?? 0,}));}));diff --git a/server/services/catalogDB.js b/server/services/catalogDB.jsindex dd7df7fc2f..c7e31b47a7 100644--- a/server/services/catalogDB.js+++ b/server/services/catalogDB.js@@ -164,8 +164,11 @@ export async function updateScrap(id, patch = {}) {}if (fields.length === 0) return getScrap(id);params.push(id);+ // `AND deleted = false` keeps PATCH consistent with GET — a PATCH on a+ // soft-deleted row returns zero rows so the route 404s, instead of silently+ // mutating a row the next GET would refuse to return.const result = await query(- `UPDATE catalog_scraps SET ${fields.join(', ')} WHERE id = $${idx} RETURNING *`,+ `UPDATE catalog_scraps SET ${fields.join(', ')} WHERE id = $${idx} AND deleted = false RETURNING *`,params,);return rowToScrap(result.rows[0]);@@ -247,8 +250,11 @@ export async function updateIngredient(id, patch = {}) {}if (fields.length === 0) return getIngredient(id);params.push(id);+ // Mirrors updateScrap: PATCH on a soft-deleted row returns zero rows so the+ // route 404s. Revival of soft-deleted rows is intentionally separate via+ // `reviveDeletedIngredient`, so this filter doesn't conflict with that path.const result = await query(- `UPDATE catalog_ingredients SET ${fields.join(', ')} WHERE id = $${idx} RETURNING *`,+ `UPDATE catalog_ingredients SET ${fields.join(', ')} WHERE id = $${idx} AND deleted = false RETURNING *`,params,);return rowToIngredient(result.rows[0]);diff --git a/server/services/catalogSync.js b/server/services/catalogSync.jsindex d28a52428b..66d1c0c044 100644--- a/server/services/catalogSync.js+++ b/server/services/catalogSync.js@@ -7,7 +7,7 @@* three-table relational store, not a single flat row set.** Pull protocol:- * GET /api/catalog/sync?since.scraps=A&since.ingredients=B&since.sources=C&since.refs=D&limit=100+ * GET /api/catalog/sync?since[scraps]=A&since[ingredients]=B&since[sources]=C&since[refs]=D&limit=100* → { scraps[], ingredients[], sources[], refs[], maxSequences, hasMore }** The four BIGSERIAL `sync_sequence` columns are INDEPENDENT — a row at@@ -47,7 +47,10 @@ const CURSOR_KEYS = ['scraps', 'ingredients', 'sources', 'refs'];// active table get silently filtered out forever.function normalizeCursors(since) {if (since && typeof since === 'object' && !Array.isArray(since)) {- return Object.fromEntries(CURSOR_KEYS.map((k) => [k, since[k] ?? '0']));+ return Object.fromEntries(CURSOR_KEYS.map((k) => {+ const v = since[k];+ return [k, typeof v === 'string' && /^\d+$/.test(v) ? v : '0'];+ }));}const scalar = typeof since === 'string' && /^\d+$/.test(since) ? since : '0';return Object.fromEntries(CURSOR_KEYS.map((k) => [k, scalar]));