feat(cli): port supabase inspect db to native TypeScript#5554
Merged
Conversation
Replace the Phase 0 Go proxies for all 13 active `inspect db` subcommands and their 12 deprecated aliases with native TypeScript handlers that connect to Postgres directly via LegacyDbConnection and render Go-parity Glamour tables. - Add a `query` method to LegacyDbSession (sql-pg impl via client.unsafe). - Add shared infra at inspect/db/: LegacyInspectQuerySpec + runner, cell formatters, internal-schema LIKE-escape, runtime layer, command boilerplate (LEGACY_INSPECT_DB_FLAGS + handler pipe), and the deprecation-notice builder. - One verbatim <name>.query.ts spec per active subcommand; deprecated aliases route to the active spec (preserving Go's table-record-counts inconsistency). - Preserve Go parity: stderr connection diagnostic, whitespace-collapsed stmt cells (matching RE2 `\s`, not JS `\s`), vacuum -1 -> No stats, bloat header. - Consolidate 25 proxy SIDE_EFFECTS.md into one shared family doc. - Flip the 25 porting-status rows to `ported`.
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase@5554Preview package for commit |
…e2e shard 3/3) Go wraps almost every `inspect db` table cell in a `…` code-span (e.g. `role_stats.go:43`). Glamour's AsciiStyle strips the backticks from a non-empty span but leaves an empty span (``) as the two literal backtick characters, so an empty cell renders as `` and contributes width 2. The TS port stripped backticks at projection time and rendered an empty value as nothing, diverging from Go on the role-stats `custom_config` cell for the `postgres` row (e2e parity: inspect db role-stats). `legacyInspectText` now models Go's backtick-wrapped `%s` (empty -> ``). The few columns Go leaves unwrapped get explicit formatters: - `legacyInspectPlainText` for the vacuum_stats timestamp columns (bare `%s|`, empty stays empty). - `legacyInspectBacktickStmt` for the calls/outliers query columns, which Go wraps unlike the bare locks/blocking statements.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c17b4e335f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
….layers) The shared inspect-db runtime layer hardcoded the command-runtime path as ["inspect","db"] and provided it to all 25 leaf subcommands, so withLegacyCommandInstrumentation recorded every subcommand as `inspect db` in the PostHog `cli_command_executed` event. Go records each leaf's full `cmd.CommandPath()` (root_analytics.go:32-38) — its inspect tree is a real 3-level hierarchy (cmd/inspect.go:26-248) — so each of the 25 leaves emits a distinct command name. The shared path collapsed them into one event, diverging from Go and destroying per-command usage/error attribution. `legacyInspectDbRuntimeLayer` is now a factory taking the leaf name and appending it to ["inspect","db"]; each command file passes its own cobra `Use` name. Deprecated aliases record the alias the user typed (e.g. `inspect db cache-hit`), not the backend command they delegate to, matching Go's CommandPath() (cmd/inspect.go:139-247). Mirrors the sibling convention in legacy-management-api-runtime.layer.ts:80.
jgoux
reviewed
Jun 12, 2026
jgoux
left a comment
Contributor
There was a problem hiding this comment.
Left one inline review finding.
avallete
approved these changes
Jun 12, 2026
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.
What changed
Ports all of
supabase inspect db(CLI-1316) from Phase 0 Go proxies to native TypeScript in the legacy shell. The 13 active subcommands (db-stats,replication-slots,locks,blocking,outliers,calls,index-stats,long-running-queries,bloat,role-stats,vacuum-stats,table-stats,traffic-profile) and their 12 deprecated aliases now connect to Postgres directly via the already-portedLegacyDbConnection, run the embedded query, and render Go-parity Glamour tables — no more shelling out to the Go binary.Highlights
LegacyDbSession.queryadded to the connection service +@effect/sql-pglayer (positionalclient.unsafe(sql, params)binding); the one other object-literal consumer (test dbmock) updated.inspect/db/:LegacyInspectQuerySpec+ thelegacyRunInspectQueryrunner, pure cell formatters (%s/%t/%d/%.1f/whitespace-collapsed stmt), the 29-entry internal-schema list +legacyLikeEscapeSchema,legacyInspectDbRuntimeLayer, command boilerplate (LEGACY_INSPECT_DB_FLAGS+ handler pipe), and the deprecation-notice builder.<name>.query.tsspec per active subcommand; deprecated aliases route to the active spec — including preserving Go's quirk wheretable-record-countswarns "table-stats" but runs the index-stats query.Go parity preserved
--db-url/--linked/--localselector flags (mutually exclusive;--linkeddefault-true derived from absence), no--project-ref. One deliberate divergence — see below.ConnectByConfig).\sset ([\t\n\f\r ]+ individual\v), not JS\s.vacuum-statsrenders 9 of 11 columns with the one-shot-1→No stats;bloatuses the clean 4-column header.Command "<name>" is deprecated, use "<target>" instead.to stderr.json/stream-jsonmodes emit{ rows }(additive — Go has no machine output for inspect).Behavioral change vs Go⚠️ (release note)
Explicit
--linked=falseno longer triggers the mutual-exclusion error. Go uses cobra'sMarkFlagsMutuallyExclusive, which keys off whether a flag was explicitly provided (cobra'sChanged), counting even--linked=falseas set. So in the Go CLI,supabase inspect db locks --linked=false --localfails flag validation. This port checks the parsed boolean value instead, so an explicit--linked=falseis indistinguishable from the default and the command proceeds to connect using--local(or--db-url).We're keeping the TS behavior intentionally — treating
--linked=falseas "not selecting linked" rather than as a hard conflict is the more sensible interpretation, and the realistic conflict cases (two positive selectors set, e.g.--linked --localor--db-url … --local) are still rejected exactly as in Go. Calling it out here so it lands in the release notes as a deliberate, user-observable difference.Docs / tracking
SIDE_EFFECTS.mdconsolidated into one shared family doc.inspect dbrows ingo-cli-porting-status.mdflippedwrapped→ported.Closes CLI-1316