Repository navigation
Closed
Description
Overview
Tab state and the active database id are persisted in the webview's localStorage and restored on launch without checking them against the daemon. After a database change, the app restores tabs for nodes that do not exist and shows them as "Loading...". Clicking one closes it.
Problem Statement
Observed in the desktop app after moving to a fresh database:
localStorage["nodespace:tab-state"]is a single constant key, not scoped to a database. The persisted tabs pointed at node ids from a previous database.- Restored tabs render with their persisted title ("Loading...") and attempt to load.
- The only existence check is
hydrateNodeinpane-content.svelte(lines 85-117), and it runs only when a tab becomes active. If the node is missing it logsNode <id> not found — closing stale taband closes the tab, so a user sees the tabs close one at a time as they click them. localStorage["nodespace.activeDatabaseId"]held01M5EVRN2…while the daemon had registered01M697HCK…. The mismatch is silent when the daemon falls back to its default database. When the two ids are both real but different, every call fails withno database registered with id …, and hydration reads that as "node not found" and closes every tab on click.- Some tabs are not nodes: a type's view tab has
content.nodeIdequal to the type id (for exampletask) withnodeType: "query". Any validation has to treat those as valid when the type exists.
Proposed Solution
Validate persisted tab state when it is restored, before anything renders, and scope it to the database it was saved under.
Documentation
- Frontend State & Persistence - how frontend state is restored and where it persists; update it with the restore-time validation.
- ADR-053 - one daemon serves several databases, each with its own id; tab state belongs to one of them.
- No prior ADR covers tab persistence.
Acceptance Criteria
- On restore, each persisted tab is checked against the active database (node ids that resolve, type-view tabs whose type exists, settings and search tabs). Tabs that do not resolve are dropped before render; none shows "Loading..." for a missing node.
- Persisted tab state is keyed by database id. Opening database B never restores database A's tabs.
- A persisted active database id that the daemon has not registered is replaced by the daemon's default instead of being used for calls.
- A test restores tab state containing a missing node id, a valid node id, a valid type-view tab and a stale type-view tab, and asserts only the valid ones remain.
- A test covers a stale
activeDatabaseId. - Code passes
bun run quality:fix;bun run test:changedpasses.
Technical Specifications
Reference Files
packages/desktop-app/src/lib/services/tab-persistence-service.ts-load, validation and sanitization of loaded statepackages/desktop-app/src/lib/components/layout/pane-content.svelte-hydrateNode(lines 85-117), the on-click closepackages/desktop-app/src/lib/stores/navigation.svelte.ts- tab model (type,content.nodeId,content.nodeType)
Implementation Details
Keep hydrateNode's close-on-missing as a last-resort guard; restore-time validation is the primary fix.
Related Issues
- None
Activity
mstomar125 commentedon Nov 2, 2026
Picking this up (sweep drain).