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

address review (round 7): id regex parity, dedupe layouts, catch manifest failures

Adam Eivy3a44c5d979ad
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsx
index ff246cac7f..ea2299933d 100644
--- a/client/src/components/CmdKSearch.jsx
+++ b/client/src/components/CmdKSearch.jsx
@@ -97,16 +97,22 @@ export default function CmdKSearch() {
if (!open || navActionsFetchedRef.current) return;
navActionsFetchedRef.current = true;
let cancelled = false;
- getPaletteManifest().then((data) => {
- if (cancelled) return;
- const nav = (data?.nav || []).map(precompute);
- const actions = (data?.actions || []).map(precompute);
- setManifest((prev) => ({
- nav,
- actions,
- layouts: prev?.layouts || [],
- }));
- });
+ // request() toasts the failure centrally; on rejection we fall back to
+ // an empty shape so the palette still renders (layouts + search work).
+ // Also: if the fetch fails, allow a retry on next open by un-setting the
+ // ref so the user isn't stuck with a blank nav list forever.
+ getPaletteManifest()
+ .catch(() => { navActionsFetchedRef.current = false; return { nav: [], actions: [] }; })
+ .then((data) => {
+ if (cancelled) return;
+ const nav = (data?.nav || []).map(precompute);
+ const actions = (data?.actions || []).map(precompute);
+ setManifest((prev) => ({
+ nav,
+ actions,
+ layouts: prev?.layouts || [],
+ }));
+ });
return () => { cancelled = true; };
}, [open]);
diff --git a/server/services/dashboardLayouts.js b/server/services/dashboardLayouts.js
index c2df72115d..fa4fad4dbf 100644
--- a/server/services/dashboardLayouts.js
+++ b/server/services/dashboardLayouts.js
@@ -63,6 +63,10 @@ const DEFAULT_STATE = {
};
const BUILTIN_IDS = new Set(DEFAULT_LAYOUTS.map((l) => l.id));
+// Kept in lockstep with routes/dashboardLayouts.js#idSchema — both layers
+// must reject ids the other can't round-trip, or the client ends up with
+// layouts it can display but not activate/delete.
+const ID_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
// Sanitize a single layout entry — protect against hand-edits that produce
// non-object elements, missing fields, non-array widget lists, or duplicate
@@ -71,7 +75,7 @@ const BUILTIN_IDS = new Set(DEFAULT_LAYOUTS.map((l) => l.id));
// flag can't downgrade a built-in into a deletable user layout.
const sanitizeLayout = (l) => {
if (!l || typeof l !== 'object') return null;
- if (typeof l.id !== 'string' || !l.id) return null;
+ if (typeof l.id !== 'string' || !ID_RE.test(l.id) || l.id.length > 60) return null;
if (typeof l.name !== 'string' || !l.name) return null;
const widgets = [];
const seen = new Set();
@@ -89,9 +93,16 @@ const sanitizeLayout = (l) => {
export async function getState() {
await ensureDir(PATHS.data);
const raw = await readJSONFile(STATE_PATH, DEFAULT_STATE, { logError: false });
- const sanitized = Array.isArray(raw.layouts)
- ? raw.layouts.map(sanitizeLayout).filter(Boolean)
- : [];
+ const sanitized = [];
+ const seenIds = new Set();
+ if (Array.isArray(raw.layouts)) {
+ for (const entry of raw.layouts) {
+ const s = sanitizeLayout(entry);
+ if (!s || seenIds.has(s.id)) continue; // first-occurrence wins; no React key collisions
+ seenIds.add(s.id);
+ sanitized.push(s);
+ }
+ }
const layouts = sanitized.length > 0 ? sanitized : DEFAULT_LAYOUTS;
const activeLayoutId = layouts.find((l) => l.id === raw.activeLayoutId)
? raw.activeLayoutId