Skip to content

feat(connections): connect through a Unix socket, locally or over the SSH tunnel (#1002) - #1250

Merged
debba merged 11 commits into
TabularisDB:mainfrom
markankamaransheogarat-sys:feat/unix-socket-connections
Nov 16, 2026
Merged

debba merged 11 commits into
TabularisDB:mainfrom
markankamaransheogarat-sys:feat/unix-socket-connections

Conversation

@markankamaransheogarat-sys

@markankamaransheogarat-sys markankamaransheogarat-sys commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1002. Based on the Unix socket design in #492 (@debba); supersedes #1246.

Adds a capability-gated Unix socket endpoint in place of Host and Port. MySQL/MariaDB dial the socket directly; PostgreSQL accepts a socket filename (including its port) or socket directory. Local socket connections disable database TLS, bypass database-scope TCP proxies and reject AWS IAM authentication. The PostgreSQL TLS connector handles sockets without empty-hostname validation while retaining the existing validation for TCP connections.

SSH forwards to the socket on the SSH server through system OpenSSH or russh streamlocal forwarding, including a proxied bastion. K8s and AWS SSM remain TCP-only and clear the socket path. Windows hides/rejects local Unix sockets but can reach a remote socket through SSH.

Plugin drivers opt in with the unix_socket capability; unsupported drivers do not get the endpoint selector. The connection types, capability schemas and plugin guide are updated together. Labels and hints cover all 13 locales. Connection labels and pool keys distinguish socket endpoints, and MySQL URLs can import ?socket=.

The branch is integrated with current main, preserving provider metadata/credential bindings in the connection modal. A CI race in the existing trigger-editor test is corrected by waiting for its mocked Monaco onMount before editing/saving its buffer. Delaying that callback reproduced the original failure; the corrected synchronization passes without an artificial delay in the committed test.

Validation on 2595d1e:

  • Complete frontend suite: 606 files, 9,610 tests passed.
  • Complete desktop-free Rust library suite: 2,703 passed, 18 ignored, including TLS, SSH and tunnel regressions.
  • PostgreSQL 16 live Unix socket regression: Test Connection, pool checkout/query and startup-script preflight pass.
  • Frontend lint, typecheck/production build and regenerated plugin guest artifacts pass.
  • All 4 integrated Chromium UI checks pass: environment saving, provider setup/workspace and Vim notebooks.

Remote SSH-to-socket behavior was not repeated in the native desktop UI. Merge remains conditional on green CI for this head.

* @param params - Connection parameters (any object carrying the three fields)
* @returns The trimmed socket path, or null when none applies
*/
/**

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.

WARNING: hasUnixSockets was inserted between the effectiveLocalSocketPath JSDoc and its function

The doc block above (lines 181-188, "The local Unix socket path in effect for a connection...") now sits directly before the hasUnixSockets JSDoc, so effectiveLocalSocketPath (below hasUnixSockets) has no documentation and an orphaned doc block precedes an unrelated function. Move hasUnixSockets (with its JSDoc) above the effectiveLocalSocketPath doc block, or below effectiveLocalSocketPath.

Comment thread src/utils/connections.ts Outdated

const socketPath = effectiveLocalSocketPath(params);
if (socketPath) {
return `${socketPath}/${params.database}`;

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.

SUGGESTION: Socket display string reads as a filesystem path

${socketPath}/${params.database} produces e.g. /tmp/mysql.sock/mydb, which looks like a path inside the socket file. connectionSubtitle uses socketPath · db for the same case. Consider a distinct, unambiguous format (e.g. socket:/tmp/mysql.sock/mydb) so the label is not mistaken for a path and stays consistent with the pool key's socket:<path> convention.

Comment thread src/utils/connectionStringParser.ts Outdated
// `mysql://root@localhost/db?socket=/tmp/mysql.sock`: the socket replaces
// host:port (the host is kept so the form can switch back).
const unix_socket_path =
resolved.id === 'mysql' ? url.searchParams.get('socket')?.trim() || undefined : undefined;

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.

SUGGESTION: ?socket= import is hardcoded to the driver id mysql

resolved.id === 'mysql' ignores ?socket= for any other MySQL-dialect or unix_socket-capable driver that owns the mysql/mariadb scheme (e.g. a MariaDB plugin), even though the rest of the PR gates the feature on the unix_socket capability. .rules/plugins.md asks for capabilities over driver ids; consider checking the driver's unix_socket capability / sql_dialect === 'mysql' here (the modal already does this at importingMysql).

connection_uri_in_keychain: false,
// `?socket=` switches the form to the socket endpoint; a string
// without it goes back to host and port.
unix_socket_path: parsed.unix_socket_path,

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.

WARNING: Imported ?socket= can be saved while the socket UI is hidden (Windows)

On Windows hasUnixSockets() is false, so canUseSocket/socketMode are false (unless SSH is on) and the host/port inputs are shown, but this line still writes the imported unix_socket_path into formData. It is then persisted and sent to the backend, where local_unix_socket_path() is set and build_mysql_options returns "Unix socket connections are not supported on Windows" - with no visible field the user can edit to fix it, and host/port are silently ignored. Drop the parsed socket when !hasUnixSockets() (and no SSH), or clear unix_socket_path when the socket endpoint is not selectable.

Comment thread src/i18n/locales/en.json Outdated
"socketPathForwardActive": "The SSH server connects to this socket instead of Host and Port. A database on a socket cannot negotiate TLS, so it is turned off; the SSH tunnel still encrypts the whole path.",
"socketPathNotAbsolute": "Enter an absolute path, as it appears on the machine that connects to the socket.",
"socketPathDirectory": "Point at the socket file itself, not the directory holding it.",
"socketPathTunnel": "Not used while a Kubernetes tunnel is enabled.",

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.

SUGGESTION: newConnection.socketPathTunnel is never used

The key is added to all 11 locales but nothing in src/ references it (the endpoint selector is hidden while K8s is enabled, so the message is never rendered). Either render it where the socket is ignored or drop the key from every locale.

@kilo-code-bot

kilo-code-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No New Issues Found | Recommendation: Merge

Files Reviewed (incremental changes since the last review)
  • plugins/tabularium-extensions.schema.json

Notes:

  • The only PR-authored change since the last review is commit 82509c4, which removes a stray }, between the unix_socket and no_connection_required entries in plugins/tabularium-extensions.schema.json. The surrounding object is well-formed now.
  • The rest of the incremental diff comes from merging main into the branch, not from this PR, so I did not review it.
  • No earlier findings are still open.

No code was run (read-only mode).

Previous Review Summaries (14 snapshots, latest commit 8ecc080)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8ecc080)

Status: No New Issues Found | Recommendation: Merge

Files Reviewed (incremental changes since the last review)
  • plugins/tabularium-extensions.schema.json

Notes:

  • Schema fix: The only change since the last review removes a stray }, between the unix_socket and no_connection_required capability entries. The leftover brace made the schema invalid JSON. The surrounding object is now well-formed.
  • Earlier findings: The earlier inline comments are all outdated (their lines no longer map to the current diff), so none are carried forward.

No code was run (read-only mode).

Previous review (commit 5ed11f7)

Status: No New Issues Found | Recommendation: Merge

Files Reviewed (incremental changes since the last review)
  • packages/web-ui/src/utils/connections.ts
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx
  • src-tauri/src/pool_manager.rs
  • src-tauri/src/pool_manager_tests.rs
  • src-tauri/tests/integration_tests.rs

Notes:

  • Socket eligibility: isSocketEligible consolidates three duplicated copies of the socket-eligibility logic (render path, database discovery, connection-string import) into one helper. It keeps the same rules: no URI passthrough, no K8s/SSM tunnel, and either SSH or a local driver unix_socket capability on a platform with Unix sockets. The import path and the database-list path now use the merged form plus overrides, so an explicit unix_socket_path reset is honoured.
  • Postgres TLS: PostgresTlsConnector substitutes "localhost" only for an empty hostname, which tokio_postgres passes for Unix-socket connections before it takes the SSL-disabled branch. Real hostnames pass through unchanged, so TCP chain and hostname validation is preserved. The unit tests cover both the empty-hostname case and rejection of an invalid DNS name.
  • Live regression test: test_postgres_unix_socket_live_regression is #[ignore], #[cfg(unix)] and skips when no socket is found.
  • Earlier comments: The earlier hasUnixSockets / effectiveLocalSocketPath JSDoc ordering comment no longer applies. In current code each function sits directly under its own doc block.

No code was run (read-only mode).

Previous review (commit 2074474)

Status: No New Issues Found | Recommendation: Merge

Files Reviewed (1 file in the incremental diff)
  • src-tauri/tests/integration_tests.rs

Notes: The incremental diff since the last review adds only test_postgres_unix_socket_live_regression, an #[ignore], #[cfg(unix)] live regression test. It covers test_connection, pool checkout and query, and a startup-script pool over a Unix socket.

  • API use: The test uses the existing public APIs PostgresDriver::test_connection, get_postgres_pool_with_id and close_pool_with_id.
  • Socket path: It passes the .s.PGSQL.<port> socket file path, which matches what pool_manager.rs expects.
  • Cleanup: Both pools are closed at the end of the test.
  • Skip behaviour: The test skips with a message when no socket is found.

Earlier inline comments on this PR (from previous commits) remain in the review threads; they are not re-listed here.

No code was run (read-only mode).

Previous review (commit 92b9ddb)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files in the incremental diff)
  • src-tauri/src/pool_manager.rs
  • src-tauri/src/pool_manager_tests.rs

Notes: The incremental diff since the last review adds PostgresTlsConnector, a wrapper around MakeRustlsConnect. It substitutes "localhost" only when tokio_postgres passes an empty hostname, which happens for Unix socket connections, so TLS connector construction no longer fails with InvalidDnsNameError.

  • TCP behaviour: Real hostnames pass through unchanged, so certificate and hostname verification is preserved.
  • Call sites: build_postgres_tls_connector returns the new type, and run_postgres_startup_script, the pool manager and test_connection still compile against it because it derives Clone and implements MakeTlsConnect.
  • Tests: New tests cover the empty hostname, a valid hostname and an invalid DNS name.

No code was run (read-only mode).

Previous review (commit 1c55fa8)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files in the incremental diff)
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx
  • packages/web-ui/src/utils/connections.ts
  • packages/web-ui/tests/components/modals/NewConnectionModal.test.tsx
  • packages/web-ui/tests/utils/connections.test.ts

Notes: The branch was rebased onto a newer main, so the diff against the previously reviewed commit includes unrelated changes from main. This review covered only the PR's own commits, mainly a41aa3b0 and 1c55fa89.

  • Shared helper: isSocketEligible now backs canUseSocket, loadDatabases and the connection-string import path. It keeps the earlier behaviour: URI-passthrough drivers and K8s or SSM tunnels exclude sockets, while SSH or a driver unix_socket capability on a Unix platform allows them.
  • Import path: The import check now also allows a socket path when SSH is enabled even if the driver lacks the unix_socket capability. That matches canUseSocket, so the imported path stays visible and editable in the form.
  • Database discovery: loadDatabases merges formData and overrides before the eligibility check. An explicit unix_socket_path: undefined override from an import therefore clears a stale socket path.
  • Tests: The helper has unit tests, and a modal test covers an import that switches back to host and port.

No code was run (read-only mode).

Previous review (commit 129bd1d)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files in the incremental diff)
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx
  • packages/web-ui/src/utils/connections.ts
  • packages/web-ui/tests/components/modals/NewConnectionModal.test.tsx
  • packages/web-ui/tests/utils/connections.test.ts

Notes: The incremental diff since 989c8bde extracts the duplicated socket-eligibility logic into a shared isSocketEligible helper. The helper is used by canUseSocket, loadDatabases and the connection-string import path. It matches the previous inline conditions: URI passthrough, K8s and SSM exclude sockets, and SSH or a driver unix_socket capability on a Unix platform allow them. The helper has unit tests, and a new modal test covers an import that switches back to host/port and drops the socket path. The removed Array.isArray guard in loadDatabases is covered by the surrounding try/catch. No code was run (read-only mode).

Previous review (commit 989c8bd)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files in the incremental diff)
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx
  • packages/web-ui/tests/components/modals/NewConnectionModal.test.tsx

Notes: The incremental diff since 402d058e makes loadDatabases drop a hidden unix_socket_path when socket mode is inactive. Socket mode is computed from the effective driver, overrides, SSH, K8s and SSM state, matching canUseSocket/socketMode. It also guards a non-array list_databases result. New tests cover the hidden-socket, edit-time discovery and SSH-tunnel cases. The earlier AWS SSM fix remains intact. No code was run (read-only mode).

Previous review (commit 402d058)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files in the incremental diff)
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx
  • packages/web-ui/tests/components/modals/NewConnectionModal.test.tsx

Notes: The incremental diff since 28703076 only re-wraps two lines (the tunnelEnabled expression and a test expect). It has no behavioral change, and the earlier AWS SSM fix remains intact. No code was run (read-only mode).

Previous review (commit 2870307)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files in the incremental diff)
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx
  • packages/web-ui/src/utils/connections.ts
  • packages/web-ui/tests/components/modals/NewConnectionModal.test.tsx
  • packages/web-ui/tests/utils/connections.test.ts

Notes: The incremental diff since 2e783153 fixes the earlier AWS SSM finding. ssm_enabled now counts as a tunnel in tunnelEnabled, canUseSocket, effectiveLocalSocketPath, validateConnectionParams and the ?socket= import guard. New tests cover each of these paths. The earlier JSDoc ordering finding in connections.ts was already fixed. No code was run (read-only mode).

Previous review (commit 2e78315)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/web-ui/src/components/modals/NewConnectionModal.tsx 653 tunnelEnabled / canUseSocket ignore ssm_enabled: with AWS SSM on, the socket UI and "uses this socket" hint stay active and unix_socket_path is saved, but resolve_ssm_params clears it and forwards to the hidden host:port
Files Reviewed (35 files)
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx - 1 issue
  • packages/web-ui/src/utils/connections.ts, connectionStringParser.ts, credentials.ts, contexts/DatabaseContext.ts, types/plugins.ts
  • packages/web-ui/src/i18n/locales/*.json (11 files)
  • packages/web-ui/tests/** (modal, parser, connections tests)
  • plugins/PLUGIN_GUIDE.md, plugins/manifest.schema.json, plugins/tabularium-extensions.schema.json
  • src-tauri/src/application/tunnels.rs, tunnels_tests.rs
  • src-tauri/src/ssh_tunnel.rs, pool_manager.rs, pool_manager_tests.rs, models.rs
  • src-tauri/src/drivers/{driver_trait.rs,mysql/mod.rs,postgres/mod.rs,sqlite/mod.rs}, plugins/driver.rs
  • src-tauri/tests/postgres_integration/parity.rs

Notes: The only commit since the last review (2e783153) is a CI trigger with no content change, so the previous findings were re-verified against current code. The SSM finding is still present and already has an active inline comment. The earlier JSDoc ordering finding in connections.ts is fixed. No code was run (read-only mode).

Fix these issues in Kilo Cloud

Previous review (commit 4b92aed)

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/web-ui/src/components/modals/NewConnectionModal.tsx 653 tunnelEnabled / canUseSocket ignore ssm_enabled: with AWS SSM on, the socket UI and "uses this socket" hint stay active and unix_socket_path is saved, but resolve_ssm_params clears it and forwards to the hidden host:port
Files Reviewed (35 files)
  • packages/web-ui/src/components/modals/NewConnectionModal.tsx - 1 issue
  • packages/web-ui/src/utils/connections.ts, connectionStringParser.ts, credentials.ts, contexts/DatabaseContext.ts, types/plugins.ts
  • packages/web-ui/src/i18n/locales/*.json (11 files)
  • packages/web-ui/tests/** (modal, parser, connections tests)
  • plugins/PLUGIN_GUIDE.md, plugins/manifest.schema.json, plugins/tabularium-extensions.schema.json
  • src-tauri/src/application/tunnels.rs, tunnels_tests.rs
  • src-tauri/src/ssh_tunnel.rs, pool_manager.rs, pool_manager_tests.rs, models.rs
  • src-tauri/src/drivers/{driver_trait.rs,mysql/mod.rs,postgres/mod.rs,sqlite/mod.rs}, plugins/driver.rs
  • src-tauri/tests/postgres_integration/parity.rs

Notes: The PR was rebased onto a newer main, so this is a full review of the current diff. The earlier JSDoc, ?socket= capability, socketPathTunnel and socket display-string findings are resolved in the current code. The unix_socket capability is now in the manifest schemas and plugin guide, and the hidden-path case is handled by the socketMode guard on save and test. No code was run (read-only mode).

Fix these issues in Kilo Cloud

Previous review (commit 8aadc33)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (16 files in this increment)
  • src/components/modals/NewConnectionModal.tsx - imported ?socket= is now only applied when the socket field is available
  • src/utils/connectionStringParser.ts - ?socket= import now follows the unix_socket capability instead of the mysql id
  • src/utils/connections.ts - JSDoc restored to effectiveLocalSocketPath; socket display string is now path (db)
  • src/i18n/locales/*.json (11 files) - unused newConnection.socketPathTunnel removed
  • tests/utils/connectionStringParser.test.ts, tests/utils/connections.test.ts - updated and extended for the changes above

Notes: The latest commit resolves all five earlier findings, and the changed code raises no new issues. No code was run (read-only mode).

Previous review (commit 96af7ee)

Status: 5 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
src/utils/connections.ts 189 hasUnixSockets was inserted between the effectiveLocalSocketPath JSDoc and its function, leaving that function undocumented and an orphaned doc block before an unrelated one
src/components/modals/NewConnectionModal.tsx 2587 An imported ?socket= is written to the form even where the socket UI is hidden (Windows without SSH). It is saved and the backend then rejects it, with no visible field to fix

SUGGESTION

File Line Issue
src/utils/connections.ts 232 formatConnectionString renders a socket as /path/to.sock/db, which reads like a path inside the socket file
src/utils/connectionStringParser.ts 380 ?socket= import is gated on the hardcoded id mysql, not on the unix_socket capability or MySQL dialect
src/i18n/locales/en.json 1312 newConnection.socketPathTunnel is added to all locales but never used
Files Reviewed (1 file in this increment)
  • src/components/modals/NewConnectionModal.tsx - 1 issue (carried forward)

Notes: The latest commit only swaps text-amber-500 for the text-accent-warning token on the socket path hints and raises no new issues. The four earlier findings in unchanged files were re-checked against current code and are still present. No code was run (read-only mode).

Fix these issues in Kilo Cloud

Previous review (commit 5f47447)

Status: 5 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
src/utils/connections.ts 189 hasUnixSockets was inserted between the effectiveLocalSocketPath JSDoc and its function, leaving that function undocumented and an orphaned doc block before an unrelated one
src/components/modals/NewConnectionModal.tsx 2587 An imported ?socket= is written to the form even where the socket UI is hidden (Windows without SSH). It is saved and the backend then rejects it, with no visible field to fix

SUGGESTION

File Line Issue
src/utils/connections.ts 232 formatConnectionString renders a socket as /path/to.sock/db, which reads like a path inside the socket file
src/utils/connectionStringParser.ts 380 ?socket= import is gated on the hardcoded id mysql, not on the unix_socket capability or MySQL dialect
src/i18n/locales/en.json 1312 newConnection.socketPathTunnel is added to all locales but never used
Files Reviewed (33 files)
  • src-tauri/src/commands.rs
  • src-tauri/src/drivers/driver_trait.rs
  • src-tauri/src/drivers/mysql/mod.rs
  • src-tauri/src/drivers/postgres/mod.rs
  • src-tauri/src/drivers/sqlite/mod.rs
  • src-tauri/src/models.rs
  • src-tauri/src/plugins/driver.rs
  • src-tauri/src/pool_manager.rs
  • src-tauri/src/pool_manager_tests.rs
  • src-tauri/src/ssh_tunnel.rs
  • src-tauri/tests/postgres_integration/parity.rs
  • src/components/modals/NewConnectionModal.tsx - 1 issue
  • src/contexts/DatabaseContext.ts
  • src/i18n/locales/*.json (11 locales) - 1 issue
  • src/types/plugins.ts
  • src/utils/connectionStringParser.ts - 1 issue
  • src/utils/connections.ts - 2 issues
  • src/utils/credentials.ts
  • tests/components/modals/NewConnectionModal.test.tsx
  • tests/utils/connectionStringParser.test.ts
  • tests/utils/connections.test.ts

Notes: Rust changes were reviewed by reading only; no tests were run (read-only mode). SSH, K8s and SSM tunnels clear the socket path before the drivers see it, and the pool key and driver options use local_unix_socket_path() consistently.

Fix these issues in Kilo Cloud


Reviewed by claude-sonnet-5.5 · Input: 256 · Output: 1.2K · Cached: 290.8K

Review guidance: REVIEW.md from base branch main

@markankamaransheogarat-sys markankamaransheogarat-sys changed the title feat(connections): Unix socket support, locally and through the SSH tunnel (#1002) feat(connections): connect through a Unix socket, locally or over the SSH tunnel (#1002) Oct 21, 2026

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for porting #492 and bringing it up to date, and for crediting it properly! params_through_tunnel is the part I like best: it clears unix_socket_path so the driver can't bypass the tunnel's local port, and it turns DB TLS off only when the forward goes to a socket. Keeping socket and TCP endpoints apart in both the tunnel and the pool keys, with tests, is exactly right.

A few things need fixing:

Plugin contract. The new unix_socket capability isn't in plugins/manifest.schema.json or PLUGIN_GUIDE.md. The schema's capabilities object has additionalProperties: false, so a plugin that opts in through its manifest, as the description says, would fail schema validation. Please also document what plugin drivers receive in unix_socket_path (see .rules/plugins.md).

A hidden socket path still gets sent. socketMode is canUseSocket && unix_socket_path !== undefined, but the test and save builders spread the whole formData. On Windows: enable SSH, pick Socket Path, then disable SSH. The field disappears and Host/Port come back, but the path is still saved, and the backend refuses it with "Unix socket connections are not supported on Windows". validateConnectionParams also stops asking for a host. On Linux, doing the same with a driver that lacks the capability leaves a stale path that skips the DB-scope proxy and changes the pool key. Dropping unix_socket_path whenever !socketMode fixes it.

Rebase. #676 moved things around. resolve_connection_transport, resolve_ssh_params, resolve_ssm_params and resolve_k8s_params now live in src-tauri/src/application/tunnels.rs, so ssh_forward_destination, params_through_tunnel and the socket short-circuit go there, with their tests in application/tunnels_tests.rs. Other changes:

  • The two expand_k8s_connection_params hunks can be dropped, because main's version already delegates to resolve_expanded_connection_params.
  • new_with_tcp_override is now new_with_askpass(...), so SshForwardDestination has to go through that signature.
  • Main's resolve_ssh_params has no is_alive check, so the tunnel reuse hunk doesn't apply as is.
  • The frontend moves to packages/web-ui/src. NewConnectionModal changed quite a bit, so that one needs a manual merge.

The good news is that once the logic is in application/, the web RPC gets socket support for free.

Smaller things:

  • SSM isn't taken into account on the frontend: with SSM on, the UI says the socket is used, but the backend clears it.
  • Postgres directory paths work locally but not over SSH, because streamlocal needs the socket file. unixSocketPathIssue only warns on a trailing /, so /var/run/postgresql passes the check and then fails at the SSH channel.
  • The description says the Windows tests run in CI, but unit tests only run on ubuntu-24.04, so the #[cfg(windows)] test never runs.
  • connections.ts has a capabilities == null && (driver === 'mysql' || driver === 'postgres') fallback, which goes against rule 2 in .rules/plugins.md.
  • Over an SSH-forwarded socket, ssl_mode is forced to disable and then the cleartext auth check refuses the connection, while a local socket is exempt. Rare, but inconsistent.
  • In tabularis web, hasUnixSockets() reads the browser's navigator.platform, but the server is the one dialing the socket.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

Addressed all feedback and rebased on latest main:

  • Application layer rebase: Routed SSH/SSM/K8s tunnel and Unix socket logic through src-tauri/src/application/tunnels.rs and added unit test coverage in tunnels_tests.rs.
  • Plugin contract: Added the unix_socket capability flag to plugins/manifest.schema.json, plugins/tabularium-extensions.schema.json, and documented driver behavior in plugins/PLUGIN_GUIDE.md.
  • Form state sanitization: When !socketMode (e.g. disabling SSH on Windows where local sockets are unavailable, or toggling away from socket mode), unix_socket_path is explicitly omitted from saved/tested parameters so stale paths do not fail validation or bypass routing.
  • Frontend migration: Fully merged and verified under packages/web-ui. All unit tests (connections.test.ts, connectionStringParser.test.ts, NewConnectionModal.test.tsx) pass (242 tests), pnpm build (tsc -b && vite build) green, and cargo check clean.

const supportsUnixSocket = activeDriver?.capabilities?.unix_socket === true && hasUnixSockets();
const tunnelEnabled = !!formData.ssh_enabled || !!formData.k8s_enabled;
const socketPathSet = !!formData.unix_socket_path?.trim();
const canUseSocket =

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.

WARNING: Socket UI stays active while AWS SSM is enabled, but the backend discards the socket

tunnelEnabled (line 651) and canUseSocket only account for SSH and K8s, not ssm_enabled. With SSM on, the endpoint selector and Socket Path field stay visible, usesLocalSocket is true (so the hint says "The connection uses this socket instead of Host and Port"), and socketMode keeps unix_socket_path in the saved/tested params. resolve_ssm_params then sets unix_socket_path = None and forwards to host:port, which is hidden in socket mode and so unset (it falls back to localhost:DEFAULT_REMOTE_PORT). The user is told one thing and the connection does something else. Treat SSM like K8s here: exclude ssm_enabled from canUseSocket and include it in tunnelEnabled, so the path is dropped by the socketMode guard when SSM is on.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

Addressed the SSM tunnel edge case flagged by @kilo-code-bot and @debba:

  • UI consistency (NewConnectionModal.tsx): AWS SSM tunnels (like K8s) only support TCP forwarding, and resolve_ssm_params sets unix_socket_path = None. Updated tunnelEnabled to include ssm_enabled, and canUseSocket / socketFieldAvailable to require !formData.ssm_enabled. When SSM is active, the socket endpoint selector and "uses this socket" hints are hidden and socketMode is disabled so stale paths are omitted on save/test.
  • Utils & Validation (connections.ts): effectiveLocalSocketPath now returns null when ssm_enabled is active, and validateConnectionParams requires a host.
  • Tests: Added unit test coverage in connections.test.ts and NewConnectionModal.test.tsx verifying that enabling AWS SSM suppresses the socket selector and enforces host requirement.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

@debba All requested points have been fully addressed:

  1. Rebase & Application Layer: Routed through src-tauri/src/application/tunnels.rs and cleanly rebased on main.
  2. Plugin Contract: Added unix_socket capability to manifest.schema.json, tabularium-extensions.schema.json, and documented driver expectations in PLUGIN_GUIDE.md.
  3. Form Sanitization & SSM: Stale unix_socket_path is explicitly omitted whenever !socketMode. Handled AWS SSM tunnels (disabling socket mode, hiding hints, requiring host).
  4. CI & Reviews:
    • Prettier & ESLint formatting clean.
    • All 14 CI checks passing green (test, test-postgres, test-mysql 8.4/5.7, web-e2e).
    • @kilo-code-bot re-review concluded with: "No Issues Found | Recommendation: Merge".

Ready for your final review and approval!

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for working through the rebase and the SSM case. The socket transport now sits in application/tunnels.rs, the plugin schemas and guide include unix_socket, and Test/Save omit the path when socket mode is unavailable. The SSM selector change is in place too.

One part of the hidden-path fix is still missing: loadDatabases in packages/web-ui/src/components/modals/NewConnectionModal.tsx spreads formData and overrides without applying the socket-mode check used by Test/Save.

I reproduced it with the real modal using the existing test harness: an edited connection has unix_socket_path: '/tmp/old.sock' and a driver without the local socket capability. The UI shows Host/Port and no socket selector, but clicking Load databases still sends /tmp/old.sock to list_databases. My added check expecting the path to be omitted fails. This also leaves the Windows flow from my previous review broken for database discovery, and on Unix the backend can dial the hidden socket instead of the host shown in the form.

Please sanitize the discovery parameters too, including the edit-time overrides path, and add a regression test that captures the list_databases request while the socket field is hidden. Keep the valid SSH-forwarded socket case working.

The existing 244 targeted frontend tests, typecheck, build, ESLint, Prettier, frontend boundary/inventory checks and the desktop-free cargo check pass. The failure above is an uncovered case, not a CI failure. Requesting changes until it is fixed.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

Addressed the discovery sanitization feedback:

  • loadDatabases in NewConnectionModal now evaluates socket eligibility across both form state and overrides, omitting/stripping unix_socket_path when local socket support or SSH tunneling is inactive.
  • Handled array safety when updating database selection state from list_databases.
  • Added unit regression tests capturing that unix_socket_path is omitted from list_databases during both manual load and edit-time initial discovery when socket mode is disabled, while preserving it when SSH forwarding is active.

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the quick turnaround on discovery. loadDatabases now works out socket eligibility from both the form and the edit-time overrides, and the two new tests are the right ones. I put the previous version of the modal back and both "omits hidden unix_socket_path" tests failed, then passed again with your change. The SSH-forwarded case also still sends the path, as it should.

There's one regression in the new code that I need fixed before merging. In loadDatabases, the path is picked with overrides?.unix_socket_path !== undefined ? overrides.unix_socket_path : formData.unix_socket_path. The connection string import calls loadDatabases(parsedFields) with unix_socket_path: undefined on purpose when the string has no ?socket=, because that's how it switches the form back to host and port. With the new check, that explicit undefined falls back to the old formData value.

I reproduced it in the modal test harness: edit a MySQL connection with SSH on and /var/run/mysqld/mysqld.sock, then paste mysql://root:pw@db2.example.com:3306/shop. The form shows db2.example.com, but list_databases still gets unix_socket_path: '/var/run/mysqld/mysqld.sock', so discovery goes to the old socket. Before this commit the plain spread let the undefined win and nothing was sent. The same applies to a local socket on Linux and macOS, since the built-in MySQL driver has the unix_socket capability.

The simplest fix is to build the merged object first ({...formData, ...overrides}) and work out eligibility and the path from that, so an explicit key in overrides keeps winning like it did before. Checking 'unix_socket_path' in overrides also works. Please add a regression test for the import case: start in socket mode, paste a string without ?socket=, and assert that the captured list_databases params have no unix_socket_path.

A few smaller things while you're in there:

  1. The eligibility rules are now copied in three places in NewConnectionModal.tsx: canUseSocket, loadDatabases and socketFieldAvailable in the import handler. A small pure helper in utils/connections.ts taking the capabilities and the SSH/K8s/SSM flags, with its own unit tests, would keep them from drifting. This bug is a good example of why.
  2. In loadDatabases, unix_socket_path is set to undefined, deleted from listParamsBase, and then deleted again from listParams, which can't contain it anymore. One of those is enough.
  3. list_databases is typed as string[] in the API contract, so the Array.isArray fallback isn't needed. If it ever did trigger, the picker would quietly come up empty instead of showing an error. I'd drop it.

Everything else checks out on my side: the targeted frontend tests (247), build, ESLint, Prettier, the tunnels and pool_manager Rust tests and the desktop-free cargo check all pass, and CI is green. Once the import case is fixed and covered, I'll do a manual pass and we can merge.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

Thanks for catching the import regression!

Addressed all points in commit 129bd1d:

  1. Merged overrides in loadDatabases: built the merged connection parameters object ({ ...formData, ...overrides }) so that explicit unix_socket_path: undefined passed during connection string import reliably overrides the stale form socket path, switching back to host and port discovery.
  2. Dedicated isSocketEligible helper: extracted the pure eligibility logic to packages/web-ui/src/utils/connections.ts (isSocketEligible), handling driver capabilities (unix_socket, connection_uri), tunnel state (ssh_enabled, k8s_enabled, ssm_enabled), and OS platform Unix socket support. Replaced duplicated checks in canUseSocket, loadDatabases, and socketFieldAvailable. Added 8 unit tests covering all permutations in packages/web-ui/tests/utils/connections.test.ts.
  3. Redundant deletion & API type cleanup: removed the duplicate delete listParams.unix_socket_path in loadDatabases and dropped the unneeded Array.isArray fallback for list_databases.
  4. Regression test: added an import test in packages/web-ui/tests/components/modals/NewConnectionModal.test.tsx verifying that importing a connection string without ?socket= over an active socket form switches discovery back to host/port and omits unix_socket_path from list_databases.

All 187 targeted tests, TypeScript typecheck, Vite build, Prettier, ESLint, web boundaries, and API inventory checks pass cleanly.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

@debba Rebased onto current main now that #1342 removed the web UI API inventory, so the stale inventory failure in test is gone and all checks are green again. The connection string import fix is unchanged: an explicit unix_socket_path: undefined from the import now overrides the stale form value, and discovery switches back to host and port.

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing the import reset and pulling socket eligibility into isSocketEligible. I ran the new import regression against the previous modal: it fails with the stale /var/run/mysqld/mysqld.sock, then passes with this head. All 267 targeted frontend tests, 98 existing pool tests, 27 SSH tests and 11 application tunnel tests pass.

The real socket check turned up a blocker in the PostgreSQL path. I started a separate PostgreSQL 16 fixture and pointed unix_socket_path at its .s.PGSQL.5432 file. get_postgres_pool_with_id builds the pool, but pool.get() fails with Backend(Error { kind: Tls, cause: Some(InvalidDnsNameError) }). The fixture is healthy and its socket accepts connections; a temporary test that reads its three seeded rows fails at pool checkout.

build_postgres_configurations correctly sets host_path and disables SSL. The problem is that tokio-postgres still calls make_tls_connect(hostname.unwrap_or("")) before entering the SSL-disabled connection path. A Unix socket has no hostname, and MakeRustlsConnect rejects the empty name. Disabling SSL in the config alone therefore doesn't make this connector usable over a local socket.

Please make the PostgreSQL connector handle a local socket without hostname validation while preserving the existing TCP TLS checks, and add a live socket regression. The same connector is used by Test Connection and the startup-script preflight, so please cover those paths too. The import fix is good; I'm requesting changes for the PostgreSQL socket failure.

@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

@debba Addressed the PostgreSQL Unix socket TLS blocker and rebased cleanly onto latest main:

  1. PostgresTlsConnector wrapper: Introduced PostgresTlsConnector in src-tauri/src/pool_manager.rs implementing MakeTlsConnect<S>. When tokio-postgres connects to a Unix domain socket, it evaluates make_tls_connect(hostname.unwrap_or("")). MakeRustlsConnect rejects the empty string with InvalidDnsNameError. PostgresTlsConnector intercepts empty hostnames and provides a "localhost" fallback so construction succeeds without TLS error. For TCP connections, hostnames are passed through unchanged to strictly enforce server certificate and hostname verification.
  2. Unified across all PostgreSQL paths:
    • Connection Pool: build_and_connect_postgres_pool supplies PostgresTlsConnector to PgPoolManager::new(cfg, tls_connector), allowing pool.get() checkouts to succeed over Unix sockets.
    • Startup Script Preflight: run_postgres_startup_script receives PostgresTlsConnector and connects cleanly before pool initialization.
    • Test Connection: PostgresDriver::test_connection uses build_postgres_tls_connector, verifying connectivity without hostname validation errors over sockets.
  3. Tests:
    • Added unit tests in src-tauri/src/pool_manager_tests.rs:
      • postgres_tls_connector_accepts_empty_hostname_for_unix_sockets: asserts make_tls_connect("") succeeds.
      • postgres_tls_connector_preserves_hostname_verification_for_tcp: asserts valid hostnames pass while invalid DNS names remain rejected.
    • Added live Unix socket regression test in src-tauri/tests/integration_tests.rs (test_postgres_unix_socket_live_regression, #[cfg(unix)]), verifying test_connection, pool checkout, query execution, and startup-script preflight against a live Unix socket fixture (discovering PG_UNIX_SOCKET or standard .s.PGSQL.5432 paths).

All unit and integration checks, TypeScript typecheck, and Vitest test suites (246/246) pass cleanly.

NewtTheWolf
NewtTheWolf previously approved these changes Nov 12, 2026

@NewtTheWolf NewtTheWolf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing the empty-hostname TLS construction. On 8ecc0806, PostgresTlsConnector supplies the local fallback only for an empty hostname; nonempty TCP hostnames still go through the existing verifier. The pool, Test Connection and startup-script paths all use that connector.

I ran the added live regression against an isolated PostgreSQL 17.9 server through its actual .s.PGSQL.5432 Unix socket. Test Connection succeeded, pool checkout returned the expected query result, and the startup-script preflight also succeeded. That test ran and passed; it was not an ignored test silently skipped.

The 318 affected frontend tests, typecheck, lint, production build and desktop-free cargo check pass. The full Rust library suite passes serially with 2,546 passed and 19 ignored. I have not exercised a remote SSH socket or the modal in the native app during this pass.

The reported PostgreSQL blocker is resolved on my side. Approved, leaving Debba's outstanding review for Debba to clear.

@NewtTheWolf
NewtTheWolf requested a review from debba November 12, 2026 22:45

@debba debba left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing the empty-hostname TLS construction and using the connector consistently in the pool, Test Connection and startup-script paths. Nonempty TCP hostnames still go through the existing connector unchanged.

I ran the 318 affected frontend tests, typecheck and all 20 TLS connector tests on this head. I also ran the added live regression against an isolated PostgreSQL 16 server through its actual Unix socket: Test Connection, pool checkout/query and startup-script preflight all succeed. The TLS failure from my previous review is resolved.

One integration blocker remains. A local merge with current main conflicts in src-tauri/src/application/tunnels.rs, src-tauri/src/application/tunnels_tests.rs and src-tauri/src/ssh_tunnel.rs. Please rebase those transport changes onto main, preserving socket forwarding and the TLS correction, then rerun the tunnel tests and live socket regression on the integrated revision.

Requesting changes for the rebase. I have not repeated the remote SSH socket flow in the desktop app.

…TabularisDB#1002)

- Rebase on upstream/main after application layer tunnel migration (TabularisDB#676)
- Wire SshForwardDestination and params_through_tunnel into application/tunnels.rs
- Add unix_socket capability to manifest.schema.json, tabularium-extensions, and PLUGIN_GUIDE.md
- Clear unix_socket_path when not in socketMode in NewConnectionModal
- Clear unix_socket_path in K8s and SSM tunnels
…alidation

AWS SSM tunnels, like Kubernetes port-forwards, only support TCP forwards.
When ssm_enabled is true, resolve_ssm_params clears unix_socket_path.

Ensure the web UI is fully consistent with backend behavior:
- Include ssm_enabled in tunnelEnabled and exclude it from canUseSocket
  in NewConnectionModal so the socket endpoint selector and active hint
  are hidden and socketMode is disabled.
- Sanitize imported ?socket= connection strings by checking !ssm_enabled
  in socketFieldAvailable.
- Treat ssm_enabled as overriding local socket in effectiveLocalSocketPath
  and require a host in validateConnectionParams.
- Add unit test coverage for SSM tunnel socket exclusion in both
  connections.test.ts and NewConnectionModal.test.tsx.
…tion string import

- Merge formData and overrides in loadDatabases so explicit undefined overrides clear stale unix_socket_path
- Extract isSocketEligible pure helper in utils/connections.ts with dedicated unit tests
- Remove redundant delete and drop unused Array.isArray fallback on list_databases
- Add regression test for pasting connection string without ?socket= over socket form
@markankamaransheogarat-sys

Copy link
Copy Markdown
Contributor Author

@debba Rebased onto upstream/main and resolved the conflicts in ssh_tunnel.rs, tunnels.rs, and tunnels_tests.rs by unifying SshForwardDestination into ForwardTarget (Fixed, UnixSocket, Socks5). Verified Rust tests (ssh_tunnel, application::tunnels_tests, pool_manager_tests) and frontend checks (vitest + tsc --noEmit).

debba
debba previously approved these changes Nov 16, 2026

@debba debba left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Unix socket/TLS correction is preserved after integration with current main, including provider metadata bindings in the connection modal and all 13 locales.

On 2595d1e, the CI trigger-editor failure is addressed by explicitly awaiting the mocked Monaco onMount before editing/saving its buffer. Delaying that callback reproduced the original assertion failure; the corrected synchronization passes. The committed test contains no artificial delay.

Final local validation: complete frontend suite (606 files, 9,610 tests), 2,703 desktop-free Rust library tests (18 ignored), lint, production build/typecheck, PostgreSQL 16 live socket regression (Test Connection, pool query and startup-script preflight), and all 4 integrated Chromium environment/provider/Vim checks pass. Generated guest artifacts remain synchronized. Remote SSH-to-socket behavior was not repeated in the native desktop UI.

Merge remains conditional on green CI for this head.

@debba
debba merged commit 60248db into TabularisDB:main Nov 16, 2026
15 checks passed
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.

[Feat]: MySQL / MariaDB connection through a local Unix socket

3 participants