AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): unify subscription sign-in cards across onboarding and integrations (#14801)
Nicholas Tindlede282b895703
diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/ConnectStep.tsx b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/ConnectStep.tsxindex 11782e094b..a5c1ca9204 100644--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/ConnectStep.tsx+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/ConnectStep.tsx@@ -3,16 +3,12 @@import { Button } from "@/components/atoms/Button/Button";import { FadeIn } from "@/components/atoms/FadeIn/FadeIn";import { Text } from "@/components/atoms/Text/Text";-import { DeviceAuthConnectButton } from "@/components/contextual/DeviceAuth/DeviceAuthConnectButton";import { AutopilotAvatar } from "@/components/molecules/AutopilotAvatar/AutopilotAvatar";-import { ProviderBox } from "./components/ProviderBox";+import { MicrosoftCopilotProviderBox } from "@/components/contextual/IntegrationsPanel/components/AIConnectionsSection/MicrosoftCopilotProviderBox";+import { UpcomingProviderBoxes } from "@/components/contextual/IntegrationsPanel/components/AIConnectionsSection/UpcomingProviderBoxes";+import { ProviderBox } from "@/components/contextual/IntegrationsPanel/components/AIConnectionsSection/ProviderBox";import { useConnectStep } from "./useConnectStep";-const UPCOMING = [- { name: "Grok", logoSrc: "/integrations/xai.webp" },- { name: "GitHub Copilot", logoSrc: "/integrations/github.png" },-];-/*** The last thing a self-host install asks for: a model to run on.*@@ -44,7 +40,7 @@ export function ConnectStep() {</div><div- className="grid w-full grid-cols-1 gap-3 sm:grid-cols-3"+ className="grid w-full grid-cols-2 gap-3 sm:grid-cols-4"aria-label="Subscriptions"><ProviderBox@@ -54,37 +50,19 @@ export function ConnectStep() {isBusy={isConnecting}onClick={connect}/>- {UPCOMING.map((provider) => (- <ProviderBox- key={provider.name}- {...provider}- state="coming-soon"- />- ))}+ <MicrosoftCopilotProviderBox+ isLinked={isMicrosoftLinked}+ onSuccess={finishConnection}+ />+ <UpcomingProviderBoxes /></div>- <div className="w-full rounded-2xl border border-zinc-200 bg-white p-4">- {isMicrosoftLinked ? (- <Text variant="body" as="p">- Your Microsoft 365 Copilot is connected. It can answer chats but- does not run AutoGPT tools.- </Text>- ) : (- <>- <DeviceAuthConnectButton- provider="microsoft_365_copilot"- providerName="Microsoft 365 Copilot"- onSuccess={finishConnection}- />- <Text variant="small" as="p" tone="muted" className="mt-3">- Requires a paid Microsoft Copilot or Copilot Business add-on- from your work or school organization. The included Microsoft- 365 Copilot Chat does not qualify. This connection answers chats- but does not run AutoGPT tools.- </Text>- </>- )}- </div>+ {isMicrosoftLinked && (+ <Text variant="small" as="p" tone="muted" className="text-center">+ Your Microsoft 365 Copilot is connected. It can answer chats but+ does not run AutoGPT tools.+ </Text>+ )}<Button size="small" onClick={skip} className="h-10 w-56 rounded-xl">Nextdiff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/__tests__/ConnectStep.test.tsx b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/__tests__/ConnectStep.test.tsxindex e5bfb9a56e..dae46df1ec 100644--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/__tests__/ConnectStep.test.tsx+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/__tests__/ConnectStep.test.tsx@@ -6,7 +6,12 @@ import {import type { AIConnectionOffer } from "@/app/api/__generated__/models/aIConnectionOffer";import type { ProviderTiers } from "@/app/api/__generated__/models/providerTiers";import { server } from "@/mocks/mock-server";-import { render, screen, waitFor } from "@/tests/integrations/test-utils";+import {+ render,+ screen,+ waitFor,+ within,+} from "@/tests/integrations/test-utils";import { type QueryClient, useQueryClient } from "@tanstack/react-query";import userEvent from "@testing-library/user-event";import { beforeEach, describe, expect, it, vi } from "vitest";@@ -229,20 +234,35 @@ describe("ConnectStep", () => {expect(screen.getByRole("button", { name: "Next" })).toBeDefined();});- it("offers Microsoft device sign-in alongside subscription cards", async () => {+ it("opens Microsoft device sign-in from its logo card", async () => {mockOffers([offer()]);render(<ConnectStep />);+ const card = await screen.findByRole("button", {+ name: "Microsoft 365 Copilot",+ });+ expect(card.querySelector("img")?.getAttribute("src")).toBe(+ "/integrations/microsoft.webp",+ );+ expect(screen.queryByRole("dialog")).toBeNull();expect(- await screen.findByRole("button", {+ screen.queryByText(+ /included Microsoft 365 Copilot Chat does not qualify/i,+ ),+ ).toBeNull();+ await userEvent.click(card);++ const dialog = await screen.findByRole("dialog");+ expect(+ within(dialog).getByRole("button", {name: /Connect Microsoft 365 Copilot/,}),).toBeDefined();expect(- screen.getByText(/included Microsoft 365 Copilot Chat does not qualify/i),+ within(dialog).getByText(+ /included Microsoft 365 Copilot Chat does not qualify/i,+ ),).toBeDefined();- expect(screen.getByRole("button", { name: /ChatGPT/ })).toBeDefined();- expect(screen.getByRole("button", { name: "Next" })).toBeDefined();});it("refreshes Microsoft connection status without advancing the wizard", async () => {@@ -253,9 +273,9 @@ describe("ConnectStep", () => {<ConnectStep /></>,);- await screen.findByRole("button", {- name: /Connect Microsoft 365 Copilot/,- });+ await userEvent.click(+ await screen.findByRole("button", { name: "Microsoft 365 Copilot" }),+ );await waitFor(() =>expect(queryClient?.getQueryState(getGetV2ListChatConnectionsQueryKey())@@ -271,6 +291,8 @@ describe("ConnectStep", () => {expect(await screen.findByText(/Your Microsoft 365 Copilot is connected/),).toBeDefined();+ expect(screen.getByText("Connected")).toBeDefined();+ expect(screen.queryByRole("dialog")).toBeNull();expect(useOnboardingWizardStore.getState().currentStep).toBe(3);expect(screen.getByRole("button", { name: /ChatGPT/ })).toBeDefined();expect(@@ -286,7 +308,10 @@ describe("ConnectStep", () => {await screen.findByText(/Your Microsoft 365 Copilot is connected/),).toBeDefined();expect(screen.getByRole("button", { name: /ChatGPT/ })).toBeDefined();- expect(screen.queryByText("Connected")).toBeNull();+ expect(screen.getByText("Connected")).toBeDefined();+ expect(+ screen.queryByRole("button", { name: "Microsoft 365 Copilot" }),+ ).toBeNull();expect(screen.getByText(/does not run AutoGPT tools/)).toBeDefined();});@@ -296,7 +321,7 @@ describe("ConnectStep", () => {expect(await screen.findByText("Connected")).toBeDefined();expect(- screen.getByRole("button", { name: /Connect Microsoft 365 Copilot/ }),+ screen.getByRole("button", { name: "Microsoft 365 Copilot" }),).toBeDefined();});@@ -307,7 +332,7 @@ describe("ConnectStep", () => {expect(await screen.findByText(/Your Microsoft 365 Copilot is connected/),).toBeDefined();- expect(screen.getByText("Connected")).toBeDefined();+ expect(screen.getAllByText("Connected")).toHaveLength(2);expect(screen.queryByRole("button", { name: /ChatGPT/ })).toBeNull();expect(screen.queryByRole("button", { name: /Connect Microsoft 365 Copilot/ }),diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/useConnectStep.ts b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/useConnectStep.tsindex bde29cf8c6..149382b155 100644--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/useConnectStep.ts+++ b/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/useConnectStep.ts@@ -5,6 +5,7 @@ import {useGetV2ListChatConnections,} from "@/app/api/__generated__/endpoints/chat/chat";import { useQueryClient } from "@tanstack/react-query";+import { isProviderLinked } from "@/components/contextual/IntegrationsPanel/components/AIConnectionsSection/helpers";import { useOAuthConnect } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/useOAuthConnect";import { useOnboardingWizardStore } from "../../store";@@ -37,14 +38,7 @@ export function useConnectStep() {finishConnection,isConnecting: isPending,skip: nextStep,- isChatGPTLinked: (offers ?? []).some(- (offer) =>- offer.auth_provider === "codex" && Boolean(offer.credential_id),- ),- isMicrosoftLinked: (offers ?? []).some(- (offer) =>- offer.auth_provider === "microsoft_365_copilot" &&- Boolean(offer.credential_id),- ),+ isChatGPTLinked: isProviderLinked(offers, "codex"),+ isMicrosoftLinked: isProviderLinked(offers, "microsoft_365_copilot"),};}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsxindex 32ce113482..8780b5c91d 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx@@ -15,7 +15,9 @@ import {getGetV1ListCredentialsMockHandler401,getGetV1ListProvidersMockHandler,getPostV1CreateCredentialsMockHandler,+ getPostV1InitiateDeviceCodeOauthFlowMockHandler200,} from "@/app/api/__generated__/endpoints/integrations/integrations.msw";+import { getGetV2ListChatConnectionsMockHandler200 } from "@/app/api/__generated__/endpoints/chat/chat.msw";import type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";import type { ProviderMetadata } from "@/app/api/__generated__/models/providerMetadata";@@ -285,6 +287,83 @@ describe("SettingsIntegrationsPage — search", () => {});describe("SettingsIntegrationsPage — connect dialog", () => {+ test("starts Microsoft device sign-in from the AI subscriptions logo card", async () => {+ server.use(+ getGetV2ListChatConnectionsMockHandler200({ offers: [] }),+ getGetV1ListCredentialsMockHandler([]),+ getPostV1InitiateDeviceCodeOauthFlowMockHandler200({+ state_token: "test-state",+ user_code: "TEST-CODE",+ verification_url: "https://microsoft.com/devicelogin",+ verification_url_complete: null,+ expires_in: 900,+ interval: 5,+ }),+ );+ render(<SettingsIntegrationsPage />);++ const card = await screen.findByRole("button", {+ name: "Microsoft 365 Copilot",+ });+ expect(card.querySelector("img")?.getAttribute("src")).toContain(+ "/integrations/microsoft.webp",+ );+ fireEvent.click(card);+ const dialog = await screen.findByRole("dialog");+ expect(+ within(dialog).getByText(+ /included Microsoft 365 Copilot Chat does not qualify/i,+ ),+ ).toBeDefined();+ fireEvent.click(+ within(dialog).getByRole("button", {+ name: "Connect Microsoft 365 Copilot",+ }),+ );+ expect(await within(dialog).findByText("TEST-CODE")).toBeDefined();+ expect(+ within(dialog)+ .getByRole("link", { name: "Open Microsoft 365 Copilot" })+ .getAttribute("href"),+ ).toBe("https://microsoft.com/devicelogin");+ });++ test("uses the Microsoft logo in the service catalog and sign-in details", async () => {+ server.use(+ getGetV2ListChatConnectionsMockHandler200({ offers: [] }),+ getGetV1ListCredentialsMockHandler([]),+ getGetV1ListProvidersMockHandler([+ makeProvider({+ name: "microsoft_365_copilot",+ description: "Use your work or school Microsoft 365 Copilot plan",+ supported_auth_types: ["device_code"],+ }),+ ]),+ );+ render(<SettingsIntegrationsPage />);+ fireEvent.click(+ (await screen.findAllByRole("button", { name: /connect.*service/i }))[0],+ );+ const dialog = await screen.findByRole("dialog");+ const provider = await within(dialog).findByRole("button", {+ name: /Microsoft 365 Copilot/,+ });+ expect(provider.querySelector("img")?.getAttribute("src")).toContain(+ "/integrations/microsoft.webp",+ );+ fireEvent.click(provider);+ expect(+ (+ await within(dialog).findByAltText("Microsoft 365 Copilot logo")+ ).getAttribute("src"),+ ).toContain("/integrations/microsoft.webp");+ expect(+ within(dialog).getByRole("button", {+ name: "Connect Microsoft 365 Copilot",+ }),+ ).toBeDefined();+ });+test("Connect Service opens a dialog with the provider list", async () => {server.use(getGetV1ListCredentialsMockHandler([]),diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/AIConnectionsSection.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/AIConnectionsSection.tsxindex e24188ffde..8293a16253 100644--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/AIConnectionsSection.tsx+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/AIConnectionsSection.tsx@@ -13,12 +13,20 @@ import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";import { Text } from "@/components/atoms/Text/Text";import { cn } from "@/lib/utils";+import { IntegrationLogo } from "@/components/molecules/IntegrationLogo/IntegrationLogo";+import { UpcomingProviderBoxes } from "./UpcomingProviderBoxes";+import { ProviderBox } from "./ProviderBox";+import { MicrosoftCopilotProviderBox } from "./MicrosoftCopilotProviderBox";import { ManageConnectionDialog } from "./ManageConnectionDialog";import { isSelectable, tierSummary } from "./helpers";import { useAIConnectionsSection } from "./useAIConnectionsSection";export function AIConnectionsSection() {const {+ connectChatGPT,+ isConnectingChatGPT,+ isChatGPTLinked,+ isMicrosoftLinked,connections,accountFor,credentialFor,@@ -27,6 +35,7 @@ export function AIConnectionsSection() {isSaving,isLoading,isError,+ refetch,} = useAIConnectionsSection();const [managing, setManaging] = useState<AIConnectionOffer | null>(null);@@ -90,7 +99,27 @@ export function AIConnectionsSection() {</div>)}- <UpcomingConnections />+ {!isLoading && (+ <div+ role="group"+ aria-label="Available AI subscriptions"+ className="mt-4 grid w-full grid-cols-2 gap-3 sm:grid-cols-4"+ >+ {!isChatGPTLinked && (+ <ProviderBox+ name="ChatGPT"+ logoSrc="/integrations/openai.png"+ state="available"+ isBusy={isConnectingChatGPT}+ onClick={connectChatGPT}+ />+ )}+ {!isMicrosoftLinked && (+ <MicrosoftCopilotProviderBox isLinked={false} onSuccess={refetch} />+ )}+ <UpcomingProviderBoxes />+ </div>+ )}<ManageConnectionDialogconnection={managing}@@ -138,6 +167,19 @@ function ConnectionRow({</span>)}+ {(connection.auth_provider === "codex" ||+ connection.auth_provider === "microsoft_365_copilot") && (+ <IntegrationLogo+ provider={+ connection.auth_provider === "codex"+ ? "openai"+ : "microsoft_365_copilot"+ }+ alt=""+ size={32}+ className="shrink-0"+ />+ )}<span className="flex min-w-0 flex-col gap-1"><span className="flex flex-wrap items-center gap-2"><Text variant="body-medium" as="span" className="text-black">@@ -227,35 +269,3 @@ function ConnectionRow({</div>);}--/**- * Names what is coming without claiming it works yet. Each provider needs its- * own adapter and its own provider/legal approval before it can appear as a- * real row above, so this promises nothing about capability or timing.- */-function UpcomingConnections() {- return (- <div className="mt-3 flex items-start gap-3 rounded-2xl border border-dashed border-[#DADADC] p-4">- <span- aria-hidden- className="mt-[2px] flex h-4 w-4 flex-none items-center justify-center text-[#9A9A9F]"- >- <Icon icon={SparklesIcon} size={16} />- </span>- <span className="flex min-w-0 flex-col gap-1">- <span className="flex flex-wrap items-center gap-2">- <Text variant="body-medium" as="span" className="text-[#505057]">- GitHub Copilot and Grok- </Text>- <span className="inline-flex items-center rounded-[10px] bg-[#EFF1F4] px-2 py-[2px] text-[13px] font-medium leading-[20px] text-[#505057]">- Coming soon- </span>- </span>- <Text variant="small" as="span" className="text-[#505057]">- More subscriptions you already pay for. Each one shows up here once it- is approved to run AutoGPT agents.- </Text>- </span>- </div>- );-}diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/MicrosoftCopilotProviderBox.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/MicrosoftCopilotProviderBox.tsxnew file mode 100644index 0000000000..550d4ce8be--- /dev/null+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/MicrosoftCopilotProviderBox.tsx@@ -0,0 +1,56 @@+"use client";++import { useState } from "react";+import { Text } from "@/components/atoms/Text/Text";+import { DeviceAuthConnectButton } from "@/components/contextual/DeviceAuth/DeviceAuthConnectButton";+import { Dialog } from "@/components/molecules/Dialog/Dialog";+import { ProviderBox } from "./ProviderBox";++interface Props {+ isLinked: boolean;+ onSuccess: () => void;+}++export function MicrosoftCopilotProviderBox({ isLinked, onSuccess }: Props) {+ const [isOpen, setIsOpen] = useState(false);++ function handleSuccess() {+ setIsOpen(false);+ onSuccess();+ }++ const card = (+ <ProviderBox+ name="Microsoft 365 Copilot"+ logoSrc="/integrations/microsoft.webp"+ state={isLinked ? "connected" : "available"}+ />+ );++ if (isLinked) return card;++ return (+ <Dialog+ title="Connect Microsoft 365 Copilot"+ variant="compact"+ controlled={{ isOpen, set: setIsOpen }}+ >+ <Dialog.Trigger>{card}</Dialog.Trigger>+ <Dialog.Content>+ <div className="flex flex-col gap-4">+ <Text variant="small" as="p" tone="muted">+ Requires a paid Microsoft Copilot or Copilot Business add-on from+ your work or school organization. The included Microsoft 365 Copilot+ Chat does not qualify. This connection answers chats but does not+ run AutoGPT tools.+ </Text>+ <DeviceAuthConnectButton+ provider="microsoft_365_copilot"+ providerName="Microsoft 365 Copilot"+ onSuccess={handleSuccess}+ />+ </div>+ </Dialog.Content>+ </Dialog>+ );+}diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/ProviderBox.stories.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/ProviderBox.stories.tsxnew file mode 100644index 0000000000..153e0ae8c7--- /dev/null+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/ProviderBox.stories.tsx@@ -0,0 +1,54 @@+import type { Meta, StoryObj } from "@storybook/nextjs";+import { UpcomingProviderBoxes } from "./UpcomingProviderBoxes";+import { ProviderBox } from "./ProviderBox";++const meta = {+ title: "Integrations/Subscription Provider",+ component: ProviderBox,+ parameters: { layout: "centered" },+ args: {+ name: "Microsoft 365 Copilot",+ logoSrc: "/integrations/microsoft.webp",+ state: "available",+ },+ decorators: [+ (Story, context) => (+ <div className={context.parameters.providerGrid ? "w-[40rem]" : "w-48"}>+ <Story />+ </div>+ ),+ ],+} satisfies Meta<typeof ProviderBox>;++export default meta;+type Story = StoryObj<typeof meta>;++export const Available: Story = {};+export const Connected: Story = { args: { state: "connected" } };+export const Connecting: Story = { args: { isBusy: true } };+export const ComingSoon: Story = {+ args: {+ name: "GitHub Copilot",+ logoSrc: "/integrations/github.png",+ state: "coming-soon",+ },+};++export const AllProviders: Story = {+ parameters: { providerGrid: true },+ render: () => (+ <div className="grid grid-cols-4 gap-3">+ <ProviderBox+ name="ChatGPT"+ logoSrc="/integrations/openai.png"+ state="available"+ />+ <ProviderBox+ name="Microsoft 365 Copilot"+ logoSrc="/integrations/microsoft.webp"+ state="available"+ />+ <UpcomingProviderBoxes />+ </div>+ ),+};diff --git a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/components/ProviderBox.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/ProviderBox.tsxsimilarity index 81%rename from autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/components/ProviderBox.tsxrename to autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/ProviderBox.tsxindex 422bf13a86..fbc0aaad08 100644--- a/autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/ConnectStep/components/ProviderBox.tsx+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/ProviderBox.tsx@@ -18,7 +18,7 @@ interface Props {}const FRAME =- "flex w-full flex-col items-center gap-3 rounded-2xl border bg-white px-4 py-6 text-center";+ "flex h-44 w-full min-w-0 flex-col items-center gap-3 rounded-2xl border bg-white px-3 py-4 text-center";// One subscription the experts could run on. Available ones are a button// that starts the sign-in; connected and coming-soon ones just say so.@@ -31,13 +31,16 @@ export function ProviderBox({}: Props) {const body = (<>- <span className="relative flex h-12 w-12 items-center justify-center">+ <span className="relative flex h-12 w-12 shrink-0 items-center justify-center"><Imagesrc={logoSrc}alt=""width={48}height={48}- className={cn("rounded-xl", state === "coming-soon" && "opacity-50")}+ className={cn(+ "h-12 w-12 rounded-xl object-contain",+ state === "coming-soon" && "opacity-50",+ )}/>{isBusy && (<Icon@@ -47,11 +50,14 @@ export function ProviderBox({/>)}</span>- <span className="flex flex-col items-center gap-1">+ <span className="flex w-full flex-col items-center gap-1"><Textvariant="body-medium"as="span"- className={state === "coming-soon" ? "text-zinc-500" : "text-black"}+ className={cn(+ "flex min-h-11 items-center justify-center",+ state === "coming-soon" ? "text-zinc-500" : "text-black",+ )}>{name}</Text>diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/UpcomingProviderBoxes.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/UpcomingProviderBoxes.tsxnew file mode 100644index 0000000000..d66df5008a--- /dev/null+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/UpcomingProviderBoxes.tsx@@ -0,0 +1,18 @@+import { ProviderBox } from "./ProviderBox";++export function UpcomingProviderBoxes() {+ return (+ <>+ <ProviderBox+ name="Grok"+ logoSrc="/integrations/xai.webp"+ state="coming-soon"+ />+ <ProviderBox+ name="GitHub Copilot"+ logoSrc="/integrations/github.png"+ state="coming-soon"+ />+ </>+ );+}diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/__tests__/AIConnectionsSection.test.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/__tests__/AIConnectionsSection.test.tsxindex f2deed5d91..4190aee319 100644--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/__tests__/AIConnectionsSection.test.tsx+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/__tests__/AIConnectionsSection.test.tsx@@ -10,9 +10,41 @@ import {} from "@/app/api/__generated__/endpoints/integrations/integrations.msw";import type { AIConnectionOffer } from "@/app/api/__generated__/models/aIConnectionOffer";import { server } from "@/mocks/mock-server";-import { render, screen, waitFor } from "@/tests/integrations/test-utils";+import {+ act,+ render,+ screen,+ waitFor,+ within,+} from "@/tests/integrations/test-utils";import userEvent from "@testing-library/user-event";-import { describe, expect, it, vi } from "vitest";+import { beforeEach, describe, expect, it, vi } from "vitest";++const connectChatGPT = vi.hoisted(() =>+ vi.fn<(onSuccess: () => void) => void>(),+);+vi.mock(+ "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/components/DetailView/useOAuthConnect",+ () => ({+ useOAuthConnect: ({ onSuccess }: { onSuccess: () => void }) => ({+ connect: () => connectChatGPT(onSuccess),+ isPending: false,+ }),+ }),+);++vi.mock("@/components/contextual/DeviceAuth/DeviceAuthConnectButton", () => {+ function MockDeviceAuthConnectButton({+ providerName,+ onSuccess,+ }: {+ providerName: string;+ onSuccess: () => void;+ }) {+ return <button onClick={() => onSuccess()}>Connect {providerName}</button>;+ }+ return { DeviceAuthConnectButton: MockDeviceAuthConnectButton };+});import { AIConnectionsSection } from "../AIConnectionsSection";@@ -139,6 +171,102 @@ function mockTransports(}describe("AIConnectionsSection", () => {+ beforeEach(() => {+ connectChatGPT.mockClear();+ });++ it("refreshes connected subscriptions after ChatGPT sign-in succeeds", async () => {+ mockTransports([platform(true)]);+ render(<AIConnectionsSection />);+ await userEvent.click(+ await screen.findByRole("button", { name: "ChatGPT" }),+ );++ mockTransports([platform(true), chatgpt(false)]);+ act(() => connectChatGPT.mock.calls[0][0]());++ expect(await screen.findByText("Connected")).toBeDefined();+ expect(+ screen+ .getByRole("radio", { name: /ChatGPT/ })+ .querySelector("img")+ ?.getAttribute("src"),+ ).toBe("/integrations/openai.png");+ expect(screen.queryByRole("button", { name: "ChatGPT" })).toBeNull();+ expect(+ screen.getByRole("button", { name: "Microsoft 365 Copilot" }),+ ).toBeDefined();+ expect(+ screen+ .getByRole("radio", { name: /Self-hosted chat/ })+ .getAttribute("aria-checked"),+ ).toBe("true");+ });++ it("refreshes connected subscriptions and closes the Microsoft sign-in dialog on success", async () => {+ mockTransports([platform(true)]);+ render(<AIConnectionsSection />);+ await userEvent.click(+ await screen.findByRole("button", { name: "Microsoft 365 Copilot" }),+ );+ const dialog = await screen.findByRole("dialog");++ mockTransports([platform(true), microsoft(false)]);+ await userEvent.click(+ within(dialog).getByRole("button", {+ name: "Connect Microsoft 365 Copilot",+ }),+ );++ expect(await screen.findByText("Connected")).toBeDefined();+ expect(+ screen+ .getByRole("radio", { name: /Microsoft 365 Copilot/ })+ .querySelector("img")+ ?.getAttribute("src"),+ ).toBe("/integrations/microsoft.webp");+ expect(+ screen.queryByRole("button", { name: "Microsoft 365 Copilot" }),+ ).toBeNull();+ expect(screen.queryByRole("dialog")).toBeNull();+ expect(screen.getByRole("button", { name: "ChatGPT" })).toBeDefined();+ expect(+ screen+ .getByRole("radio", { name: /Self-hosted chat/ })+ .getAttribute("aria-checked"),+ ).toBe("true");+ });++ it("offers ChatGPT first and starts sign-in from its logo card", async () => {+ mockTransports([platform(true)]);+ render(<AIConnectionsSection />);++ const cards = await screen.findByRole("group", {+ name: "Available AI subscriptions",+ });+ const buttons = within(cards).getAllByRole("button");+ expect(buttons.map((button) => button.textContent)).toEqual([+ "ChatGPT",+ "Microsoft 365 Copilot",+ ]);+ expect(buttons[0].querySelector("img")?.getAttribute("src")).toBe(+ "/integrations/openai.png",+ );+ await userEvent.click(buttons[0]);+ expect(connectChatGPT).toHaveBeenCalledTimes(1);+ });++ it("keeps only Microsoft sign-in available once ChatGPT is connected", async () => {+ mockTransports([platform(true), chatgpt(false)]);+ render(<AIConnectionsSection />);++ expect(await screen.findByText("Connected")).toBeDefined();+ expect(screen.queryByRole("button", { name: "ChatGPT" })).toBeNull();+ expect(+ screen.getByRole("button", { name: "Microsoft 365 Copilot" }),+ ).toBeDefined();+ });+it("lists every connection with what backs a run on it", async () => {mockTransports([platform(true), chatgpt(false)]);@@ -167,7 +295,9 @@ describe("AIConnectionsSection", () => {render(<AIConnectionsSection />);- expect(await screen.findByText("ChatGPT")).toBeDefined();+ expect(+ await screen.findByRole("button", { name: "ChatGPT" }),+ ).toBeDefined();expect(screen.queryByText("Connected")).toBeNull();expect(screen.queryByRole("button", { name: "Manage" })).toBeNull();});@@ -406,8 +536,12 @@ describe("AIConnectionsSection", () => {render(<AIConnectionsSection />);- expect(await screen.findByText("GitHub Copilot and Grok")).toBeDefined();- expect(screen.getByText("Coming soon")).toBeDefined();+ expect(await screen.findByText("GitHub Copilot")).toBeDefined();+ expect(screen.getByText("Grok")).toBeDefined();+ expect(screen.getAllByText("Coming soon")).toHaveLength(2);+ expect(+ screen.queryByRole("button", { name: /GitHub Copilot|Grok/ }),+ ).toBeNull();});it("names the models each connection runs", async () => {diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/helpers.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/helpers.tsindex b6319b3dfc..a6b2feb675 100644--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/helpers.ts+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/helpers.ts@@ -2,6 +2,16 @@ import type { AIConnectionOffer } from "@/app/api/__generated__/models/aIConnectimport type { SetDefaultTransportRequest } from "@/app/api/__generated__/models/setDefaultTransportRequest";import type { SetDefaultTransportRequestAuthProvider } from "@/app/api/__generated__/models/setDefaultTransportRequestAuthProvider";+export function isProviderLinked(+ offers: AIConnectionOffer[] | undefined,+ authProvider: string,+): boolean {+ return (offers ?? []).some(+ (offer) =>+ offer.auth_provider === authProvider && Boolean(offer.credential_id),+ );+}+const MICROSOFT_SCOPE_LABELS: Record<string, string> = {"User.Read": "Basic account profile","Sites.Read.All": "SharePoint and OneDrive files",diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/useAIConnectionsSection.ts b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/useAIConnectionsSection.tsindex 0aed137aed..583712461c 100644--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/useAIConnectionsSection.ts+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/AIConnectionsSection/useAIConnectionsSection.ts@@ -13,7 +13,9 @@ import type { AIConnectionOffer } from "@/app/api/__generated__/models/aIConnectimport type { CredentialsMetaResponse } from "@/app/api/__generated__/models/credentialsMetaResponse";import { toast } from "@/components/molecules/Toast/use-toast";-import { routeOf, visibleOffers } from "./helpers";+import { useOAuthConnect } from "../ConnectServiceDialog/components/DetailView/useOAuthConnect";++import { isProviderLinked, routeOf, visibleOffers } from "./helpers";export function useAIConnectionsSection() {const queryClient = useQueryClient();@@ -95,7 +97,21 @@ export function useAIConnectionsSection() {setDefault({ data: routeOf(offer) });}+ function refreshConnections() {+ void connectionsQuery.refetch();+ }++ const { connect: connectChatGPT, isPending: isConnectingChatGPT } =+ useOAuthConnect({+ provider: "codex",+ onSuccess: refreshConnections,+ });+return {+ connectChatGPT,+ isConnectingChatGPT,+ isChatGPTLinked: isProviderLinked(offers, "codex"),+ isMicrosoftLinked: isProviderLinked(offers, "microsoft_365_copilot"),connections: offers,accountFor,credentialFor,diff --git a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ProviderGroup/ProviderGroup.tsx b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ProviderGroup/ProviderGroup.tsxindex d7a9921478..5fde20c3d4 100644--- a/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ProviderGroup/ProviderGroup.tsx+++ b/autogpt_platform/frontend/src/components/contextual/IntegrationsPanel/components/ProviderGroup/ProviderGroup.tsx@@ -2,6 +2,7 @@import { useState } from "react";import Image from "next/image";+import { integrationIconSrc } from "@/components/molecules/IntegrationLogo/helpers";import {Accordion,AccordionContent,@@ -68,9 +69,9 @@ export function ProviderGroup({function ProviderAvatar({ provider }: { provider: ProviderGroupView }) {const [broken, setBroken] = useState(false);- const src = provider.logoUrl ?? `/integrations/${provider.id}.png`;+ const src = provider.logoUrl ?? integrationIconSrc(provider.id);- if (broken) {+ if (!src || broken) {return (<divaria-hidden="true"diff --git a/autogpt_platform/frontend/src/components/molecules/IntegrationLogo/helpers.ts b/autogpt_platform/frontend/src/components/molecules/IntegrationLogo/helpers.tsindex b526f15abe..6d4fb21398 100644--- a/autogpt_platform/frontend/src/components/molecules/IntegrationLogo/helpers.ts+++ b/autogpt_platform/frontend/src/components/molecules/IntegrationLogo/helpers.ts@@ -11,5 +11,6 @@ export function integrationIconSrc(provider: string): string | null {.toLowerCase().replace(/[\s-]+/g, "_").replace(/[^a-z0-9_]/g, "");+ if (slug === "microsoft_365_copilot") return "/integrations/microsoft.webp";return slug ? `/integrations/${slug}.png` : null;}