From 2033ab912f7c1d0b07a52424a77271adbf695152 Mon Sep 17 00:00:00 2001 From: Tonio Date: Tue, 1 Dec 2026 09:14:24 +0000 Subject: [PATCH] Update the Connect account dialog and provider chooser (#23361) ## Thinking Path > - Paperclip helps people manage agents. > - Each agent can use a managed provider account. > - People can connect that account during onboarding or from agent settings. > - The two screens used different sign-in controls. > - This change brings the wizard controls to the account dialog and groups other providers in a grid. ## Linked Issues or Issue Description **Subsystem affected** Agent settings and managed AI connections. **Current behavior** The account dialog uses different controls from onboarding and displays other providers in separate lists. **Proposed behavior** Show provider sign-in, code entry, expiry, and retry inside the credential panel. Show other providers in a compact grid. ## What Changed - Share the provider marks and sign-in controls with onboarding. - Keep the account fields visible while sign-in prepares. - Crossfade between the account form and provider grid. Keep the modal width stable. ## Verification - All 29 tests in AdapterLoginChrome and AgentProviderConnection passed. - The UI TypeScript check passed. - To check the layout, open Connect account from agent settings, choose Other Models, then return to the provider form. ## Risks - The dialog shares controls with onboarding. Changes to their defaults could affect both entry points. - Subscription sign-in depends on the selected execution environment. ## Model Used OpenAI GPT-6 through Codex, with local editing and test 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) - [ ] 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 - [ ] 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 - [ ] I will address all Greptile and reviewer comments before requesting merge --- ui/src/components/OnboardingWizard.tsx | 57 +----------- .../AiConnectionCredentialStep.tsx | 27 ++++-- .../ai-connections/AiConnectionField.tsx | 93 +++++++++++++++---- .../ai-connections/AiProviderSetup.tsx | 60 ++++++------ .../AgentProviderConnection.test.tsx | 39 +++++++- .../new-agent/AgentProviderConnection.tsx | 90 +++++++++++++++--- .../components/onboarding/ModelSourceMark.tsx | 55 +++++++++++ .../onboarding/ModelSourceTiles.tsx | 17 ++-- ui/src/index.css | 5 + 9 files changed, 309 insertions(+), 134 deletions(-) create mode 100644 ui/src/components/onboarding/ModelSourceMark.tsx diff --git a/ui/src/components/OnboardingWizard.tsx b/ui/src/components/OnboardingWizard.tsx index 849c09ae477..7a8b505b1d1 100644 --- a/ui/src/components/OnboardingWizard.tsx +++ b/ui/src/components/OnboardingWizard.tsx @@ -1,3 +1,4 @@ +import { ModelSourceMark } from "./onboarding/ModelSourceMark"; import { OnboardingSignInMark, OnboardingSignInRetry } from "./AdapterLoginChrome"; import type { AiConnectionLoginIntent } from "@paperclipai/shared"; import { cancelAdapterLoginSession, cancelPendingAdapterLogin, matchesAdapterLoginTarget } from "./useAdapterLoginCancellation"; @@ -27,7 +28,7 @@ import { OnboardingGatewaySetup } from "./onboarding/OnboardingGatewaySetup"; import { randomAgentAppearance, resolveAgentAppearance, agentAppearanceSchema } from "@paperclipai/shared"; import { OnboardingCharacter } from "./onboarding/OnboardingCharacter"; import { useCallback, useEffect, useState, useMemo, useRef } from "react"; -import type { ComponentType, CSSProperties } from "react"; +import type { CSSProperties } from "react"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import { AnimatePresence, MotionConfig, motion } from "motion/react"; import type { @@ -248,46 +249,6 @@ function adapterConfigHasAnthropicApiKey(config: Record): boole return binding.type === "secret_ref" || binding.type === "user_secret_ref"; } -/** - * Full-colour brand marks for the sources this step offers. - * - * The registry's own icons are monochrome, drawn to sit in dense config UI - * where a row of saturated logos would be noise. This step is the opposite - * case: two large tiles carrying the whole choice, where the brand is the - * fastest thing to recognise. - * - * Keyed by adapter type with a fallback, so the row stays registry-driven. An - * adapter with no brand file here still renders — with its registry icon — - * rather than a gap where a tile should be. - */ -const MODEL_SOURCE_BRAND_MARKS: Record = { - claude_local: "/brands/claude-color.svg", -}; - - -/** - * OpenAI's blossom, inline rather than served from `/brands`. - * - * The supplied asset is a white fill, which was fine while this row only ever - * sat on a dark tile. It follows the reader's system setting now, and white on - * the light tile is invisible. Inlining lets the path take - * `currentColor` and be legible in both, which an `` cannot do. - */ -function OpenAiBlossom({ className }: { className?: string }) { - return ( - - - - ); -} - -const MODEL_SOURCE_INLINE_MARKS: Record> = { - codex_local: OpenAiBlossom, -}; - /** * The environment variable each source reads its key from. * @@ -305,20 +266,6 @@ function apiKeyEnvKeyFor(adapterType: string): string { return API_KEY_ENV_KEYS[adapterType] ?? "API_KEY"; } -function ModelSourceMark({ - type, - Fallback, -}: { - type: string; - Fallback: ComponentType<{ className?: string }>; -}) { - const Inline = MODEL_SOURCE_INLINE_MARKS[type]; - if (Inline) return ; - const brand = MODEL_SOURCE_BRAND_MARKS[type]; - if (!brand) return ; - return ; -} - export { ONBOARDING_STORAGE_KEY } from "../lib/onboarding-state"; const INCOMPLETE_ONBOARDING_STATE_MESSAGE = diff --git a/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx b/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx index a508cc87e73..99bebaa2acf 100644 --- a/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx +++ b/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx @@ -26,6 +26,9 @@ type Props = { connectionId?: string; name: string; hideName?: boolean; + defaultAccountDialog?: boolean; + onOtherModels?: () => void; + advancedProviders?: ReactNode; nameForMethod?: (method: AiAuthMethod) => string; ownership: "personal" | "shared"; agentIds: string[]; @@ -44,8 +47,10 @@ export function AiConnectionCredentialStep(props: Props) { return ; } -function SubscriptionConnectionStep({ companyId, provider, initialMethod, fixedMethod, connectionId, name: initialName, hideName, nameForMethod, ownership, agentIds, allAgents, environmentId: suppliedEnvironmentId, loginAgentId, onComplete, onCancel, defaults, disabled }: Props) { +function SubscriptionConnectionStep({ defaultAccountDialog, onOtherModels, advancedProviders, companyId, provider, initialMethod, fixedMethod, connectionId, name: initialName, hideName, nameForMethod, ownership, agentIds, allAgents, environmentId: suppliedEnvironmentId, loginAgentId, onComplete, onCancel, defaults, disabled }: Props) { const [name, setName] = useState(initialName); + const [draftMethod, setDraftMethod] = useState<"subscription" | "api">(initialMethod === "api_key" ? "api" : "subscription"); + const [draftKey, setDraftKey] = useState(""); const [chosenEnvironment, setChosenEnvironment] = useState(); const client = useQueryClient(); const envs = useQuery({ queryKey: queryKeys.environments.list(companyId), queryFn: () => environmentsApi.list(companyId) }); @@ -90,33 +95,34 @@ function SubscriptionConnectionStep({ companyId, provider, initialMethod, fixedM const loading = [envs, caps, settings, experimental, general].some((query) => query.isPending) || (provider === "google" && health.isPending) || views.some((view) => view.kind === "reconnecting"); const loadError = views.find((view) => view.kind === "error"); const intent: AiConnectionLoginIntent = { provider: provider as AiConnectionLoginIntent["provider"], method: "subscription", name, ownership, agentIds, allAgents, connectionId }; - return
- {!hideName && } + const dialogFields = defaultAccountDialog && (provider === "anthropic" || provider === "openai"); + const accountFields = <>{!hideName && }{defaults}; + return
+ {!dialogFields && accountFields} {!suppliedEnvironmentId && !forced.forced && loginEnvironments.length > 1 && } {loadError ? - : environmentError ?

{environmentError}

: null} - {defaults} - {loading ?

Preparing sign-in…

: {environmentError}

: null} + {loading && !dialogFields ?

Preparing sign-in…

: {}} testConnection={async () => false} - managedAccount={{ intent, nameForMethod, initialMethod, fixedMethod: fixedMethod ?? Boolean(connectionId), disabled: disabled || loading || Boolean(environmentError) || Boolean(loadError) || !name.trim(), onComplete: (result) => { void client.invalidateQueries({ queryKey: ["ai-connections", companyId] }); void client.invalidateQueries({ queryKey: ["tools"] }); onComplete(result); } }} + managedAccount={{ draft: dialogFields ? { method: draftMethod, setMethod: setDraftMethod, apiKey: draftKey, setApiKey: setDraftKey } : undefined, preparingEnvironment: loading, defaultAccountDialog, onOtherModels, accountFields: dialogFields ? accountFields : undefined, advancedProviders, intent, nameForMethod, initialMethod, fixedMethod: fixedMethod ?? Boolean(connectionId), disabled: disabled || loading || Boolean(environmentError) || Boolean(loadError) || !name.trim(), onComplete: (result) => { void client.invalidateQueries({ queryKey: ["ai-connections", companyId] }); void client.invalidateQueries({ queryKey: ["tools"] }); onComplete(result); } }} />}
; } -function ApiKeyConnectionStep({ companyId, provider, connectionId, name: initialName, hideName, nameForMethod, ownership, agentIds, allAgents, environmentId: suppliedEnvironmentId, defaults, disabled, onComplete, onCancel }: Props) { +function ApiKeyConnectionStep({ 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(); @@ -143,6 +149,7 @@ function ApiKeyConnectionStep({ companyId, provider, connectionId, name: initial {environmentError &&

{environmentError}

} {defaults} { 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 /> + {advancedProviders}
; } diff --git a/ui/src/components/ai-connections/AiConnectionField.tsx b/ui/src/components/ai-connections/AiConnectionField.tsx index 9fdbdbe9371..e2c247162e2 100644 --- a/ui/src/components/ai-connections/AiConnectionField.tsx +++ b/ui/src/components/ai-connections/AiConnectionField.tsx @@ -1,4 +1,6 @@ -import { useRef, useState } from "react"; +import { useLayoutEffect, useRef, useState, type ReactNode } from "react"; +import { AnimatePresence, MotionConfig, motion, useIsPresent, useReducedMotion } from "motion/react"; +import { CARD_ENTER, CARD_EXIT } from "../onboarding/onboarding-motion"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { aiConnectionBindingSchema, @@ -30,6 +32,36 @@ import { import { ANALYTICS_MASK_CLASS } from "@/lib/analytics/privacy"; import { cn } from "@/lib/utils"; +function AccountDialogBody({ view, children }: { view: string; children: ReactNode }) { + const body = useRef(null); + const [height, setHeight] = useState(); + const reduced = useReducedMotion(); + useLayoutEffect(() => { + const element = body.current; + if (!element) return; + const measure = () => setHeight(element.offsetHeight); + measure(); + const observer = new ResizeObserver(measure); + observer.observe(element); + return () => observer.disconnect(); + }, []); + return +
+ + + {children} + + +
+
; +} + +function AccountDialogView({ children }: { children: ReactNode }) { + return
{children}
; +} + export function aiProviderForAdapter( adapterType: string, ): AiProvider | undefined { @@ -86,6 +118,16 @@ export function AiConnectionField({ const [pendingAdoption, setPendingAdoption] = useState(); const [connecting, setConnecting] = useState(false); const [advancedSetup, setAdvancedSetup] = useState(false); + const viewGeneration = useRef(0); + const generation = viewGeneration.current; + const showSetup = (advanced: boolean) => { + viewGeneration.current++; + setAdvancedSetup(advanced); + }; + const closeConnection = () => { + viewGeneration.current++; + setConnecting(false); + }; const [reconnecting, setReconnecting] = useState(); const [allAgents, setAllAgents] = useState(true); const [savedAccount, setSavedAccount] = useState<{ connectionId: string; grantId: string; method: AiAuthMethod }>(); @@ -116,13 +158,13 @@ export function AiConnectionField({ onSuccess: async (result) => { await client.invalidateQueries({ queryKey: ["ai-connections", companyId] }); changeBinding({ provider: provider!, method: result.method, mode: "responsible_user" }); - setConnecting(false); + closeConnection(); }, }); const openConnection = (reconnect?: AiManagedConnectionSummary) => { returnFocus.current = document.activeElement as HTMLElement; setReconnecting(reconnect); - setAdvancedSetup(!reconnect && (preferAdvanced || provider === "openrouter")); + showSetup(!reconnect && (preferAdvanced || provider === "openrouter")); setAllAgents(accounts.data?.canManageConnections ?? false); setSavedAccount(undefined); selectDefault.reset(); @@ -220,29 +262,30 @@ export function AiConnectionField({ - { if (!selectDefault.isPending) setConnecting(open); }}> - - - {reconnecting ? "Reconnect account" : "Connect account"} - - {advancedSetup ? "Choose a provider connection for this agent." : reconnecting ? "Sign in again to repair your current default account. Its agent access stays the same." : "This account will become your default for this provider. Your tasks will use it; other users keep their own default."} + { if (!open && !selectDefault.isPending) closeConnection(); }}> + + + {reconnecting ? "Reconnect account" : "Connect account"} + + {advancedSetup ? "Choose a provider connection for this agent." : reconnecting ? "Sign in again to repair your current default account. Its agent access stays the same." : <>This account will become your default for this provider.
Your tasks will use it. Other users keep their own default.}
+ + {advancedSetup ? preferAdvanced ? setConnecting(false) : setAdvancedSetup(false)} + onCancel={() => preferAdvanced ? closeConnection() : showSetup(false)} onComplete={binding => { + if (generation !== viewGeneration.current) return; void client.invalidateQueries({ queryKey: ["ai-connections", companyId] }); - setConnecting(false); + closeConnection(); changeBinding(binding); }} /> : <> - {!reconnecting && !savedAccount && } {savedAccount ?
{selectDefault.error ? <>

{describeError(selectDefault.error).body}

@@ -250,6 +293,16 @@ export function AiConnectionField({ :

Selecting your default account…

}
: showSetup(true)} + defaults={!reconnecting && } + advancedProviders={!reconnecting && provider !== "anthropic" && provider !== "openai" &&
+ Advanced providers + +
} companyId={companyId} provider={provider} initialMethod={reconnecting?.method ?? method} @@ -261,17 +314,17 @@ export function AiConnectionField({ allAgents={allAgents} environmentId={environmentId} loginAgentId={agentId} - onCancel={() => setConnecting(false)} + onCancel={() => closeConnection()} onComplete={(result) => { + if (generation !== viewGeneration.current) return; setSavedAccount(result); selectDefault.mutate(result); }} />} - {!reconnecting && !savedAccount &&
- Advanced providers - -
} + } +
+
diff --git a/ui/src/components/ai-connections/AiProviderSetup.tsx b/ui/src/components/ai-connections/AiProviderSetup.tsx index f86f46763da..9638fa3f310 100644 --- a/ui/src/components/ai-connections/AiProviderSetup.tsx +++ b/ui/src/components/ai-connections/AiProviderSetup.tsx @@ -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 { PluginTile } from "@/pages/apps/PluginMarketplace"; import { AppLogo } from "@/pages/apps/AppLogo"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; @@ -78,6 +79,7 @@ export function AiProviderSetup({ initialProtocol, providerLabel, advancedOnly = false, + providerGrid = false, hideCancel = false, hideProviderHeading = false, submitLabel, @@ -92,6 +94,7 @@ export function AiProviderSetup({ initialProtocol?: AiProviderRouting["protocol"]; providerLabel?: string; advancedOnly?: boolean; + providerGrid?: boolean; hideCancel?: boolean; hideProviderHeading?: boolean; submitLabel?: string; @@ -220,34 +223,33 @@ export function AiProviderSetup({ setApiKey(""); }, }); - const choices = (advancedOnly: boolean) => ( - Boolean("advanced" in p && p.advanced) === advancedOnly) - .map((p) => ({ - ...p, - icon: - p.id === "gateway" || p.id === "local" ? ( - - {p.id === "gateway" ? ( - - ) : ( - - )} - - ) : ( - - ), - }))} - onSelect={(id) => { - setProvider(id as ProviderChoice); - setStep("connect"); - setApiKey(""); - setAuth("bearer"); - save.reset(); - }} - /> - ); + function selectProvider(id: string) { + setProvider(id as ProviderChoice); + setStep("connect"); + setApiKey(""); + setAuth("bearer"); + save.reset(); + } + function choices(advancedFilter?: boolean) { + const options = providers + .filter(p => advancedFilter === undefined || ("advanced" in p) === advancedFilter) + .map(p => ({ + ...p, + icon: p.id === "gateway" || p.id === "local" ? ( + + {p.id === "gateway" ? : } + + ) : , + })); + if (providerGrid) return ( +
+ {options.map(p => selectProvider(p.id)} />)} +
+ ); + return ; + } const modelSettings = (