Skip to content

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.

feat(frontend/copilot): composer + menu opens the connect-service dialog (#14001)

Abhimanyu Yadavdf35080141d6
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsx
index 91c89bcbbb..10663c560b 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ComposerPlusMenu.tsx
@@ -91,11 +91,11 @@ export function ComposerPlusMenu({
<DropdownMenuItem
onSelect={() => {
onClearGuidedPrompt?.();
- openModal("integrations");
+ openModal("connect");
}}
>
<Icon icon={PlugSocketIcon} className="mr-2 h-4 w-4" />
- Integrations
+ Connect service
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => openModal("skills")}>
<Icon icon={BookOpen01Icon} className="mr-2 h-4 w-4" />
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ComposerPlusMenu.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ComposerPlusMenu.test.tsx
index b6e823bc65..ecdfb5fb53 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ComposerPlusMenu.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/__tests__/ComposerPlusMenu.test.tsx
@@ -33,7 +33,7 @@ describe("ComposerPlusMenu", () => {
const items = await screen.findAllByRole("menuitem");
expect(items.map((item) => item.textContent)).toEqual([
"Attach file",
- "Integrations",
+ "Connect service",
"Skills",
"Scheduled",
]);
@@ -53,7 +53,7 @@ describe("ComposerPlusMenu", () => {
expect(screen.getByTestId("modal-probe").textContent).toBe("skills");
});
- it("selecting Scheduled and Integrations open their modals", async () => {
+ it("selecting Scheduled and Connect service open their modals", async () => {
render(
<>
<ComposerPlusMenu onFilesSelected={vi.fn()} />
@@ -68,9 +68,9 @@ describe("ComposerPlusMenu", () => {
openMenu();
fireEvent.click(
- await screen.findByRole("menuitem", { name: /integrations/i }),
+ await screen.findByRole("menuitem", { name: /connect service/i }),
);
- expect(screen.getByTestId("modal-probe").textContent).toBe("integrations");
+ expect(screen.getByTestId("modal-probe").textContent).toBe("connect");
});
it("adds a flat workspace option after Attach file when its flag is enabled", async () => {
@@ -88,7 +88,7 @@ describe("ComposerPlusMenu", () => {
expect(items.map((item) => item.textContent)).toEqual([
"Attach file",
"Use File from Workspace",
- "Integrations",
+ "Connect service",
"Skills",
"Scheduled",
]);
@@ -99,7 +99,7 @@ describe("ComposerPlusMenu", () => {
expect(onUseWorkspaceFile).toHaveBeenCalledTimes(1);
});
- it("clears the guided prompt for Attach file and Integrations but not Skills or Scheduled", async () => {
+ it("clears the guided prompt for Attach file and Connect service but not Skills or Scheduled", async () => {
const onClearGuidedPrompt = vi.fn();
render(
<ComposerPlusMenu
@@ -116,7 +116,7 @@ describe("ComposerPlusMenu", () => {
openMenu();
fireEvent.click(
- await screen.findByRole("menuitem", { name: /integrations/i }),
+ await screen.findByRole("menuitem", { name: /connect service/i }),
);
expect(onClearGuidedPrompt).toHaveBeenCalledTimes(2);
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx
index 963d3e5977..5ac646883f 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/CopilotModals.tsx
@@ -1,5 +1,6 @@
"use client";
+import { ConnectServiceDialog } from "@/components/contextual/IntegrationsPanel/components/ConnectServiceDialog/ConnectServiceDialog";
import { IntegrationsPanel } from "@/components/contextual/IntegrationsPanel/IntegrationsPanel";
import { SchedulesPanel } from "@/components/contextual/SchedulesPanel/SchedulesPanel";
import { SkillsPanel } from "@/components/contextual/SkillsPanel/SkillsPanel";
@@ -57,6 +58,11 @@ export function CopilotModals() {
<IntegrationsPanel withHeading={false} />
</Dialog.Content>
</Dialog>
+
+ <ConnectServiceDialog
+ open={modal === "connect"}
+ onOpenChange={handleOpenChange}
+ />
</>
);
}
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx
index 4e713e77fe..d3d853cb51 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/CopilotModals/__tests__/CopilotModals.test.tsx
@@ -1,11 +1,20 @@
-import { getGetV1ListCredentialsMockHandler } from "@/app/api/__generated__/endpoints/integrations/integrations.msw";
+import {
+ getGetV1ListCredentialsMockHandler,
+ getGetV1ListProvidersMockHandler,
+} from "@/app/api/__generated__/endpoints/integrations/integrations.msw";
import {
getGetV1ListExecutionSchedulesForAUserMockHandler,
getListCopilotFollowupSchedulesMockHandler,
} from "@/app/api/__generated__/endpoints/schedules/schedules.msw";
import { getListCopilotSkillsMockHandler } from "@/app/api/__generated__/endpoints/skills/skills.msw";
import { server } from "@/mocks/mock-server";
-import { fireEvent, render, screen } from "@/tests/integrations/test-utils";
+import {
+ fireEvent,
+ render,
+ screen,
+ within,
+} from "@/tests/integrations/test-utils";
+import { NuqsTestingAdapter } from "nuqs/adapters/testing";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { useCopilotUIStore } from "../../../store";
import { useCopilotModal } from "../../../useCopilotModal";
@@ -13,13 +22,29 @@ import { CopilotModals } from "../CopilotModals";
function Harness() {
const { openModal } = useCopilotModal();
+
+ function openSkills() {
+ openModal("skills");
+ }
+
+ function openScheduled() {
+ openModal("scheduled");
+ }
+
+ function openIntegrations() {
+ openModal("integrations");
+ }
+
+ function openConnect() {
+ openModal("connect");
+ }
+
return (
<>
- <button onClick={() => openModal("skills")}>open-skills</button>
- <button onClick={() => openModal("scheduled")}>open-scheduled</button>
- <button onClick={() => openModal("integrations")}>
- open-integrations
- </button>
+ <button onClick={openSkills}>open-skills</button>
+ <button onClick={openScheduled}>open-scheduled</button>
+ <button onClick={openIntegrations}>open-integrations</button>
+ <button onClick={openConnect}>open-connect</button>
<CopilotModals />
</>
);
@@ -96,4 +121,58 @@ describe("CopilotModals", () => {
(await screen.findAllByText("Connect Service")).length,
).toBeGreaterThan(0);
});
+
+ test("opens the connect dialog directly, without the credentials list", async () => {
+ server.use(
+ getGetV1ListProvidersMockHandler([
+ {
+ name: "github",
+ description: "Issues and PRs",
+ supported_auth_types: ["oauth2", "api_key"],
+ },
+ ]),
+ );
+ render(<Harness />);
+ fireEvent.click(screen.getByText("open-connect"));
+
+ const dialog = await screen.findByRole("dialog");
+ expect(await within(dialog).findByText("Issues and PRs")).toBeDefined();
+ expect(screen.queryByText("No integration connected")).toBeNull();
+ });
+
+ test("renders the connect dialog from a ?modal=connect deep link", async () => {
+ render(
+ <NuqsTestingAdapter searchParams="?modal=connect">
+ <Harness />
+ </NuqsTestingAdapter>,
+ );
+
+ const dialog = await screen.findByRole("dialog");
+ expect(within(dialog).getByText("Connect a service")).toBeDefined();
+ });
+
+ test("closing the connect dialog clears the modal query param", async () => {
+ const onUrlUpdate = vi.fn();
+ render(
+ <NuqsTestingAdapter
+ searchParams="?modal=connect"
+ onUrlUpdate={onUrlUpdate}
+ >
+ <Harness />
+ </NuqsTestingAdapter>,
+ );
+
+ const dialog = await screen.findByRole("dialog");
+ fireEvent.click(within(dialog).getByRole("button", { name: "Close" }));
+
+ await vi.waitFor(() => {
+ expect(screen.queryByRole("dialog")).toBeNull();
+ });
+ await vi.waitFor(() => {
+ expect(
+ onUrlUpdate.mock.calls.at(-1)?.[0].searchParams.get("modal"),
+ ).toBeNull();
+ expect(onUrlUpdate).toHaveBeenCalled();
+ });
+ });
});
diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotModal.ts b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotModal.ts
index a4a89877a9..9f6b78b334 100644
--- a/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotModal.ts
+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/useCopilotModal.ts
@@ -1,6 +1,11 @@
import { parseAsStringLiteral, useQueryState } from "nuqs";
-export const COPILOT_MODALS = ["integrations", "skills", "scheduled"] as const;
+export const COPILOT_MODALS = [
+ "integrations",
+ "connect",
+ "skills",
+ "scheduled",
+] as const;
export type CopilotModalType = (typeof COPILOT_MODALS)[number];
export function useCopilotModal() {