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 17): derive builtIn at write-time + client-side widget cap

Adam Eivycea582131848
diff --git a/client/src/components/dashboard/LayoutEditor.jsx b/client/src/components/dashboard/LayoutEditor.jsx
index 14b580e9b5..b461954fee 100644
--- a/client/src/components/dashboard/LayoutEditor.jsx
+++ b/client/src/components/dashboard/LayoutEditor.jsx
@@ -12,9 +12,11 @@ import toast from '../ui/Toast';
// the editor functional in degraded states). Kept in sync with the server's
// ID_MAX_LENGTH by convention — the server value is authoritative.
const FALLBACK_ID_MAX = 60;
+const FALLBACK_WIDGETS_MAX = 50;
export default function LayoutEditor({ layouts, activeLayoutId, limits, onClose, onSave, onDelete, onDuplicate }) {
const idMax = limits?.idMaxLength || FALLBACK_ID_MAX;
+ const widgetsMax = limits?.widgetsMax || FALLBACK_WIDGETS_MAX;
const [editingId, setEditingId] = useState(activeLayoutId);
const editing = layouts.find((l) => l.id === editingId);
const [widgets, setWidgets] = useState(editing?.widgets ?? []);
@@ -95,8 +97,19 @@ export default function LayoutEditor({ layouts, activeLayoutId, limits, onClose,
};
const add = (id) => {
- setWidgets((prev) => (prev.includes(id) ? prev : [...prev, id]));
- setDirty(true);
+ let added = false;
+ setWidgets((prev) => {
+ if (prev.includes(id)) return prev;
+ // Match server's Zod cap so users don't hit a 400 on Save after
+ // silently accumulating past the limit.
+ if (prev.length >= widgetsMax) {
+ toast.error(`Layouts are capped at ${widgetsMax} widgets`);
+ return prev;
+ }
+ added = true;
+ return [...prev, id];
+ });
+ if (added) setDirty(true);
};
// Each async handler awaits an API write through onSave/onDuplicate/
diff --git a/server/services/dashboardLayouts.js b/server/services/dashboardLayouts.js
index 648c502902..47b4e9b38b 100644
--- a/server/services/dashboardLayouts.js
+++ b/server/services/dashboardLayouts.js
@@ -143,9 +143,14 @@ export async function setActiveLayout(id) {
export async function saveLayout(layout) {
const state = await getState();
const idx = state.layouts.findIndex((l) => l.id === layout.id);
+ // Derive `builtIn` from BUILTIN_IDS at write-time (not from the persisted
+ // flag) so a hand-edited JSON that deleted the default `ops` entry can't
+ // produce a new `ops` that sanitizeLayout() later treats as built-in while
+ // the write-path echoed `builtIn: false` to the client.
+ const builtIn = BUILTIN_IDS.has(layout.id);
const merged = idx >= 0
- ? state.layouts.map((l, i) => i === idx ? { ...l, ...layout, builtIn: l.builtIn } : l)
- : [...state.layouts, { ...layout, builtIn: false }];
+ ? state.layouts.map((l, i) => i === idx ? { ...l, ...layout, builtIn } : l)
+ : [...state.layouts, { ...layout, builtIn }];
const next = { activeLayoutId: state.activeLayoutId, layouts: merged };
await atomicWrite(STATE_PATH, next);
return { ...next, limits: LIMITS };