Skip to content

Restored tabs and the active database id are never checked against the daemon #4197

Closed

Description

@malibio

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 hydrateNode in pane-content.svelte (lines 85-117), and it runs only when a tab becomes active. If the node is missing it logs Node <id> not found — closing stale tab and closes the tab, so a user sees the tabs close one at a time as they click them.
  • localStorage["nodespace.activeDatabaseId"] held 01M5EVRN2… while the daemon had registered 01M697HCK…. 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 with no 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.nodeId equal to the type id (for example task) with nodeType: "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:changed passes.

Technical Specifications

Reference Files

  • packages/desktop-app/src/lib/services/tab-persistence-service.ts - load, validation and sanitization of loaded state
  • packages/desktop-app/src/lib/components/layout/pane-content.svelte - hydrateNode (lines 85-117), the on-click close
  • packages/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

  1. added
    bug
    on Oct 31, 2026
  2. self-assigned this
    on Nov 2, 2026
  3. mstomar125 commented on Nov 2, 2026

    @mstomar125
    Contributor

    Picking this up (sweep drain).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugfrontendui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions