Commit Graph

15 Commits

Author SHA1 Message Date
Charis 3b7052b5a9 cleanup: fix import order and prefixes for studio/data (#44501) 2026-04-03 09:15:57 +02:00
Joshen Lim f0fbcbd2a3 Add preflight EXPLAIN check to table editor rows (#42321)
## Context

Part of an investigation to see how we can make the dashboard more
resilient for large databases by ensuring that the dashboard never
becomes the reason for taking down the database accidentally.

Am proposing that for interfaces that rely heavily on queries to the
database for data to render, we add preflight checks to ensure that we
never run queries that exceed a certain cost threshold (and also have UI
handlers to communicate this) - this can be done by running an EXPLAIN
query before running the actual query, and if the cost from the EXPLAIN
exceeds a specified threshold, the UI throws an error then and skips
calling the actual query.

## Demo
Am piloting this with the Table Editor, and got an example here in which
my table has 500K+ rows, and I'm trying to sort on an unindexed column:


https://github.com/user-attachments/assets/ccad2ea9-d62c-4106-8295-2a6df5941474

With this UX, the pros are that
- It's relatively seamless and not too invasive, most users won't notice
this unless they run into this specific scenario
- We can incrementally apply this to other parts of the dashboard, next
will probably be Auth Users for example

However there are some considerations:
- The additional EXPLAIN query adds a bit more latency to the query
since its a separate API request to the query endpoint
- ^ On a similar note, it will hammer the API a bit more, which may
result in higher probability of 429s
- However, I reckon that the preflight checks are meant to be used
sparingly and only for certain parts of the dashboard that we believe
may cause high load.
- e.g for the Table Editor, reckon we only need this for fetching rows?
The count query is largely optimized already (although we could just add
a preflight check there too)
- It's just meant to be a safeguard to prevent running heavy queries on
the database



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Query preflight with cost checks and a user-facing high-cost dialog
showing cost details and remediation suggestions.
* Grid exposes an explicit error flag and surfaces richer error
metadata.

* **Bug Fixes**
* Standardized error handling and more consistent error displays across
the app.
* Explain analysis now reports an additional max-cost metric for
queries.

* **UI**
* Tweaked empty-state interaction/layout and slightly wider header
delete control.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ali Waseem <waseema393@gmail.com>
2026-02-03 17:55:54 +08:00
Joshen Lim 85aa76ba0a Add readme for SQL Editor overview (#42167)
## Context

Just adding some documentation to the more complex parts of the
dashboard in hopes to ease working on these parts for those who aren't
familiar

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Folder creation and updates in the SQL Editor now properly sync to the
backend with API calls, success notifications, and improved error
handling.
* Snippet save/upsert behavior updated: saves run via API with
optimistic handling and debounced execution; default automatic refresh
after save has been reduced to avoid unnecessary invalidations.

* **Documentation**
* Added a comprehensive SQL Editor guide covering UI, data flow, snippet
management, and improvement notes.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-03 15:01:56 +08:00
Ali Waseem edb59e0674 Fix: updated RLS to use messages instead of formatted error (#40356)
updated RLS to use messages instead of formatted error
2025-11-11 13:08:32 -05:00
Ivan Vasilov 8b657165b5 chore: Migrate to use custom type for ReactQuery queries and mutations (#40073)
* Add custom types for queries, mutations and infinite queries.

* Migrate all queries to use the new type.

* Migrate all infinite queries to useCustomInfiniteQueryOptions.

* Migrate all mutations to use useCustomMutationOptions.

* Add type to all imports in `types` folder.
2025-11-03 13:18:13 +01:00
Ivan Vasilov da4a40e308 chore: Migrate RQ functions to use object syntax style (#39895)
* Migrate all uses of invalidateQueries to use object syntax.

* Migrate the remainder of useInfiniteQuery.

* Migrate all setQueriesData.

* Migrate all fetchQuery uses.

* Migrate some leftover functions from RQ.

* Fix issues found by Charis.
2025-10-28 10:43:14 +01:00
Alaister Young 8855d05803 chore(studio): swap react-query to object syntax (#39842)
* chore(studio): swap react-query to object syntax

* Fix small issues found

* Fix realtime settings

* Nit

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-10-27 09:38:27 +01:00
Sean Oliver e978a084b2 feat: add table activation tracking (#39090)
Add telemetry tracking for activation-related table operations
- Implement SQL event parser to detect table creation, data insertion, and RLS enablement
- Add telemetry tracking for these operations in table editor as well
- Add test coverage for SQL event parser
2025-10-01 14:54:51 -07:00
Jonathan Summers-Muir 21bbc93afa Chore/table editor filter sorts logic moved to hooks (#35138)
* init

* update Popovers to use new hooks

* Update Header.tsx

* made primitive components for filter and sorts

* Delete FilterPopoverWrapper.tsx

* Delete SortPopoverWrapper.tsx

* remove

* Create README.md

* Update README.md

* fix sort popover issues

* Update SupabaseGrid.tsx

* move DeleteConfirmationDialogs into context

* fix issue with

* more stuff for alaister

* fix ts and tables pages

* First round of clean up

* Update README.md

* Smol fix

* Fix issues identified

* Smol fix

* Fix updating table name in database/tables not invalidating

* Improve SQL editor invalidation logic

* Add fix to reopen last opened table when landing on table editor

* Smol fix

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-04-30 14:19:21 +08:00
Joshen Lim ae2203b5e7 Reinstate SQL editor results events (#33736)
* Reinstate SQL editor results events

* remove random console.log

* fix event name

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
2025-02-20 18:46:23 +07:00
Joshen Lim 8d527f7f9e Update database-triggers react queries to use methods from data/fetchers (#33546)
* Update database-triggers-query to use get from data/fetchers

* Update database triggers mutation RQs to use methods from data/fetchers

* Don't cd to the directory, use the --dir parameter of pnpm.

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2025-02-12 16:04:35 +08:00
Joshen Lim 9d6cf3ee51 Add contextual invalidation in SQL Editor (#32675) 2025-01-09 18:06:31 +08:00
Ivan Vasilov df52ea7ee0 feat: Replace all toasts with sonner (#28250)
* Update the design of the sonner toasts. Add the close button by default.

* Migrate studio and www apps to use the SonnerToaster.

* Migrate all toasts from studio.

* Migrate all leftover toasts in studio.

* Add a new toast component with progress. Use it in studio.

* Migrate the design-system app.

* Refactor the consent toast to use sonner.

* Switch docs to use the new sonner toasts.

* Remove toast examples from the design-system app.

* Remove all toast-related components and old code.

* Fix the progress bar in the toast progress component. Also make the bottom components vertically centered.

* Fix the width of the toast progress.

* Use text-foreground-lighter instead of muted for ToastProgress text

* Rename ToastProgress to SonnerProgress.

* Shorten the text in sonner progress.

* Use the correct classes for the close button. Add a const var for the default toast duration. Remove the custom width class from sonner.

* Set the position for all progress toasts to bottom right. Set the duration for all toasts to the default (when reusing a toast id from loading/progress toast, the duration is set to infinity).

* Fix the playwright tests.

* Refactor imports to use ui instead of @ui.

* Change all imports of react-hot-toast with sonner. These components were merged since the last commit to this branch.

* Remove react-hot-toast lib.

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
2024-08-31 07:50:51 +08:00
Ivan Vasilov 1f38fe2012 feat: New Policy Editor (#19166)
* Add two more sizes to the Panel component.

* Add alias for the older openai-api library. The new one is added under the openai name.

* Add API routes

* Add components for the new AI RLS panel.

* Bunch of changes to the AI Policy Editor.

* Add a button for opening the new Policy Editor.

* Add a feature flag for the new editor.

* Add a confirmation modal when closing the panel.

* Fix leftover data when closing the panel.

* Make the copy button work.

* Add the next/swc packages to package-lock.json.

* Merge master

* Scaffold debug sql in rls editor

* Small improvements to policy chat

* Hook up debug to ai assistant panel

* Improve debug UX

* Add debug request badge

* Some styling fix

* Small styling fix

* Another small styling fix

* Shift create new policy ai button + fix error stylign with code editor height

* Add tooltips to apply changes and copy code from assistant message

* Hide assistant button is not platform

* Small lint

* Add default error handlers to all AI RQ mutations

* Small fix

* Remove IS PLATFORM check for rls assistant

* Add placeholder to RLS code editor

* Fix diff + rls code editor

* Add placeholder message after sending prompt

* Small style

* RLSCodeEditor hit tab if empty to populate placeholder text

* Light mode nudeges

* Update logic for when confirmation close modal should show

* Set render overview ruler as false for rls diff editor

* improve chat UX to make it smoother (thank you alaister for your help 🙏)

* Dynamically do keepPreviousData

* Gracefully handle errors for add prompt

* Use animated ai icon while message is loading

* using Sheet component

* Address commernts

* Bit more improvements

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
2023-11-29 17:12:50 +08:00
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00