Skip to content

fix: allow toggling databases on server-managed (DATABASE_URL) connections#16

Merged
matej21 merged 1 commit into
mainfrom
fix/server-managed-database-toggle
Jun 25, 2026
Merged

fix: allow toggling databases on server-managed (DATABASE_URL) connections#16
matej21 merged 1 commit into
mainfrom
fix/server-managed-database-toggle

Conversation

@matej21

@matej21 matej21 commented Jun 25, 2026

Copy link
Copy Markdown
Member

Problem

Opening Manage Databases… on a server-managed connection (one seeded from DATABASE_URL, id env-default) and toggling an additional database fails with:

Toggle failed: Connection not found: env-default

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 called storage.updateConnectionActiveDatabases(connectionId, …). Local storage has no record for env-default, so it throws Connection not found — which aborts the UI refresh and surfaces the toast, even though the backend activation worked.

Fix

Skip the local-storage write for serverManaged connections in both the activate and deactivate paths. Non-managed connections are unchanged.

Verification

  • bun run typecheck ✅, biome lint
  • Manual browser test against a real Postgres with a 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

…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 matej21 merged commit a34bacd into main Jun 25, 2026
2 checks passed
@matej21 matej21 deleted the fix/server-managed-database-toggle branch June 25, 2026 16:26
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant