Files
PaperClipAI/ui/src/pages/apps/app-detail/AdvancedPanel.tsx
T
DottaandClaude Opus 5.5 8b616b949d fix(connections): drop MCP wording and the MCP guide link from Google Workspace setup (#22793)
<!-- Write all pull request text in Simplified Technical English
(ASD-STE100): short sentences, one instruction per sentence, simple
approved vocabulary, and the active voice. -->

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents use Google Workspace through the built-in Google Workspace
connection
> - Since #22634, Gmail, Drive, Docs, Sheets, Slides, and Calendar run
on Paperclip's own REST tools, not on Google's hosted MCP servers
> - The connect screen still showed "Secure MCP sign-in" and a "Review
requirements" link to Google's MCP servers guide
> - This text is wrong for this connection, it is internal jargon, and
Google's OAuth reviewers read this screen
> - This pull request removes the MCP wording and the MCP guide link
from Google Workspace setup and from its audit details
> - The benefit is that users and reviewers see only true, plain text
for this connection

## Linked Issues or Issue Description

Refs #22634

**What happened?**

On a Cloud workspace, the Google Workspace connect page showed the
subtitle "Secure MCP sign-in" while the sign-in opened and after it
failed to open. The setup page also showed a "Review requirements" link
to `developers.google.com/workspace/guides/configure-mcp-servers`. On a
self-hosted instance, the "How to set up a Google OAuth client" link
went to the same MCP servers guide. Audit details for a Google REST call
showed "Transport: mcp_remote" and "MCP method: tools/call".

**What did you expect to happen?**

The connect page says "Secure sign-in". The Paperclip-managed method on
Cloud has no requirements link, because the user has no requirements to
review. On a self-hosted instance, the customer-owned client method
links to Google's OAuth client guide. Audit details for a Google REST
call do not show MCP terms.

**Steps to reproduce**

1. Turn on the Google Workspace connector in **Settings →
Experimental**.
2. Open **Apps** and choose **Google Workspace**.
3. Start the sign-in, then close or block the sign-in window.
4. Before this change: the header shows "Secure MCP sign-in", and the
setup step shows "Review requirements" with a link to Google's MCP
servers guide.

## What Changed

- `ui/src/features/connections/ConnectionSetupFlow.tsx`:
`OAuthConnectStateScreen` shows "Secure sign-in" for a curated app. A
server that the user pasted as an MCP server keeps "Secure MCP sign-in".
This is generic: there is no Google-specific code.
- `packages/shared/src/app-definitions/google-workspace.json`: remove
the top-level `docsUrl` (the MCP servers guide). The Paperclip-managed
method now has no "Review requirements" link. The customer-owned
method's `consoleLinks.docs` is now Google's OAuth client guide
(`create-credentials#oauth-client-id`). The "Review requirements" link
and the self-hosted "How to set up a Google OAuth client" link both use
it. Its guidance text names the Gmail, Drive, Docs, Sheets, Slides, and
Calendar APIs instead of "the Google Workspace MCP APIs". This file is a
reviewed definition: `scripts/ingest-app-definitions.mjs` copies it
as-is, so a regeneration keeps the fix.
- `server/src/services/tool-gateway.ts`: an audit record for a Google
Workspace REST call no longer has `mcpMethod`.
- `ui/src/pages/tools/AuditTab.tsx`: audit details show the connection
type label ("Remote HTTP") as "Type" instead of the raw `mcp_remote`
value. This uses the same label as the connection's "Connection
details".
- `doc/connections/GOOGLE-WORKSPACE.md`: the self-hosted section links
Google's OAuth client guide.
- `tests/runner-e2e/source-sdk-public-inputs.json`: refreshed pinned
inputs.

## Verification

- Red first, then green:
- `packages/shared/src/google-workspace-setup-links.test.ts`: no Google
Workspace method links the MCP servers guide, the managed method has no
requirements link, the customer method links the OAuth client guide, and
method text has no "MCP". It failed 4/4 before the fix.
- `ui/src/features/connections/OAuthConnectStateScreen.google.test.tsx`:
in the preparing, opening, and "couldn't open the sign-in window"
states, the Google Workspace screen shows "Secure sign-in", no "MCP",
and no link to `configure-mcp-servers`. A pasted server keeps "Secure
MCP sign-in". It failed 3/4 before the fix.
- `server/src/__tests__/google-workspace-rest-transport.test.ts`: the
Gmail REST audit record has no `mcpMethod`. It failed without the server
change.
- `npx vitest run` for shared app definition tests (67 passed),
`ui/src/pages/tools` and `ui/src/pages/apps/app-detail` (121 passed),
and the server REST transport file (53 passed).
- `tsc --noEmit` for `server` and `ui`: no new errors.
- `pnpm verify` exits 2 because a doc under `doc/connections` is a
global CI input. Required CI supplies the broad coverage.

## Risks

- Low risk. Text and link changes only, plus one optional audit field.
- Other curated OAuth apps now show "Secure sign-in" instead of "Secure
MCP sign-in" on the sign-in state screen. The new text is true for every
curated app.
- Audit details for all connectors show "Type: Remote HTTP" instead of
"Transport: mcp_remote".
- Saved Google Workspace connections still show
`https://workspacemcp.googleapis.com/mcp/v1` as the address in
"Connection details". It is the stored connection identity. This pull
request does not change stored data.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Claude Code agent with tool use
and code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 12:01:21 -06:00

633 lines
23 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useState } from "react";
import { useMutation } from "@tanstack/react-query";
import { ArrowUpRight, ChevronRight, Loader2, Lock } from "lucide-react";
import type {
AppDefinition,
ConnectionGrant,
GoogleWorkspaceServiceSelection,
ToolConnection,
ToolConnectionCredentialPolicy,
} from "@paperclipai/shared";
import { connectionCredentialConfigPath, credentialConfigPath, getAvailableConnectionMethod, humanizeConnectionDisplayName } from "@paperclipai/shared";
import { toolsApi } from "@/api/tools";
import { Button } from "@/components/ui/button";
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible";
import { Input } from "@/components/ui/input";
import { ToggleSwitch } from "@/components/ui/toggle-switch";
import { useToast } from "@/context/ToastContext";
import { redactUrlSecrets } from "@/lib/redact-url-secrets";
import { useAuthorizationWindow } from "@/hooks/useAuthorizationWindow";
import { cn } from "@/lib/utils";
import { connectionTransportLabel } from "@/lib/connection-transport-label";
import { Link } from "@/lib/router";
import type { AppDetailSectionProps } from "./types";
import { RevokeGrantDialog } from "./IdentitiesSection";
import { describeError } from "@/api/errors";
import { useGoogleWorkspaceServiceGate } from "@/features/connections/GoogleWorkspaceServices";
export function AdvancedPanel({
connection,
appName,
galleryEntry,
removing,
onRemove,
onReplaced,
canReplaceCredential = true,
credentialUnavailableMessage = "You don't have permission to replace this identity's credential.",
appToggleDisabled,
onToggleApp,
identityGrant = null,
identityCurrentUserId = null,
identityProviderName,
credentialPolicy,
identityActionPending = false,
onReconnectIdentity,
onRevokeIdentity,
}: Pick<AppDetailSectionProps, "connection" | "appName" | "galleryEntry"> & {
removing: boolean;
onRemove: () => void;
onReplaced: () => void;
canReplaceCredential?: boolean;
credentialUnavailableMessage?: string;
appToggleDisabled: boolean;
onToggleApp: () => void;
identityGrant?: ConnectionGrant | null;
identityCurrentUserId?: string | null;
identityProviderName?: string;
credentialPolicy?: ToolConnectionCredentialPolicy;
identityActionPending?: boolean;
onReconnectIdentity?: () => void;
onRevokeIdentity?: (grant: ConnectionGrant) => void;
}) {
return (
<div className="space-y-4 border-t border-border pt-8">
<TechnicalDetails connection={connection} />
<DangerZone
appName={appName}
connection={connection}
galleryEntry={galleryEntry}
removing={removing}
onRemove={onRemove}
onReplaced={onReplaced}
canReplaceCredential={canReplaceCredential}
credentialUnavailableMessage={credentialUnavailableMessage}
toggleDisabled={appToggleDisabled}
onToggleConnection={onToggleApp}
identityGrant={identityGrant}
identityCurrentUserId={identityCurrentUserId}
identityProviderName={identityProviderName ?? appName}
credentialPolicy={credentialPolicy}
identityActionPending={identityActionPending}
onReconnectIdentity={onReconnectIdentity}
onRevokeIdentity={onRevokeIdentity}
/>
</div>
);
}
function connectionMethodUnavailable(connection: ToolConnection, galleryEntry: AppDefinition | null): boolean {
const methodKey = connection.config?.connectionMethodKey;
return typeof methodKey === "string"
&& methodKey.length > 0
&& !!galleryEntry
&& Array.isArray(galleryEntry.methods)
&& !getAvailableConnectionMethod(galleryEntry, methodKey);
}
function KeySection({
connection,
galleryEntry,
onReplaced,
canReplace,
unavailableMessage,
}: {
connection: ToolConnection;
galleryEntry: AppDefinition | null;
onReplaced: () => void;
canReplace: boolean;
unavailableMessage: string;
}) {
const [open, setOpen] = useState(false);
return (
<section>
<div className="flex items-center justify-between">
<div className="flex items-start gap-3">
<Lock className="mt-0.5 h-4 w-4 text-muted-foreground" />
<div>
<h2 className="text-sm font-medium text-foreground">Reconnect</h2>
<p className="mt-0.5 text-xs text-muted-foreground">
{canReplace ? "Replace the stored credential." : unavailableMessage}
</p>
</div>
</div>
{canReplace && !open && (
<Button size="sm" variant="outline" onClick={() => setOpen(true)}>
Reconnect
</Button>
)}
</div>
{open && (
<div className="pt-4">
<ReconnectForm
connection={connection}
galleryEntry={galleryEntry}
onCancel={() => setOpen(false)}
onReconnected={() => {
setOpen(false);
onReplaced();
}}
/>
</div>
)}
</section>
);
}
export function ReconnectCard({
connection,
galleryEntry,
onReconnected,
onReconnect,
canReconnect = true,
reconnectUnavailableMessage,
}: {
connection: ToolConnection;
galleryEntry: AppDefinition | null;
onReconnected: () => void;
onReconnect?: () => void;
canReconnect?: boolean;
reconnectUnavailableMessage?: string;
}) {
const { pushToast } = useToast();
const authorization = useAuthorizationWindow();
const workspaceGate = useGoogleWorkspaceServiceGate();
const reconnectOAuth = useMutation({
// Reconnect is not a new identity choice. Personal-only connections must
// put the replacement token back on the signed-in user's existing grant;
// shared and legacy fallback connections keep using the organization slot.
mutationFn: (workspaceServices?: GoogleWorkspaceServiceSelection) => {
const services = workspaceServices ? { workspaceServices } : {};
return connection.credentialPolicy === "per_user"
? toolsApi.startOAuth(connection.id, { asCurrentUser: true, ...services })
: workspaceServices ? toolsApi.startOAuth(connection.id, services) : toolsApi.startOAuth(connection.id);
},
onSuccess: async (start) => {
try {
await authorization.open(start);
} catch (error) {
pushToast({
title: "Couldn’t start sign-in",
body: describeError(error).body,
tone: "error",
});
}
},
onError: (error) => {
authorization.cancel();
pushToast({
title: "Couldn’t start sign-in",
body: describeError(error).body,
tone: "error",
});
},
});
const verifyVercel = useMutation({
mutationFn: () => toolsApi.checkConnectionHealth(connection.id),
onSuccess: () => {
pushToast({
title: "Vercel credential verified",
body: `${humanizeConnectionDisplayName(connection)} is back online.`,
tone: "success",
});
onReconnected();
},
onError: (error) => pushToast({
title: "Credential still needs attention",
body: describeError(error).body,
tone: "error",
}),
});
const oauth = connection.authKind === "oauth";
const managedByVercel = connection.credentialSource === "vercel_connect";
const methodUnavailable = connectionMethodUnavailable(connection, galleryEntry);
return (
<div className="flex flex-col gap-4 rounded-lg border border-amber-500/50 bg-amber-500/10 px-4 py-3">
{authorization.fallback}
{workspaceGate.dialog}
<div className="min-w-0">
<h2 className="text-sm font-semibold text-amber-900 dark:text-amber-100">
{methodUnavailable ? "Connection no longer supported" : oauth ? "Reconnect required" : "This app needs reconnecting"}
</h2>
<p className="mt-0.5 text-sm text-amber-800 dark:text-amber-200">
{methodUnavailable
? "Add a supported connection from Connectors, then remove this connection."
: connection.healthMessage?.trim() || (oauth
? "Authorization expired or was revoked. Sign in again to restore access."
: "The key stopped working. Paste a new one to get it back online.")}
</p>
</div>
<div className="shrink-0">
{!canReconnect ? (
<p className="text-sm text-amber-800 dark:text-amber-200">
{reconnectUnavailableMessage ?? "You don't have permission to reconnect this identity."}
</p>
) : methodUnavailable ? (
<Button size="sm" variant="outline" asChild>
<Link to={`/apps/connect?source=${encodeURIComponent(galleryEntry!.slug)}`}>
Add supported connection
</Link>
</Button>
) : onReconnect ? (
<Button size="sm" variant="outline" onClick={onReconnect}>Reconnect</Button>
) : managedByVercel && !oauth ? (
<div className="flex items-center gap-2">
<Button type="button" size="sm" variant="outline" asChild>
<a href="https://vercel.com/connect" target="_blank" rel="noreferrer">
Manage in Vercel <ArrowUpRight className="ml-1.5 h-3.5 w-3.5" />
</a>
</Button>
<Button
type="button"
size="sm"
disabled={verifyVercel.isPending}
onClick={() => verifyVercel.mutate()}
>
{verifyVercel.isPending && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
Check again
</Button>
</div>
) : oauth ? (
<Button
type="button"
size="sm"
disabled={reconnectOAuth.isPending}
onClick={() => workspaceGate.run(connection, (services) => { authorization.reserve(); reconnectOAuth.mutate(services); })}
>
{reconnectOAuth.isPending && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
{reconnectOAuth.isPending ? "Opening sign-in…" : "Reconnect"}
</Button>
) : (
<ReconnectForm connection={connection} galleryEntry={galleryEntry} onReconnected={onReconnected} />
)}
</div>
</div>
);
}
function ReconnectForm({
connection,
galleryEntry,
onCancel,
onReconnected,
}: {
connection: ToolConnection;
galleryEntry: AppDefinition | null;
onCancel?: () => void;
onReconnected: () => void;
}) {
const { pushToast } = useToast();
const methodKey = typeof connection.config?.connectionMethodKey === "string"
? connection.config.connectionMethodKey
: null;
const method = galleryEntry && Array.isArray(galleryEntry.methods)
? getAvailableConnectionMethod(galleryEntry, methodKey)
: null;
const galleryFields = (method?.credentialFields ?? []).map((field) => ({
...field,
configPath: credentialConfigPath(field, method),
helpUrl: method?.consoleLinks?.keys ?? method?.consoleLinks?.docs ?? "",
}));
const fields = galleryFields.length > 0 ? galleryFields : (connection.credentialRefs ?? [])
.filter((ref) => ref.placement === "header" || ref.placement === "url")
.map((ref) => ({
configPath: connectionCredentialConfigPath(ref),
label: ref.placement === "url" ? "MCP server URL" : ref.prefix === "Bearer " ? "App key" : ref.key ?? ref.name,
helpUrl: "",
required: true,
}));
const [values, setValues] = useState<Record<string, string>>({});
const [single, setSingle] = useState("");
const usesFields = fields.length > 0;
const reconnect = useMutation({
mutationFn: () => {
const credentialValues = usesFields
? values
: { "credentials.authorization": single.trim() };
return toolsApi.reconnectConnection(connection.id, credentialValues);
},
onSuccess: (result) => {
const healthy =
result.connection.healthStatus === "ok" || result.connection.healthStatus === "healthy" || result.connection.healthStatus === "unknown";
if (healthy) {
pushToast({
title: "Reconnected",
body: `${humanizeConnectionDisplayName(connection)} is back online.`,
tone: "success",
});
onReconnected();
} else {
pushToast({
title: "Still not working",
body: result.connection.healthMessage?.trim() || "That key didn't check out. Try another.",
tone: "error",
});
}
},
onError: (error) =>
pushToast({
title: "That key didn't work",
body: describeError(error).body,
tone: "error",
}),
});
const filled = usesFields
? fields.every((f) => f.required === false || (values[f.configPath]?.trim().length ?? 0) > 0)
: single.trim().length > 0;
if (connection.credentialSource === "vercel_connect") {
return (
<p className="text-sm text-muted-foreground">
Credentials for this connection are managed in Vercel Connect.
</p>
);
}
return (
<div className="space-y-3">
{usesFields ? (
fields.map((field) => (
<div key={field.configPath}>
<label className="text-xs font-medium text-foreground">{field.label}</label>
<Input
type="password"
aria-label={field.label}
autoComplete="off"
value={values[field.configPath] ?? ""}
onChange={(e) => setValues({ ...values, [field.configPath]: e.target.value })}
placeholder="****************"
className="mt-1 h-10 font-mono"
/>
{field.helpUrl && (
<a
href={field.helpUrl}
target="_blank"
rel="noreferrer"
className="mt-1 inline-flex items-center gap-1 text-xs font-semibold text-foreground underline underline-offset-2"
>
Where do I find this? <ArrowUpRight className="h-3 w-3" />
</a>
)}
</div>
))
) : (
<Input
type="password"
aria-label="App key"
autoComplete="off"
value={single}
onChange={(e) => setSingle(e.target.value)}
placeholder="Paste your new key"
className="h-10 font-mono"
/>
)}
<div className="flex items-center gap-2">
<Button size="sm" disabled={!filled || reconnect.isPending} onClick={() => reconnect.mutate()}>
{reconnect.isPending && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
{reconnect.isPending ? "Checking..." : "Check & reconnect"}
</Button>
{onCancel && (
<Button size="sm" variant="ghost" onClick={onCancel} disabled={reconnect.isPending}>
Cancel
</Button>
)}
</div>
</div>
);
}
function TechnicalDetails({ connection }: { connection: ToolConnection }) {
const [open, setOpen] = useState(false);
return (
<Collapsible open={open} onOpenChange={setOpen} asChild>
<section>
<CollapsibleTrigger asChild>
<button type="button" className="flex w-full items-center gap-3 py-1 text-left">
<span className="min-w-0 flex-1 text-sm font-medium text-foreground">Connection details</span>
<ChevronRight
className={cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform", open && "rotate-90")}
/>
</button>
</CollapsibleTrigger>
<CollapsibleContent>
<dl className="mt-4 grid gap-2 pb-2 text-xs sm:grid-cols-(--gtc-59)">
<dt className="text-muted-foreground">Address</dt>
<dd className="break-all font-mono text-foreground">{connectionAddress(connection)}</dd>
<dt className="text-muted-foreground">Type</dt>
<dd className="text-foreground">{connectionTransportLabel(connection.transport)}</dd>
</dl>
</CollapsibleContent>
</section>
</Collapsible>
);
}
export function DangerZone({
appName,
connection,
galleryEntry = null,
removing,
onRemove,
onReplaced,
canReplaceCredential = true,
credentialUnavailableMessage = "You don't have permission to replace this identity's credential.",
toggleDisabled = false,
onToggleConnection,
identityGrant = null,
identityCurrentUserId = null,
identityProviderName = appName,
credentialPolicy,
identityActionPending = false,
onReconnectIdentity,
onRevokeIdentity,
}: {
appName: string;
connection?: ToolConnection;
galleryEntry?: AppDefinition | null;
removing: boolean;
onRemove: () => void;
onReplaced?: () => void;
canReplaceCredential?: boolean;
credentialUnavailableMessage?: string;
toggleDisabled?: boolean;
onToggleConnection?: () => void;
identityGrant?: ConnectionGrant | null;
identityCurrentUserId?: string | null;
identityProviderName?: string;
credentialPolicy?: ToolConnectionCredentialPolicy;
identityActionPending?: boolean;
onReconnectIdentity?: () => void;
onRevokeIdentity?: (grant: ConnectionGrant) => void;
}) {
const [open, setOpen] = useState(false);
const [confirming, setConfirming] = useState(false);
const [revokeTarget, setRevokeTarget] = useState<ConnectionGrant | null>(null);
const paused = connection
? connection.enabled === false || connection.status === "disabled"
: false;
const methodUnavailable = connection ? connectionMethodUnavailable(connection, galleryEntry) : false;
return (
<Collapsible
open={open}
onOpenChange={(nextOpen) => {
setOpen(nextOpen);
if (!nextOpen) setConfirming(false);
}}
asChild
>
<section>
<CollapsibleTrigger asChild>
<button
type="button"
className="flex w-full items-center gap-3 py-1 text-left"
>
<span className="min-w-0 flex-1 text-sm font-medium text-destructive">Danger zone</span>
<ChevronRight
className={cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform", open && "rotate-90")}
/>
</button>
</CollapsibleTrigger>
<CollapsibleContent>
<div className="mt-3 divide-y divide-border border-t border-border">
{connection && onToggleConnection ? (
<div className="flex items-center justify-between gap-4 py-4">
<h2 className="text-sm font-medium text-foreground">Pause connection</h2>
<ToggleSwitch
aria-label="Pause connection"
checked={paused}
disabled={toggleDisabled}
onCheckedChange={onToggleConnection}
size="lg"
/>
</div>
) : null}
{connection && !methodUnavailable && connection.authKind !== "oauth" ? (
<div className="py-4">
<KeySection
connection={connection}
galleryEntry={galleryEntry}
onReplaced={onReplaced ?? (() => undefined)}
canReplace={canReplaceCredential}
unavailableMessage={credentialUnavailableMessage}
/>
</div>
) : null}
{connection?.authKind === "oauth" && !methodUnavailable && (onReconnectIdentity || !canReplaceCredential) ? (
<div className="flex flex-wrap items-center justify-between gap-3 py-4">
<div>
<p className="text-sm font-medium text-foreground">Reconnect</p>
<p className="text-xs text-muted-foreground">
{canReplaceCredential
? `Sign in to ${identityProviderName} again.`
: credentialUnavailableMessage}
</p>
</div>
{canReplaceCredential && onReconnectIdentity ? (
<Button
size="sm"
variant="outline"
disabled={identityActionPending}
onClick={onReconnectIdentity}
>
{identityActionPending ? <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" /> : null}
Reconnect
</Button>
) : null}
</div>
) : null}
{identityGrant?.capabilities?.canRevoke
&& identityGrant.status !== "revoked"
&& onRevokeIdentity ? (
<div className="flex flex-wrap items-center justify-between gap-3 py-4">
<div>
<p className="text-sm font-medium text-foreground">Revoke identity</p>
<p className="text-xs text-muted-foreground">
Disconnect the identity currently used by this app.
</p>
</div>
<Button
variant="destructive"
size="sm"
onClick={() => setRevokeTarget(identityGrant)}
>
Revoke
</Button>
</div>
) : null}
<div className="flex flex-wrap items-center justify-between gap-3 py-4">
<div>
<p className="text-sm font-medium text-foreground">Remove this app</p>
<p className="text-xs text-muted-foreground">
{`Deletes credentials for ${appName} and removes agent access. Reconnecting requires a new sign-in or key.`}
</p>
</div>
{confirming ? (
<div className="flex items-center gap-2">
<Button variant="ghost" size="sm" onClick={() => setConfirming(false)} disabled={removing}>
Cancel
</Button>
<Button variant="destructive" size="sm" onClick={onRemove} disabled={removing}>
{removing && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
Yes, remove it
</Button>
</div>
) : (
<Button variant="destructive" size="sm" onClick={() => setConfirming(true)}>
Remove app
</Button>
)}
</div>
</div>
</CollapsibleContent>
{revokeTarget && credentialPolicy ? (
<RevokeGrantDialog
grant={revokeTarget}
providerName={identityProviderName}
pending={identityActionPending}
credentialPolicy={credentialPolicy}
isOwnIdentity={revokeTarget.kind === "user" && revokeTarget.subjectUserId === identityCurrentUserId}
onCancel={() => setRevokeTarget(null)}
onConfirm={() => {
onRevokeIdentity?.(revokeTarget);
setRevokeTarget(null);
}}
/>
) : null}
</section>
</Collapsible>
);
}
export function connectionAddress(connection: ToolConnection): string {
const config = connection.config ?? connection.transportConfig ?? {};
const value = config.url ?? config.endpoint ?? config.remoteUrl;
if (typeof value === "string" && value.trim().length > 0) return redactUrlSecrets(value);
if (connection.transport === "local_stdio") return "Local command";
return "Not set";
}
export { connectionTransportLabel };