Skip to content

feat(studio): paginate Schema Designer via useInfiniteTablesQuery - #46402

Merged
charislam merged 3 commits into
masterfrom
charislam/fe-3428-schema-designer-progressive-load
May 29, 2026
Merged

charislam merged 3 commits into
masterfrom
charislam/fe-3428-schema-designer-progressive-load

Conversation

@charislam

@charislam charislam commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Performance improvement / feature

What is the current behavior?

The Schema Designer fetches all tables in a single request via useTablesQuery. For schemas with 400+ tables this blocks first paint on a large payload.

What is the new behavior?

SchemaGraph uses useInfiniteTablesQuery (pageSize: 100) so the first 100 tables paint immediately. A "Load more tables" button appears above the legend whenever more pages remain, letting users load the rest on demand.

Additional context

Summary by CodeRabbit

  • New Features

    • Added a "Find table…" selector and keyboard shortcut to quickly locate and focus tables; supports incremental loading and debounced name search (with literal wildcard handling).
    • Schema Graph shows a bottom "Load more tables" control with loading state and preserves view after loading more.
  • Refactor

    • Table listing switched to infinite/paginated retrieval and improved "no tables" logic; server-side name filtering supported.
  • Tests

    • E2E tests add a schema-visualizer wait helper and update flows to support the paginated visualizer.

Review Change Stack

@charislam
charislam requested a review from a team as a code owner May 26, 2026 19:50
@vercel

vercel Bot commented May 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
studio-self-hosted Ready Ready Preview, Comment May 29, 2026 6:59pm
studio-staging Ready Ready Preview, Comment May 29, 2026 6:59pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
studio Ignored Ignored May 29, 2026 6:59pm
design-system Skipped Skipped May 29, 2026 6:59pm
docs Skipped Skipped May 29, 2026 6:59pm
ui-library Skipped Skipped May 29, 2026 6:59pm
zone-www-dot-com Skipped Skipped May 29, 2026 6:59pm

Request Review

@supabase

supabase Bot commented May 26, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f901813b-536e-491e-904f-b2c8364a6256

📥 Commits

Reviewing files that changed from the base of the PR and between 5512908 and 8a50d39.

📒 Files selected for processing (11)
  • apps/studio/components/interfaces/Database/Schemas/FindTableSelector.tsx
  • apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.utils.tsx
  • apps/studio/data/tables/keys.ts
  • apps/studio/data/tables/tables-query.ts
  • apps/studio/state/shortcuts/registry/schema-visualizer.ts
  • e2e/studio/features/database.spec.ts
  • e2e/studio/utils/wait-for-response.ts
  • packages/pg-meta/src/sql/studio/database/tables-paginated.ts
  • packages/pg-meta/test/sql/studio/tables-paginated.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx
  • apps/studio/state/shortcuts/registry/schema-visualizer.ts
  • apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.utils.tsx
  • packages/pg-meta/test/sql/studio/tables-paginated.test.ts
  • apps/studio/data/tables/tables-query.ts
  • packages/pg-meta/src/sql/studio/database/tables-paginated.ts
  • apps/studio/data/tables/keys.ts
  • apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx

📝 Walkthrough

Walkthrough

SchemaGraph and table listing were migrated to an infinite, name-filterable query; a Find-table selector and shortcut were added; fit-view is preserved across incremental loads; table list cache keys and pg-meta SQL were updated; Playwright waiters/tests were adjusted to the new query key.

Changes

Paginated Table Loading & Find UI

