Skip to content

feat(databases): tree nav, database overview, and shared table actions#1471

Open
dawsontoth wants to merge 2 commits into
stagefrom
claude/databases-nav-redesign-1e5b1d
Open

feat(databases): tree nav, database overview, and shared table actions#1471
dawsontoth wants to merge 2 commits into
stagefrom
claude/databases-nav-redesign-1e5b1d

Conversation

@dawsontoth

Copy link
Copy Markdown
Contributor

What & why

Rebuilds the Databases left nav on the same react-complex-tree tech the Applications tab uses, and adds a database overview page. The old dropdown + flat table list only showed one database at a time, had no filter, and kept per-item actions in the right-pane toolbar only.

Now:

  • + Create a Table row at the top → databases as top-level items → tables nested underneath.
  • Type-to-filter (the library's built-in search).
  • Single-click selects — a database opens its new overview page, a table opens its data grid; double-click / chevron expands a database (the Applications model).

Highlights

  • Database overview page — DB size, audit size, table count, and a per-table breakdown (size, columns, primary key, last updated) with record counts backfilled lazily. Sizes/schema are instant from the describe_all map already loaded; counts come from a separate counted describe_all. Opening the tab now lands on the first database's overview.
  • Right-click menus — databases (Create a Table, Drop Database) and tables (Add Record(s), Import Data, Export CSV, Drop Table). The table actions live in one TableContextMenuItems component shared by the tree and the overview's table list, so right-clicking a row in either place opens the same menu and they can't drift.
  • Single modal hub — the action modals were lifted into an always-mounted DatabaseActionModals driven by target-carrying watched values, so an action can target any db/table (even one that isn't open, or an empty database), not just the currently-open one. CSV download extracted into useExportTableCsv (toolbar keeps its filter-aware export; the tree/overview export the whole table).
  • Removed the redundant sidebar Import Data button (it's in the header).

Fixes folded in

  • Context menu didn't re-anchor on a second right-click while already open (Radix keeps it mounted through its exit animation, so it never re-measured) — the menu appeared over the wrong row. Fixed by remounting the content keyed to the cursor position. Also applied to the Applications file tree, which had the same bug.
  • Latent crash in useInstanceSchemaTablePermission (a missing optional chain) that the new right-click menus would trigger for restricted (non-structure_user) users.

No new backend operations

Everything reuses existing operations/modals (create_table, drop_table, drop_database, insert, imports, CSV export). Rename was explicitly out of scope.

Verification

  • Browser-verified end-to-end against a real cluster: tree render, type-to-filter, single/double-click, both context menus (including targeting a not-currently-open table and re-anchoring between rows), the overview stats, and the overview-row menu opening the correctly-targeted modal.
  • Light + dark mode checked; the tree icons now match the Applications palette (green +, orange containers, neutral high-contrast leaves).
  • tsc -b, oxlint, and dprint pass. vitest green (28 tests, incl. new coverage for the tree-item builder).

🤖 Generated with Claude Code

Rebuild the Databases left nav on the applications tab's react-complex-tree:
databases as top-level items with their tables nested, a "+ Create a Table"
row, and built-in type-to-filter. Single-click selects (database -> new
overview page, table -> data grid); double-click / chevron expands.

- Add a database overview page: DB size, audit size, table count, and a
  per-table breakdown (size, columns, primary key, last updated) with record
  counts backfilled lazily. Landing on the tab now shows the first DB's overview.
- Right-click menus for databases (Create a Table, Drop Database) and tables
  (Add Record(s), Import Data, Export CSV, Drop Table). The table actions live
  in one TableContextMenuItems component shared by the tree and the overview's
  table list, so the two menus can't drift.
- Lift the action modals into a single always-mounted DatabaseActionModals hub
  driven by target-carrying watched values, so an action can target any
  db/table -- not just the open one. Extract the CSV download into useExportTableCsv.
- Fix a Radix quirk where an already-open context menu didn't re-anchor on a
  second right-click: remount the content keyed by cursor position. Also applied
  to the applications file tree, which had the same bug.
- Fix a latent crash in useInstanceSchemaTablePermission (missing optional chain)
  that the new right-click menus would trigger for restricted users.
- Remove the redundant sidebar "Import Data" button (already in the header).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dawsontoth dawsontoth requested a review from a team as a code owner July 10, 2026 23:32
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 46.96% 4502 / 9585
🔵 Statements 47.3% 4801 / 10148
🔵 Functions 38.86% 1071 / 2756
🔵 Branches 39.14% 2905 / 7422
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/features/instance/applications/components/ApplicationsSidebar/ItemArrow.tsx 0% 0% 0% 0% 28-44
src/features/instance/databases/index.tsx 0% 0% 0% 0% 12-78
src/features/instance/databases/components/DatabaseActionModals.tsx 0% 0% 0% 0% 22-99
src/features/instance/databases/components/DatabaseOverview.tsx 0% 0% 0% 0% 17-142
src/features/instance/databases/components/DatabaseTableView.tsx 0% 0% 0% 0% 61-460
src/features/instance/databases/components/DatabasesSidebar.tsx 0% 0% 0% 0% 6-18
src/features/instance/databases/components/TableContextMenuItems.tsx 0% 0% 0% 0% 21-56
src/features/instance/databases/components/TableRowContextMenu.tsx 0% 0% 0% 0% 17-44
src/features/instance/databases/components/DatabasesTree/DatabaseTreeContextMenu.tsx 0% 0% 0% 0% 29-73
src/features/instance/databases/components/DatabasesTree/ItemTitle.tsx 33.33% 0% 0% 33.33% 12-26
src/features/instance/databases/components/DatabasesTree/buildItems.ts 100% 83.33% 100% 100%
src/features/instance/databases/components/DatabasesTree/getItemTitle.ts 80% 75% 100% 80% 13
src/features/instance/databases/components/DatabasesTree/index.tsx 3.22% 0% 0% 3.7% 21-87
src/features/instance/databases/components/DatabasesTree/specialItems.ts 100% 100% 100% 100%
src/features/instance/databases/components/DatabasesTree/useDatabaseTreeViewState.ts 0% 0% 0% 0% 16-47
src/features/instance/databases/hooks/useExportTableCsv.ts 0% 0% 0% 0% 23-69
src/features/instance/databases/modals/CreateNewTableModal.tsx 5% 0% 0% 5% 49-165
src/features/instance/databases/modals/DeleteDatabaseModal.tsx 0% 0% 0% 0% 15-62
src/features/instance/databases/modals/DeleteTableModal.tsx 0% 0% 0% 0% 15-67
src/hooks/usePermissions.ts 13.04% 5.55% 15.38% 13.18% 29, 36-42, 50, 57-217
Generated in workflow #1439 for commit a4222dd by the Vitest Coverage Report Action

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the database management UI by replacing the select-based sidebar with a tree-based navigation sidebar, introducing a database overview component, and consolidating action modals into a single, always-mounted component. It also extracts CSV export logic into a reusable hook and adds context menus for right-click actions. The review feedback suggests adding unique key props to the consolidated modals to ensure proper state resets when switching targets, and wrapping the CSV blob URL revocation in a setTimeout to prevent download failures in certain browsers.

Comment thread src/features/instance/databases/components/DatabaseActionModals.tsx
Comment thread src/features/instance/databases/hooks/useExportTableCsv.ts Outdated
…evoke

Address PR review:
- Give the consolidated action modals a per-target `key` so their internal
  state resets on switch, and drop CreateNewTableModal's manual reset effect
  (the remount now seeds the prefilled database).
- Defer URL.revokeObjectURL in useExportTableCsv so it can't cancel the
  download before Firefox / iOS Safari start fetching the blob.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant