From c0d86dee6fdfb9882eded4f5c7c4d9669bd49c6c Mon Sep 17 00:00:00 2001 From: kjgbot Date: Sun, 15 Nov 2026 23:36:11 -0800 Subject: [PATCH 1/4] fix(connections): show verified authorization and explain retryable unknowns --- src/admin/contracts.ts | 6 ++- src/flows/flow-connections.test.tsx | 60 ++++++++++++++++++++++++ src/flows/flow-connections.tsx | 73 +++++++++++++++++++++++++++-- 3 files changed, 134 insertions(+), 5 deletions(-) diff --git a/src/admin/contracts.ts b/src/admin/contracts.ts index 4207aa2..aeb442c 100644 --- a/src/admin/contracts.ts +++ b/src/admin/contracts.ts @@ -233,10 +233,14 @@ export const integrationProviderSchema = z.object({ credentialFields: z.array(z.object({ key: z.string(), label: z.string(), secret: z.boolean(), required: z.boolean(), placeholder: z.string().optional() })).optional(), connection: z.object({ status: z.enum(["ready", "error"]), + authorizationStatus: z.enum(["active", "inactive", "unknown"]).optional(), + authorizationReason: z.string().optional(), + authorizationCheckedAt: z.string().optional(), + upstreamConnected: z.boolean().nullable().optional(), connectionId: z.string().optional(), version: z.string().optional(), providerConfigKey: nullableText, - authMode: z.enum(["oauth2", "api_key"]).optional(), + authMode: z.enum(["oauth2", "api_key", "github_app"]).optional(), accountLabel: nullableText, scopes: z.array(z.string()).optional(), connectedAt: nullableText, diff --git a/src/flows/flow-connections.test.tsx b/src/flows/flow-connections.test.tsx index a843d4f..2df07f6 100644 --- a/src/flows/flow-connections.test.tsx +++ b/src/flows/flow-connections.test.tsx @@ -127,3 +127,63 @@ it("sends expired refreshes through sign-in recovery with a visible error", asyn await screen.findByText(/Your session has expired/), ).toBeInTheDocument(); }); + +it("requires actual authorization proof and explains a retryable unknown", async () => { + api.integrationProviders.mockResolvedValueOnce({ + providers: [ + { + ...providers[0], + connection: { + ...providers[0].connection, + authorizationStatus: "unknown", + authorizationReason: "check_timed_out", + authorizationCheckedAt: "2026-11-16T07:00:00Z", + }, + }, + ], + canManage: true, + }); + render(); + await screen.findByText("Authorization unverified"); + expect(screen.queryByText("Ready")).not.toBeInTheDocument(); + expect( + screen.getByText("The provider check timed out. Use Refresh to retry."), + ).toBeInTheDocument(); + api.integrationProviders.mockResolvedValueOnce({ + providers: [ + { + ...providers[0], + connection: { + ...providers[0].connection, + authorizationStatus: "active", + authorizationReason: "provider_verified", + authorizationCheckedAt: "2026-11-16T07:01:00Z", + }, + }, + ], + canManage: true, + }); + fireEvent.click(screen.getByRole("button", { name: "Refresh" })); + await screen.findByText("Ready"); + expect(screen.getByText("Verified with the provider.")).toBeInTheDocument(); +}); +it("keeps a sync failure visible even when authorization has been verified", async () => { + api.integrationProviders.mockResolvedValueOnce({ + providers: [ + { + ...providers[0], + connection: { + ...providers[0].connection, + status: "error", + authorizationStatus: "active", + authorizationReason: "provider_verified", + }, + }, + ], + canManage: true, + }); + render(); + await screen.findByText("Needs attention"); + expect(screen.getByText("Active")).toBeInTheDocument(); + expect(screen.getByText("Verified with the provider.")).toBeInTheDocument(); +}); diff --git a/src/flows/flow-connections.tsx b/src/flows/flow-connections.tsx index 5495c7e..5233131 100644 --- a/src/flows/flow-connections.tsx +++ b/src/flows/flow-connections.tsx @@ -15,7 +15,7 @@ export type IntegrationListEntry = { connectionId?: string; version?: string; providerConfigKey: string | null; - authMode?: "oauth2" | "api_key"; + authMode?: "oauth2" | "api_key" | "github_app"; accountLabel?: string | null; scopes?: string[]; lastEventAt?: string | null; @@ -23,6 +23,9 @@ export type IntegrationListEntry = { name?: string; inherited?: boolean; upstreamConnected?: boolean | null; + authorizationStatus?: "active" | "inactive" | "unknown"; + authorizationReason?: string; + authorizationCheckedAt?: string; }; import s from "./flow-connections.module.css"; @@ -33,8 +36,37 @@ export function connectionAuthLabel( ? "OAuth" : entry.authMode === "api_key" ? "Access token" - : "Not recorded"; + : entry.authMode === "github_app" + ? "App credentials" + : "Not recorded"; } + +export function authorizationExplanation(reason?: string): string { + const explanations: Record = { + provider_verified: "Verified with the provider.", + backend_verified: "Verified by the connection service.", + credentials_rejected: + "The provider rejected these credentials. Reconnect to restore access.", + connection_missing: "This connection is missing at the connection service.", + insufficient_permissions: + "The provider refused the verification check. Check permissions, then Refresh.", + rate_limited: + "The provider limited this check. Wait a moment, then Refresh.", + check_timed_out: "The provider check timed out. Use Refresh to retry.", + checks_busy: "Connection checks are busy. Use Refresh to retry.", + unsupported_provider: + "Automatic verification is not available for this provider yet.", + unexpected_response: + "The provider response could not confirm authorization. Use Refresh to retry.", + credentials_unavailable: + "Credentials could not be checked. Use Refresh to retry.", + }; + return ( + explanations[reason ?? ""] ?? + "Authorization could not be checked. Use Refresh to retry." + ); +} + function label(entry: IntegrationListEntry) { return entry.displayName; } @@ -82,10 +114,13 @@ function state(entry: IntegrationListEntry): { } { if (entry.upstreamConnected === false) return { label: "Disconnected upstream", variant: "warning" }; - if (entry.status === "ready") - return { label: "Connected", variant: "success" }; + if (entry.authorizationStatus === "inactive") + return { label: "Authorization expired", variant: "warning" }; if (["error", "degraded"].includes(entry.status)) return { label: "Needs attention", variant: "warning" }; + if (entry.authorizationStatus !== "active") + return { label: "Authorization unverified", variant: "default" }; + if (entry.status === "ready") return { label: "Ready", variant: "success" }; if (entry.status === "syncing") return { label: "Syncing", variant: "default" }; return { label: "Status unverified", variant: "default" }; @@ -138,6 +173,10 @@ function ConnectionsView({ displayName: provider.displayName, connectionLabel: c.metadata?.displayName, status: c.status, + upstreamConnected: c.upstreamConnected, + authorizationStatus: c.authorizationStatus, + authorizationReason: c.authorizationReason, + authorizationCheckedAt: c.authorizationCheckedAt, connectionId: c.connectionId, version: c.version, providerConfigKey: c.providerConfigKey ?? null, @@ -342,6 +381,32 @@ function ConnectionsView({
Permissions
{entry.scopes?.join(", ") || "Not recorded"}
+
+
Authorization
+
+ {entry.authorizationStatus === "active" + ? "Active" + : entry.authorizationStatus === "inactive" + ? "Inactive" + : "Unverified"} +
+
+
+
Authorization check
+
+ {authorizationExplanation(entry.authorizationReason)} +
+
+
+
Checked
+
+ {entry.authorizationCheckedAt + ? new Date( + entry.authorizationCheckedAt, + ).toLocaleString() + : "Not checked"} +
+
{entry.inherited ? (

From 792e0d5711a8fe78994c8761e5196de9f837ec6d Mon Sep 17 00:00:00 2001 From: kjgbot Date: Sun, 15 Nov 2026 23:47:11 -0800 Subject: [PATCH 2/4] fix(connections): describe inactive authorization without assuming expiry --- src/flows/flow-connections.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flows/flow-connections.tsx b/src/flows/flow-connections.tsx index 5233131..d3351b8 100644 --- a/src/flows/flow-connections.tsx +++ b/src/flows/flow-connections.tsx @@ -115,7 +115,7 @@ function state(entry: IntegrationListEntry): { if (entry.upstreamConnected === false) return { label: "Disconnected upstream", variant: "warning" }; if (entry.authorizationStatus === "inactive") - return { label: "Authorization expired", variant: "warning" }; + return { label: "Authorization inactive", variant: "warning" }; if (["error", "degraded"].includes(entry.status)) return { label: "Needs attention", variant: "warning" }; if (entry.authorizationStatus !== "active") From 0b087d18417339c136309165e8ca06bdec01ecac Mon Sep 17 00:00:00 2001 From: kjgbot Date: Sun, 15 Nov 2026 23:58:05 -0800 Subject: [PATCH 3/4] test(connections): distinguish rejected credentials from saved presence --- src/flows/flow-connections.test.tsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/flows/flow-connections.test.tsx b/src/flows/flow-connections.test.tsx index 2df07f6..83803f3 100644 --- a/src/flows/flow-connections.test.tsx +++ b/src/flows/flow-connections.test.tsx @@ -187,3 +187,28 @@ it("keeps a sync failure visible even when authorization has been verified", asy expect(screen.getByText("Active")).toBeInTheDocument(); expect(screen.getByText("Verified with the provider.")).toBeInTheDocument(); }); + +it("shows inactive authorization for a present saved credential rejected by the provider", async () => { + api.integrationProviders.mockResolvedValueOnce({ + providers: [ + { + ...providers[0], + connection: { + ...providers[0].connection, + upstreamConnected: true, + authorizationStatus: "inactive", + authorizationReason: "credentials_rejected", + }, + }, + ], + canManage: true, + }); + render(); + await screen.findByText("Authorization inactive"); + expect(screen.queryByText("Ready")).not.toBeInTheDocument(); + expect( + screen.getByText( + "The provider rejected these credentials. Reconnect to restore access.", + ), + ).toBeInTheDocument(); +}); From 82a0c8ccb5f4467b670f12228bcce6c4dcb9e98e Mon Sep 17 00:00:00 2001 From: kjgbot Date: Mon, 16 Nov 2026 11:38:06 -0800 Subject: [PATCH 4/4] fix(connections): bypass cached proof on explicit Refresh --- src/admin/api.ts | 4 ++-- src/flows/flow-connections.test.tsx | 1 + src/flows/flow-connections.tsx | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/admin/api.ts b/src/admin/api.ts index 71661f4..ea9d302 100644 --- a/src/admin/api.ts +++ b/src/admin/api.ts @@ -194,8 +194,8 @@ export const adminApi = { }), /** Integration status for just-in-time connects (flows, CLI). */ - integrationProviders: (workspace: string, signal?: AbortSignal) => - call(`${ws(workspace)}/integrations/providers`, integrationProvidersSchema, { signal }), + integrationProviders: (workspace: string, signal?: AbortSignal, refreshAuthorization = false) => + call(`${ws(workspace)}/integrations/providers${refreshAuthorization ? "?refreshAuthorization=true" : ""}`, integrationProvidersSchema, { signal }), disconnectIntegration: (workspace: string, provider: string, connectionId?: string, version?: string) => { const query = new URLSearchParams({ ...(connectionId ? { connectionId } : {}), ...(version ? { version } : {}) }); return call(`${ws(workspace)}/integrations/${enc(provider)}${query.size ? `?${query}` : ""}`, null, { method: "DELETE" }); diff --git a/src/flows/flow-connections.test.tsx b/src/flows/flow-connections.test.tsx index 83803f3..5d4074b 100644 --- a/src/flows/flow-connections.test.tsx +++ b/src/flows/flow-connections.test.tsx @@ -165,6 +165,7 @@ it("requires actual authorization proof and explains a retryable unknown", async }); fireEvent.click(screen.getByRole("button", { name: "Refresh" })); await screen.findByText("Ready"); + expect(api.integrationProviders).toHaveBeenLastCalledWith("workspace", undefined, true); expect(screen.getByText("Verified with the provider.")).toBeInTheDocument(); }); it("keeps a sync failure visible even when authorization has been verified", async () => { diff --git a/src/flows/flow-connections.tsx b/src/flows/flow-connections.tsx index d3351b8..a2355fd 100644 --- a/src/flows/flow-connections.tsx +++ b/src/flows/flow-connections.tsx @@ -53,6 +53,11 @@ export function authorizationExplanation(reason?: string): string { rate_limited: "The provider limited this check. Wait a moment, then Refresh.", check_timed_out: "The provider check timed out. Use Refresh to retry.", + authorization_inactive: "The backend reports authorization is inactive. Reconnect to restore access.", + provider_unavailable: "The provider is unavailable. Use Refresh to retry.", + backend_unavailable: "The connection backend is unavailable. Use Refresh to retry.", + backend_status_unknown: "The backend could not confirm authorization. Use Refresh to retry.", + not_checked: "This saved connection is missing information required for a check.", checks_busy: "Connection checks are busy. Use Refresh to retry.", unsupported_provider: "Automatic verification is not available for this provider yet.", @@ -162,8 +167,8 @@ function ConnectionsView({ const busy = useRef(false); const generation = useRef(0); - async function load(signal?: AbortSignal) { - const result = await adminApi.integrationProviders(workspaceId, signal); + async function load(signal?: AbortSignal, refreshAuthorization = false) { + const result = await adminApi.integrationProviders(workspaceId, signal, refreshAuthorization); return result.providers.flatMap((provider) => { const c = provider.connection; return c @@ -219,7 +224,7 @@ function ConnectionsView({ setError(null); setConfirm(null); try { - const result = await load(); + const result = await load(undefined, true); if (mine === generation.current) setEntries(result); } catch (failure) { if (mine === generation.current) setError(message(failure));