Repository navigation
Description
Context
#1536's first slice put a Databases submenu in the daemon tray and made picking one open the app on it. Two behaviours were deliberately left out; both are visible to a user, so they are worth closing rather than leaving as folklore.
1. The submenu is rendered once, at daemon boot
controller.databases_changed(...) has exactly one call site — right after open_default_database. Nothing pushes again, so the submenu reflects the registry as it was when the daemon started: a database created, removed or renamed afterwards is wrong until the daemon restarts.
This is also why the label deliberately shows default · synced rather than open: spawn_idle_reaper closes idle databases and in-app switching opens others, so a "currently open" marker pushed once at boot would be confidently wrong within minutes of normal use. The marker is worth having — it just needs live refresh first.
Shape: push a fresh RegistrySnapshot on every registry mutation (DatabaseServiceImpl's create / register / set_default / rename / remove handlers) and on open/close/evict in DatabaseManager. Threading a TrayController into the manager is one option; a watch::Sender<RegistrySnapshot> on the manager with a single bridge task forwarding into the tray proxy is cleaner and would serve #2033 too. The tray side already handles repeat snapshots — rebuild_databases_menu is written for it and tolerates partial failure.
Once live, add the open marker back (there is a test pinning its current absence — update it).
2. Picking a database while the app is already running
open_ui returns early when the spawned child is still alive, so the click logs and does nothing. That is the common case — the tray is most often used while the app is open.
Worse, it is inconsistent: when the app was launched outside the tray there is no child to notice, so the same click spawns a second app process on the chosen database. There is no single-instance plugin in src-tauri, so nothing dedupes it.
Shape: needs cross-process focus (NSRunningApplication::activate and platform equivalents) plus a select signal to the running app so it can switch databases in place — the app already supports the switch itself (set_active_database / databaseStore.switchTo). Until then, consider marking the app's current database in the label so a no-op click reads as "already there".
Acceptance
- Creating/removing/renaming a database updates the tray submenu without a daemon restart
- Opening/closing (including idle eviction) updates it, and the
openmarker is restored - Picking a database while the app is running switches it in place and focuses the window
- Exactly one app instance regardless of how it was launched
-
bun run test:allgreen,bun run quality:fixclean
Follows up #1536.
Activity
mstomar125 commentedon Aug 12, 2026
First half landed in #2042 (merged). Leaving this open for the second.
Done — live refresh + the open marker:
openmarker is restoredDatabaseManagerpublishes a change signal on every registry/open-set mutation and the daemon forwards it to the tray for the process lifetime, replacing the two one-shot pushes. A counter rides the channel rather than the snapshot — building a snapshot takes the same locks the mutation holds, so publishing from inside one would invite a deadlock; observers re-read after waking, which also collapses bursts into a single refresh.That is what made the
openmarker safe to restore, exactly as you framed it: it was omitted because a boot-time push would be wrong within minutes, not because the marker was unwanted. Order is fixed (default · open · synced) since a reshuffling label reads as flicker under live updates.Still open — the cross-process half:
Untouched deliberately. Both need cross-process focus (
NSRunningApplication::activate+ platform equivalents) and a single-instance plugin, and neither can be exercised or verified from a headless session — the machine's GUI console belongs to another user here, so a native window has nowhere to render. This wants a desktop session.Worth noting the inconsistency you flagged is unchanged and still the sharper bug of the two: launched outside the tray, a click spawns a second app process on the chosen database, because nothing dedupes. The interim mitigation you suggested — marking the app's current database so a no-op click reads as "already there" — is now cheap to add, since the label is rebuilt live; it just needs the app to report which database it is on.
mstomar125 commentedon Aug 20, 2026
Closed via #2180 (merged 424dcba), completing the second half — the first half (live tray-submenu refresh, the
openmarker) landed earlier in #2042.What #2180 did
open_uino longer tracks whether a spawned UI process is still alive (it fundamentally can't do that reliably — a process launched outside the tray is invisible to it). Instead it always spawns a fresh UI process, and dedup is delegated to the app itself viatauri-plugin-single-instance, registered as the desktop app's first plugin:unminimize+show+set_focus— the cross-process equivalent ofNSRunningApplication::activateon every desktop platform Tauri targets), so even a plain "Open NodeSpace" click while already running now does something instead of silently no-op'ing.--database <id>, the CLI counterpart of the existingNODESPACE_INITIAL_DATABASEenv var — needed because an already-exited relaunch process's environment isn't visible to the running instance), the frontend switches to it via the samedatabaseStore.switchTopath an in-app switcher click already uses, and focuses the window.A follow-up adversarial review of the diff found three real issues, all fixed before merge: the tray-supplied database id is now validated against the registered list before
switchTocommits to it (mirroring a guardload()already applied to the same input); a relaunch landing in the narrow window before the frontend's event listener has registered now also falls back to a pull-based one-shot read so the switch isn't silently dropped; and a doc-comment correction — the single-instance plugin's macOS backend claims its lock with a non-atomic probe (unlike Windows/Linux), so the dedup guarantee there is very strong but not absolute.Real cross-process window focus wasn't interactively verified from this headless session (no GUI console) — the mechanism, IPC wiring, and every unit/integration test around it are verified, but the actual "does it visibly raise" behavior wants a real desktop session to confirm firsthand.
All five acceptance boxes checked off above.
bun run test:allandbun run quality:fixboth green.