Repository navigation
Route the restored database at startup before mounting the workspace (closes #3058) - #3066
Conversation
…loses #3058) load() now awaits set_active_database for the restored selection before committing it, so a remembered or tray-picked non-default database is the gRPC routing target too, not only the window pin and switcher. When that database is not the daemon default, the sidebar stores' unrouted boot loads are evicted and reloaded via the helper switchTo now shares. The workspace panes mount only once a database is selected, so restored tabs never read from the default first. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Pragmatic Code Review: PR #3066Review Type: Initial review. The PR had no earlier reviews or comments. Requirements Check (#3058)Requirement: at startup, the restored database must also be the gRPC routing target, not only the window pin and the switcher.
Ran locally: Code Review Findings🟡 [Improvement] The tray-pick ordering the comment relies on is not guaranteed
Result: the UI shows a and routing points at b, which is the same split this issue fixes, and it lasts until a manual switch. The window is small. It needs a pending or live tray pick ( const seqAtStart = this.switchSeq; // read, never bump: must not abort an in-flight switchTo
...
if (this.activeDatabaseId !== null || this.switchSeq !== seqAtStart) return;
await invoke('set_active_database', { id: resolved });
if (this.activeDatabaseId !== null || this.switchSeq !== seqAtStart) return;Reading the counter keeps the deliberate choice not to abort a mid-flush 🟢 [Nit] A failed 🟢 [Nit / follow-up, pre-existing] The startup conflict nudge reads before routing is set 🟢 Positive notes
Recommendation: APPROVEThe change fixes #3058 correctly. The boot-time unrouted reads are handled well by the existing generation guards. The one 🟡 is a narrow reverse-order race with the tray pick and a comment that overstates the guarantee. It is a small fix (read |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
- load() now defers to a switchTo that is in flight or started since it began, so a tray pick that already sent set_active_database can no longer be re-pointed by load()'s later send. Adds the reverse-ordering test. - Skipped: empty state for a failed load() (switcher already shows the error; reconnect retries). Conflicts-store routing gap filed as #3067. Addresses reviewer recommendations from PR review. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Review addressed (a6e9f12)✅ 🟡 Tray-pick race (reverse ordering) — ⏭️ 🟢 Blank content area on failed ⏭️ 🟢 Startup conflicts notice counts default DB — pre-existing (switchTo never reloaded conflicts either), and Frontend: 5360 passed; pre-push gate passed. Re-Review DecisionNO RE-REVIEW NEEDED — the change is a small, test-covered guard implementing the reviewer's suggested approach; no other logic changed. |
Summary
databaseStore.load()now awaitsset_active_database(resolved)before committing the selection, so a remembered or tray-picked non-default database becomes the gRPC routing target (and node-event watch target), not only the window pin and switcher.switchTointoevictAndReloadActiveDatabase(); onlyswitchToresets tabs, so restored tabs survive a restart.app-shell.sveltemountsPaneManageronly onceactiveDatabaseIdis set, so restored tabs never read from the default database first.load()is routing wins (itsset_active_databaseis sent later, andload()re-checks the selection after the await).Pin and routing stay separate commands: pinning is per-window, routing is process-wide.
Tests
database.test.tscases: routing before commit, reload on non-default restore, no reload on default restore, tray pick during load wins.🤖 Generated with Claude Code