Project picker names the connected Supabase organization, and says to change it on the approval page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minimus7andClaude Opus 5.5 committed 2026-11-09 12:11:40 -06:00
1 parent c7df0dba8f
commit cb56fd11a0
3 files changed
+18 -4

No files matched your search

+3 -2
View File
@@ -1,7 +1,7 @@
import { NextResponse } from "next/server";
import { sameOrigin, setupAccess } from "@/lib/setup";
import { fillFrom } from "@/lib/supabase-fill";
import { accountConnected, createProject, listProjects } from "@/lib/supabase-mcp";
import { accountConnected, createProject, listOrgs, listProjects } from "@/lib/supabase-mcp";
const LOOPBACK = /^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/;
const local = async (request: Request) => LOOPBACK.test(request.headers.get("host") ?? "") && (await setupAccess()).allowed && accountConnected();
@@ -11,7 +11,8 @@ const local = async (request: Request) => LOOPBACK.test(request.headers.get("hos
export async function GET(request: Request) {
if (!(await local(request))) return NextResponse.json({ error: "Only on this computer, after Connect Supabase." }, { status: 403 });
try {
return NextResponse.json({ projects: await listProjects() });
const [projects, orgs] = await Promise.all([listProjects(), listOrgs()]);
return NextResponse.json({ projects, orgs: orgs.map((o) => o.name) });
} catch (e) {
console.error("[broke] supabase projects:", e instanceof Error ? e.message : e);
return NextResponse.json({ error: "Couldn't list your Supabase projects. Press Connect Supabase again." }, { status: 502 });
+5 -2
View File
@@ -214,10 +214,11 @@ type Project = { id: string; name: string; region?: string; status?: string };
// public key and creates the tables (POST /api/setup/supabase/project).
export function ProjectPicker({ onDone }: { onDone: () => void }) {
const [projects, setProjects] = useState<Project[] | null>(null);
const [orgs, setOrgs] = useState<string[]>([]);
const [busy, setBusy] = useState<string | null>(null);
const [msg, setMsg] = useState("");
useEffect(() => {
fetch("/api/setup/supabase/project").then((r) => r.json()).then((b: { projects?: Project[]; error?: string }) => (b.error ? setMsg(b.error) : setProjects(b.projects ?? []))).catch(() => setMsg("Couldn't reach broke. Is it still running?"));
fetch("/api/setup/supabase/project").then((r) => r.json()).then((b: { projects?: Project[]; orgs?: string[]; error?: string }) => { if (b.error) setMsg(b.error); else { setProjects(b.projects ?? []); setOrgs(b.orgs ?? []); } }).catch(() => setMsg("Couldn't reach broke. Is it still running?"));
}, []);
async function use(body: { ref?: string; create?: boolean }, label: string) {
setBusy(label);
@@ -229,8 +230,10 @@ export function ProjectPicker({ onDone }: { onDone: () => void }) {
else setMsg(b?.error ?? "That didn't work. Try again.");
}
if (!projects && !msg) return <p className="text-sm text-muted">Finding your projects…</p>;
const where = orgs.length ? `Supabase organization${orgs.length > 1 ? "s" : ""} ${orgs.map((o) => `“${o}”`).join(", ")}` : "your Supabase account";
return (
<div className="space-y-3">
<p className="text-sm text-muted">{projects?.length ? `Projects in ${where}:` : `Connected to ${where}, which has no projects yet.`}</p>
{!!projects?.length && (
<ul className="space-y-2">
{projects.map((p) => (
@@ -247,7 +250,7 @@ export function ProjectPicker({ onDone }: { onDone: () => void }) {
{msg && <p className="text-sm text-bad">{msg}</p>}
<div className="pt-1 space-y-1">
<ConnectSupabaseButton onDone={onDone} fresh quiet label="Use a different Supabase organization" />
<p className="text-xs text-muted">Signs in to Supabase again, so you can choose the organization that has the project you want.</p>
<p className="text-xs text-muted">Signs in to Supabase again. On Supabase&apos;s approval page, change the organization to the one that has the project you want before you approve.</p>
</div>
</div>
);