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): Settings v2 API keys page (SECRT-2273) (#12907)
Abhimanyu Yadav34374dfd55d2
diff --git a/autogpt_platform/frontend/AGENTS.md b/autogpt_platform/frontend/AGENTS.mdindex 152d0f239d..fee844ccaf 100644--- a/autogpt_platform/frontend/AGENTS.md+++ b/autogpt_platform/frontend/AGENTS.md@@ -86,6 +86,7 @@ See @CONTRIBUTING.md for complete patterns. Quick reference:- Regenerate with `pnpm generate:api`- Pattern: `use{Method}{Version}{OperationName}`4. **Styling**: Tailwind CSS only, use design tokens, Phosphor Icons only+ - Always import the `-Icon`-suffixed alias from `@phosphor-icons/react` (e.g. `TrashIcon`, `PlusIcon`, `SquareIcon`) — bare exports like `Trash`/`Plus` are deprecated.5. **Testing**: Integration tests are the default (~90%). See `TESTING.md` for full details.- **New pages/features**: Write integration tests in `__tests__/` next to `page.tsx` using Vitest + RTL + MSW- **API mocking**: Use Orval-generated MSW handlers from `@/app/api/__generated__/endpoints/{tag}/{tag}.msw.ts`diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/__tests__/placeholder-pages.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/__tests__/placeholder-pages.test.tsxindex e8bb01134c..7ed8421642 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/__tests__/placeholder-pages.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/__tests__/placeholder-pages.test.tsx@@ -5,7 +5,6 @@ import SettingsCreatorDashboardPage from "../creator-dashboard/page";import SettingsBillingPage from "../billing/page";import SettingsIntegrationsPage from "../integrations/page";import SettingsPreferencesPage from "../preferences/page";-import SettingsApiKeysPage from "../api-keys/page";import SettingsOAuthAppsPage from "../oauth-apps/page";const pages = [@@ -14,7 +13,6 @@ const pages = [{ Component: SettingsBillingPage, title: "Billing" },{ Component: SettingsIntegrationsPage, title: "Integrations" },{ Component: SettingsPreferencesPage, title: "Settings" },- { Component: SettingsApiKeysPage, title: "AutoGPT API Keys" },{ Component: SettingsOAuthAppsPage, title: "OAuth Apps" },];diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/create.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/create.test.tsxnew file mode 100644index 0000000000..03c0fa60c1--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/create.test.tsx@@ -0,0 +1,353 @@+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";++import {+ fireEvent,+ render,+ screen,+ waitFor,+ within,+} from "@/tests/integrations/test-utils";+import { server } from "@/mocks/mock-server";+import {+ getGetV1ListUserApiKeysMockHandler,+ getPostV1CreateNewApiKeyMockHandler200,+ getPostV1CreateNewApiKeyMockHandler422,+ getPostV1CreateNewApiKeyResponseMock200,+} from "@/app/api/__generated__/endpoints/api-keys/api-keys.msw";++import SettingsApiKeysPage from "../page";++const toastSpy = vi.fn();++vi.mock("@/components/molecules/Toast/use-toast", async (importOriginal) => {+ const actual =+ await importOriginal<+ typeof import("@/components/molecules/Toast/use-toast")+ >();+ return {+ ...actual,+ toast: (...args: Parameters<typeof actual.toast>) => toastSpy(...args),+ };+});++function openCreateDialog() {+ const createButtons = screen.getAllByRole("button", {+ name: /^create key$/i,+ });+ fireEvent.click(createButtons[0]);+}++describe("SettingsApiKeysPage - create flow", () => {+ beforeEach(() => {+ toastSpy.mockClear();+ });++ test("opens the create dialog with a form when Create Key is clicked", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler([]));++ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();++ const dialog = await screen.findByRole("dialog");+ expect(within(dialog).getByText(/create api key/i)).toBeDefined();+ expect(within(dialog).getByLabelText(/^name$/i)).toBeDefined();+ expect(within(dialog).getByLabelText(/description/i)).toBeDefined();+ expect(within(dialog).getByText(/permissions/i)).toBeDefined();+ });++ test("toggling a permission off re-disables the submit button", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler([]));++ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();+ const dialog = await screen.findByRole("dialog");++ fireEvent.change(within(dialog).getByLabelText(/^name$/i), {+ target: { value: "Toggle Key" },+ });+ const checkbox = within(dialog).getByRole("checkbox", {+ name: /execute graph/i,+ });++ fireEvent.click(checkbox);+ const submit = within(dialog).getByRole("button", {+ name: /create key/i,+ }) as HTMLButtonElement;+ await waitFor(() => {+ expect(submit.disabled).toBe(false);+ });++ fireEvent.click(checkbox);+ await waitFor(() => {+ expect(submit.disabled).toBe(true);+ });+ });++ test("disables submit until the form is valid", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler([]));++ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();+ const dialog = await screen.findByRole("dialog");++ const submit = within(dialog).getByRole("button", { name: /create key/i });+ expect((submit as HTMLButtonElement).disabled).toBe(true);++ fireEvent.change(within(dialog).getByLabelText(/^name$/i), {+ target: { value: "Integration Test Key" },+ });+ // Still invalid — no permission picked yet.+ await waitFor(() => {+ expect((submit as HTMLButtonElement).disabled).toBe(true);+ });++ fireEvent.click(+ within(dialog).getByRole("checkbox", { name: /execute graph/i }),+ );++ await waitFor(() => {+ expect((submit as HTMLButtonElement).disabled).toBe(false);+ });+ });++ test("submits successfully and switches to the success view with plain text key", async () => {+ const plain = "plain-secret-key-abc123";+ server.use(+ getGetV1ListUserApiKeysMockHandler([]),+ getPostV1CreateNewApiKeyMockHandler200(+ getPostV1CreateNewApiKeyResponseMock200({ plain_text_key: plain }),+ ),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();+ const dialog = await screen.findByRole("dialog");++ fireEvent.change(within(dialog).getByLabelText(/^name$/i), {+ target: { value: "My New Key" },+ });+ fireEvent.click(+ within(dialog).getByRole("checkbox", { name: /execute graph/i }),+ );++ const submit = within(dialog).getByRole("button", {+ name: /create key/i,+ }) as HTMLButtonElement;+ await waitFor(() => {+ expect(submit.disabled).toBe(false);+ });+ fireEvent.click(submit);++ expect(await screen.findByText(/your new api key/i)).toBeDefined();+ expect(await screen.findByText(plain)).toBeDefined();+ expect(+ within(dialog).getAllByRole("button", { name: /^close$/i }).length,+ ).toBeGreaterThan(0);+ });++ test("dismisses the dialog via the header Close button when not submitting", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler([]));++ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();+ const dialog = await screen.findByRole("dialog");++ fireEvent.click(within(dialog).getByRole("button", { name: /^close$/i }));++ await waitFor(() => {+ expect(screen.queryByRole("dialog")).toBeNull();+ });+ });++ test("keeps the form open when the API returns 422", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([]),+ getPostV1CreateNewApiKeyMockHandler422(),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();+ const dialog = await screen.findByRole("dialog");++ fireEvent.change(within(dialog).getByLabelText(/^name$/i), {+ target: { value: "Should Fail" },+ });+ fireEvent.click(+ within(dialog).getByRole("checkbox", { name: /execute graph/i }),+ );++ const submit = within(dialog).getByRole("button", {+ name: /create key/i,+ }) as HTMLButtonElement;+ await waitFor(() => {+ expect(submit.disabled).toBe(false);+ });+ fireEvent.click(submit);++ // No transition to the success view — form inputs remain mounted.+ await waitFor(() => {+ expect(within(dialog).getByLabelText(/^name$/i)).toBeDefined();+ });+ expect(screen.queryByText(/your new api key/i)).toBeNull();+ });++ test("reopening the dialog after a successful create resets the form", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([]),+ getPostV1CreateNewApiKeyMockHandler200(+ getPostV1CreateNewApiKeyResponseMock200({+ plain_text_key: "reset-me",+ }),+ ),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();+ let dialog = await screen.findByRole("dialog");++ fireEvent.change(within(dialog).getByLabelText(/^name$/i), {+ target: { value: "First Key" },+ });+ fireEvent.click(+ within(dialog).getByRole("checkbox", { name: /execute graph/i }),+ );++ const submit = within(dialog).getByRole("button", {+ name: /create key/i,+ }) as HTMLButtonElement;+ await waitFor(() => {+ expect(submit.disabled).toBe(false);+ });+ fireEvent.click(submit);++ await screen.findByText("reset-me");+ const closeButtons = within(dialog).getAllByRole("button", {+ name: /^close$/i,+ });+ fireEvent.click(closeButtons[closeButtons.length - 1]);++ await waitFor(() => {+ expect(screen.queryByRole("dialog")).toBeNull();+ });++ openCreateDialog();+ dialog = await screen.findByRole("dialog");++ const nameInput = within(dialog).getByLabelText(+ /^name$/i,+ ) as HTMLInputElement;+ expect(nameInput.value).toBe("");+ expect(within(dialog).queryByText(/your new api key/i)).toBeNull();+ });++ describe("success view", () => {+ const plain = "sk-super-secret-1234567890";+ const originalClipboard = Object.getOwnPropertyDescriptor(+ globalThis.navigator,+ "clipboard",+ );+ let writeTextSpy: ReturnType<typeof vi.fn>;++ async function submitUntilSuccessView() {+ server.use(+ getGetV1ListUserApiKeysMockHandler([]),+ getPostV1CreateNewApiKeyMockHandler200(+ getPostV1CreateNewApiKeyResponseMock200({ plain_text_key: plain }),+ ),+ );+ render(<SettingsApiKeysPage />);+ await screen.findByText(/no api key found/i);++ openCreateDialog();+ const dialog = await screen.findByRole("dialog");+ fireEvent.change(within(dialog).getByLabelText(/^name$/i), {+ target: { value: "Copyable Key" },+ });+ fireEvent.click(+ within(dialog).getByRole("checkbox", { name: /execute graph/i }),+ );+ const submit = within(dialog).getByRole("button", {+ name: /create key/i,+ }) as HTMLButtonElement;+ await waitFor(() => {+ expect(submit.disabled).toBe(false);+ });+ fireEvent.click(submit);+ await screen.findByText(plain);+ return dialog;+ }++ function installClipboard(writeText: ReturnType<typeof vi.fn>) {+ Object.defineProperty(globalThis.navigator, "clipboard", {+ configurable: true,+ value: { writeText },+ });+ }++ afterEach(() => {+ if (originalClipboard) {+ Object.defineProperty(+ globalThis.navigator,+ "clipboard",+ originalClipboard,+ );+ } else {+ // @ts-expect-error — ensure a missing clipboard stays missing across tests+ delete globalThis.navigator.clipboard;+ }+ });++ test("copies the plaintext key and shows a success toast when Copy is clicked", async () => {+ writeTextSpy = vi.fn().mockResolvedValue(undefined);+ installClipboard(writeTextSpy);++ const dialog = await submitUntilSuccessView();++ fireEvent.click(within(dialog).getByRole("button", { name: /^copy$/i }));++ await waitFor(() => {+ expect(writeTextSpy).toHaveBeenCalledWith(plain);+ });+ await waitFor(() => {+ expect(toastSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ title: "Copied to clipboard",+ variant: "success",+ }),+ );+ });+ });++ test("shows a destructive toast when the clipboard write fails", async () => {+ writeTextSpy = vi.fn().mockRejectedValue(new Error("denied"));+ installClipboard(writeTextSpy);++ const dialog = await submitUntilSuccessView();++ fireEvent.click(within(dialog).getByRole("button", { name: /^copy$/i }));++ await waitFor(() => {+ expect(toastSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ title: "Could not copy to clipboard",+ variant: "destructive",+ }),+ );+ });+ });+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/delete.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/delete.test.tsxnew file mode 100644index 0000000000..f396ca4971--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/delete.test.tsx@@ -0,0 +1,194 @@+import { describe, expect, test } from "vitest";++import {+ fireEvent,+ render,+ screen,+ waitFor,+ within,+} from "@/tests/integrations/test-utils";+import { server } from "@/mocks/mock-server";+import {+ getDeleteV1RevokeApiKeyMockHandler200,+ getDeleteV1RevokeApiKeyMockHandler422,+ getGetV1ListUserApiKeysMockHandler,+} from "@/app/api/__generated__/endpoints/api-keys/api-keys.msw";+import type { APIKeyInfo } from "@/app/api/__generated__/models/aPIKeyInfo";+import { APIKeyPermission } from "@/app/api/__generated__/models/aPIKeyPermission";+import { APIKeyStatus } from "@/app/api/__generated__/models/aPIKeyStatus";++import SettingsApiKeysPage from "../page";++function makeKey(overrides: Partial<APIKeyInfo> = {}): APIKeyInfo {+ return {+ id: "key-base",+ user_id: "user-1",+ name: "Base Key",+ head: "sk-abcd1234",+ tail: "wxyz5678",+ status: APIKeyStatus.ACTIVE,+ scopes: [APIKeyPermission.EXECUTE_GRAPH],+ created_at: new Date("2025-01-01T00:00:00Z"),+ last_used_at: null,+ revoked_at: null,+ expires_at: null,+ description: null,+ ...overrides,+ };+}++describe("SettingsApiKeysPage - revoke flow", () => {+ test("clicking the row trash opens a single-key confirm dialog", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "k1", name: "Alpha" }),+ makeKey({ id: "k2", name: "Beta" }),+ ]),+ getDeleteV1RevokeApiKeyMockHandler200(),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText("Alpha");++ fireEvent.click(screen.getByRole("button", { name: /delete alpha/i }));++ const dialog = await screen.findByRole("dialog");+ expect(within(dialog).getByText(/revoke api key/i)).toBeDefined();+ expect(+ within(dialog).getByRole("button", { name: /^revoke key$/i }),+ ).toBeDefined();+ expect(+ within(dialog).getByRole("button", { name: /cancel/i }),+ ).toBeDefined();+ });++ test("cancel closes the confirm dialog without deleting", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "k1", name: "Alpha" }),+ ]),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText("Alpha");++ fireEvent.click(screen.getByRole("button", { name: /delete alpha/i }));+ const dialog = await screen.findByRole("dialog");++ fireEvent.click(within(dialog).getByRole("button", { name: /cancel/i }));++ await waitFor(() => {+ expect(screen.queryByRole("dialog")).toBeNull();+ });++ // Row is still rendered; no crash, no redirect.+ expect(screen.getByText("Alpha")).toBeDefined();+ });++ test("confirming revoke closes the dialog", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "k1", name: "Alpha" }),+ ]),+ getDeleteV1RevokeApiKeyMockHandler200(),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText("Alpha");++ fireEvent.click(screen.getByRole("button", { name: /delete alpha/i }));+ const dialog = await screen.findByRole("dialog");++ fireEvent.click(+ within(dialog).getByRole("button", { name: /^revoke key$/i }),+ );++ await waitFor(() => {+ expect(screen.queryByRole("dialog")).toBeNull();+ });+ });++ test("selecting multiple rows surfaces the selection bar with count", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "k1", name: "Alpha" }),+ makeKey({ id: "k2", name: "Beta" }),+ makeKey({ id: "k3", name: "Gamma" }),+ ]),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText("Alpha");++ fireEvent.click(screen.getByRole("checkbox", { name: /select alpha/i }));+ fireEvent.click(screen.getByRole("checkbox", { name: /select beta/i }));++ expect(await screen.findByText(/2 selected/i)).toBeDefined();+ expect(+ screen.getByRole("button", { name: /delete selected/i }),+ ).toBeDefined();+ });++ test("keeps the dialog open and does not clear selection when revoke fails", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "k1", name: "Alpha" }),+ makeKey({ id: "k2", name: "Beta" }),+ ]),+ getDeleteV1RevokeApiKeyMockHandler422(),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText("Alpha");++ fireEvent.click(screen.getByRole("checkbox", { name: /select alpha/i }));+ fireEvent.click(screen.getByRole("checkbox", { name: /select beta/i }));+ await screen.findByText(/2 selected/i);++ fireEvent.click(screen.getByRole("button", { name: /delete selected/i }));+ const dialog = await screen.findByRole("dialog");++ fireEvent.click(+ within(dialog).getByRole("button", { name: /^revoke keys$/i }),+ );++ // Dialog stays open, selection bar still present, nothing cleared.+ await waitFor(() => {+ expect(+ within(dialog).getByRole("button", { name: /^revoke keys$/i }),+ ).toBeDefined();+ });+ expect(screen.getByText(/2 selected/i)).toBeDefined();+ });++ test("batch delete opens a multi-key confirm dialog and closes on confirm", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "k1", name: "Alpha" }),+ makeKey({ id: "k2", name: "Beta" }),+ ]),+ getDeleteV1RevokeApiKeyMockHandler200(),+ );++ render(<SettingsApiKeysPage />);+ await screen.findByText("Alpha");++ fireEvent.click(screen.getByRole("checkbox", { name: /select alpha/i }));+ fireEvent.click(screen.getByRole("checkbox", { name: /select beta/i }));++ await screen.findByText(/2 selected/i);++ fireEvent.click(screen.getByRole("button", { name: /delete selected/i }));++ const dialog = await screen.findByRole("dialog");+ expect(within(dialog).getByText(/revoke 2 api keys/i)).toBeDefined();++ fireEvent.click(+ within(dialog).getByRole("button", { name: /^revoke keys$/i }),+ );++ await waitFor(() => {+ expect(screen.queryByRole("dialog")).toBeNull();+ });+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/main.test.tsxnew file mode 100644index 0000000000..0b110c298d--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/__tests__/main.test.tsx@@ -0,0 +1,161 @@+import { describe, expect, test } from "vitest";++import { fireEvent, render, screen } from "@/tests/integrations/test-utils";+import { server } from "@/mocks/mock-server";+import {+ getGetV1ListUserApiKeysMockHandler,+ getGetV1ListUserApiKeysMockHandler401,+} from "@/app/api/__generated__/endpoints/api-keys/api-keys.msw";+import type { APIKeyInfo } from "@/app/api/__generated__/models/aPIKeyInfo";+import { APIKeyPermission } from "@/app/api/__generated__/models/aPIKeyPermission";+import { APIKeyStatus } from "@/app/api/__generated__/models/aPIKeyStatus";++import SettingsApiKeysPage from "../page";++function makeKey(overrides: Partial<APIKeyInfo> = {}): APIKeyInfo {+ return {+ id: "key-base",+ user_id: "user-1",+ name: "Base Key",+ head: "sk-abcd1234",+ tail: "wxyz5678",+ status: APIKeyStatus.ACTIVE,+ scopes: [APIKeyPermission.EXECUTE_GRAPH],+ created_at: new Date("2025-01-01T00:00:00Z"),+ last_used_at: null,+ revoked_at: null,+ expires_at: null,+ description: null,+ ...overrides,+ };+}++describe("SettingsApiKeysPage - list rendering", () => {+ test("renders header title and Create Key button", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler([]));++ render(<SettingsApiKeysPage />);++ expect(+ await screen.findByRole("heading", { name: /autogpt api keys/i }),+ ).toBeDefined();++ const createButtons = screen.getAllByRole("button", {+ name: /create key/i,+ });+ expect(createButtons.length).toBeGreaterThan(0);+ });++ test("shows empty state when the user has no keys", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler([]));++ render(<SettingsApiKeysPage />);++ expect(await screen.findByText(/no api key found/i)).toBeDefined();+ });++ test("renders a row per ACTIVE key with masked secret and last-used label", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({+ id: "k1",+ name: "Prod Key",+ head: "sk-head111",+ tail: "tail99999",+ last_used_at: null,+ }),+ ]),+ );++ render(<SettingsApiKeysPage />);++ expect(await screen.findByText("Prod Key")).toBeDefined();+ expect(screen.getByText("sk-head111••••••••tail99999")).toBeDefined();+ expect(screen.getByText(/never used/i)).toBeDefined();+ expect(+ screen.getByRole("checkbox", { name: /select prod key/i }),+ ).toBeDefined();+ expect(+ screen.getByRole("button", { name: /delete prod key/i }),+ ).toBeDefined();+ });++ test("filters REVOKED keys out of the rendered list", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "a", name: "Active Key" }),+ makeKey({+ id: "r",+ name: "Revoked Key",+ status: APIKeyStatus.REVOKED,+ }),+ ]),+ );++ render(<SettingsApiKeysPage />);++ expect(await screen.findByText("Active Key")).toBeDefined();+ expect(screen.queryByText("Revoked Key")).toBeNull();+ });++ test("renders an error card (not the empty state) when the API fails", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler401());++ render(<SettingsApiKeysPage />);++ expect(await screen.findByText(/something went wrong/i)).toBeDefined();+ expect(screen.queryByText(/no api key found/i)).toBeNull();+ });++ test("error card 'Try again' refetches and recovers when the API succeeds", async () => {+ server.use(getGetV1ListUserApiKeysMockHandler401());++ render(<SettingsApiKeysPage />);++ await screen.findByText(/something went wrong/i);++ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "recovered", name: "Recovered Key" }),+ ]),+ );++ fireEvent.click(screen.getByRole("button", { name: /try again/i }));++ expect(await screen.findByText("Recovered Key")).toBeDefined();+ });++ test("clicking the row info icon opens the details dialog for that key", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "a", name: "Inspectable Key" }),+ ]),+ );++ render(<SettingsApiKeysPage />);++ const infoButton = await screen.findByRole("button", {+ name: /view details for inspectable key/i,+ });+ fireEvent.click(infoButton);++ const dialog = await screen.findByRole("dialog");+ expect(dialog.textContent).toContain("Inspectable Key");+ });++ test("renders multiple keys in order", async () => {+ server.use(+ getGetV1ListUserApiKeysMockHandler([+ makeKey({ id: "a", name: "Alpha Key" }),+ makeKey({ id: "b", name: "Beta Key" }),+ makeKey({ id: "c", name: "Gamma Key" }),+ ]),+ );++ render(<SettingsApiKeysPage />);++ expect(await screen.findByText("Alpha Key")).toBeDefined();+ expect(screen.getByText("Beta Key")).toBeDefined();+ expect(screen.getByText("Gamma Key")).toBeDefined();+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyInfoDialog/APIKeyInfoDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyInfoDialog/APIKeyInfoDialog.tsxnew file mode 100644index 0000000000..225106b805--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyInfoDialog/APIKeyInfoDialog.tsx@@ -0,0 +1,89 @@+"use client";++import type { ReactNode } from "react";+import { format } from "date-fns";++import type { APIKeyInfo } from "@/app/api/__generated__/models/aPIKeyInfo";+import { Text } from "@/components/atoms/Text/Text";+import { Dialog } from "@/components/molecules/Dialog/Dialog";++import { maskAPIKey } from "../APIKeyList/helpers";+import { humanizePermission } from "../CreateAPIKeyDialog/schema";++interface Props {+ open: boolean;+ apiKey: APIKeyInfo;+ onOpenChange: (open: boolean) => void;+}++export function APIKeyInfoDialog({ open, apiKey, onOpenChange }: Props) {+ return (+ <Dialog+ title={apiKey.name}+ styling={{ maxWidth: "30rem" }}+ controlled={{ isOpen: open, set: onOpenChange }}+ >+ <Dialog.Content>+ <div className="flex flex-col gap-4 px-1">+ <Section label="Key">+ <code className="font-mono text-sm text-zinc-800">+ {maskAPIKey(apiKey.head, apiKey.tail)}+ </code>+ </Section>++ {apiKey.description && (+ <Section label="Description">+ <Text variant="body" className="text-zinc-700">+ {apiKey.description}+ </Text>+ </Section>+ )}++ <Section label="Scopes">+ {apiKey.scopes.length === 0 ? (+ <Text variant="body" className="text-zinc-500">+ No scopes+ </Text>+ ) : (+ <ul className="flex flex-wrap gap-1.5">+ {apiKey.scopes.map((scope) => (+ <li+ key={scope}+ className="rounded-full bg-zinc-100 px-2.5 py-1 text-xs text-zinc-700"+ >+ {humanizePermission(scope)}+ </li>+ ))}+ </ul>+ )}+ </Section>++ <Section label="Created">+ <Text variant="body" className="text-zinc-700">+ {format(new Date(apiKey.created_at), "PPP p")}+ </Text>+ </Section>++ <Section label="Last used">+ <Text variant="body" className="text-zinc-700">+ {apiKey.last_used_at+ ? format(new Date(apiKey.last_used_at), "PPP p")+ : "Never used"}+ </Text>+ </Section>+ </div>+ </Dialog.Content>+ </Dialog>+ );+}++function Section({ label, children }: { label: string; children: ReactNode }) {+ return (+ <div className="flex flex-col gap-1">+ <Text variant="small-medium" as="span" className="text-zinc-500">+ {label}+ </Text>+ {children}+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyInfoDialog/__tests__/APIKeyInfoDialog.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyInfoDialog/__tests__/APIKeyInfoDialog.test.tsxnew file mode 100644index 0000000000..2e058a60b2--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyInfoDialog/__tests__/APIKeyInfoDialog.test.tsx@@ -0,0 +1,93 @@+import { describe, expect, test, vi } from "vitest";++import { render, screen, within } from "@/tests/integrations/test-utils";+import type { APIKeyInfo } from "@/app/api/__generated__/models/aPIKeyInfo";+import { APIKeyPermission } from "@/app/api/__generated__/models/aPIKeyPermission";+import { APIKeyStatus } from "@/app/api/__generated__/models/aPIKeyStatus";++import { APIKeyInfoDialog } from "../APIKeyInfoDialog";++function buildApiKey(overrides: Partial<APIKeyInfo> = {}): APIKeyInfo {+ return {+ id: "key_1",+ user_id: "user_1",+ name: "Production key",+ head: "pk_live_",+ tail: "abcd1234",+ status: APIKeyStatus.ACTIVE,+ scopes: [APIKeyPermission.EXECUTE_GRAPH, APIKeyPermission.READ_GRAPH],+ created_at: new Date("2026-01-15T10:30:00Z"),+ last_used_at: new Date("2026-03-20T08:15:00Z"),+ description: "Used by the production API",+ ...overrides,+ };+}++describe("APIKeyInfoDialog", () => {+ test("renders name, masked key, description, scopes, and timestamps", () => {+ const apiKey = buildApiKey();++ render(<APIKeyInfoDialog apiKey={apiKey} open onOpenChange={vi.fn()} />);++ const dialog = screen.getByRole("dialog");++ expect(within(dialog).getByText("Production key")).toBeDefined();+ expect(within(dialog).getByText(/pk_live_.+abcd1234/)).toBeDefined();+ expect(+ within(dialog).getByText(/used by the production api/i),+ ).toBeDefined();+ expect(within(dialog).getByText(/execute graph/i)).toBeDefined();+ expect(within(dialog).getByText(/read graph/i)).toBeDefined();+ expect(within(dialog).getByText(/^created$/i)).toBeDefined();+ expect(within(dialog).getByText(/^last used$/i)).toBeDefined();+ });++ test("renders 'No scopes' when the key has no permissions", () => {+ render(+ <APIKeyInfoDialog+ apiKey={buildApiKey({ scopes: [] })}+ open+ onOpenChange={vi.fn()}+ />,+ );++ expect(screen.getByText(/no scopes/i)).toBeDefined();+ expect(screen.queryByText(/execute graph/i)).toBeNull();+ });++ test("renders 'Never used' when last_used_at is missing", () => {+ render(+ <APIKeyInfoDialog+ apiKey={buildApiKey({ last_used_at: null })}+ open+ onOpenChange={vi.fn()}+ />,+ );++ expect(screen.getByText(/never used/i)).toBeDefined();+ });++ test("hides the description section when description is empty", () => {+ render(+ <APIKeyInfoDialog+ apiKey={buildApiKey({ description: "" })}+ open+ onOpenChange={vi.fn()}+ />,+ );++ expect(screen.queryByText(/^description$/i)).toBeNull();+ });++ test("does not render dialog contents when open is false", () => {+ render(+ <APIKeyInfoDialog+ apiKey={buildApiKey()}+ open={false}+ onOpenChange={vi.fn()}+ />,+ );++ expect(screen.queryByRole("dialog")).toBeNull();+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/APIKeyList.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/APIKeyList.tsxnew file mode 100644index 0000000000..ccec7ff672--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/APIKeyList.tsx@@ -0,0 +1,102 @@+"use client";++import { AnimatePresence, motion, useReducedMotion } from "framer-motion";++import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";++import { APIKeyListEmpty } from "../APIKeyListEmpty/APIKeyListEmpty";+import { APIKeyListSkeleton } from "../APIKeyListSkeleton/APIKeyListSkeleton";+import { APIKeyRow } from "../APIKeyRow/APIKeyRow";+import { APIKeySelectionBar } from "../APIKeySelectionBar/APIKeySelectionBar";+import { DeleteAPIKeyDialog } from "../DeleteAPIKeyDialog/DeleteAPIKeyDialog";+import { useAPIKeyListView } from "./useAPIKeyListView";++export function APIKeyList() {+ const {+ keys,+ isLoading,+ isError,+ error,+ refetch,+ isEmpty,+ selection,+ deleteTarget,+ requestDelete,+ closeDeleteDialog,+ handleDeleted,+ } = useAPIKeyListView();+ const reduceMotion = useReducedMotion();++ if (isLoading) return <APIKeyListSkeleton />;+ if (isError) {+ const message = error instanceof Error ? error.message : undefined;+ return (+ <ErrorCard+ context="API keys"+ responseError={message ? { message } : undefined}+ onRetry={() => {+ refetch();+ }}+ />+ );+ }+ if (isEmpty) return <APIKeyListEmpty />;++ return (+ <div className="flex w-full flex-col gap-3">+ <AnimatePresence initial={false}>+ {selection.selectedCount > 0 && (+ <motion.div+ key="selection-bar"+ initial={+ reduceMotion+ ? { opacity: 0 }+ : { opacity: 0, height: 0, marginBottom: -12 }+ }+ animate={+ reduceMotion+ ? { opacity: 1 }+ : { opacity: 1, height: "auto", marginBottom: 0 }+ }+ exit={+ reduceMotion+ ? { opacity: 0 }+ : { opacity: 0, height: 0, marginBottom: -12 }+ }+ transition={{ duration: 0.2, ease: [0, 0, 0.2, 1] }}+ className="sticky top-0 z-20 overflow-hidden bg-[#F9F9FA]"+ >+ <APIKeySelectionBar+ selectedCount={selection.selectedCount}+ allSelected={selection.allSelected}+ onSelectAll={selection.selectAll}+ onDeselectAll={selection.clear}+ onDeleteSelected={() => requestDelete([...selection.selectedIds])}+ />+ </motion.div>+ )}+ </AnimatePresence>++ <div className="flex flex-col divide-y divide-zinc-200 overflow-hidden rounded-[8px] border border-zinc-200 bg-white">+ {keys.map((key) => (+ <APIKeyRow+ key={key.id}+ apiKey={key}+ selected={selection.isSelected(key.id)}+ onToggleSelected={() => selection.toggle(key.id)}+ onDelete={() => requestDelete([key.id])}+ />+ ))}+ </div>++ {deleteTarget && (+ <DeleteAPIKeyDialog+ open+ keyIds={deleteTarget}+ onOpenChange={closeDeleteDialog}+ onDeleted={handleDeleted}+ />+ )}+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/helpers.test.tsnew file mode 100644index 0000000000..01b804ba1e--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/helpers.test.ts@@ -0,0 +1,30 @@+import { describe, expect, test } from "vitest";++import { formatLastUsed, maskAPIKey } from "./helpers";++describe("maskAPIKey", () => {+ test("joins head, a fixed mask, and tail", () => {+ expect(maskAPIKey("pk_live_", "abcd1234")).toBe("pk_live_••••••••abcd1234");+ });++ test("handles empty head and tail", () => {+ expect(maskAPIKey("", "")).toBe("••••••••");+ });+});++describe("formatLastUsed", () => {+ test("returns 'Never used' when last used is null", () => {+ expect(formatLastUsed(null)).toBe("Never used");+ });++ test("returns 'Never used' when last used is undefined", () => {+ expect(formatLastUsed(undefined)).toBe("Never used");+ });++ test("returns a relative-time phrase when last used is a Date", () => {+ const twoHoursAgo = new Date(Date.now() - 2 * 60 * 60 * 1000);+ const result = formatLastUsed(twoHoursAgo);+ expect(result.startsWith("Used ")).toBe(true);+ expect(result.includes("ago")).toBe(true);+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/helpers.tsnew file mode 100644index 0000000000..971ebdc6fa--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/helpers.ts@@ -0,0 +1,12 @@+import { formatDistanceToNow } from "date-fns";++export function maskAPIKey(head: string, tail: string): string {+ return `${head}••••••••${tail}`;+}++export function formatLastUsed(+ lastUsedAt: Date | string | null | undefined,+): string {+ if (!lastUsedAt) return "Never used";+ return `Used ${formatDistanceToNow(new Date(lastUsedAt), { addSuffix: true })}`;+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/useAPIKeyListView.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/useAPIKeyListView.tsnew file mode 100644index 0000000000..c4cd08d926--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/useAPIKeyListView.ts@@ -0,0 +1,41 @@+"use client";++import { useMemo, useState } from "react";++import { useAPIKeysList } from "../hooks/useAPIKeysList";+import { useAPIKeySelection } from "./useAPIKeySelection";++export function useAPIKeyListView() {+ const list = useAPIKeysList();+ // Stabilise the id array so useAPIKeySelection's effect doesn't re-run on+ // every parent render (the effect only cares when the set of ids changes).+ const allIds = useMemo(() => list.keys.map((key) => key.id), [list.keys]);+ const selection = useAPIKeySelection(allIds);+ const [deleteTarget, setDeleteTarget] = useState<string[] | null>(null);++ function requestDelete(ids: string[]) {+ setDeleteTarget(ids);+ }++ function closeDeleteDialog(open: boolean) {+ if (!open) setDeleteTarget(null);+ }++ function handleDeleted() {+ selection.clear();+ }++ return {+ keys: list.keys,+ isLoading: list.isLoading,+ isError: list.isError,+ error: list.error,+ refetch: list.refetch,+ isEmpty: list.isEmpty,+ selection,+ deleteTarget,+ requestDelete,+ closeDeleteDialog,+ handleDeleted,+ };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/useAPIKeySelection.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/useAPIKeySelection.tsnew file mode 100644index 0000000000..14e58050ba--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyList/useAPIKeySelection.ts@@ -0,0 +1,44 @@+import { useEffect, useState } from "react";++export function useAPIKeySelection(allIds: string[]) {+ const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());++ useEffect(() => {+ setSelectedIds((prev) => {+ if (prev.size === 0) return prev;+ const existing = new Set(allIds);+ const next = new Set<string>();+ for (const id of prev) {+ if (existing.has(id)) next.add(id);+ }+ return next.size === prev.size ? prev : next;+ });+ }, [allIds]);++ function toggle(id: string) {+ setSelectedIds((prev) => {+ const next = new Set(prev);+ if (next.has(id)) next.delete(id);+ else next.add(id);+ return next;+ });+ }++ function selectAll() {+ setSelectedIds(new Set(allIds));+ }++ function clear() {+ setSelectedIds(new Set());+ }++ return {+ selectedIds,+ selectedCount: selectedIds.size,+ allSelected: allIds.length > 0 && selectedIds.size === allIds.length,+ isSelected: (id: string) => selectedIds.has(id),+ toggle,+ selectAll,+ clear,+ };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListEmpty/APIKeyListEmpty.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListEmpty/APIKeyListEmpty.tsxnew file mode 100644index 0000000000..6841ef98da--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListEmpty/APIKeyListEmpty.tsx@@ -0,0 +1,22 @@+"use client";++import { Text } from "@/components/atoms/Text/Text";++import { APIKeyMarquee } from "./components/APIKeyMarquee";++export function APIKeyListEmpty() {+ return (+ <div className="flex flex-col items-center justify-center gap-4 px-6 py-10 text-center">+ <APIKeyMarquee />+ <div className="flex flex-col items-center gap-1">+ <Text variant="large-medium" as="span" className="text-textBlack">+ No API key found+ </Text>+ <Text variant="body" className="max-w-[360px] text-zinc-500">+ You haven't created an API key yet. Create one to start using the+ AutoGPT Platform API.+ </Text>+ </div>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListEmpty/components/APIKeyMarquee.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListEmpty/components/APIKeyMarquee.tsxnew file mode 100644index 0000000000..09e9291516--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListEmpty/components/APIKeyMarquee.tsx@@ -0,0 +1,46 @@+"use client";++import { motion, useReducedMotion } from "framer-motion";+import { KeyIcon } from "@phosphor-icons/react";++const GHOST_CARDS = Array.from({ length: 4 }, (_, i) => i);++export function APIKeyMarquee() {+ const reduceMotion = useReducedMotion();++ return (+ <div+ aria-hidden+ className="relative h-[260px] w-[340px] overflow-hidden"+ style={{+ maskImage:+ "linear-gradient(to bottom, transparent 0%, black 35%, black 65%, transparent 100%)",+ WebkitMaskImage:+ "linear-gradient(to bottom, transparent 0%, black 35%, black 65%, transparent 100%)",+ }}+ >+ <motion.div+ className="flex flex-col items-center gap-4 will-change-transform"+ animate={reduceMotion ? undefined : { y: ["0%", "-50%"] }}+ transition={+ reduceMotion+ ? undefined+ : { duration: 14, ease: "linear", repeat: Infinity }+ }+ >+ {[...GHOST_CARDS, ...GHOST_CARDS].map((_, i) => (+ <GhostCard key={i} />+ ))}+ </motion.div>+ </div>+ );+}++function GhostCard() {+ return (+ <div className="flex h-[64px] w-[320px] items-center gap-4 rounded-xl border border-zinc-200/80 bg-white px-5 shadow-[0_1px_2px_rgba(0,0,0,0.04)]">+ <KeyIcon size={18} className="shrink-0 text-zinc-400" />+ <div className="h-2.5 flex-1 rounded-full bg-zinc-100" />+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListSkeleton/APIKeyListSkeleton.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListSkeleton/APIKeyListSkeleton.tsxnew file mode 100644index 0000000000..9525e32eff--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyListSkeleton/APIKeyListSkeleton.tsx@@ -0,0 +1,31 @@+"use client";++import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";++const PLACEHOLDER_ROWS = Array.from({ length: 6 }, (_, i) => i);++export function APIKeyListSkeleton() {+ return (+ <div+ role="status"+ aria-label="Loading API keys"+ className="flex w-full flex-col divide-y divide-zinc-200 overflow-hidden rounded-[8px] border border-zinc-200 bg-white"+ >+ {PLACEHOLDER_ROWS.map((i) => (+ <div+ key={i}+ className="flex items-center justify-between py-4 pl-3 pr-5"+ >+ <div className="flex items-center gap-3">+ <Skeleton className="h-5 w-5" />+ <div className="flex flex-col gap-2">+ <Skeleton className="h-4 w-40" />+ <Skeleton className="h-3 w-56" />+ </div>+ </div>+ <Skeleton className="h-5 w-5" />+ </div>+ ))}+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyRow/APIKeyRow.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyRow/APIKeyRow.tsxnew file mode 100644index 0000000000..7f2c0a52aa--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeyRow/APIKeyRow.tsx@@ -0,0 +1,116 @@+"use client";++import { useState } from "react";+import {+ CheckSquareIcon,+ InfoIcon,+ SquareIcon,+ TrashIcon,+} from "@phosphor-icons/react";++import type { APIKeyInfo } from "@/app/api/__generated__/models/aPIKeyInfo";+import { Text } from "@/components/atoms/Text/Text";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/atoms/Tooltip/BaseTooltip";++import { APIKeyInfoDialog } from "../APIKeyInfoDialog/APIKeyInfoDialog";+import { formatLastUsed, maskAPIKey } from "../APIKeyList/helpers";++interface Props {+ apiKey: APIKeyInfo;+ selected: boolean;+ onToggleSelected: () => void;+ onDelete: () => void;+}++export function APIKeyRow({+ apiKey,+ selected,+ onToggleSelected,+ onDelete,+}: Props) {+ const [infoOpen, setInfoOpen] = useState(false);+ const maskedKey = maskAPIKey(apiKey.head, apiKey.tail);+ const lastUsedLabel = formatLastUsed(apiKey.last_used_at);++ return (+ <div+ data-selected={selected}+ className="flex items-center justify-between py-4 pl-3 pr-5 transition-colors data-[selected=true]:bg-zinc-100"+ >+ <div className="flex items-center gap-3">+ <button+ type="button"+ role="checkbox"+ aria-checked={selected}+ aria-label={`Select ${apiKey.name}`}+ onClick={onToggleSelected}+ className={`shrink-0 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-800 ${+ selected+ ? "text-zinc-800 hover:text-zinc-900"+ : "text-zinc-500 hover:text-zinc-700"+ }`}+ >+ {selected ? (+ <CheckSquareIcon size={20} weight="fill" />+ ) : (+ <SquareIcon size={20} />+ )}+ </button>+ <div className="flex flex-col gap-1">+ <div className="flex items-center gap-2">+ <Text variant="body-medium" as="span" className="text-textBlack">+ {apiKey.name}+ </Text>+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <button+ type="button"+ aria-label={`View details for ${apiKey.name}`}+ onClick={() => setInfoOpen(true)}+ className="shrink-0 rounded text-zinc-500 transition-colors hover:text-zinc-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-800"+ >+ <InfoIcon size={16} />+ </button>+ </TooltipTrigger>+ <TooltipContent side="top">View key details</TooltipContent>+ </Tooltip>+ </TooltipProvider>+ </div>+ <div className="flex items-center gap-3 whitespace-nowrap">+ <Text variant="label" as="span" className="text-zinc-700">+ {maskedKey}+ </Text>+ <Text+ variant="small"+ as="span"+ className="leading-[20px] text-zinc-500"+ >+ {lastUsedLabel}+ </Text>+ </div>+ </div>+ </div>++ <button+ type="button"+ aria-label={`Delete ${apiKey.name}`}+ onClick={onDelete}+ className="shrink-0 rounded text-zinc-500 transition-colors hover:text-zinc-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-800"+ >+ <TrashIcon size={20} />+ </button>++ <APIKeyInfoDialog+ open={infoOpen}+ apiKey={apiKey}+ onOpenChange={setInfoOpen}+ />+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeySelectionBar/APIKeySelectionBar.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeySelectionBar/APIKeySelectionBar.tsxnew file mode 100644index 0000000000..90006c4bba--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeySelectionBar/APIKeySelectionBar.tsx@@ -0,0 +1,45 @@+import { TrashIcon } from "@phosphor-icons/react";+import { Button } from "@/components/atoms/Button/Button";+import { Text } from "@/components/atoms/Text/Text";++interface Props {+ selectedCount: number;+ allSelected: boolean;+ onSelectAll: () => void;+ onDeselectAll: () => void;+ onDeleteSelected: () => void;+}++export function APIKeySelectionBar({+ selectedCount,+ allSelected,+ onSelectAll,+ onDeselectAll,+ onDeleteSelected,+}: Props) {+ return (+ <div className="flex w-full items-center justify-between rounded-[4px] border border-zinc-200 bg-zinc-100 px-4 py-2">+ <div className="flex items-center gap-5">+ <Text variant="body" as="span" className="text-zinc-700">+ {selectedCount} selected+ </Text>+ {!allSelected && (+ <Button variant="ghost" size="small" onClick={onSelectAll}>+ Select All+ </Button>+ )}+ <Button variant="ghost" size="small" onClick={onDeselectAll}>+ Deselect+ </Button>+ </div>+ <Button+ variant="destructive"+ size="small"+ leftIcon={<TrashIcon size={16} />}+ onClick={onDeleteSelected}+ >+ Delete selected+ </Button>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeysHeader/APIKeysHeader.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeysHeader/APIKeysHeader.tsxnew file mode 100644index 0000000000..5ff0c13ca5--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/APIKeysHeader/APIKeysHeader.tsx@@ -0,0 +1,43 @@+"use client";++import { PlusIcon } from "@phosphor-icons/react";+import { Button } from "@/components/atoms/Button/Button";+import { Text } from "@/components/atoms/Text/Text";++interface Props {+ onCreate: () => void;+}++export function APIKeysHeader({ onCreate }: Props) {+ return (+ <div className="flex flex-col items-start gap-4 pb-6 sm:flex-row sm:items-center sm:justify-between">+ <div className="flex min-w-0 flex-col">+ <Text variant="h4" as="h1" className="leading-[28px] text-textBlack">+ AutoGPT API Keys+ </Text>+ <Text variant="body" className="mt-4 max-w-[600px] text-zinc-700">+ Manage API keys that let external tools access your AutoGPT account.+ </Text>+ </div>++ <Button+ variant="primary"+ size="small"+ leftIcon={<PlusIcon size={16} />}+ onClick={onCreate}+ className="sm:hidden"+ >+ Create Key+ </Button>+ <Button+ variant="primary"+ size="large"+ leftIcon={<PlusIcon size={20} />}+ onClick={onCreate}+ className="hidden sm:inline-flex"+ >+ Create Key+ </Button>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/CreateAPIKeyDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/CreateAPIKeyDialog.tsxnew file mode 100644index 0000000000..0d1d813cd1--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/CreateAPIKeyDialog.tsx@@ -0,0 +1,53 @@+"use client";++import { Dialog } from "@/components/molecules/Dialog/Dialog";++import { CreateAPIKeyForm } from "./components/CreateAPIKeyForm";+import { CreateAPIKeySuccess } from "./components/CreateAPIKeySuccess";+import { useCreateAPIKeyForm } from "./useCreateAPIKeyForm";++interface Props {+ open: boolean;+ onOpenChange: (open: boolean) => void;+}++export function CreateAPIKeyDialog({ open, onOpenChange }: Props) {+ const { form, view, plainTextKey, isPending, handleSubmit, handleClose } =+ useCreateAPIKeyForm({ onClose: () => onOpenChange(false) });++ const isSuccess = view === "success";+ const title = isSuccess ? "Your new API key" : "Create API key";++ return (+ <Dialog+ title={title}+ styling={{ maxWidth: "34rem" }}+ controlled={{+ isOpen: open,+ set: (next) => {+ if (next) {+ onOpenChange(true);+ return;+ }+ if (isPending) return;+ handleClose();+ },+ }}+ >+ <Dialog.Content>+ {isSuccess ? (+ <CreateAPIKeySuccess+ plainTextKey={plainTextKey}+ onClose={handleClose}+ />+ ) : (+ <CreateAPIKeyForm+ form={form}+ onSubmit={handleSubmit}+ isPending={isPending}+ />+ )}+ </Dialog.Content>+ </Dialog>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeyForm.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeyForm.tsxnew file mode 100644index 0000000000..163bd4a520--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeyForm.tsx@@ -0,0 +1,92 @@+"use client";++import type { UseFormReturn } from "react-hook-form";++import { Button } from "@/components/atoms/Button/Button";+import { Input } from "@/components/atoms/Input/Input";+import {+ Form,+ FormControl,+ FormField,+ FormItem,+ FormMessage,+} from "@/components/molecules/Form/Form";++import type { CreateAPIKeyFormValues } from "../schema";+import { PermissionsCheckboxGroup } from "./PermissionsCheckboxGroup";++interface Props {+ form: UseFormReturn<CreateAPIKeyFormValues>;+ onSubmit: (values: CreateAPIKeyFormValues) => Promise<void> | void;+ isPending: boolean;+}++export function CreateAPIKeyForm({ form, onSubmit, isPending }: Props) {+ return (+ <Form form={form} onSubmit={onSubmit} className="flex flex-col gap-4 px-1">+ <FormField+ control={form.control}+ name="name"+ render={({ field }) => (+ <FormItem>+ <FormControl>+ <Input+ {...field}+ id={field.name}+ label="Name"+ placeholder="My integration key"+ wrapperClassName="!mb-0"+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />++ <FormField+ control={form.control}+ name="description"+ render={({ field }) => (+ <FormItem>+ <FormControl>+ <Input+ {...field}+ id={field.name}+ label="Description (optional)"+ placeholder="Describe what this key is used for"+ wrapperClassName="!mb-0"+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />++ <FormField+ control={form.control}+ name="permissions"+ render={({ field }) => (+ <FormItem>+ <FormControl>+ <PermissionsCheckboxGroup+ value={field.value}+ onChange={field.onChange}+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />++ <Button+ type="submit"+ variant="primary"+ size="large"+ disabled={!form.formState.isValid || isPending}+ loading={isPending}+ >+ Create Key+ </Button>+ </Form>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeySuccess.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeySuccess.tsxnew file mode 100644index 0000000000..5ac209f798--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/CreateAPIKeySuccess.tsx@@ -0,0 +1,53 @@+"use client";++import { CopyIcon } from "@phosphor-icons/react";++import { Button } from "@/components/atoms/Button/Button";+import { Text } from "@/components/atoms/Text/Text";+import { toast } from "@/components/molecules/Toast/use-toast";++interface Props {+ plainTextKey: string;+ onClose: () => void;+}++export function CreateAPIKeySuccess({ plainTextKey, onClose }: Props) {+ async function handleCopy() {+ try {+ await navigator.clipboard.writeText(plainTextKey);+ toast({ title: "Copied to clipboard", variant: "success" });+ } catch {+ toast({+ title: "Could not copy to clipboard",+ description: "Please copy the key manually.",+ variant: "destructive",+ });+ }+ }++ return (+ <div className="flex flex-col gap-4 px-1">+ <Text variant="body" className="text-zinc-700">+ Copy your key now. For security, we won't show it again.+ </Text>++ <div className="flex items-center gap-2 rounded-md border border-zinc-200 bg-zinc-50 p-3">+ <code className="flex-1 break-all font-mono text-xs text-zinc-800">+ {plainTextKey}+ </code>+ <Button+ variant="secondary"+ size="small"+ leftIcon={<CopyIcon size={16} />}+ onClick={handleCopy}+ >+ Copy+ </Button>+ </div>++ <Button variant="primary" size="large" onClick={onClose}>+ Close+ </Button>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/PermissionsCheckboxGroup.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/PermissionsCheckboxGroup.tsxnew file mode 100644index 0000000000..2eaf8be2c9--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/components/PermissionsCheckboxGroup.tsx@@ -0,0 +1,64 @@+"use client";++import { CheckSquareIcon, SquareIcon } from "@phosphor-icons/react";++import type { APIKeyPermission } from "@/app/api/__generated__/models/aPIKeyPermission";+import { Text } from "@/components/atoms/Text/Text";++import { PERMISSION_OPTIONS } from "../schema";++interface Props {+ value: APIKeyPermission[];+ onChange: (next: APIKeyPermission[]) => void;+}++export function PermissionsCheckboxGroup({ value, onChange }: Props) {+ function toggle(permission: APIKeyPermission) {+ if (value.includes(permission)) {+ onChange(value.filter((p) => p !== permission));+ } else {+ onChange([...value, permission]);+ }+ }++ return (+ <div className="flex flex-col gap-2">+ <Text+ id="api-key-permissions-label"+ variant="large-medium"+ as="span"+ className="text-textBlack"+ >+ Permissions+ </Text>+ <div+ role="group"+ aria-labelledby="api-key-permissions-label"+ className="grid max-h-[220px] grid-cols-2 gap-x-4 gap-y-2 overflow-y-auto"+ >+ {PERMISSION_OPTIONS.map((option) => {+ const checked = value.includes(option.value);+ return (+ <button+ key={option.value}+ type="button"+ role="checkbox"+ aria-checked={checked}+ onClick={() => toggle(option.value)}+ className="flex items-center gap-2 rounded text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-800"+ >+ {checked ? (+ <CheckSquareIcon size={18} weight="fill" />+ ) : (+ <SquareIcon size={18} />+ )}+ <Text variant="body" as="span" className="text-zinc-700">+ {option.label}+ </Text>+ </button>+ );+ })}+ </div>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/schema.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/schema.tsnew file mode 100644index 0000000000..459c701e22--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/schema.ts@@ -0,0 +1,36 @@+import { z } from "zod";++import { APIKeyPermission } from "@/app/api/__generated__/models/aPIKeyPermission";++export const createAPIKeySchema = z.object({+ name: z+ .string()+ .trim()+ .min(1, "Name is required")+ .max(100, "Name must be 100 characters or less"),+ description: z+ .string()+ .trim()+ .max(500, "Description must be 500 characters or less")+ .optional(),+ permissions: z+ .array(z.nativeEnum(APIKeyPermission))+ .min(1, "Select at least one permission"),+});++export type CreateAPIKeyFormValues = z.infer<typeof createAPIKeySchema>;++export function humanizePermission(permission: APIKeyPermission): string {+ return permission+ .toLowerCase()+ .split("_")+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))+ .join(" ");+}++export const PERMISSION_OPTIONS = Object.values(APIKeyPermission).map(+ (permission) => ({+ value: permission,+ label: humanizePermission(permission),+ }),+);diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/useCreateAPIKeyForm.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/useCreateAPIKeyForm.tsnew file mode 100644index 0000000000..138dd6ef96--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/CreateAPIKeyDialog/useCreateAPIKeyForm.ts@@ -0,0 +1,56 @@+"use client";++import { useState } from "react";+import { zodResolver } from "@hookform/resolvers/zod";+import { useForm } from "react-hook-form";++import { useCreateAPIKey } from "../hooks/useCreateAPIKey";+import { createAPIKeySchema, type CreateAPIKeyFormValues } from "./schema";++type View = "form" | "success";++interface Args {+ onClose: () => void;+}++export function useCreateAPIKeyForm({ onClose }: Args) {+ const [view, setView] = useState<View>("form");+ const [plainTextKey, setPlainTextKey] = useState("");+ const { createKey, isPending } = useCreateAPIKey();++ const form = useForm<CreateAPIKeyFormValues>({+ resolver: zodResolver(createAPIKeySchema),+ defaultValues: { name: "", description: "", permissions: [] },+ mode: "onChange",+ });++ async function handleSubmit(values: CreateAPIKeyFormValues) {+ try {+ const result = await createKey({+ name: values.name,+ description: values.description || null,+ permissions: values.permissions,+ });+ setPlainTextKey(result.plain_text_key);+ setView("success");+ } catch {+ // Toast is surfaced by useCreateAPIKey; keep form open so user can retry.+ }+ }++ function handleClose() {+ setView("form");+ setPlainTextKey("");+ form.reset();+ onClose();+ }++ return {+ form,+ view,+ plainTextKey,+ isPending,+ handleSubmit,+ handleClose,+ };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/DeleteAPIKeyDialog/DeleteAPIKeyDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/DeleteAPIKeyDialog/DeleteAPIKeyDialog.tsxnew file mode 100644index 0000000000..2139f97569--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/DeleteAPIKeyDialog/DeleteAPIKeyDialog.tsx@@ -0,0 +1,71 @@+"use client";++import { Button } from "@/components/atoms/Button/Button";+import { Text } from "@/components/atoms/Text/Text";+import { Dialog } from "@/components/molecules/Dialog/Dialog";++import { useRevokeAPIKey } from "../hooks/useRevokeAPIKey";++interface Props {+ open: boolean;+ keyIds: string[];+ onOpenChange: (open: boolean) => void;+ onDeleted?: () => void;+}++export function DeleteAPIKeyDialog({+ open,+ keyIds,+ onOpenChange,+ onDeleted,+}: Props) {+ const { revoke, isPending } = useRevokeAPIKey();+ const isBatch = keyIds.length > 1;++ async function handleConfirm() {+ const succeeded = await revoke(keyIds);+ if (!succeeded) return;+ onDeleted?.();+ onOpenChange(false);+ }++ return (+ <Dialog+ title={isBatch ? `Revoke ${keyIds.length} API keys?` : "Revoke API key?"}+ styling={{ maxWidth: "28rem" }}+ controlled={{+ isOpen: open,+ set: (next) => {+ if (isPending) return;+ onOpenChange(next);+ },+ }}+ >+ <Dialog.Content>+ <div className="flex flex-col gap-4 px-1">+ <Text variant="body" className="text-zinc-700">+ This action cannot be undone. Integrations using{" "}+ {isBatch ? "these keys" : "this key"} will immediately lose access.+ </Text>++ <div className="flex justify-end gap-2 pt-2">+ <Button+ variant="secondary"+ onClick={() => onOpenChange(false)}+ disabled={isPending}+ >+ Cancel+ </Button>+ <Button+ variant="destructive"+ loading={isPending}+ onClick={handleConfirm}+ >+ {isBatch ? "Revoke keys" : "Revoke key"}+ </Button>+ </div>+ </div>+ </Dialog.Content>+ </Dialog>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useAPIKeysList.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useAPIKeysList.tsnew file mode 100644index 0000000000..7927e1d98b--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useAPIKeysList.ts@@ -0,0 +1,31 @@+"use client";++import {+ getGetV1ListUserApiKeysQueryKey,+ useGetV1ListUserApiKeys,+} from "@/app/api/__generated__/endpoints/api-keys/api-keys";+import { APIKeyStatus } from "@/app/api/__generated__/models/aPIKeyStatus";++export const API_KEYS_QUERY_KEY = getGetV1ListUserApiKeysQueryKey();++export function useAPIKeysList() {+ const query = useGetV1ListUserApiKeys({+ query: {+ select: (response) =>+ response.status === 200+ ? response.data.filter((key) => key.status === APIKeyStatus.ACTIVE)+ : [],+ },+ });++ const keys = query.data ?? [];++ return {+ keys,+ isLoading: query.isLoading,+ isError: query.isError,+ error: query.error,+ refetch: query.refetch,+ isEmpty: !query.isLoading && !query.isError && keys.length === 0,+ };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useCreateAPIKey.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useCreateAPIKey.tsnew file mode 100644index 0000000000..fe437a592c--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useCreateAPIKey.ts@@ -0,0 +1,42 @@+"use client";++import { useQueryClient } from "@tanstack/react-query";++import { usePostV1CreateNewApiKey } from "@/app/api/__generated__/endpoints/api-keys/api-keys";+import type { CreateAPIKeyRequest } from "@/app/api/__generated__/models/createAPIKeyRequest";+import type { CreateAPIKeyResponse } from "@/app/api/__generated__/models/createAPIKeyResponse";+import { toast } from "@/components/molecules/Toast/use-toast";++import { API_KEYS_QUERY_KEY } from "./useAPIKeysList";++export function useCreateAPIKey() {+ const queryClient = useQueryClient();++ const mutation = usePostV1CreateNewApiKey({+ mutation: {+ onSuccess: () => {+ queryClient.invalidateQueries({ queryKey: API_KEYS_QUERY_KEY });+ toast({ title: "API key created", variant: "success" });+ },+ onError: (error) => {+ toast({+ title: "Failed to create API key",+ description: error instanceof Error ? error.message : undefined,+ variant: "destructive",+ });+ },+ },+ });++ async function createKey(payload: CreateAPIKeyRequest) {+ // The custom Orval mutator throws on non-2xx, so reaching this line+ // guarantees the success variant of the discriminated union.+ const response = await mutation.mutateAsync({ data: payload });+ return response.data as CreateAPIKeyResponse;+ }++ return {+ createKey,+ isPending: mutation.isPending,+ };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useRevokeAPIKey.ts b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useRevokeAPIKey.tsnew file mode 100644index 0000000000..e75583ae33--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/components/hooks/useRevokeAPIKey.ts@@ -0,0 +1,52 @@+"use client";++import { useState } from "react";+import { useQueryClient } from "@tanstack/react-query";++import { deleteV1RevokeApiKey } from "@/app/api/__generated__/endpoints/api-keys/api-keys";+import { toast } from "@/components/molecules/Toast/use-toast";++import { API_KEYS_QUERY_KEY } from "./useAPIKeysList";++export function useRevokeAPIKey() {+ const queryClient = useQueryClient();+ const [isPending, setIsPending] = useState(false);++ async function revoke(keyIds: string[]): Promise<boolean> {+ if (keyIds.length === 0) return true;++ setIsPending(true);+ try {+ const results = await Promise.allSettled(+ keyIds.map((id) => deleteV1RevokeApiKey(id)),+ );+ const failures = results.filter((r) => r.status === "rejected");++ if (failures.length === 0) {+ toast({+ title:+ keyIds.length === 1+ ? "API key revoked"+ : `${keyIds.length} API keys revoked`,+ variant: "success",+ });+ } else {+ toast({+ title: "Some API keys could not be revoked",+ description: `${failures.length} of ${keyIds.length} failed.`,+ variant: "destructive",+ });+ }++ await queryClient.invalidateQueries({+ queryKey: API_KEYS_QUERY_KEY,+ });++ return failures.length === 0;+ } finally {+ setIsPending(false);+ }+ }++ return { revoke, isPending };+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/page.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/page.tsxindex b240a89560..d919200cd4 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/page.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/api-keys/page.tsx@@ -1,16 +1,23 @@"use client";-import { Text } from "@/components/atoms/Text/Text";+import { useState } from "react";++import { APIKeyList } from "./components/APIKeyList/APIKeyList";+import { APIKeysHeader } from "./components/APIKeysHeader/APIKeysHeader";+import { CreateAPIKeyDialog } from "./components/CreateAPIKeyDialog/CreateAPIKeyDialog";export default function SettingsApiKeysPage() {+ const [createOpen, setCreateOpen] = useState(false);++ function openCreate() {+ setCreateOpen(true);+ }+return (<>- <Text variant="h4" className="text-[#1F1F20]">- AutoGPT API Keys- </Text>- <Text variant="large" className="mt-2 text-zinc-600">- Coming soon.- </Text>+ <APIKeysHeader onCreate={openCreate} />+ <APIKeyList />+ <CreateAPIKeyDialog open={createOpen} onOpenChange={setCreateOpen} /></>);}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsxindex 9be3c77dc6..d450a60e2a 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsx@@ -3,6 +3,7 @@import { ReactNode } from "react";import { usePathname } from "next/navigation";import { motion, useReducedMotion } from "framer-motion";+import { ScrollArea } from "@/components/ui/scroll-area";import { SettingsSidebar } from "./components/SettingsSidebar/SettingsSidebar";import { SettingsMobileNav } from "./components/SettingsMobileNav/SettingsMobileNav";@@ -15,15 +16,18 @@ export default function SettingsLayout({ children }: { children: ReactNode }) {<SettingsSidebar /><div className="flex flex-1 flex-col overflow-hidden"><SettingsMobileNav />- <main className="flex-1 overflow-y-auto bg-[#F9F9FA] px-4 pt-2 md:px-[111px] md:pt-[39px]">- <motion.div- key={pathname}- initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 8 }}- animate={{ opacity: 1, y: 0 }}- transition={{ duration: 0.28, ease: [0, 0, 0.2, 1] as const }}- >- {children}- </motion.div>+ <main className="flex-1 overflow-hidden bg-[#F9F9FA]">+ <ScrollArea showScrollToTop className="h-full">+ <motion.div+ key={pathname}+ initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 8 }}+ animate={{ opacity: 1, y: 0 }}+ transition={{ duration: 0.28, ease: [0, 0, 0.2, 1] as const }}+ className="mx-auto max-w-[1100px] px-4 pb-8 pt-2 md:pt-[39px]"+ >+ {children}+ </motion.div>+ </ScrollArea></main></div></div>diff --git a/autogpt_platform/frontend/src/components/ui/scroll-area.tsx b/autogpt_platform/frontend/src/components/ui/scroll-area.tsxindex 6d9cd61b97..d5acd4e4de 100644--- a/autogpt_platform/frontend/src/components/ui/scroll-area.tsx+++ b/autogpt_platform/frontend/src/components/ui/scroll-area.tsx@@ -2,34 +2,71 @@import * as React from "react";import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";+import { AnimatePresence, motion, useReducedMotion } from "framer-motion";+import { ArrowUpIcon } from "@phosphor-icons/react";import { cn } from "@/lib/utils";+interface ScrollAreaProps+ extends React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> {+ orientation?: "vertical" | "horizontal" | "both";+ showScrollToTop?: boolean;+}+const ScrollArea = React.forwardRef<React.ElementRef<typeof ScrollAreaPrimitive.Root>,- React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {- orientation?: "vertical" | "horizontal" | "both";- }->(({ className, children, orientation = "vertical", ...props }, ref) => (- <ScrollAreaPrimitive.Root- ref={ref}- className={cn("relative", className)}- {...props}- >- <ScrollAreaPrimitive.Viewport- className="h-full w-full rounded-[inherit]"- style={{- overflowX: orientation === "vertical" ? "hidden" : "scroll",- overflowY: orientation === "horizontal" ? "hidden" : "scroll",- }}- >- {children}- </ScrollAreaPrimitive.Viewport>- {orientation !== "horizontal" && <ScrollBar />}- {orientation !== "vertical" && <ScrollBar orientation="horizontal" />}- <ScrollAreaPrimitive.Corner />- </ScrollAreaPrimitive.Root>-));+ ScrollAreaProps+>(+ (+ {+ className,+ children,+ orientation = "vertical",+ showScrollToTop = false,+ ...props+ },+ ref,+ ) => {+ const viewportRef = React.useRef<HTMLDivElement | null>(null);+ const reduceMotion = useReducedMotion();+ const fabVisible = useScrolledPastThreshold(viewportRef, {+ enabled: showScrollToTop,+ threshold: 200,+ });++ function scrollToTop() {+ viewportRef.current?.scrollTo({+ top: 0,+ behavior: reduceMotion ? "auto" : "smooth",+ });+ }++ return (+ <ScrollAreaPrimitive.Root+ ref={ref}+ className={cn("relative", className)}+ {...props}+ >+ <ScrollAreaPrimitive.Viewport+ ref={viewportRef}+ className="h-full w-full rounded-[inherit]"+ style={{+ overflowX: orientation === "vertical" ? "hidden" : "scroll",+ overflowY: orientation === "horizontal" ? "hidden" : "scroll",+ }}+ >+ {children}+ </ScrollAreaPrimitive.Viewport>+ {orientation !== "horizontal" && <ScrollBar />}+ {orientation !== "vertical" && <ScrollBar orientation="horizontal" />}+ <ScrollAreaPrimitive.Corner />+ {showScrollToTop && (+ <ScrollToTopFab visible={fabVisible} onClick={scrollToTop} />+ )}+ </ScrollAreaPrimitive.Root>+ );+ },+);ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;const ScrollBar = React.forwardRef<@@ -54,4 +91,64 @@ const ScrollBar = React.forwardRef<));ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;+function useScrolledPastThreshold(+ viewportRef: React.RefObject<HTMLDivElement | null>,+ { enabled, threshold }: { enabled: boolean; threshold: number },+) {+ const [visible, setVisible] = React.useState(false);++ React.useEffect(() => {+ if (!enabled) return;+ const viewport = viewportRef.current;+ if (!viewport) return;++ function update() {+ // TS can't narrow the captured `viewport` inside a nested closure, so+ // keep the guard — the outer early-return still covers runtime.+ if (!viewport) return;+ setVisible(viewport.scrollTop > threshold);+ }++ update();+ viewport.addEventListener("scroll", update, { passive: true });+ return () => viewport.removeEventListener("scroll", update);+ }, [enabled, threshold, viewportRef]);++ return visible;+}++interface ScrollToTopFabProps {+ visible: boolean;+ onClick: () => void;+}++function ScrollToTopFab({ visible, onClick }: ScrollToTopFabProps) {+ const reduceMotion = useReducedMotion();++ return (+ <AnimatePresence>+ {visible && (+ <motion.button+ type="button"+ onClick={onClick}+ aria-label="Scroll to top"+ className="absolute bottom-6 left-1/2 z-30 flex h-11 w-11 -translate-x-1/2 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-md transition-colors hover:bg-primary/90 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"+ initial={+ reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.95, y: 8 }+ }+ animate={+ reduceMotion ? { opacity: 1 } : { opacity: 1, scale: 1, y: 0 }+ }+ exit={+ reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.95, y: 8 }+ }+ transition={{ duration: 0.15, ease: [0, 0, 0.2, 1] }}+ >+ <ArrowUpIcon size={20} weight="bold" />+ </motion.button>+ )}+ </AnimatePresence>+ );+}+export { ScrollArea, ScrollBar };