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
refactor([codex5-dashboard-intent-layouts]): address review findings
[._.]/ Adam Eivy4b58a0ce2320
diff --git a/client/src/components/dashboard/WidgetSuggestions.jsx b/client/src/components/dashboard/WidgetSuggestions.jsxindex 9bf5a1f7be..8cadf82226 100644--- a/client/src/components/dashboard/WidgetSuggestions.jsx+++ b/client/src/components/dashboard/WidgetSuggestions.jsx@@ -16,11 +16,7 @@ export default function WidgetSuggestions({ presentWidgetIds, dashboardState, onif (!w.gate) return false;if (present.has(w.id)) return false;if (dismissed.has(w.id)) return false;- // Defensive: future gate predicates might destructure partial state.- let active;- try { active = w.gate(dashboardState); }- catch { return false; }- return Boolean(active);+ return Boolean(w.gate(dashboardState));});}, [presentWidgetIds, dashboardState, dismissed]);diff --git a/client/src/components/dashboard/WidgetSuggestions.test.jsx b/client/src/components/dashboard/WidgetSuggestions.test.jsxindex 8904da6500..fb0be5e257 100644--- a/client/src/components/dashboard/WidgetSuggestions.test.jsx+++ b/client/src/components/dashboard/WidgetSuggestions.test.jsx@@ -36,11 +36,13 @@ describe('WidgetSuggestions', () => {expect(screen.getByText(/Quick Stats/)).toBeDefined();});- it('calls onAdd with just the widget id (no layout shape leakage)', () => {+ it('calls onAdd with only the widget id — no layout shape passed', () => {const onAdd = vi.fn().mockResolvedValue();render(<WidgetSuggestions presentWidgetIds={['cos']} dashboardState={populatedState} onAdd={onAdd} />);fireEvent.click(screen.getByLabelText('Add Quick Stats to layout'));+ expect(onAdd).toHaveBeenCalledTimes(1);expect(onAdd).toHaveBeenCalledWith('quick-stats');+ expect(onAdd.mock.calls[0]).toHaveLength(1);});it('dismissing a suggestion hides it for the lifetime of the mount', () => {@@ -49,12 +51,4 @@ describe('WidgetSuggestions', () => {fireEvent.click(screen.getByLabelText('Dismiss Quick Stats suggestion'));expect(screen.queryByText(/Quick Stats/)).toBeNull();});-- it('swallows gate-predicate exceptions without surfacing the widget', () => {- // Future widgets may add gate predicates that destructure partial state.- const { container } = render(- <WidgetSuggestions presentWidgetIds={[]} dashboardState={undefined} onAdd={() => {}} />- );- expect(container).toBeEmptyDOMElement();- });});diff --git a/client/src/pages/Dashboard.jsx b/client/src/pages/Dashboard.jsxindex 5a0c1af884..d773fc91f6 100644--- a/client/src/pages/Dashboard.jsx+++ b/client/src/pages/Dashboard.jsx@@ -69,10 +69,18 @@ export default function Dashboard() {if (cancelled) return;setLayouts(data.layouts);const desiredActiveId = pickActiveLayoutId(data.activeLayoutId, data.layouts, autoSwitchedRef.current);- autoSwitchedRef.current = true;setActiveLayoutId(desiredActiveId);- if (desiredActiveId !== data.activeLayoutId) {- api.setActiveDashboardLayout(desiredActiveId).catch(() => {});+ if (desiredActiveId === data.activeLayoutId) {+ autoSwitchedRef.current = true;+ } else {+ // Only mark "auto-switched" after the server confirms — a failing+ // PUT would otherwise leave the UI on the window layout while the+ // server still says the old one, with no retry path until reload.+ api.setActiveDashboardLayout(desiredActiveId)+ .then(() => { autoSwitchedRef.current = true; })+ .catch(() => {+ setActiveLayoutId((current) => (current === desiredActiveId ? data.activeLayoutId : current));+ });}if (data.limits) setLayoutLimits(data.limits);setLayoutsError(null);@@ -216,6 +224,9 @@ export default function Dashboard() {const result = await api.saveDashboardLayout(id, { name, widgets, grid, activateWindow });setLayouts(result.layouts);setActiveLayoutId(id);+ // Lock in for the day so a window-driven auto-switch on the next mount+ // doesn't bump the user off the brand-new layout they just created.+ recordManualLayoutPick(id);// Mirror selectLayout's revert-on-failure so the picker doesn't// diverge from server state if the active-write fails. Only revert// if the UI still reflects the id we tried to set; a later selectiondiff --git a/client/src/utils/timeWindow.js b/client/src/utils/timeWindow.jsindex 56ba615c92..51cf11c0cc 100644--- a/client/src/utils/timeWindow.js+++ b/client/src/utils/timeWindow.js@@ -59,11 +59,12 @@ const pruneStaleUserPickKeys = (todayKey) => {export function recordManualLayoutPick(layoutId, now = new Date()) {if (typeof window === 'undefined' || !window.localStorage) return;- try {- const todayKey = userPickKey(now);- window.localStorage.setItem(todayKey, String(layoutId));- pruneStaleUserPickKeys(todayKey);- } catch { /* quota / disabled — auto-switch will fire next visit */ }+ // Prune BEFORE set so a quota-exceeded setItem still frees space first —+ // otherwise the catch swallows the throw and stale prior-day keys grow.+ const todayKey = userPickKey(now);+ pruneStaleUserPickKeys(todayKey);+ try { window.localStorage.setItem(todayKey, String(layoutId)); }+ catch { /* quota / disabled — auto-switch will fire next visit */ }}function readManualLayoutPick(now = new Date()) {diff --git a/server/services/dashboardLayouts.js b/server/services/dashboardLayouts.jsindex e51549091f..b294f112ca 100644--- a/server/services/dashboardLayouts.js+++ b/server/services/dashboardLayouts.js@@ -5,9 +5,10 @@* list of widget ids; the client's widget registry decides how to render* each id. Persisted to data/dashboard-layouts.json.*- * Seeded on first read with the "Everything" layout (id `default`, mirrors- * the current hardcoded dashboard) plus "Focus", "Morning Review", and "Ops"- * starter layouts so the feature has value out of the box.+ * Built-ins seeded on first read: Everything, Focus, Morning Review, Ops,+ * Deep Work, Health, Agent Watch. The intent-named trio (Deep Work / Health+ * / Agent Watch) is also exported as INTENT_LAYOUTS so migration 030 can+ * seed them into existing installs without forking the grid geometry.*/import { join } from 'path';