• Will Chen's avatar
    Multi supabase accounts (#2014) · c4ee578c
    Will Chen 提交于
    Fixes #527 
    
    <!-- CURSOR_SUMMARY -->
    > [!NOTE]
    > Enables org-scoped Supabase connectivity across the app with
    per-organization tokens and org-aware project/branch/logs/function
    operations.
    > 
    > - DB: migration `0019` adds `apps.supabase_organization_slug`; drizzle
    schema updated
    > - Settings/schema: introduce
    `supabase.organizations{slug->{tokens,...}}`; helper
    `isSupabaseConnected`; encrypt/decrypt per-org tokens
    > - OAuth: `handleSupabaseOAuthReturn` now stores credentials under the
    detected organization
    > - IPC: new channels `supabase:list-organizations`,
    `supabase:delete-organization`, `supabase:list-all-projects`; existing
    branches/logs/set/unset handlers accept `organizationSlug`; preload
    allowlist and ipc_client updated
    > - Supabase management: clients selectable per organization; all calls
    (projects, branches, logs, SQL, deploy/delete/bulk-update functions,
    context/client code) accept `organizationSlug`
    > - UI/hooks: `SupabaseConnector` and `SupabaseIntegration` list/manage
    organizations, group projects by org, persist org on selection, and
    handle org-scoped branch switching; `useSupabase` adds org state and
    org-aware loaders; preview panel loads edge logs with org
    > - Misc: AGENTS.md adds database/migrations guidance; minor test
    fixture tweak
    > 
    > <sup>Written by [Cursor
    Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
    402bb2cd357dfd9c5d4de28ee68cb4719ca75a51. This will update automatically
    on new commits. Configure
    [here](https://cursor.com/dashboard?tab=bugbot).</sup>
    <!-- /CURSOR_SUMMARY -->
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    <!-- This is an auto-generated description by cubic. -->
    ---
    ## Summary by cubic
    Adds multi-organization Supabase support so you can connect multiple
    orgs, pick projects by org, and manage tokens per org. Updates UI,
    settings, IPC, and the app schema to store organization context with
    each connected project.
    
    - **New Features**
    - Connect multiple Supabase organizations; list, add, and delete
    organizations.
    - Project picker groups projects by organization; selection persists
    organizationSlug on the app.
    - Branch switching keeps the selected organization context; “Disconnect
    Project” still works.
    - Per-organization token storage and refresh; new IPC:
    supabase:list-organizations, supabase:delete-organization,
    supabase:list-all-projects.
    - Settings shows connected organizations and “Disconnect All”; legacy
    single-account flows continue to work.
    
    - **Migration**
    - Apply SQL migration 0019 to add supabase_organization_slug to the apps
    table.
    
    <sup>Written for commit 402bb2cd357dfd9c5d4de28ee68cb4719ca75a51.
    Summary will update automatically on new commits.</sup>
    
    <!-- End of auto-generated description by cubic. -->
    c4ee578c
ipc_client.ts 40.4 KB