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: harden palette against layouts-endpoint failure; reseed defaults if all layouts hand-deleted

Adam Eivy6a6c8f897178
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsx
index 04e2d9cec2..9ae39f079e 100644
--- a/client/src/components/CmdKSearch.jsx
+++ b/client/src/components/CmdKSearch.jsx
@@ -98,7 +98,10 @@ export default function CmdKSearch() {
nav: (data?.nav || []).map(precompute),
actions: (data?.actions || []).map(precompute),
}));
- Promise.all([manifestPromise, getDashboardLayouts()]).then(([m, dashboards]) => {
+ // Fetch layouts independently so a layouts-endpoint failure can't kill
+ // nav + actions at the same time — each recovers with an empty list.
+ const layoutsPromise = getDashboardLayouts().catch(() => ({ layouts: [] }));
+ Promise.all([manifestPromise, layoutsPromise]).then(([m, dashboards]) => {
const layouts = (dashboards?.layouts || []).map((l) => precompute({
id: `layout.${l.id}`,
layoutId: l.id,
diff --git a/server/services/dashboardLayouts.js b/server/services/dashboardLayouts.js
index d3c421bfd6..0c7b7e67a4 100644
--- a/server/services/dashboardLayouts.js
+++ b/server/services/dashboardLayouts.js
@@ -97,8 +97,12 @@ export async function deleteLayout(id) {
if (!target) throw new Error(`Unknown layout id: ${id}`);
if (target.builtIn) throw new Error(`Cannot delete built-in layout: ${id}`);
const remaining = state.layouts.filter((l) => l.id !== id);
- const activeLayoutId = state.activeLayoutId === id ? remaining[0].id : state.activeLayoutId;
- const next = { activeLayoutId, layouts: remaining };
+ // Guard against the pathological case where the JSON was hand-edited to
+ // remove every built-in — fall back to reseeding defaults rather than
+ // indexing into an empty array.
+ const nextLayouts = remaining.length > 0 ? remaining : DEFAULT_LAYOUTS;
+ const activeLayoutId = state.activeLayoutId === id ? nextLayouts[0].id : state.activeLayoutId;
+ const next = { activeLayoutId, layouts: nextLayouts };
await atomicWrite(STATE_PATH, next);
return next;
}