feat: fetch databases in connection dialog#6
Open
jonasnobile wants to merge 1 commit intomainfrom
Open
Conversation
67ee0e2 to
2acd750
Compare
5 tasks
5f02c6e to
75a9d38
Compare
Adds a "Fetch" button next to the Database field that connects with the entered credentials and replaces the input with a dropdown of databases on the server. The list is cleared whenever the user changes a field that would target a different server (type, host, port, user, password, SSL, SSH tunnel, URL paste) so a database picked from one server can't be silently saved against another. Backed by a new listDatabasesForConfig method on ConnectionManager that uses an ephemeral driver (mirroring testConnection) and falls back to a maintenance database when none is given. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
75a9d38 to
440728e
Compare
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.
Summary
Adds a Fetch button next to the Database field in the connection dialog that connects with the entered credentials, queries the server's catalog, and replaces the input with a dropdown to pick from. Saves users from having to know or type the database name when adding a new connection. Works for PostgreSQL and MySQL.
How it works
ConnectionManager.listDatabasesForConfig(config)creates an ephemeral driver (same pattern astestConnection), connects, runs a dialect-specific catalog query (pg_database/information_schema.schemata), then disconnects. SSH tunnels are set up and torn down too. When the user hasn't picked a database yet, falls back topostgres(PG) orinformation_schema(MySQL). Exposed as thedatabases.listForConfigRPC.ConnectionDialogowns the fetched-list state. The list is auto-cleared whenever the user changes a field that targets a different server — type, host, port, user, password, SSL mode, SSH tunnel, or a pasted URL. Prevents the case where a user fetches against server A, picks a database, edits the host to server B, and silently saves a config that mixes the two.Why "ephemeral" matters
The existing
databases.listRPC requires a saved + connectedconnectionId, which doesn't exist while the user is filling out the dialog. The new method follows the same ephemeral pattern astestConnectionso no state is registered in the connection manager — verified by a test (does not leak active drivers).Test plan
bun test tests/list-databases-for-config.test.ts— 7 integration tests against PG + MariaDB (docker-compose):template0/template1mysql/information_schema/performance_schema/syspostgres/information_schemawhen DB is emptybun test tests/connection-manager.test.ts— added SQLite-rejection testCI status
This branch is the feature commit only. CI's
format:check,lint, andtscwill fail on pre-existing-on-main issues (CLAUDE.md trailing newline, two biome warnings inindexeddb.ts/grid.ts, a literal-key access inquery-executor.ts, an unusedisLinuxinbackend-desktop/index.ts). Those are addressed by the companion PR #7 — merge it first, then rebase this one and CI will go green. The single line intests/connection-manager.test.tsthat overlaps between the two PRs is identical (both remove the same trailing blank line), so merge order doesn't matter for that file.Known follow-ups (not in this PR)
postgresfallback can fail on hardened installs that drop the default DB; error message will be opaque rather than actionable.validateConfigrequires non-empty password (pre-existing — same astestConnection); local trust auth would surface here too.connections.testdoes — same surface as before, but worth noting that the dialog now has two paths that transmit creds.🤖 Generated with Claude Code