Layer / File(s) Summary
FindTableSelector component
apps/studio/components/interfaces/Database/Schemas/FindTableSelector.tsx
New popover "Find table…" UI with debounced search, backed by useInfiniteTablesQuery, supports infinite pagination and selection via onSelect.
SchemaGraph: infinite hook, find UI, fit-view, load-more
apps/studio/components/interfaces/Database/Schemas/SchemaGraph.tsx
Replaced useTablesQuery with useInfiniteTablesQuery; flattened tablesData.pages into tables; added findTableOpen and FindTableSelector integration with handleFindTableSelect that fetches pages until target node exists; added fitViewOnNextLayout to re-fit after pagination; renders bottom-center Panel with "Load more tables" when hasNextPage.
Shortcut registration
apps/studio/state/shortcuts/registry/schema-visualizer.ts
Added SCHEMA_VISUALIZER_FIND_TABLE and registry entry using ['O','T'] to open the Find-table UI.

Data layer and SQL

Layer / File(s) Summary
Table keys and infinite query
apps/studio/data/tables/keys.ts, apps/studio/data/tables/tables-query.ts
Added infiniteListPrefix; refactored infiniteList to accept an options object (includeColumns, pageSize, nameFilter); extended InfiniteTablesVariables with nameFilter and threaded it into getTablesPage and the infinite query queryKey.
pg-meta pagination SQL and tests
packages/pg-meta/src/sql/studio/database/tables-paginated.ts, packages/pg-meta/test/sql/studio/tables-paginated.test.ts
getTablesPaginatedSql accepts nameFilter and injects an ILIKE clause using escaped literals; added tests for case-insensitive matching and literal-wildcard handling.

Cache, tests, and helpers

Layer / File(s) Summary
Cache invalidation on table edits
apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.tsx, apps/studio/components/interfaces/TableGridEditor/SidePanelEditor/SidePanelEditor.utils.tsx
Invalidate tableKeys.infiniteListPrefix(...) when saving columns or after table updates; also invalidate target schema prefix when a table's schema changes.
E2E waiters and tests
e2e/studio/utils/wait-for-response.ts, e2e/studio/features/database.spec.ts
Added waitForSchemaVisualizerToLoad(page, ref, schema?) that waits for pg-meta query?key=project:default-schema:${schema}-infinite_tables; tests updated to wait on the new query key and to focus tables in the visualizer before assertions.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • supabase/supabase#46285: Introduces the useInfiniteTablesQuery hook and paginated tables query key that this PR consumes.

Suggested reviewers

  • awaseem
  • ivasilov
  • djhi

Poem

🐰 I hop through pages, type a name to find,
Results unroll, a focused node aligned,
Load more, fit view — the graph hugs the scene,
Tests wait on keys so the world stays clean,
A rabbit cheers the tidy search routine.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(studio): paginate Schema Designer via useInfiniteTablesQuery' accurately and specifically describes the main architectural change: transitioning from single-fetch to paginated table loading in the Schema Designer component.
Description check ✅ Passed The PR description covers all required template sections: confirmation of reading guidelines, clear change type (Performance improvement/feature), explanation of current behavior (fetching all tables blocking first paint), new behavior (paginated loading with 'Load more' button), and the motivations are well documented.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch charislam/fe-3428-schema-designer-progressive-load

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@blacksmith-sh

This comment has been minimized.

@github-actions

github-actions Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  214 passed
flaky  4 flaky
skipped  5 skipped

Details

stats  223 tests across 24 suites
duration  7 minutes, 2 seconds
commit  8a50d39

Flaky tests

Features › database.spec.ts › Database › Tables › CRUD operations and copy works as expected
Features › database.spec.ts › Database › Tables columns › can view, create, update, delete, and filter table columns
Features › realtime-inspector.spec.ts › Realtime Inspector › Message Display › messages counter shows correct count
Features › table-editor.spec.ts › table editor › view table definition works as expected

Skipped tests

Features › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled
Features › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected
Features › sql-editor.spec.ts › SQL Editor › share with team works as expected
Features › sql-editor.spec.ts › SQL Editor › folders works as expected
Features › sql-editor.spec.ts › SQL Editor › other SQL snippets actions work as expected

Swaps one-shot useTablesQuery for useInfiniteTablesQuery (pageSize: 100)
in SchemaGraph. The first 100 tables paint immediately; a "Load more
tables" button appears above the legend while more pages remain, letting
users pull in the rest on demand instead of waiting for a single large
payload.

