Keep provider navigation visible in Connect account (#23602)

## Thinking Path

> - Paperclip helps people manage AI agents.
> - Agents use provider connections to run tasks.
> - People choose those providers in the Connect account dialog.
> - A selected provider needs a direct path back to the grid.
> - Two cards keep that path visible during sign-in.

## Linked Issues or Issue Description

**Subsystem affected**

Connect account dialog.

**Current behavior**

The grid entry disappears for some providers. A disabled Next button
takes up space during automatic sign-in.

**Proposed behavior**

Show the selected provider and Other Models together. Show a primary
action when the flow requires one.

## What Changed

- Added access to the provider grid from native and custom connection
forms.
- Hid the footer during automatic sign-in and retained explicit
connection actions.

## Verification

- Ran the two AgentProviderConnection test files. All 13 tests passed.

## Risks

- Switching to another provider leaves the current credential draft.

## Model Used

GPT-6 (Codex).
This commit is contained in:
Tonio authored and GitHub committed 2026-12-03 09:35:02 +00:00
1 parent 741bed6651
commit 24e095c160
6 files changed
+39 -20

No files matched your search

@@ -2,6 +2,8 @@ import { AI_CONNECTION_CAPABILITIES, adapterLoginCommandKey, pluginLoginChoices,
import { useMemo, useState, type ReactNode } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { type AiProvider, type AiAuthMethod, type AiConnectionLoginIntent } from "@paperclipai/shared";
import { AccountProviderTiles } from "../onboarding/ModelSourceTiles";
import { AppLogo } from "@/pages/apps/AppLogo";
import { AgentProviderConnection } from "@/components/new-agent/AgentProviderConnection";
import { ProviderApiKeyCard } from "@/components/AdapterLoginChrome";
import { Button } from "@/components/ui/button";
@@ -140,7 +142,7 @@ function SubscriptionConnectionStep({ defaultAccountDialog, providerDialog, onOt
</div>;
}
function ApiKeyConnectionStep({ providerDialog, advancedProviders, companyId, provider, connectionId, name: initialName, hideName, nameForMethod, ownership, agentIds, allAgents, environmentId: suppliedEnvironmentId, defaults, disabled, onComplete, onCancel }: Props) {
function ApiKeyConnectionStep({ providerDialog, onOtherModels, advancedProviders, companyId, provider, connectionId, name: initialName, hideName, nameForMethod, ownership, agentIds, allAgents, environmentId: suppliedEnvironmentId, defaults, disabled, onComplete, onCancel }: Props) {
const [name, setName] = useState(initialName);
const [apiKey, setApiKey] = useState("");
const client = useQueryClient();
@@ -157,6 +159,7 @@ function ApiKeyConnectionStep({ providerDialog, advancedProviders, companyId, pr
onSettled: () => setApiKey(""),
});
return <div className={providerDialog ? "w-full min-w-0 space-y-4" : "mx-auto w-full min-w-0 max-w-xl space-y-4"}>
{onOtherModels && <AccountProviderTiles source={{ id: provider, label: copilot ? "GitHub Copilot" : "OpenRouter", icon: <AppLogo name={copilot ? "GitHub Copilot" : "OpenRouter"} brandKey={provider} /> }} mode="api" onOtherModels={onOtherModels} />}
{!hideName && <label className="block space-y-2 text-sm">Connection name<Input value={name} onChange={(event) => setName(event.target.value)} disabled={Boolean(connectionId)} /></label>}
{save.error && <p role="alert" className="text-sm text-destructive">{describeError(save.error).body}</p>}
{copilot && <p className="text-sm text-muted-foreground">Use a personal fine-grained token with Copilot Requests permission. <a className="underline" href="https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli" target="_blank" rel="noreferrer">GitHub token instructions</a>. Verification discovers models in the selected environment and sends no model prompt. Repository access uses a separate connection.</p>}
@@ -168,6 +171,6 @@ function ApiKeyConnectionStep({ providerDialog, advancedProviders, companyId, pr
<ProviderApiKeyCard providerName={copilot ? "GitHub Copilot" : provider === "google" ? "Antigravity" : "OpenRouter"} value={apiKey} onChange={setApiKey} onSubmit={() => { if (!preparing && !environmentError && name.trim() && apiKey.trim()) save.mutate(); }} disabled={disabled || save.isPending || preparing || Boolean(environmentError)} placeholder={copilot ? "github_pat_..." : "Enter API key here"} autoFocus />
{defaults}
{advancedProviders}
<div className="flex justify-between gap-2"><Button variant="ghost" onClick={onCancel}>Cancel</Button><Button disabled={disabled || !name.trim() || !apiKey.trim() || save.isPending || preparing || Boolean(environmentError)} onClick={() => save.mutate()}>{save.isPending ? "Connecting…" : "Connect"}</Button></div>
<div className="flex justify-between gap-2">{!onOtherModels && <Button variant="ghost" onClick={onCancel}>Cancel</Button>}<Button className="ml-auto" disabled={disabled || !name.trim() || !apiKey.trim() || save.isPending || preparing || Boolean(environmentError)} onClick={() => save.mutate()}>{save.isPending ? "Connecting…" : "Connect"}</Button></div>
</div>;
}
@@ -294,15 +294,11 @@ export function AiConnectionField({
</div> :
<AiConnectionCredentialStep
defaultAccountDialog
onOtherModels={reconnecting ? undefined : () => showSetup(true)}
onOtherModels={() => { setReconnecting(undefined); showSetup(true); }}
defaults={!reconnecting && <label className="flex items-center gap-2 text-sm">
<Checkbox checked={allAgents} disabled={!accounts.data?.canManageConnections} onCheckedChange={(checked) => setAllAgents(checked === true)} />
Allow all agents in this company to use this account for my tasks
</label>}
advancedProviders={!reconnecting && provider !== "anthropic" && provider !== "openai" && <details>
<summary className="cursor-pointer text-sm text-muted-foreground">Advanced providers</summary>
<Button type="button" variant="ghost" onClick={() => showSetup(true)}>Choose another provider or gateway</Button>
</details>}
companyId={companyId}
provider={provider}
initialMethod={reconnecting?.method ?? method}
@@ -16,6 +16,7 @@ import { describeError } from "@/api/errors";
import { QueryErrorState, useQueryView } from "@/components/QueryView";
import { ConnectionChoiceList } from "@/features/connections/ConnectionChoiceList";
import { ConnectionAccessDefaults, connectionDefaultSummarySentence } from "@/features/connections/ConnectionSetupFlow";
import { AccountProviderTiles } from "../onboarding/ModelSourceTiles";
import { PluginTile } from "@/pages/apps/PluginMarketplace";
import { AppLogo } from "@/pages/apps/AppLogo";
import { Button } from "@/components/ui/button";
@@ -320,6 +321,7 @@ export function AiProviderSetup({
) : !advanced ? (
<AiConnectionCredentialStep
providerDialog={providerGrid}
onOtherModels={providerGrid ? cancel : undefined}
companyId={companyId}
provider={nativeProvider}
connectionId={reconnect?.id}
@@ -344,6 +346,7 @@ export function AiProviderSetup({
save.mutate();
}}
>
{providerGrid && provider && <AccountProviderTiles source={{ id: provider, label, icon: provider === "gateway" ? <Network /> : provider === "local" ? <Monitor /> : <AppLogo name={label} brandKey={aiConnectionCatalogSlug(provider)} /> }} mode={provider === "gateway" || provider === "local" ? "advanced" : "api"} onOtherModels={cancel} />}
{(provider === "gateway" || provider === "local") && (
<>
<label className="block space-y-2 text-xs text-muted-foreground">
@@ -458,15 +461,15 @@ export function AiProviderSetup({
</p>
)}
{accessDefaults}
<div className="flex items-center justify-between gap-3">
<Button
<div className={cn("flex items-center gap-3", providerGrid ? "justify-end" : "justify-between")}>
{!providerGrid && <Button
type="button"
variant="ghost"
onClick={cancel}
disabled={save.isPending}
>
Back
</Button>
</Button>}
<Button
type="submit"
disabled={
@@ -118,7 +118,8 @@ describe("Connect account dialog", () => {
flushSync(() => button("Sign in")!.click());
expect(open).toHaveBeenCalledOnce();
expect(button(waiting)?.disabled).toBe(true);
expect(button("Next")?.disabled).toBe(true);
expect(button("Next")).toBeUndefined();
expect(button("Back")).toBeUndefined();
expect(host.querySelector("a")).toBeNull();
} finally {
open.mockRestore();
@@ -4,7 +4,7 @@ import { aiConnectionsApi } from "@/api/ai-connections";
import { useLocalAiLogin } from "../ai-connections/useLocalAiLogin";
import type { AiConnectionBinding, AiConnectionLoginIntent } from "@paperclipai/shared";
import { useEffect, useRef, useState, type ReactNode } from "react";
import { Cable, Cpu, Loader2 } from "lucide-react";
import { Cable, Loader2 } from "lucide-react";
import { useQuery } from "@tanstack/react-query";
import { motion } from "motion/react";
import {
@@ -25,7 +25,7 @@ import {
} from "../AdapterLoginChrome";
import { Button } from "../ui/button";
import { ModelSourceMark } from "../onboarding/ModelSourceMark";
import { ModelSourceTiles, type ModelConnectionMode } from "../onboarding/ModelSourceTiles";
import { ModelSourceTiles, otherModelsTile, type ModelConnectionMode } from "../onboarding/ModelSourceTiles";
import { useQueryView } from "../QueryView";
import { CredentialModeLink } from "../onboarding/CredentialModeLink";
import { FooterNav } from "../onboarding/FooterNav";
@@ -306,8 +306,7 @@ export function AgentProviderConnection({
onBeforeRetry: () => setError(null),
});
const localLoginAction = localLoginPrimary.action;
const wizardCard = managedAccount?.defaultAccountDialog &&
(adapterType === "claude_local" || adapterType === "codex_local");
const wizardCard = managedAccount?.defaultAccountDialog;
const inlineLogin = Boolean((wizardCard || managedAccount?.providerDialog) && opened && method === "subscription");
const localReady = inlineLogin && !needsLogin && canUseLocalLogin && localLogin.status === "ready";
const autoSaved = useRef(false);
@@ -357,14 +356,14 @@ export function AgentProviderConnection({
label: provider,
icon: providerMark,
},
...(wizardCard && managedAccount?.onOtherModels ? [{ id: "other", label: "Other Models", icon: <Cpu className="size-5" /> }] : []),
...(managedAccount?.onOtherModels ? [otherModelsTile] : []),
]}
mode={advanced ? "advanced" : method}
selectedId={advancedConnection ? (advanced ? "advanced" : method) : opened ? adapterType : null}
collapsed={!managedAccount?.providerDialog && !wizardCard && !advancedConnection && opened}
onSelect={id => {
if (managedAccount?.disabled) return;
if (id === "other") { managedAccount?.onOtherModels?.(); return; }
if (managedAccount?.disabled) return;
if (advancedConnection) switchMode(id as ModelConnectionMode);
else setOpened(true);
}}
@@ -559,8 +558,8 @@ export function AgentProviderConnection({
)}
{managedAccount?.accessSettings && <div className="mt-6">{managedAccount.accessSettings}</div>}
{managedAccount?.advancedProviders && <div className="pt-2">{managedAccount.advancedProviders}</div>}
<FooterNav
onBack={() => {
{(!inlineLogin || (localReady && error)) && <FooterNav
onBack={managedAccount?.onOtherModels || managedAccount?.defaultAccountDialog || managedAccount?.providerDialog ? undefined : () => {
if (opened && !advancedConnection) {
localLoginPrimary.resetSubmitting();
cancel();
@@ -627,7 +626,7 @@ export function AgentProviderConnection({
return;
} else void connect();
}}
/>
/>}
</>}
</div>
);
@@ -1,6 +1,7 @@
import { useRef, type ReactNode } from "react";
import { AnimatePresence, motion } from "motion/react";
import { Cpu } from "lucide-react";
import { cn } from "../../lib/utils";
import {
SOURCE_EXIT_FADE,
@@ -32,6 +33,22 @@ export type ModelSource = {
credentialMode?: ModelConnectionMode | null;
};
export const otherModelsTile: ModelSource = {
id: "other",
label: "Other Models",
icon: <Cpu className="size-5" />,
};
export function AccountProviderTiles({ source, mode, onOtherModels }: {
source: ModelSource;
mode: ModelConnectionMode;
onOtherModels: () => void;
}) {
return <ModelSourceTiles label="Connect your model provider" sources={[source, otherModelsTile]}
selectedId={source.id} mode={mode} collapsed={false} animateLayout={false}
onSelect={id => { if (id === otherModelsTile.id) onOtherModels(); }} />;
}
const CREDENTIAL_TAG_LABEL: Record<ModelConnectionMode, string> = {
subscription: "Subscription",
api: "API key",