Repository navigation
Description
Overview
Client-side counterpart of ADR-053 (../nodespace-docs/decisions/053-one-daemon-multiple-databases.md): once the daemon serves N databases (#1532), the CLI and Tauri app must let users target, create, and switch databases — live, with no daemon restart.
Problem Statement
The frontend has no database concept beyond a read-only display path. The File-menu "New Database… / Open Database…" flow writes a config value the daemon never reads, then shows a "restart required" notice — a silent no-op end to end. No Tauri command or gRPC call carries a database identifier.
Proposed Solution
Stamp the active database id on every gRPC call, add a switcher UI backed by the new DatabaseService, and delete the dead restart flow. CLI gains database selection flags and subcommands.
Implementation Approach
CLI
- Global
--database <name|id>flag andNODESPACE_DATABASEenv var → setsx-ns-database-idmetadata on every RPC; absent → default database. nodespace database list|create|register|remove|rename|usesubcommands overDatabaseService.- Update
diagnostics(packages/cli/src/commands/diagnostics.rs) — it callsresolve_db_path()directly today; it must enumerate the registry instead. - Update the CLI SKILL.md for the new flags/subcommands (parity obligation with the local agent — see Align CLI + SKILL.md with local-agent capability and guidance (external-harness parity) #1529).
Desktop app
GrpcClient(src-tauri/src/grpc_client.rs) stampsx-ns-database-idfrom the frontend-supplied active database id on every call; single channel unchanged.- New
database.svelte.tsstore (Svelte 5 runes): registry list, active database id, status per database. Switching = set active id, flush and reload all data stores, resubscribe event streams filtered bydatabase_id. - Switcher UI in the app chrome showing the active database and a per-entry glyph (local-only / synced). File menu "New Database… / Open Database…" re-wired to
DatabaseService.Create/Registerwith a native folder picker for location. - Rewrite
settings/sections/database-settings.svelteas database management (list, rename, set default, remove). - Delete:
select_new_database,reset_database_to_default,restart_apprestart flow, and therestartPendingnotice (src-tauri/src/commands/settings.rs,app-shell.sveltehandler). - Frontend event listeners filter on
database_idfrom the stream envelope.
Acceptance Criteria
- User can create a second database from the UI and switch to it without any restart
- Switcher shows all registered databases with active + sync-state indication
- All data stores flush and reload on switch; no cross-database data bleed (test with distinct content per database)
-
nodespace --database <name>andNODESPACE_DATABASEroute CLI commands to the named database -
nodespace databasesubcommands work end-to-end - Dead restart flow and its commands are deleted
- CLI SKILL.md documents the new database selection surface
- Tests pass (bun run test:all)
- Code passes bun run quality:fix
Technical Specifications
Reference Files
- gRPC client:
packages/desktop-app/src-tauri/src/grpc_client.rs - Settings commands:
packages/desktop-app/src-tauri/src/commands/settings.rs - Menu wiring:
packages/desktop-app/src-tauri/src/lib.rs—menu-select-databaseevent - Settings pane:
packages/desktop-app/src/lib/components/settings/sections/database-settings.svelte - CLI diagnostics:
packages/cli/src/commands/diagnostics.rs
Implementation Details
- Follow the canonical runes store pattern (see the reactivity ADR and Unify the frontend store layer on Svelte 5 runes #1513 — coordinate to avoid refactoring the same stores twice).
- Backend event emits currently target
get_webview_window("main")— unchanged here; multi-window is out of scope. - Coordinate with Collapse the four-way hand-synced backend-adapter duplication #1500 (backend-adapter duplication) where the adapter layer is touched.
Dependencies
- Daemon database manager: registry, per-database services, and gRPC routing #1532 (daemon routing and DatabaseService)
Related Issues
- Unify the frontend store layer on Svelte 5 runes #1513
- Collapse the four-way hand-synced backend-adapter duplication #1500
- Align CLI + SKILL.md with local-agent capability and guidance (external-harness parity) #1529
Non-Goals
Multi-window support; per-database sync UI states beyond the local/synced glyph (sync lifecycle is a follow-on issue).
Activity
mstomar125 commentedon Jul 7, 2026
Not picked up today — hard-blocked by #1532.
The
DatabaseServiceproto, its generated CLI/desktop client stubs, the daemon database registry, and thex-ns-database-idrouting +database_idevent-envelope contract this ticket consumes do not exist until #1532 lands (the current daemon opens exactly one DB viaresolve_db_path()). Even after #1532, the surface is multi-day: a per-call metadata interceptor, a new Tauri command module + menu rewire, a Svelte runes store flushing ~7 data stores + event re-filtering, a settings pane, a CLIdatabasesubcommand, and tests across three runners. Ordered after #1532.mstomar125 commentedon Jul 9, 2026
CLI half is up as #1597 — client-side database selection: the
x-ns-database-idrouting interceptor, the global--database <name|id>/NODESPACE_DATABASEselector (name→id resolved client-side againstDatabaseService.List), thenodespace database list|create|register|remove|rename|usesubcommands, and adiagnosticsrewrite that enumerates the registry. SKILL.md documents the new surface; integration tests cover the registry round-trip, name→id resolution, ambiguity, and cross-database write isolation.Remaining for this issue (separate PRs, keeping #1533 open): the desktop half —
GrpcClientstamping the active database id, adatabase.svelte.tsstore, the switcher UI, File-menu Create/Register wiring, rewriting the Database settings pane as management, deleting the restart flow, and filtering frontend event listeners ondatabase_id.Add client-side multi-database selection to the CLI (ADR-053) (#1597)
mstomar125 commentedon Jul 9, 2026
Desktop half is up as #1598 — the sidebar-header database switcher: a
DatabaseIdInterceptorstampingx-ns-database-idon the routed clients +set_active_database(rebuilds only the routed clients, bumps a generationwatch), thedatabaseTauri commands, adatabase.svelte.tsstore (switch = flush → re-point → clear → reset → reload), thedatabase-switcher.sveltedropdown (active db + local/synced glyph, New…/Open…), adatabase-settings.sveltemanagement rewrite, anddatabase_idevent filtering. The watcher now rides the sharedGrpcClientand re-opensWatchNodeson switch.restart_app(orphaned) removed.With this + the CLI half (#1597), ADR-053 client selection is functional end to end. Known follow-on hardening: per-request database tagging to close the in-flight-read orphan window on a switch; and a manual GUI click-test on a build with two registered databases.
Add desktop database switcher and client-side routing (ADR-053) (#1598)
mstomar125 commentedon Jul 9, 2026
Resolved — client-side multi-database selection is functional end to end
Both halves are merged: the CLI (#1597) and the desktop app (#1598). Every acceptance criterion is met.
Acceptance criteria
create_database) and selecting an entry (set_active_database+ live re-point/reload); no restart. (Desktop: live database switcher + client-side routing (ADR-053) #1598)database-switcher.sveltelists all databases with a checkmark on the active one and a per-entry local/synced glyph. (Desktop: live database switcher + client-side routing (ADR-053) #1598)switchToflushes pending saves → re-points the routed clients → clears the shared node store / structure tree → resets the workspace → reloads; the watcher re-opensWatchNodesagainst the new database, and every frontend event listener drops events whosedatabase_id≠ the active database (guard). Reviewer confirmed the Rust switch/re-subscribe path is race-free. (Desktop: live database switcher + client-side routing (ADR-053) #1598)nodespace --database <name>andNODESPACE_DATABASEroute CLI commands — a global selector resolved to a registry id client-side and stamped asx-ns-database-id. (CLI: client-side multi-database selection (ADR-053) #1597)nodespace databasesubcommands —list|create|register|remove|rename|useoverDatabaseService. (CLI: client-side multi-database selection (ADR-053) #1597)select_new_database/reset_database_to_default(earlier ADR-053 cleanup) and the now-orphanedrestart_appare gone. (Remove vestigial active_database_path daemon setting (ADR-053) #1595/Desktop: live database switcher + client-side routing (ADR-053) #1598)bun run test:allpasses /bun run quality:fixclean — CLI 5 unit + 15 integration; desktopbun run test3966, svelte-check 0/0, workspace clippy-D warningsclean; CItest:all+test:e2egreen on both PRs.PRs
x-ns-database-idinterceptor,--database/NODESPACE_DATABASE,nodespace databasesubcommands, diagnostics registry rewrite.GrpcClientrouting +set_active_database,databaseTauri commands,database.svelte.tsstore,database-settings.sveltemanagement rewrite, watcher re-subscribe,database_idevent filtering.Follow-on (non-blocking, tracked separately)
Closing as complete. Non-goals (per this issue) remain follow-ons: per-database compute scoping (#1534), per-database cloud sync (#1535), tray/multi-window polish (#1536), registry-driven Pro UI (#1537).