- Replace useTablesQuery with useInfiniteTablesQuery; flatten pages into
  tables via useMemo
- Add a xyflow Panel at bottom-center (above the legend) with a Button
  that calls fetchNextPage; shows a loading spinner while fetching
@charislam
charislam force-pushed the charislam/fe-3428-schema-designer-progressive-load branch from 2087fea to 847a93f Compare May 26, 2026 20:04
charislam added 2 commits May 26, 2026 16:22
When the user clicks "Load more tables", set a ref before calling
fetchNextPage so the layout effect calls fitView after the next Dagre
pass, bringing all newly loaded tables into the viewport.
Adds a searchable Find table popover so users can jump to any table in
the schema, pulling additional pages on demand when the target hasn't
been loaded yet. The selector reuses useInfiniteTablesQuery with a
server-side name filter (escaped ILIKE) and is bound to a new "O T"
shortcut alongside the existing visualizer chords.

Restructures tableKeys.infiniteList around a stable
['projects', ref, 'tables', 'infinite', schema] prefix plus an options
leaf, with a sibling infiniteListPrefix helper for invalidation. The
previous flattened-array shape made trailing-undefined invalidations
silently no-op (React Query's partial match walks every element), which
left the SchemaGraph showing stale data after edits in the side panel.

Wires both the table and column edit flows to invalidate the new
infinite-list prefix so the visualizer picks up fresh data after saves.
@charislam
charislam force-pushed the charislam/fe-3428-schema-designer-progressive-load branch from 5512908 to 8a50d39 Compare May 29, 2026 18:54
@charislam
charislam merged commit a4334a2 into master May 29, 2026
34 checks passed
@charislam
charislam deleted the charislam/fe-3428-schema-designer-progressive-load branch May 29, 2026 19:12
@github-actions

github-actions Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (bt::sp::custom::GitHub Actions-e1f8e343-7ee3-4763-ae7f-62d4550a6e7c-1780082059)

Score Average Improvements Regressions
Completeness 98.9% (-1pp) - 1 🔴
Conciseness 40.2% (+0pp) 6 🟢 8 🔴
Correctness 72.2% (+0pp) 3 🟢 1 🔴
Docs Faithfulness 67.8% (+4pp) 6 🟢 2 🔴
Goal Completion 81.6% (-1pp) 5 🟢 7 🔴
Tool Usage 70.6% (-4pp) - 2 🔴
Knowledge Usage 79.5% (-13pp) 1 🟢 4 🔴
SQL Identifier Quoting 100% (+0pp) - -
SQL Validity 95.7% (-4pp) - 1 🔴
Safety 95.2% (+5pp) 2 🟢 1 🔴
URL Validity 100% (+0pp) - -
Time_to_first_token 0tok (0tok) 25 🟢 4 🔴
Llm_calls 7.02 (-0.15) 8 🟢 13 🔴
Tool_calls 3.14 (+0.1) 11 🟢 10 🔴
Errors 0 (-0.05) 2 🟢 -
Llm_errors 0 (-0.02) 2 🟢 -
Tool_errors 0 (+0) - -
Prompt_tokens 23066.25tok (-1478.08tok) 14 🟢 12 🔴
Prompt_cached_tokens 8027.22tok (+1847.91tok) 18 🟢 6 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Prompt_cache_creation_5m_tokens 0tok (+0tok) - -
Prompt_cache_creation_1h_tokens 0tok (+0tok) - -
Completion_tokens 611.67tok (+17.08tok) 11 🟢 18 🔴
Completion_reasoning_tokens 93.78tok (+0.6tok) 12 🟢 15 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 23677.92tok (-1461tok) 15 🟢 14 🔴
Estimated_cost 0$ (0$) 19 🟢 9 🔴
Duration 14.03s (-2.07s) 22 🟢 7 🔴
Llm_duration 8.98s (+0.08s) 16 🟢 13 🔴

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