Commit Graph
2 Commits
Author SHA1 Message Date
Joshen Lim 2b55f7db9a Joshenlim/fe 4719 cmd k support searching for policies (#52678)
## Context

Continue to build off from
[here](https://github.com/supabase/supabase/pull/52205) to make Cmd+K
resource-aware so finding and inspecting anything in a project doesn't
depend on knowing where it lives in the dashboard.

Specifically looking into database entities for now - end state would be
that you could search for a table name for example, and Cmd K will pull
up everything related to that table for you to skim (e.g Policies,
Functions, Triggers, etc). Changes in this PR sets up searching for RLS
policies.

<img width="609" height="525" alt="image"
src="https://github.com/user-attachments/assets/212a430a-314d-48c4-a27c-2f9bb06e8457"
/>

Policies are matched on, in priority, its name and the target table.

## Performance checking

Just ran a check with Claude just to make sure that the added SQL
doesn't cause any performance degradation on the database. Plan guard
passes at 12,000 tables, under its 500ms budget. Also benchmarked
locally with a 3-character query matching every policy, results look
good so should be alright:

| Catalog | Worst-case search | No-match baseline |
|---|---|---|
| 36k policies | ~52–64ms | ~16ms |
| 120k policies | ~118–134ms | ~63ms |

## To test

- [x] Search a table name: Tables first, then its policies, under
Policies
- [x] Search a policy name: it appears under Policies and opens the
editor panel in database/policies
- [x] Policy outside `public`: schema filter switches and the policy
opens
2026-11-04 14:26:37 +08:00
Joshen Lim 7d63d764fc Joshenlim/fe 4712 cmd k support searching for database tables (#52205)
## Context

Looking into some kaizen improvements for Cmd+K, with the overarching
idea to make Cmd+K resource-aware so finding and inspecting anything in
a project doesn't depend on knowing where it lives in the dashboard.

Specifically looking into database entities for now - end state would be
that you could search for a table name for example, and Cmd K will pull
up everything *related* to that table for you to skim (e.g Policies,
Functions, Triggers, etc). Changes in this PR sets the foundation here
by starting with just the tables.
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/65054781-2385-416c-aed9-f142380e4454"
/>

This might be similar to how we currently support searching for database
entities via these "Queries" section, but these only search within the
context of the entity category, not across (e.g only tables, only
policies)
<img width="500" alt="image"
src="https://github.com/user-attachments/assets/66ca16c6-9551-4134-b1e1-0b0c4b004085"
/>

The idea isn't to replace this, but provide another way to find your
database entities so that
- You can see related entities to what you're searching at a glance
- You don't need to go to a 2nd level nav in Cmd K 

Also fwiw the bulk of the LOC changes in here are mainly tests actually,
actual LOC changes are +385, -22
2026-10-23 23:24:56 +08:00