Skip to content

Show Database Health as a visual dashboard - #148

Open
ric-v wants to merge 1 commit into
mainfrom
claude/project-thread-348iof
Open

ric-v wants to merge 1 commit into
mainfrom
claude/project-thread-348iof

Conversation

@ric-v

@ric-v ric-v commented Nov 14, 2026

Copy link
Copy Markdown
Member

What

The Database Health action used to open a long notebook of text and tables. It now opens a dashboard panel:

  • Status tiles for cache hit ratio, transaction ID age, connections, longest open transaction and database size, with gauges.
  • What to do: a short list ordered by severity, each linking to its check.
  • One card per check: table bloat, unused indexes, foreign keys without an index, blocking locks (blocked vs blocking side by side) and slowest statements. Bars, plus Copy SQL for the fix (VACUUM, DROP INDEX CONCURRENTLY, CREATE INDEX, pg_cancel_backend). "How to read this" folds hold the guidance that used to be notebook text.
  • Open as notebook in the header opens the previous step-by-step report in a temporary notebook, unchanged.

How it is built

  • HealthSQL.summary() returns one row of typed numbers (the old overview() returns pre-formatted text). unusedIndexes() also returns index_bytes.
  • src/features/health/healthModel.ts: pure view model. Thresholds and every sentence the dashboard shows live here and are unit tested.
  • src/features/health/healthHtml.ts: pure HTML renderer. Nonce-based CSP, all database text escaped.
  • src/providers/DatabaseHealthPanel.ts: runs each check separately, so a missing permission shows "Could not load" for that card and the rest still render. One panel per connection and database, Refresh re-runs the checks.
  • Status is shown as a word and a symbol as well as colour, so it reads in high-contrast themes and for colour-blind users.
  • Tables with fewer than 1,000 dead rows are ignored for bloat, since a high percentage on a tiny table is noise.

Testing

  • npm run test:unit: 849 passing, including new HealthDashboard.test.ts (thresholds, findings, escaping, partial failure).
  • Ran every dashboard query against a real PostgreSQL 16 with a bloated table, an unused index, an unindexed foreign key and a live lock. All five checks returned data, and interval columns (which node-pg returns as objects) display correctly.
  • Rendered the HTML in a browser with dark-theme variables to check the layout.

Not verified here (needs VS Code): how it looks with real theme colours in light and high-contrast themes, and the Refresh, Copy SQL and Open as notebook buttons inside the webview.

Changelog

Added under Unreleased.


Generated by Claude Code

The health report was a long notebook of text and tables. The Database Health
action now opens a webview with status tiles, a short "What to do" list and one
card per check. "Open as notebook" keeps the step-by-step report available.

- HealthSQL.summary() returns typed numbers; unusedIndexes() also returns bytes
- features/health: pure view model (thresholds, findings) and HTML renderer
- providers/DatabaseHealthPanel: per-check queries, so one failure does not
  blank the page
- Status uses a word and a symbol as well as colour

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018mXPvRzbydoRmsdiPdRqZH
@ric-v ric-v self-assigned this Nov 14, 2026

ric-v commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

The "IP Guardrail — No Premium Leakage" check is red here for the same reason it is red on main: package.json on main carries the merged Pro manifest, and this PR does not touch package.json. It is the same failure I noted on #146 and #147. Fixing it means restoring the free manifest on main in a separate PR, which I have not done without the owner's go-ahead.


Generated by Claude Code

ric-v commented Nov 14, 2026

Copy link
Copy Markdown
Member Author

"Free VSIX builds without packages/pro" fails with the same root cause as the guardrail check. make package-free runs vscode:prepublish, which on main is the Pro one (esbuild-base:pro, aliasing @nexql/pro to ./packages/pro/src/index.ts), and that path does not exist in a free checkout. check-no-pro has been red on main since 58da497 and on each merge after it. This PR does not touch package.json, so it can't fix or cause either failure; restoring the free manifest on main fixes both.


Generated by Claude Code

This branch has not been deployed

No deployments
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.

2 participants