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

Copy link
Copy Markdown
Contributor

No description provided.

CopilotAI 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
FileDescription
internal/ui/components/connection_dialog.goRender discovered targets using the new unified display helper.
internal/models/connection.goAdd Unix-socket detection and unified target formatting for display.
internal/db/discovery/unix_socket.goImplement Unix socket directory scanning and availability probing.
internal/db/discovery/unix_socket_test.goAdd tests for Unix socket discovery and config defaults.
internal/db/discovery/discovery.goInclude Unix socket scanning in overall discovery and improve sorting stability.
internal/db/discovery/config.goCentralize default connection config creation for discovered instances.
internal/app/delegates/connection.goImprove connection error target display via DisplayTarget().
internal/app/app.goUse centralized discovery config builder when connecting to discovered instances.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadinternal/db/discovery/unix_socket.go
Comment threadinternal/db/discovery/config.go Outdated
Comment threadinternal/db/discovery/unix_socket.go

CopilotAI 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 threadinternal/db/discovery/config.go
Comment threadinternal/db/discovery/unix_socket.go Outdated

CopilotAI 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 threadinternal/db/discovery/discovery.go Outdated
Comment threadinternal/db/discovery/unix_socket.go

CopilotAI 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 threadinternal/db/discovery/discovery.go
Comment threadinternal/db/discovery/unix_socket_test.go

CopilotAI 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 threadinternal/db/discovery/discovery.go
Comment threadinternal/db/discovery/config.go
Comment threadinternal/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.

CopilotAI 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 threadinternal/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 CopilotJuly 13, 2026 14:56

CopilotAI 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 threadinternal/db/discovery/unix_socket_test.go
Comment threadinternal/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.

CopilotAI 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.

@tianzhoutianzhou 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:mainJul 13, 2026
6 checks passed
@XYenon
XYenon deleted the feat/unix-socket-scan branch July 13, 2026 15:37
Sign up for freeto 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

@XYenon@tianzhou