Skip to content

feat: add unix socket discovery and connection support#6

Merged
tianzhou merged 11 commits into
pgplex:mainfrom
XYenon:feat/unix-socket-scan
Jul 13, 2026
Merged

feat: add unix socket discovery and connection support#6
tianzhou merged 11 commits into
pgplex:mainfrom
XYenon:feat/unix-socket-scan

Conversation

@XYenon

@XYenon XYenon commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/db/discovery/unix_socket.go
Comment thread internal/db/discovery/config.go Outdated
Comment thread internal/db/discovery/unix_socket.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread internal/db/discovery/config.go
Comment thread internal/db/discovery/unix_socket.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread internal/db/discovery/discovery.go Outdated
Comment thread internal/db/discovery/unix_socket.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread internal/db/discovery/discovery.go
Comment thread internal/db/discovery/unix_socket_test.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comment thread internal/db/discovery/discovery.go
Comment thread internal/db/discovery/config.go
Comment thread internal/models/connection.go Outdated
XYenon added 3 commits July 13, 2026 20:05
…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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comment thread internal/db/discovery/environment.go
Strip leading/trailing spaces from PGHOST/PGPORT/PGDATABASE/PGUSER/
PGSSLMODE so connection strings stay valid. Leave PGPASSWORD untrimmed.
@tianzhou tianzhou requested a review from Copilot July 13, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Comment thread internal/db/discovery/unix_socket_test.go
Comment thread internal/db/discovery/config.go
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

@tianzhou tianzhou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the contribution.

@tianzhou tianzhou merged commit 0534649 into pgplex:main Jul 13, 2026
6 checks passed
@XYenon XYenon deleted the feat/unix-socket-scan branch July 13, 2026 15:37
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.

3 participants