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

fix([issue-713]): resolve Recent/Pinned via nav manifest + guard storage throws (codex review)

Adam Eivy43a0de2abdc8
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 433b92f553..e2b4c30cc1 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -82,6 +82,7 @@ import {
Share2,
Pin,
PinOff,
+ Navigation,
Workflow as WorkflowIcon
} from 'lucide-react';
/* global __APP_VERSION__ */
@@ -491,6 +492,24 @@ export default function Layout() {
return () => window.removeEventListener('focus', onFocus);
}, []);
+ // Fetch the palette nav manifest once on mount so manifest-only paths
+ // (e.g. /wiki/log, /goals/tree) can be resolved in the Pinned/Recent sections
+ // even though they are not sidebar leaves.
+ const [manifestNav, setManifestNav] = useState([]);
+ useEffect(() => {
+ api.getPaletteManifest({ silent: true })
+ .then((data) => setManifestNav(Array.isArray(data?.nav) ? data.nav : []))
+ .catch((err) => console.warn(`⚠️ Layout: palette manifest fetch failed: ${err?.message || err}`));
+ }, []);
+
+ const manifestEntryByPath = useMemo(() => {
+ const map = new Map();
+ manifestNav.forEach((c) => {
+ if (c?.path && !map.has(c.path)) map.set(c.path, { path: c.path, label: c.label, icon: Navigation });
+ });
+ return map;
+ }, [manifestNav]);
+
useEffect(() => {
localStorage.setItem(SIDEBAR_KEY, String(collapsed));
}, [collapsed]);
@@ -570,8 +589,8 @@ export default function Layout() {
}, [resolvedNavItems]);
const resolveNavEntry = useCallback(
- (path) => navEntryByPath.get(path) || null,
- [navEntryByPath],
+ (path) => navEntryByPath.get(path) || manifestEntryByPath.get(path) || null,
+ [navEntryByPath, manifestEntryByPath],
);
const { pinned, recent, pin, unpin, isPinned } = useNavWorkingSet(resolveNavEntry);
diff --git a/client/src/hooks/useNavWorkingSet.js b/client/src/hooks/useNavWorkingSet.js
index 8edab03c95..816e5ac0f1 100644
--- a/client/src/hooks/useNavWorkingSet.js
+++ b/client/src/hooks/useNavWorkingSet.js
@@ -5,11 +5,11 @@ import {
recordVisit, togglePin as togglePinPure, isPinned as isPinnedPure,
} from '../utils/navWorkingSet.js';
-// Read a JSON string[] from localStorage, tolerating absent/corrupt values.
+// Read a JSON string[] from localStorage, tolerating absent/corrupt/throwing storage.
const readList = (key) => {
- const raw = localStorage.getItem(key);
- if (!raw) return [];
try {
+ const raw = localStorage.getItem(key);
+ if (!raw) return [];
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed.filter((p) => typeof p === 'string') : [];
} catch {
@@ -17,7 +17,15 @@ const readList = (key) => {
}
};
-const writeList = (key, list) => localStorage.setItem(key, JSON.stringify(list));
+// Persist a JSON string[]; ignore storage failures (private mode / quota) so the
+// in-memory React state still updates and the app never crashes on a write.
+const writeList = (key, list) => {
+ try {
+ localStorage.setItem(key, JSON.stringify(list));
+ } catch {
+ /* storage unavailable (private mode / quota) — keep in-memory state only */
+ }
+};
/**
* Sidebar working-set state (Pinned + Recent), persisted to localStorage.
diff --git a/client/src/hooks/useNavWorkingSet.test.jsx b/client/src/hooks/useNavWorkingSet.test.jsx
index 3f9f71f9a8..f3bedab5c4 100644
--- a/client/src/hooks/useNavWorkingSet.test.jsx
+++ b/client/src/hooks/useNavWorkingSet.test.jsx
@@ -1,4 +1,4 @@
-import { describe, it, expect, beforeEach } from 'vitest';
+import { describe, it, expect, beforeEach, vi } from 'vitest';
import { renderHook, act } from '@testing-library/react';
import { MemoryRouter, useNavigate } from 'react-router-dom';
import { useNavWorkingSet } from './useNavWorkingSet.js';
@@ -71,6 +71,21 @@ describe('useNavWorkingSet', () => {
expect(result.current.pinned).toEqual([]);
});
+ it('does not throw when localStorage.getItem throws (private mode)', () => {
+ const spy = vi.spyOn(Storage.prototype, 'getItem').mockImplementation(() => { throw new Error('SecurityError'); });
+ expect(() => renderHook(() => useNavWorkingSet(resolveNavEntry), { wrapper })).not.toThrow();
+ spy.mockRestore();
+ });
+
+ it('does not throw when localStorage.setItem throws (quota)', () => {
+ const spy = vi.spyOn(Storage.prototype, 'setItem').mockImplementation(() => { throw new Error('QuotaExceededError'); });
+ const { result } = renderHook(() => useNavWorkingSet(resolveNavEntry), { wrapper });
+ expect(() => act(() => result.current.pin('/brain/inbox'))).not.toThrow();
+ // in-memory state still updates despite the write failing
+ expect(result.current.isPinned('/brain/inbox')).toBe(true);
+ spy.mockRestore();
+ });
+
it('records a subsequent navigation into recent and storage', () => {
let nav;
function GrabNav() {
diff --git a/client/src/services/apiPalette.js b/client/src/services/apiPalette.js
index 1069d7e131..ba1893738b 100644
--- a/client/src/services/apiPalette.js
+++ b/client/src/services/apiPalette.js
@@ -1,6 +1,6 @@
import { request } from './apiCore.js';
-export const getPaletteManifest = () => request('/palette/manifest');
+export const getPaletteManifest = (options) => request('/palette/manifest', options);
export const runPaletteAction = (id, args = {}) =>
request(`/palette/action/${encodeURIComponent(id)}`, {