diff --git a/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx b/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx index 0b552243ff9..72b605b74a4 100644 --- a/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx +++ b/ui/src/components/ai-connections/AiConnectionCredentialStep.tsx @@ -27,6 +27,7 @@ type Props = { name: string; hideName?: boolean; defaultAccountDialog?: boolean; + inlineOpenAiSubscription?: boolean; onOtherModels?: () => void; advancedProviders?: ReactNode; nameForMethod?: (method: AiAuthMethod) => string; @@ -47,7 +48,7 @@ export function AiConnectionCredentialStep(props: Props) { return ; } -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) { +function SubscriptionConnectionStep({ defaultAccountDialog, inlineOpenAiSubscription, 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(""); @@ -134,7 +135,7 @@ function SubscriptionConnectionStep({ defaultAccountDialog, onOtherModels, advan onBack={onCancel} onConnected={() => {}} testConnection={async () => false} - 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); } }} + managedAccount={{ draft: dialogFields ? { method: draftMethod, setMethod: setDraftMethod, apiKey: draftKey, setApiKey: setDraftKey } : undefined, preparingEnvironment: loading, inlineOpenAiSubscription, 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); } }} />} ; } diff --git a/ui/src/components/ai-connections/AiProviderSetup.tsx b/ui/src/components/ai-connections/AiProviderSetup.tsx index 9638fa3f310..ef8ffab1366 100644 --- a/ui/src/components/ai-connections/AiProviderSetup.tsx +++ b/ui/src/components/ai-connections/AiProviderSetup.tsx @@ -318,6 +318,7 @@ export function AiProviderSetup({ ) : !advanced ? ( { host.remove(); }); -function renderConnection(adapterType: "antigravity_runtime" | "claude_local" | "codex_local", localEnvironment: boolean, defaultAccountDialog = false, onComplete = vi.fn()) { +function renderConnection(adapterType: "antigravity_runtime" | "claude_local" | "codex_local", localEnvironment: boolean, presentation: boolean | "other-models" = false, onComplete = vi.fn()) { const client = new QueryClient({ defaultOptions: { queries: { retry: false } } }); const provider = adapterType === "antigravity_runtime" ? "google" : adapterType === "claude_local" ? "anthropic" : "openai"; flushSync(() => { @@ -82,7 +82,8 @@ function renderConnection(adapterType: "antigravity_runtime" | "claude_local" | onConnected={() => {}} testConnection={async () => true} managedAccount={{ - defaultAccountDialog, + defaultAccountDialog: presentation === true, + inlineOpenAiSubscription: presentation === "other-models", intent: { provider, method: "subscription", @@ -101,14 +102,15 @@ function renderConnection(adapterType: "antigravity_runtime" | "claude_local" | describe("Connect account dialog", () => { it.each([ - ["claude_local", "Waiting for code…"], - ["codex_local", "Waiting…"], - ] as const)("keeps %s sign-in in the panel", async (adapter, waiting) => { + ["claude_local", "Waiting for code…", true], + ["codex_local", "Waiting…", true], + ["codex_local", "Waiting…", "other-models"], + ] as const)("keeps %s sign-in in the panel", async (adapter, waiting, presentation) => { mocks.healthGet.mockResolvedValue({ localAiLoginSupported: true }); mocks.checkLocalLogin.mockResolvedValue({ status: "sign_in_required", authorizationUrl: "https://example.test/login", code: "TEST-CODE", }); - renderConnection(adapter, true, true); + renderConnection(adapter, true, presentation); const button = (label: string) => Array.from(host.querySelectorAll("button")).find(b => b.textContent === label); const open = vi.spyOn(window, "open").mockReturnValue(null); try { diff --git a/ui/src/components/new-agent/AgentProviderConnection.tsx b/ui/src/components/new-agent/AgentProviderConnection.tsx index a96ef80812d..901cd2c2e63 100644 --- a/ui/src/components/new-agent/AgentProviderConnection.tsx +++ b/ui/src/components/new-agent/AgentProviderConnection.tsx @@ -77,6 +77,7 @@ export function AgentProviderConnection({ /** Connections supplies its access intent; presentation and login controllers stay shared. */ managedAccount?: { defaultAccountDialog?: boolean; + inlineOpenAiSubscription?: boolean; preparingEnvironment?: boolean; draft?: { method: "subscription" | "api"; @@ -306,7 +307,7 @@ export function AgentProviderConnection({ const localLoginAction = localLoginPrimary.action; const wizardCard = managedAccount?.defaultAccountDialog && (adapterType === "claude_local" || adapterType === "codex_local"); - const inlineLogin = Boolean(wizardCard && opened && method === "subscription"); + const inlineLogin = Boolean((wizardCard || managedAccount?.inlineOpenAiSubscription) && opened && method === "subscription"); const localReady = inlineLogin && !needsLogin && canUseLocalLogin && localLogin.status === "ready"; const autoSaved = useRef(false); useEffect(() => { @@ -317,7 +318,7 @@ export function AgentProviderConnection({ void connect(); } }, [localReady, managedAccount?.disabled, connect]); - const providerMark = wizardCard + const providerMark = wizardCard || inlineLogin ? : ; const switchMode = (next: ModelConnectionMode) => {