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 (codex): migrate Daily Driver into existing layouts, fix dismiss retry
[._.]/ Adam Eivyd56b3962ddbf
diff --git a/client/src/components/dashboard/builtins/DailyDriverWidget.jsx b/client/src/components/dashboard/builtins/DailyDriverWidget.jsxindex c4a994298e..2ff0ebf7b9 100644--- a/client/src/components/dashboard/builtins/DailyDriverWidget.jsx+++ b/client/src/components/dashboard/builtins/DailyDriverWidget.jsx@@ -49,10 +49,13 @@ export default function DailyDriverWidget({ dashboardState }) {useEffect(() => { fetchData(); }, [fetchData]);// Mark the day handled, then refetch dashboard state so the registry gate- // drops the card. Optimistically hides immediately.+ // drops the card (which unmounts this widget). On failure, re-enable the+ // dismiss button so the user can retry — otherwise a failed POST leaves the+ // still-visible card's only control disabled until a full reload.const handleDismiss = useCallback(async () => {setDismissing(true);- await api.markDailyDriverHandled().catch(() => null);+ const ok = await api.markDailyDriverHandled().then(() => true).catch(() => false);+ if (!ok) { setDismissing(false); return; }if (refetchDashboard) await refetchDashboard();}, [refetchDashboard]);@@ -151,11 +154,16 @@ export default function DailyDriverWidget({ dashboardState }) {</div>);})}+ {/* One-click entry INTO the goals check-in flow (navigation, not a+ bulk check-in — an aggregate check-in would fire an LLM call per+ goal, which the AI Provider Usage Policy requires stay an+ explicit per-goal action on the goals page). */}<Linkto="/goals/list"className="flex items-center justify-center gap-1 p-2 rounded-lg bg-port-accent/10 text-port-accent text-sm hover:bg-port-accent/20 transition-colors">- <Compass size={14} /> Check in on all goals+ <Compass size={14} /> Review & check in on goals+ <ArrowRight size={12} /></Link></>)}diff --git a/client/src/components/dashboard/builtins/DailyDriverWidget.test.jsx b/client/src/components/dashboard/builtins/DailyDriverWidget.test.jsxindex 4a26c7895f..ae5a959093 100644--- a/client/src/components/dashboard/builtins/DailyDriverWidget.test.jsx+++ b/client/src/components/dashboard/builtins/DailyDriverWidget.test.jsx@@ -67,7 +67,7 @@ describe('DailyDriverWidget', () => {const writersLink = screen.getByText('Writers Room').closest('a');expect(writersLink.getAttribute('href')).toBe('/writers-room');- expect(screen.getByText('Check in on all goals').closest('a').getAttribute('href')).toBe('/goals/list');+ expect(screen.getByText(/Review & check in on goals/).closest('a').getAttribute('href')).toBe('/goals/list');});it('surfaces the latest check-in recommendation on a goal row', async () => {@@ -88,4 +88,17 @@ describe('DailyDriverWidget', () => {await waitFor(() => expect(mocks.markDailyDriverHandled).toHaveBeenCalledTimes(1));await waitFor(() => expect(refetch).toHaveBeenCalledTimes(1));});++ it('re-enables the dismiss button and does not refetch when the handled request fails', async () => {+ mocks.markDailyDriverHandled.mockRejectedValue(new Error('network'));+ const refetch = vi.fn().mockResolvedValue();+ renderWidget({ refetch });+ const btn = await screen.findByLabelText('Dismiss for today');+ fireEvent.click(btn);+ await waitFor(() => expect(mocks.markDailyDriverHandled).toHaveBeenCalledTimes(1));+ // Failed dismissal must not mark the dashboard clean, and the button+ // returns to enabled so the user can retry.+ await waitFor(() => expect(btn.disabled).toBe(false));+ expect(refetch).not.toHaveBeenCalled();+ });});diff --git a/scripts/migrations/191-seed-daily-driver-widget.js b/scripts/migrations/191-seed-daily-driver-widget.jsnew file mode 100644index 0000000000..14e48b6035--- /dev/null+++ b/scripts/migrations/191-seed-daily-driver-widget.js@@ -0,0 +1,113 @@+/**+ * Seed the new `daily-driver` dashboard widget ("Daily Driver", issue #2666)+ * into the built-in `morning-review` layout for installs that already have a+ * persisted `data/dashboard-layouts.json`.+ *+ * Background:+ * `server/services/dashboardLayouts.js#DEFAULT_LAYOUTS` only seeds when the+ * file is missing. Adding `daily-driver` to the Morning Review layout in code+ * alone won't reach existing users — this migration walks the file, finds the+ * built-in `morning-review` layout, and inserts `daily-driver` into its+ * `widgets` list + `grid` if missing. User-renamed copies and other layouts+ * are not touched. Re-runs detect the widget is already present and skip.+ * Mirrors migration 145.+ *+ * The DEFAULT_LAYOUTS geometry pins daily-driver full-width at the top and+ * shifts the other Morning Review widgets down — but an existing persisted+ * layout still has those widgets at their old (top) positions, so the preferred+ * top slot collides. Per the migration-145 convention we do NOT rewrite the+ * user's existing positions; instead the collision fallback appends+ * daily-driver on a fresh row below everything (still present, still gated).+ */++import { readLayoutsDoc, writeLayoutsDoc } from './_lib.js';++const WIDGET_ID = 'daily-driver';+const WIDGET_W = 12;+const WIDGET_H = 6;++// Mirror of the geometry in `server/services/dashboardLayouts.js`+// DEFAULT_LAYOUTS `morning-review` layout — edits here must match that file or+// fresh installs + migrated installs diverge.+const PREFERRED_SLOTS = {+ 'morning-review': { x: 0, y: 0, w: WIDGET_W, h: WIDGET_H },+};+const TARGET_LAYOUT_IDS = Object.keys(PREFERRED_SLOTS);++function rectsOverlap(a, b) {+ return a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h;+}++function collidesWith(grid, candidate) {+ for (const item of grid) {+ if (rectsOverlap(item, candidate)) return true;+ }+ return false;+}++function pickGridEntry(grid, layoutId) {+ const preferred = PREFERRED_SLOTS[layoutId];+ if (preferred) {+ const candidate = { id: WIDGET_ID, x: preferred.x, y: preferred.y, w: preferred.w, h: preferred.h };+ if (!collidesWith(grid, candidate)) return candidate;+ }+ // Fall back to a clean row below everything else if the preferred slot is+ // occupied (an existing persisted layout keeps its old widget positions).+ const bottom = grid.reduce((max, it) => Math.max(max, (it.y ?? 0) + (it.h ?? 0)), 0);+ return {+ id: WIDGET_ID,+ x: 0,+ y: bottom,+ w: preferred?.w ?? WIDGET_W,+ h: preferred?.h ?? WIDGET_H,+ };+}++function applyToLayout(layout) {+ if (!layout || typeof layout !== 'object') return false;+ if (!Array.isArray(layout.widgets)) return false;++ let changed = false;+ // 1) Insert into widgets if absent.+ if (!layout.widgets.includes(WIDGET_ID)) {+ layout.widgets = [...layout.widgets, WIDGET_ID];+ changed = true;+ }+ // 2) Heal the grid entry independently — the widget id can be present in+ // `widgets` but missing from `grid` (e.g. a widgets-only edit landed without+ // an arrange-and-save pass). Treat a non-array grid as [] (the shape the+ // client's `synthesizeGrid` would auto-create at render time).+ const existingGrid = Array.isArray(layout.grid) ? layout.grid : [];+ const hasGridEntry = existingGrid.some((it) => it?.id === WIDGET_ID);+ if (!hasGridEntry) {+ layout.grid = [...existingGrid, pickGridEntry(existingGrid, layout.id)];+ changed = true;+ } else if (!Array.isArray(layout.grid)) {+ layout.grid = existingGrid;+ changed = true;+ }+ return changed;+}++export default {+ async up({ rootDir }) {+ const result = await readLayoutsDoc({ rootDir, label: 'migration 191' });+ if (!result.ok) return { updated: 0, reason: result.reason };+ const { doc, path } = result;++ let touched = 0;+ for (const layout of doc.layouts) {+ if (!layout || !TARGET_LAYOUT_IDS.includes(layout.id)) continue;+ if (applyToLayout(layout)) touched += 1;+ }++ if (touched === 0) {+ console.log(`📦 migration 191: daily-driver already present in target layouts.`);+ return { updated: 0, reason: 'already-applied' };+ }++ await writeLayoutsDoc(path, doc);+ console.log(`📦 migration 191: seeded daily-driver widget into ${touched} built-in layout(s).`);+ return { updated: touched };+ },+};diff --git a/scripts/migrations/191-seed-daily-driver-widget.test.js b/scripts/migrations/191-seed-daily-driver-widget.test.jsnew file mode 100644index 0000000000..c2ec689ebd--- /dev/null+++ b/scripts/migrations/191-seed-daily-driver-widget.test.js@@ -0,0 +1,123 @@+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';++import migration from './191-seed-daily-driver-widget.js';++const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));++describe('migration 191 — seed daily-driver widget into the morning-review layout', () => {+ let rootDir;+ let layoutsPath;++ beforeEach(() => {+ rootDir = mkdtempSync(join(tmpdir(), 'migration-191-'));+ mkdirSync(join(rootDir, 'data'), { recursive: true });+ layoutsPath = join(rootDir, 'data', 'dashboard-layouts.json');+ });++ afterEach(() => {+ rmSync(rootDir, { recursive: true, force: true });+ });++ it('no-ops cleanly when dashboard-layouts.json is missing (fresh install)', async () => {+ const result = await migration.up({ rootDir });+ expect(result.updated).toBe(0);+ expect(result.reason).toBe('no-state');+ expect(existsSync(layoutsPath)).toBe(false);+ });++ it('inserts daily-driver at the top when the preferred slot is free', async () => {+ writeJson(layoutsPath, {+ activeLayoutId: 'default',+ layouts: [+ { id: 'morning-review', name: 'Morning Review', builtIn: true, widgets: ['review-hub'], grid: [{ id: 'review-hub', x: 0, y: 8, w: 4, h: 4 }] },+ ],+ });+ const result = await migration.up({ rootDir });+ expect(result.updated).toBe(1);+ const after = readJson(layoutsPath);+ const layout = after.layouts.find((l) => l.id === 'morning-review');+ expect(layout.widgets).toContain('daily-driver');+ expect(layout.grid.find((g) => g.id === 'daily-driver')).toEqual({ id: 'daily-driver', x: 0, y: 0, w: 12, h: 6 });+ });++ it('appends below existing items when the preferred top slot is occupied', async () => {+ // The real persisted Morning Review keeps its widgets at the old top rows.+ writeJson(layoutsPath, {+ activeLayoutId: 'morning-review',+ layouts: [+ {+ id: 'morning-review', name: 'Morning Review', builtIn: true,+ widgets: ['proactive-alerts', 'upcoming-tasks'],+ grid: [+ { id: 'proactive-alerts', x: 0, y: 0, w: 4, h: 4 },+ { id: 'upcoming-tasks', x: 4, y: 0, w: 5, h: 8 },+ ],+ },+ ],+ });+ const result = await migration.up({ rootDir });+ expect(result.updated).toBe(1);+ const after = readJson(layoutsPath);+ const entry = after.layouts[0].grid.find((g) => g.id === 'daily-driver');+ expect(entry).toBeDefined();+ expect(entry.x).toBe(0);+ expect(entry.y).toBeGreaterThanOrEqual(8);+ // Existing widgets are left untouched.+ expect(after.layouts[0].grid.find((g) => g.id === 'proactive-alerts')).toEqual({ id: 'proactive-alerts', x: 0, y: 0, w: 4, h: 4 });+ });++ it('is idempotent — second run is a no-op', async () => {+ writeJson(layoutsPath, {+ activeLayoutId: 'default',+ layouts: [+ { id: 'morning-review', name: 'Morning Review', builtIn: true, widgets: ['daily-driver'], grid: [{ id: 'daily-driver', x: 0, y: 0, w: 12, h: 6 }] },+ ],+ });+ const result = await migration.up({ rootDir });+ expect(result.updated).toBe(0);+ expect(result.reason).toBe('already-applied');+ });++ it('only touches the morning-review id, not other or renamed layouts', async () => {+ writeJson(layoutsPath, {+ activeLayoutId: 'focus',+ layouts: [+ { id: 'focus', name: 'Focus', builtIn: true, widgets: ['cos'], grid: [] },+ { id: 'my-morning', name: 'My Morning', builtIn: false, widgets: ['cos'], grid: [] },+ { id: 'morning-review', name: 'Morning Review', builtIn: true, widgets: ['cos'], grid: [] },+ ],+ });+ const result = await migration.up({ rootDir });+ expect(result.updated).toBe(1);+ const after = readJson(layoutsPath);+ expect(after.layouts.find((l) => l.id === 'focus').widgets).toEqual(['cos']);+ expect(after.layouts.find((l) => l.id === 'my-morning').widgets).toEqual(['cos']);+ expect(after.layouts.find((l) => l.id === 'morning-review').widgets).toContain('daily-driver');+ });++ it('survives an unreadable JSON file', async () => {+ writeFileSync(layoutsPath, 'not json');+ const result = await migration.up({ rootDir });+ expect(result.updated).toBe(0);+ expect(result.reason).toBe('unreadable');+ });++ it('heals legacy state where widget id is in widgets[] but missing from grid[]', async () => {+ writeJson(layoutsPath, {+ activeLayoutId: 'default',+ layouts: [+ { id: 'morning-review', name: 'Morning Review', builtIn: true, widgets: ['review-hub', 'daily-driver'], grid: [{ id: 'review-hub', x: 0, y: 0, w: 4, h: 4 }] },+ ],+ });+ const result = await migration.up({ rootDir });+ expect(result.updated).toBe(1);+ const after = readJson(layoutsPath);+ const entry = after.layouts[0].grid.find((g) => g.id === 'daily-driver');+ expect(entry).toBeDefined();+ expect(after.layouts[0].widgets.filter((w) => w === 'daily-driver')).toHaveLength(1);+ });+});