fix: allow toggling databases on server-managed (DATABASE_URL) connections#16
Merged
Merged
Conversation
…tions Activating/deactivating an additional database on a server-managed connection (one seeded from DATABASE_URL, e.g. env-default) threw "Toggle failed: Connection not found: <id>". Such connections live only in the backend's in-memory app DB, never in the frontend's local storage. The backend already persists their active databases itself (ConnectionManager.activateDatabase). The frontend was additionally trying to persist the active-database list to local storage, which has no record for the connection and throws. Skip the local-storage write for serverManaged connections in both activate/deactivate paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NxZYcCWNSKYkMqT3KYdwTB
matej21
added a commit
that referenced
this pull request
Jun 26, 2026
…reloads (#17) After #16 removed the error when toggling extra databases on a server-managed (DATABASE_URL) connection, the toggle worked in-session but the databases vanished on page reload: each WebSocket gets a fresh in-memory app DB and the env connection is recreated from DATABASE_URL with no memory of what was activated. Remember the env connection's active databases in a process-scoped set, seed the connection config from it on session creation (so the fire-and-forget auto-connect reconnects them), and update it by wrapping the databases.activate/deactivate handlers — mirroring the existing connections.list wrap. Verified in a browser against a real Postgres: activate a second database, reload → it is still present; deactivate, reload → it is gone. Claude-Session: https://claude.ai/code/session_01NxZYcCWNSKYkMqT3KYdwTB Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opening Manage Databases… on a server-managed connection (one seeded from
DATABASE_URL, idenv-default) and toggling an additional database fails with:Root cause
Server-managed connections live only in the backend's in-memory app DB, never in the frontend's local storage (IndexedDB / desktop store). The backend already persists their active databases itself in
ConnectionManager.activateDatabase.The frontend store (
activateDatabase/deactivateDatabase) ran the backend RPC (which succeeds) and then additionally calledstorage.updateConnectionActiveDatabases(connectionId, …). Local storage has no record forenv-default, so it throwsConnection not found— which aborts the UI refresh and surfaces the toast, even though the backend activation worked.Fix
Skip the local-storage write for
serverManagedconnections in both the activate and deactivate paths. Non-managed connections are unchanged.Verification
bun run typecheck✅,biome lint✅DATABASE_URL-seeded connection: toggling a second database now succeeds (no toast, the database connects and appears in the tree); deactivation likewise.🤖 Generated with Claude Code
https://claude.ai/code/session_01NxZYcCWNSKYkMqT3KYdwTB