feat: add unix socket discovery and connection support#6
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Unix socket discovery to the database instance auto-discovery flow and standardizes how connection targets are displayed (including Unix socket targets), enabling users to discover/connect to local PostgreSQL instances that expose only a socket.
Changes:
- Added a Unix socket scanner that searches common socket directories and integrates results into overall discovery.
- Introduced
DisplayTarget()/UsesUnixSocket()helpers on connection/discovery models and updated UI/error rendering to use them. - Centralized “discovered instance → connection config” logic into a dedicated builder and updated connection flows to use it.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/ui/components/connection_dialog.go | Render discovered targets using the new unified display helper. |
| internal/models/connection.go | Add Unix-socket detection and unified target formatting for display. |
| internal/db/discovery/unix_socket.go | Implement Unix socket directory scanning and availability probing. |
| internal/db/discovery/unix_socket_test.go | Add tests for Unix socket discovery and config defaults. |
| internal/db/discovery/discovery.go | Include Unix socket scanning in overall discovery and improve sorting stability. |
| internal/db/discovery/config.go | Centralize default connection config creation for discovered instances. |
| internal/app/delegates/connection.go | Improve connection error target display via DisplayTarget(). |
| internal/app/app.go | Use centralized discovery config builder when connecting to discovered instances. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Amp-Thread-ID: https://ampcode.com/threads/T-019d41f5-fe46-7119-afb7-73548b6954ed Co-authored-by: Amp <amp@ampcode.com>
343528a to
e363a66
Compare
…words BuildConnectionConfig returned GetEnvironmentConfig() verbatim for the environment source, carrying Name="Environment" and the PGPASSWORD/ .pgpass password into the connection pipeline. - Clear Name on the env path so the connection ID and history entry fall back to ConnectionLabel() (e.g. user@host:port/db), matching the other discovered sources instead of producing duplicate "Environment" history entries and a fixed connection ID. - Clear Password on both the env and .pgpass paths. pgx still resolves the credential via libpq defaults (PGPASSWORD env, ~/.pgpass), so connections authenticate unchanged, but the password no longer gets persisted to the OS keyring on success.
Strip leading/trailing spaces from PGHOST/PGPORT/PGDATABASE/PGUSER/ PGSSLMODE so connection strings stay valid. Leave PGPASSWORD untrimmed.
Bound listenPostgresSocket Accept with a deadline and a select timeout so a missed dial cannot hang tests. Stop filling Password in buildPgPassConfig; libpq reads ~/.pgpass and we intentionally keep secrets out of the keyring.
tianzhou
approved these changes
Jul 13, 2026
tianzhou
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thanks for the contribution.
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.
No description provided.