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): add settings v2 profile page (#12924)
Abhimanyu Yadav599f37020673
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 2caeb55d54..1c4064e55c 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@@ -1,13 +1,11 @@import { render, screen } from "@/tests/integrations/test-utils";import { describe, expect, it } from "vitest";-import SettingsProfilePage from "../profile/page";import SettingsCreatorDashboardPage from "../creator-dashboard/page";import SettingsBillingPage from "../billing/page";import SettingsPreferencesPage from "../preferences/page";import SettingsOAuthAppsPage from "../oauth-apps/page";const pages = [- { Component: SettingsProfilePage, title: "Profile" },{ Component: SettingsCreatorDashboardPage, title: "Creator Dashboard" },{ Component: SettingsBillingPage, title: "Billing" },{ Component: SettingsPreferencesPage, title: "Settings" },diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsxindex 2d04ee99fb..4c071f493b 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/layout.tsx@@ -21,7 +21,7 @@ export default function SettingsLayout({ children }: { children: ReactNode }) {<div className="flex flex-1 flex-col overflow-hidden"><SettingsMobileNav /><main className="flex-1 overflow-hidden bg-[#F9F9FA]">- <ScrollArea showScrollToTop className="h-full">+ <ScrollArea className="h-full"><motion.divkey={pathname}initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 8 }}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/__tests__/helpers.test.ts b/autogpt_platform/frontend/src/app/(platform)/settings/profile/__tests__/helpers.test.tsnew file mode 100644index 0000000000..04c23a3d03--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/__tests__/helpers.test.ts@@ -0,0 +1,226 @@+import { describe, expect, test } from "vitest";++import {+ getInitials,+ isFormDirty,+ makeLinkRow,+ MAX_BIO_LENGTH,+ MAX_LINKS,+ profileToFormState,+ validateForm,+ type ProfileFormState,+} from "../helpers";++function rows(...values: string[]) {+ return values.map((v) => makeLinkRow(v));+}++function makeState(+ overrides: Partial<ProfileFormState> = {},+): ProfileFormState {+ return {+ name: "Jane Doe",+ username: "jane_doe",+ description: "I build agents",+ avatar_url: "https://cdn.example.com/avatar.png",+ links: rows("https://jane.dev", "", ""),+ ...overrides,+ };+}++describe("helpers / profileToFormState", () => {+ test("maps a fully populated profile and pads links to 3 slots", () => {+ const state = profileToFormState({+ username: "jane",+ name: "Jane",+ description: "bio",+ avatar_url: "https://cdn.example.com/a.png",+ links: ["https://jane.dev"],+ is_featured: false,+ });++ expect(state.username).toBe("jane");+ expect(state.name).toBe("Jane");+ expect(state.description).toBe("bio");+ expect(state.avatar_url).toBe("https://cdn.example.com/a.png");+ expect(state.links.map((l) => l.value)).toEqual([+ "https://jane.dev",+ "",+ "",+ ]);+ expect(state.links.every((l) => typeof l.id === "string")).toBe(true);+ const ids = state.links.map((l) => l.id);+ expect(new Set(ids).size).toBe(ids.length);+ });++ test("falls back to empty strings when fields are nullish", () => {+ const state = profileToFormState({+ username: null as unknown as string,+ name: null as unknown as string,+ description: null as unknown as string,+ avatar_url: null,+ links: null as unknown as string[],+ is_featured: false,+ });++ expect(state.name).toBe("");+ expect(state.username).toBe("");+ expect(state.description).toBe("");+ expect(state.avatar_url).toBe("");+ expect(state.links.map((l) => l.value)).toEqual(["", "", ""]);+ });++ test("preserves links above the initial slot count up to MAX_LINKS", () => {+ const state = profileToFormState({+ username: "j",+ name: "J",+ description: "",+ avatar_url: "",+ links: ["a", "b", "c", "d"],+ is_featured: false,+ });++ expect(state.links.map((l) => l.value)).toEqual(["a", "b", "c", "d"]);+ });++ test("truncates incoming links to MAX_LINKS", () => {+ const tooMany = Array.from(+ { length: MAX_LINKS + 3 },+ (_, i) => `https://x${i}.dev`,+ );+ const state = profileToFormState({+ username: "j",+ name: "J",+ description: "",+ avatar_url: "",+ links: tooMany,+ is_featured: false,+ });++ expect(state.links).toHaveLength(MAX_LINKS);+ expect(state.links.map((l) => l.value)).toEqual(+ tooMany.slice(0, MAX_LINKS),+ );+ });+});++describe("helpers / validateForm", () => {+ test("accepts a valid state", () => {+ const result = validateForm(makeState());+ expect(result.valid).toBe(true);+ expect(result.errors).toEqual({});+ });++ test("flags missing display name", () => {+ const result = validateForm(makeState({ name: " " }));+ expect(result.valid).toBe(false);+ expect(result.errors.name).toMatch(/required/i);+ });++ test("flags display name longer than 50 chars", () => {+ const result = validateForm(makeState({ name: "x".repeat(51) }));+ expect(result.errors.name).toMatch(/under 50/i);+ });++ test("flags missing handle", () => {+ const result = validateForm(makeState({ username: "" }));+ expect(result.errors.username).toMatch(/required/i);+ });++ test("flags handle that does not match the regex", () => {+ const result = validateForm(makeState({ username: "no spaces here" }));+ expect(result.errors.username).toMatch(/2.+30/);+ });++ test("flags bio longer than the max length", () => {+ const result = validateForm(+ makeState({ description: "x".repeat(MAX_BIO_LENGTH + 1) }),+ );+ expect(result.errors.description).toContain(String(MAX_BIO_LENGTH));+ });++ test("allows bio at exactly the max length", () => {+ const result = validateForm(+ makeState({ description: "x".repeat(MAX_BIO_LENGTH) }),+ );+ expect(result.errors.description).toBeUndefined();+ });+});++describe("helpers / isFormDirty", () => {+ const initial = makeState();++ test("returns false for an unchanged state", () => {+ expect(isFormDirty(initial, makeState())).toBe(false);+ });++ test("detects a changed name", () => {+ expect(isFormDirty(initial, makeState({ name: "Jane Smith" }))).toBe(true);+ });++ test("detects a changed username", () => {+ expect(isFormDirty(initial, makeState({ username: "other" }))).toBe(true);+ });++ test("detects a changed bio", () => {+ expect(isFormDirty(initial, makeState({ description: "different" }))).toBe(+ true,+ );+ });++ test("detects a changed avatar url", () => {+ expect(isFormDirty(initial, makeState({ avatar_url: "x" }))).toBe(true);+ });++ test("ignores empty link slots when comparing", () => {+ const next = makeState({+ links: rows("https://jane.dev", "", "", ""),+ });+ expect(isFormDirty(initial, next)).toBe(false);+ });++ test("detects a new non-empty link", () => {+ const next = makeState({+ links: rows("https://jane.dev", "https://github.com/jane", ""),+ });+ expect(isFormDirty(initial, next)).toBe(true);+ });++ test("detects a removed non-empty link", () => {+ const next = makeState({ links: rows("", "", "") });+ expect(isFormDirty(initial, next)).toBe(true);+ });++ test("detects a reordered link", () => {+ const base = makeState({+ links: rows("https://a.dev", "https://b.dev", ""),+ });+ const next = makeState({+ links: rows("https://b.dev", "https://a.dev", ""),+ });+ expect(isFormDirty(base, next)).toBe(true);+ });+});++describe("helpers / getInitials", () => {+ test("returns ? for an empty string", () => {+ expect(getInitials("")).toBe("?");+ expect(getInitials(" ")).toBe("?");+ });++ test("returns the first two letters of a single name, uppercased", () => {+ expect(getInitials("jane")).toBe("JA");+ expect(getInitials("X")).toBe("X");+ });++ test("returns first + last initial for multi-word names", () => {+ expect(getInitials("Jane Doe")).toBe("JD");+ expect(getInitials("ada b. lovelace")).toBe("AL");+ });++ test("preserves emoji and non-BMP characters as a single code point", () => {+ // Surrogate pair: U+1F98A (🦊) is two UTF-16 units.+ expect(getInitials("🦊enny")).toBe("🦊E");+ expect(getInitials("🦊enny Smith")).toBe("🦊S");+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/profile/__tests__/main.test.tsxnew file mode 100644index 0000000000..d0bab90b74--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/__tests__/main.test.tsx@@ -0,0 +1,673 @@+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 {+ getGetV2GetUserProfileMockHandler200,+ getGetV2GetUserProfileMockHandler401,+ getPostV2UpdateUserProfileMockHandler200,+ getPostV2UpdateUserProfileMockHandler422,+ getPostV2UploadSubmissionMediaMockHandler200,+ getPostV2UploadSubmissionMediaMockHandler401,+} from "@/app/api/__generated__/endpoints/store/store.msw";+import type { ProfileDetails } from "@/app/api/__generated__/models/profileDetails";++import SettingsProfilePage from "../page";++const mockUseSupabase = vi.hoisted(() => vi.fn());+const toastSpy = vi.hoisted(() => vi.fn());++vi.mock("@/lib/supabase/hooks/useSupabase", () => ({+ useSupabase: mockUseSupabase,+}));++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 makeProfile(overrides: Partial<ProfileDetails> = {}): ProfileDetails {+ return {+ username: "jane_doe",+ name: "Jane Doe",+ description: "I build agents",+ avatar_url: "https://cdn.example.com/jane.png",+ links: ["https://jane.dev", "https://github.com/jane"],+ is_featured: false,+ ...overrides,+ };+}++function authenticate() {+ mockUseSupabase.mockReturnValue({+ user: {+ id: "user-1",+ email: "[email protected]",+ app_metadata: {},+ user_metadata: {},+ aud: "authenticated",+ created_at: "2026-01-01T00:00:00.000Z",+ },+ isLoggedIn: true,+ isUserLoading: false,+ supabase: {},+ });+}++beforeEach(() => {+ toastSpy.mockClear();+ authenticate();+});++afterEach(() => {+ vi.clearAllMocks();+});++describe("SettingsProfilePage - data loading", () => {+ test("renders the page heading and description copy", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ expect(+ await screen.findByRole("heading", { name: /^profile$/i, level: 1 }),+ ).toBeDefined();+ expect(screen.getByText(/manage how you appear/i)).toBeDefined();+ });++ test("hydrates the form fields from the loaded profile", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ expect(+ ((await screen.findByLabelText(/display name/i)) as HTMLInputElement)+ .value,+ ).toBe("Jane Doe");+ expect((screen.getByLabelText(/^handle$/i) as HTMLInputElement).value).toBe(+ "jane_doe",+ );+ expect(+ (+ screen.getByPlaceholderText(+ /tell people what you build/i,+ ) as HTMLTextAreaElement | null+ )?.value,+ ).toBe("I build agents");+ expect((screen.getByLabelText(/^link 1$/i) as HTMLInputElement).value).toBe(+ "https://jane.dev",+ );+ expect((screen.getByLabelText(/^link 2$/i) as HTMLInputElement).value).toBe(+ "https://github.com/jane",+ );+ });++ test("renders an error card and recovers via Try again", async () => {+ server.use(getGetV2GetUserProfileMockHandler401());++ render(<SettingsProfilePage />);++ expect(await screen.findByText(/something went wrong/i)).toBeDefined();+ expect(+ screen.queryByRole("heading", { name: /^profile$/i, level: 1 }),+ ).toBeNull();++ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ fireEvent.click(screen.getByRole("button", { name: /try again/i }));++ expect(+ await screen.findByRole("heading", { name: /^profile$/i, level: 1 }),+ ).toBeDefined();+ });+});++describe("SettingsProfilePage - validation", () => {+ test("shows an error and disables Save when display name is cleared", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ const nameInput = (await screen.findByLabelText(+ /display name/i,+ )) as HTMLInputElement;+ fireEvent.change(nameInput, { target: { value: "" } });++ expect(await screen.findByText(/display name is required/i)).toBeDefined();+ expect(+ (+ screen.getByRole("button", {+ name: /save changes/i,+ }) as HTMLButtonElement+ ).disabled,+ ).toBe(true);+ });++ test("rejects an invalid handle and accepts a valid one", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ const handle = (await screen.findByLabelText(+ /^handle$/i,+ )) as HTMLInputElement;+ fireEvent.change(handle, { target: { value: "no spaces here" } });++ expect(await screen.findByText(/2.+30/)).toBeDefined();++ fireEvent.change(handle, { target: { value: "jane_smith" } });++ await waitFor(() => {+ expect(screen.queryByText(/2.+30/)).toBeNull();+ });+ });++ test("shows the live character counter for the bio", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({ description: "x".repeat(100) }),+ ),+ );++ render(<SettingsProfilePage />);++ expect(await screen.findByText("180 left")).toBeDefined();+ });+});++describe("SettingsProfilePage - markdown toolbar & preview", () => {+ test("Bold button wraps selected text with **", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({ description: "hello world" }),+ ),+ );++ render(<SettingsProfilePage />);++ const textarea = (await screen.findByPlaceholderText(+ /tell people what you build/i,+ )) as HTMLTextAreaElement;+ textarea.focus();+ textarea.setSelectionRange(0, 5);++ fireEvent.click(screen.getByRole("button", { name: /^bold$/i }));++ await waitFor(() => {+ expect(textarea.value).toBe("**hello** world");+ });+ });++ test("Italic button without selection inserts placeholder italic text", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile({ description: "" })),+ );++ render(<SettingsProfilePage />);++ const textarea = (await screen.findByPlaceholderText(+ /tell people what you build/i,+ )) as HTMLTextAreaElement;+ textarea.focus();+ textarea.setSelectionRange(0, 0);++ fireEvent.click(screen.getByRole("button", { name: /^italic$/i }));++ await waitFor(() => {+ expect(textarea.value).toBe("*italic text*");+ });+ });++ test("Bulleted list prepends '- ' at the start of the line, idempotently", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({ description: "first item" }),+ ),+ );++ render(<SettingsProfilePage />);++ const textarea = (await screen.findByPlaceholderText(+ /tell people what you build/i,+ )) as HTMLTextAreaElement;+ textarea.focus();+ textarea.setSelectionRange(0, 0);++ fireEvent.click(screen.getByRole("button", { name: /bulleted list/i }));++ await waitFor(() => {+ expect(textarea.value).toBe("- first item");+ });++ // Second click should not double-prefix+ fireEvent.click(screen.getByRole("button", { name: /bulleted list/i }));+ expect(textarea.value).toBe("- first item");+ });++ test("Strikethrough wraps selection with ~~", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile({ description: "abc" })),+ );++ render(<SettingsProfilePage />);++ const textarea = (await screen.findByPlaceholderText(+ /tell people what you build/i,+ )) as HTMLTextAreaElement;+ textarea.focus();+ textarea.setSelectionRange(0, 3);++ fireEvent.click(screen.getByRole("button", { name: /strikethrough/i }));++ await waitFor(() => {+ expect(textarea.value).toBe("~~abc~~");+ });+ });++ test("Link button inserts the markdown link template at cursor", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile({ description: "" })),+ );++ render(<SettingsProfilePage />);++ const textarea = (await screen.findByPlaceholderText(+ /tell people what you build/i,+ )) as HTMLTextAreaElement;+ textarea.focus();++ fireEvent.click(screen.getByRole("button", { name: /^link$/i }));++ await waitFor(() => {+ expect(textarea.value).toBe("[link text](https://)");+ });+ });++ test("Preview toggle hides the textarea and renders the markdown bio", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({ description: "**hi**" }),+ ),+ );++ render(<SettingsProfilePage />);++ expect(+ await screen.findByPlaceholderText(/tell people what you build/i),+ ).toBeDefined();++ fireEvent.click(screen.getByRole("button", { name: /^preview$/i }));++ expect(+ screen.queryByPlaceholderText(/tell people what you build/i),+ ).toBeNull();+ expect(screen.getByText("hi").tagName.toLowerCase()).toBe("strong");+ });++ test("Preview shows fallback copy when bio is empty", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile({ description: "" })),+ );++ render(<SettingsProfilePage />);++ await screen.findByPlaceholderText(/tell people what you build/i);++ fireEvent.click(screen.getByRole("button", { name: /^preview$/i }));++ expect(screen.getByText(/nothing to preview yet/i)).toBeDefined();+ });++ test("Edit toggle returns control to the textarea", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({ description: "see me" }),+ ),+ );++ render(<SettingsProfilePage />);++ await screen.findByPlaceholderText(/tell people what you build/i);++ fireEvent.click(screen.getByRole("button", { name: /^preview$/i }));+ fireEvent.click(screen.getByRole("button", { name: /^edit$/i }));++ expect(+ (+ screen.getByPlaceholderText(+ /tell people what you build/i,+ ) as HTMLTextAreaElement+ ).value,+ ).toBe("see me");+ });+});++describe("SettingsProfilePage - links section", () => {+ test("Add link adds an empty slot up to the limit", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({ links: ["https://a.dev"] }),+ ),+ );++ render(<SettingsProfilePage />);++ await screen.findByLabelText(/^link 1$/i);+ expect(screen.getByLabelText(/^link 2$/i)).toBeDefined();+ expect(screen.getByLabelText(/^link 3$/i)).toBeDefined();++ fireEvent.click(screen.getByRole("button", { name: /add link/i }));++ expect(await screen.findByLabelText(/^link 4$/i)).toBeDefined();++ fireEvent.click(screen.getByRole("button", { name: /add link/i }));++ expect(await screen.findByLabelText(/^link 5$/i)).toBeDefined();+ expect(+ screen.getByRole("button", { name: /limit of 5 reached/i }),+ ).toBeDefined();+ });++ test("Remove link discards the slot at the given index", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({ links: ["https://a.dev", "https://b.dev"] }),+ ),+ );++ render(<SettingsProfilePage />);++ await screen.findByLabelText(/^link 1$/i);++ fireEvent.click(screen.getByRole("button", { name: /^remove link 1$/i }));++ await waitFor(() => {+ expect(+ (screen.getByLabelText(/^link 1$/i) as HTMLInputElement).value,+ ).toBe("https://b.dev");+ });+ });++ test("editing a link updates its value", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ const link = (await screen.findByLabelText(+ /^link 1$/i,+ )) as HTMLInputElement;+ fireEvent.change(link, { target: { value: "https://changed.dev" } });++ expect(link.value).toBe("https://changed.dev");+ });+});++describe("SettingsProfilePage - save & discard", () => {+ test("Save and Discard are disabled when the form is pristine", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ await screen.findByLabelText(/display name/i);++ expect(+ (+ screen.getByRole("button", {+ name: /save changes/i,+ }) as HTMLButtonElement+ ).disabled,+ ).toBe(true);+ expect(+ (screen.getByRole("button", { name: /discard/i }) as HTMLButtonElement)+ .disabled,+ ).toBe(true);+ });++ test("Discard reverts edits to the initial loaded values", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ const nameInput = (await screen.findByLabelText(+ /display name/i,+ )) as HTMLInputElement;+ fireEvent.change(nameInput, { target: { value: "New Name" } });++ expect(nameInput.value).toBe("New Name");++ fireEvent.click(screen.getByRole("button", { name: /discard/i }));++ await waitFor(() => {+ expect(nameInput.value).toBe("Jane Doe");+ });+ });++ test("Save submits the profile and shows a success toast", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile()),+ getPostV2UpdateUserProfileMockHandler200(),+ );++ render(<SettingsProfilePage />);++ const nameInput = (await screen.findByLabelText(+ /display name/i,+ )) as HTMLInputElement;+ fireEvent.change(nameInput, { target: { value: "Jane Z" } });++ fireEvent.click(screen.getByRole("button", { name: /save changes/i }));++ await waitFor(() => {+ expect(toastSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ title: "Profile saved",+ variant: "success",+ }),+ );+ });+ });++ test("Save shows a destructive toast on a 422", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile()),+ getPostV2UpdateUserProfileMockHandler422(),+ );++ render(<SettingsProfilePage />);++ const nameInput = (await screen.findByLabelText(+ /display name/i,+ )) as HTMLInputElement;+ fireEvent.change(nameInput, { target: { value: "Jane Z" } });++ fireEvent.click(screen.getByRole("button", { name: /save changes/i }));++ await waitFor(() => {+ expect(toastSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ title: "Failed to save profile",+ variant: "destructive",+ }),+ );+ });+ });+});++describe("SettingsProfilePage - avatar upload", () => {+ test("uploading an avatar updates the form state", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile()),+ getPostV2UploadSubmissionMediaMockHandler200(+ "https://cdn.example.com/uploaded.png",+ ),+ );++ render(<SettingsProfilePage />);++ await screen.findByLabelText(/display name/i);++ const fileInput = document.querySelector(+ 'input[type="file"]',+ ) as HTMLInputElement;+ expect(fileInput).toBeTruthy();++ const file = new File(["x"], "avatar.png", { type: "image/png" });+ fireEvent.change(fileInput, { target: { files: [file] } });++ await waitFor(() => {+ expect(+ (+ screen.getByRole("button", {+ name: /save changes/i,+ }) as HTMLButtonElement+ ).disabled,+ ).toBe(false);+ });+ });++ test("upload error surfaces a destructive toast", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(makeProfile()),+ getPostV2UploadSubmissionMediaMockHandler401(),+ );++ render(<SettingsProfilePage />);++ await screen.findByLabelText(/display name/i);++ const fileInput = document.querySelector(+ 'input[type="file"]',+ ) as HTMLInputElement;+ const file = new File(["x"], "avatar.png", { type: "image/png" });+ fireEvent.change(fileInput, { target: { files: [file] } });++ await waitFor(() => {+ expect(toastSpy).toHaveBeenCalledWith(+ expect.objectContaining({+ title: "Failed to upload photo",+ variant: "destructive",+ }),+ );+ });+ });+});++describe("SettingsProfilePage - skeleton & nullish profile fields", () => {+ test("renders the skeleton on first render before the user resolves", () => {+ mockUseSupabase.mockReturnValue({+ user: null,+ isLoggedIn: false,+ isUserLoading: true,+ supabase: {},+ });++ const { container } = render(<SettingsProfilePage />);++ expect(+ screen.queryByRole("heading", { name: /^profile$/i, level: 1 }),+ ).toBeNull();+ expect(container.querySelectorAll(".animate-pulse").length).toBeGreaterThan(+ 0,+ );+ });++ test("hydrates safely when the API returns nullish profile fields", async () => {+ server.use(+ getGetV2GetUserProfileMockHandler200(+ makeProfile({+ name: null as unknown as string,+ username: null as unknown as string,+ description: null as unknown as string,+ avatar_url: null,+ links: null as unknown as string[],+ }),+ ),+ );++ render(<SettingsProfilePage />);++ const nameInput = (await screen.findByLabelText(+ /display name/i,+ )) as HTMLInputElement;+ expect(nameInput.value).toBe("");+ expect((screen.getByLabelText(/^handle$/i) as HTMLInputElement).value).toBe(+ "",+ );++ // 3 padded link slots+ expect(screen.getByLabelText(/^link 1$/i)).toBeDefined();+ expect(screen.getByLabelText(/^link 2$/i)).toBeDefined();+ expect(screen.getByLabelText(/^link 3$/i)).toBeDefined();+ });+});++describe("SettingsProfilePage - skeleton wrapper", () => {+ test("renders the skeleton component while the profile is loading", () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ const { container } = render(<SettingsProfilePage />);++ // Initial render — query is in-flight, skeleton shows+ expect(container.querySelectorAll(".animate-pulse").length).toBeGreaterThan(+ 0,+ );++ // Heading appears once data resolves; verifies the skeleton path was taken first+ return screen.findByRole("heading", { name: /^profile$/i, level: 1 });+ });+});++describe("SettingsProfilePage - guard rails", () => {+ test("clicking Save while invalid does not fire the update endpoint", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ const nameInput = (await screen.findByLabelText(+ /display name/i,+ )) as HTMLInputElement;+ fireEvent.change(nameInput, { target: { value: "" } });++ fireEvent.click(screen.getByRole("button", { name: /save changes/i }));++ // Disabled button + invalid form: no toast, no network call+ expect(toastSpy).not.toHaveBeenCalledWith(+ expect.objectContaining({ title: "Profile saved" }),+ );+ });++ test("renders the avatar change-photo button with proper a11y label", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ expect(+ await screen.findByRole("button", { name: /change profile photo/i }),+ ).toBeDefined();+ });++ test("links section header explains the cap", async () => {+ server.use(getGetV2GetUserProfileMockHandler200(makeProfile()));++ render(<SettingsProfilePage />);++ const links = await screen.findByText(/your links/i);+ const container = links.parentElement?.parentElement;+ expect(container).toBeTruthy();+ if (container) {+ expect(within(container).getByText(/add up to 5 links/i)).toBeDefined();+ }+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/LinksSection/LinksSection.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/LinksSection/LinksSection.tsxnew file mode 100644index 0000000000..64647a31c0--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/LinksSection/LinksSection.tsx@@ -0,0 +1,107 @@+"use client";++import { AnimatePresence, motion, useReducedMotion } from "framer-motion";+import { LinkSimpleIcon, PlusIcon, TrashIcon } from "@phosphor-icons/react";++import { Button } from "@/components/atoms/Button/Button";+import { Text } from "@/components/atoms/Text/Text";++import { type LinkRow, MAX_LINKS } from "../../helpers";++interface Props {+ links: LinkRow[];+ onChange: (index: number, value: string) => void;+ onAdd: () => void;+ onRemove: (index: number) => void;+}++const EASE_OUT = [0.16, 1, 0.3, 1] as const;++export function LinksSection({ links, onChange, onAdd, onRemove }: Props) {+ const reduceMotion = useReducedMotion();+ const canAdd = links.length < MAX_LINKS;++ return (+ <motion.div+ initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 8 }}+ animate={{ opacity: 1, y: 0 }}+ transition={{ duration: 0.32, ease: EASE_OUT, delay: 0.12 }}+ className="flex flex-col gap-4"+ >+ <div className="flex flex-col gap-1 px-4">+ <Text variant="body-medium" as="span" className="text-black">+ Your links+ </Text>+ <Text variant="small" className="text-zinc-500">+ Add up to {MAX_LINKS} links. Site, GitHub, X, anything you want+ visible.+ </Text>+ </div>++ <div className="flex flex-col gap-3">+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-2">+ <AnimatePresence initial={false}>+ {links.map((link, index) => (+ <motion.div+ key={link.id}+ layout={!reduceMotion}+ initial={+ reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97 }+ }+ animate={{ opacity: 1, scale: 1 }}+ exit={+ reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97 }+ }+ transition={{ duration: 0.18, ease: EASE_OUT }}+ >+ <div className="flex items-center gap-2">+ <div className="flex flex-1 items-center gap-2 rounded-3xl border border-zinc-200 bg-white px-4 transition-colors duration-150 focus-within:border-purple-400 focus-within:ring-1 focus-within:ring-purple-400">+ <LinkSimpleIcon+ size={16}+ weight="regular"+ className="text-zinc-400"+ />+ <input+ type="url"+ value={link.value}+ placeholder="https://"+ aria-label={`Link ${index + 1}`}+ onChange={(e) => onChange(index, e.target.value)}+ className="h-[2.875rem] w-full border-none bg-transparent text-sm text-black placeholder:text-zinc-400 focus:outline-none"+ />+ </div>+ <Button+ variant="icon"+ size="icon"+ aria-label={`Remove link ${index + 1}`}+ onClick={() => onRemove(index)}+ >+ <TrashIcon size={16} />+ </Button>+ </div>+ </motion.div>+ ))}+ </AnimatePresence>+ </div>++ {links.length === 0 ? (+ <Text variant="small" className="px-4 text-zinc-400">+ No links yet.+ </Text>+ ) : null}++ <div>+ <Button+ variant="ghost"+ size="small"+ leftIcon={<PlusIcon size={16} />}+ onClick={onAdd}+ disabled={!canAdd}+ >+ {canAdd ? "Add link" : `Limit of ${MAX_LINKS} reached`}+ </Button>+ </div>+ </div>+ </motion.div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileForm/ProfileForm.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileForm/ProfileForm.tsxnew file mode 100644index 0000000000..cf0cf92f28--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileForm/ProfileForm.tsx@@ -0,0 +1,263 @@+"use client";++import { motion, useReducedMotion } from "framer-motion";+import {+ EyeClosedIcon,+ EyeIcon,+ LinkIcon,+ ListBulletsIcon,+ TextBIcon,+ TextItalicIcon,+ TextStrikethroughIcon,+} from "@phosphor-icons/react";+import { type ReactNode, useRef, useState } from "react";+import ReactMarkdown from "react-markdown";+import remarkGfm from "remark-gfm";++import { Input } from "@/components/atoms/Input/Input";+import { Text } from "@/components/atoms/Text/Text";+import { cn } from "@/lib/utils";++import {+ MAX_BIO_LENGTH,+ type ProfileFormState,+ validateForm,+} from "../../helpers";++interface Props {+ formState: ProfileFormState;+ errors: ReturnType<typeof validateForm>["errors"];+ onChange: <K extends keyof ProfileFormState>(+ key: K,+ value: ProfileFormState[K],+ ) => void;+}++const EASE_OUT = [0.16, 1, 0.3, 1] as const;++interface MarkdownAction {+ label: string;+ icon: ReactNode;+ before: string;+ after: string;+ placeholder: string;+ block?: boolean;+}++const ACTIONS: ReadonlyArray<MarkdownAction> = [+ {+ label: "Bold",+ icon: <TextBIcon size={16} weight="bold" />,+ before: "**",+ after: "**",+ placeholder: "bold text",+ },+ {+ label: "Italic",+ icon: <TextItalicIcon size={16} />,+ before: "*",+ after: "*",+ placeholder: "italic text",+ },+ {+ label: "Strikethrough",+ icon: <TextStrikethroughIcon size={16} />,+ before: "~~",+ after: "~~",+ placeholder: "strikethrough",+ },+ {+ label: "Link",+ icon: <LinkIcon size={16} />,+ before: "[",+ after: "](https://)",+ placeholder: "link text",+ },+ {+ label: "Bulleted list",+ icon: <ListBulletsIcon size={16} />,+ before: "- ",+ after: "",+ placeholder: "list item",+ block: true,+ },+];++export function ProfileForm({ formState, errors, onChange }: Props) {+ const reduceMotion = useReducedMotion();+ const textareaRef = useRef<HTMLTextAreaElement>(null);+ const [isPreview, setIsPreview] = useState(false);+ const remaining = MAX_BIO_LENGTH - formState.description.length;+ const counterColor =+ remaining < 0+ ? "text-red-500"+ : remaining < 30+ ? "text-amber-600"+ : "text-zinc-400";++ function applyAction(action: MarkdownAction) {+ const textarea = textareaRef.current;+ if (!textarea) return;++ const value = formState.description;+ const start = textarea.selectionStart ?? 0;+ const end = textarea.selectionEnd ?? 0;+ const scrollTop = textarea.scrollTop;+ const hasSelection = start !== end;+ const selected = hasSelection ? value.substring(start, end) : "";++ let newValue: string;+ let cursorStart: number;+ let cursorEnd: number;++ if (action.block) {+ const lineStart = value.lastIndexOf("\n", start - 1) + 1;+ const alreadyPrefixed = value+ .substring(lineStart)+ .startsWith(action.before);+ if (alreadyPrefixed) {+ newValue = value;+ cursorStart = start;+ cursorEnd = end;+ } else {+ newValue =+ value.substring(0, lineStart) ++ action.before ++ value.substring(lineStart);+ cursorStart = start + action.before.length;+ cursorEnd = end + action.before.length;+ }+ } else {+ const insertText = selected || action.placeholder;+ newValue =+ value.substring(0, start) ++ action.before ++ insertText ++ action.after ++ value.substring(end);+ if (hasSelection) {+ cursorStart = start + action.before.length;+ cursorEnd = end + action.before.length;+ } else {+ cursorStart = start + action.before.length;+ cursorEnd = cursorStart + insertText.length;+ }+ }++ onChange("description", newValue);+ requestAnimationFrame(() => {+ const node = textareaRef.current;+ if (!node) return;+ node.focus({ preventScroll: true });+ node.setSelectionRange(cursorStart, cursorEnd);+ node.scrollTop = scrollTop;+ });+ }++ return (+ <motion.div+ initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 8 }}+ animate={{ opacity: 1, y: 0 }}+ transition={{ duration: 0.32, ease: EASE_OUT, delay: 0.06 }}+ className="flex w-full flex-col gap-2"+ >+ <div className="flex items-center justify-between px-4">+ <Text variant="body-medium" as="span" className="text-black">+ Bio+ </Text>+ <Text+ variant="small"+ as="span"+ className={`tabular-nums transition-colors duration-150 ${counterColor}`}+ >+ {Math.max(remaining, 0)} left+ </Text>+ </div>+ <div className="flex items-center gap-1 px-2">+ <div+ className={cn(+ "flex items-center gap-1 transition-opacity",+ isPreview && "pointer-events-none opacity-40",+ )}+ aria-hidden={isPreview}+ >+ {ACTIONS.map((action) => (+ <button+ key={action.label}+ type="button"+ aria-label={action.label}+ title={action.label}+ onMouseDown={(e) => e.preventDefault()}+ onClick={() => applyAction(action)}+ disabled={isPreview}+ className="inline-flex h-8 w-8 items-center justify-center rounded-full text-zinc-600 transition-colors hover:bg-zinc-100 hover:text-black"+ >+ {action.icon}+ </button>+ ))}+ </div>+ <button+ type="button"+ aria-pressed={isPreview}+ onClick={() => setIsPreview((v) => !v)}+ className="ml-auto inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium text-zinc-700 transition-colors hover:bg-zinc-100 hover:text-black"+ >+ {isPreview ? <EyeClosedIcon size={14} /> : <EyeIcon size={14} />}+ {isPreview ? "Edit" : "Preview"}+ </button>+ </div>+ {isPreview ? (+ <div+ className={cn(+ "min-h-[8.75rem] w-full rounded-3xl border border-zinc-200 bg-white px-4 py-2.5",+ "text-sm leading-[22px] text-black",+ )}+ >+ {formState.description.trim() ? (+ <div+ className={cn(+ "max-w-none break-words text-sm leading-[22px] text-black",+ "[&_p]:my-2 first:[&_p]:mt-0 last:[&_p]:mb-0",+ "[&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5",+ "[&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5",+ "[&_li]:my-1 [&_li]:pl-1",+ "[&_li>p]:my-0",+ "[&_a]:text-purple-600 [&_a]:underline hover:[&_a]:text-purple-700",+ "[&_strong]:font-semibold",+ "[&_em]:italic",+ "[&_del]:text-zinc-500 [&_del]:line-through",+ "[&_code]:rounded [&_code]:bg-zinc-100 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em]",+ "[&_blockquote]:border-l-2 [&_blockquote]:border-zinc-300 [&_blockquote]:pl-3 [&_blockquote]:text-zinc-600",+ "[&_h1]:my-2 [&_h1]:text-base [&_h1]:font-semibold",+ "[&_h2]:my-2 [&_h2]:text-base [&_h2]:font-semibold",+ "[&_h3]:my-2 [&_h3]:text-sm [&_h3]:font-semibold",+ )}+ >+ <ReactMarkdown remarkPlugins={[remarkGfm]}>+ {formState.description}+ </ReactMarkdown>+ </div>+ ) : (+ <Text variant="body" as="span" className="text-zinc-400">+ Nothing to preview yet.+ </Text>+ )}+ </div>+ ) : (+ <Input+ ref={textareaRef}+ id="profile-bio"+ label="Bio"+ hideLabel+ type="textarea"+ rows={5}+ placeholder="Tell people what you build, the agents you ship, and what you care about."+ value={formState.description}+ error={errors.description}+ onChange={(e) => onChange("description", e.target.value)}+ className="!rounded-3xl"+ />+ )}+ </motion.div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileHeader/ProfileHeader.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileHeader/ProfileHeader.tsxnew file mode 100644index 0000000000..9699a922d9--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileHeader/ProfileHeader.tsx@@ -0,0 +1,180 @@+"use client";++import { useRef, useState } from "react";+import { motion, useReducedMotion } from "framer-motion";+import { CameraIcon, PencilSimpleIcon, UserIcon } from "@phosphor-icons/react";+import { CircleNotchIcon } from "@phosphor-icons/react/dist/ssr";++import {+ Avatar,+ AvatarFallback,+ AvatarImage,+} from "@/components/atoms/Avatar/Avatar";+import { Input } from "@/components/atoms/Input/Input";+import { Text } from "@/components/atoms/Text/Text";++import { type ProfileFormState, validateForm } from "../../helpers";++interface Props {+ avatarUrl: string;+ name: string;+ username: string;+ errors: ReturnType<typeof validateForm>["errors"];+ onChange: <K extends keyof ProfileFormState>(+ key: K,+ value: ProfileFormState[K],+ ) => void;+ isUploading: boolean;+ onUpload: (file: File) => Promise<string | null>;+}++const EASE_OUT = [0.16, 1, 0.3, 1] as const;+// iOS-style cubic-bezier — gives the badge a smooth in-and-out feel as it+// sweeps along the avatar's circumference (Emil's drawer easing).+const BADGE_ARC_EASE = [0.32, 0.72, 0, 1] as const;++export function ProfileHeader({+ avatarUrl,+ name,+ username,+ errors,+ onChange,+ isUploading,+ onUpload,+}: Props) {+ const fileRef = useRef<HTMLInputElement>(null);+ const [isHovered, setIsHovered] = useState(false);+ const reduceMotion = useReducedMotion();++ function openFilePicker() {+ if (isUploading) return;+ fileRef.current?.click();+ }++ async function handleChange(e: React.ChangeEvent<HTMLInputElement>) {+ const file = e.target.files?.[0];+ e.target.value = "";+ if (file) {+ await onUpload(file);+ }+ }++ return (+ <motion.div+ initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 12 }}+ animate={{ opacity: 1, y: 0 }}+ transition={{ duration: 0.32, ease: EASE_OUT }}+ className="flex flex-col items-center gap-5 sm:flex-row sm:items-start sm:gap-6"+ >+ <button+ type="button"+ onClick={openFilePicker}+ onMouseEnter={() => setIsHovered(true)}+ onMouseLeave={() => setIsHovered(false)}+ disabled={isUploading}+ aria-label="Change profile photo"+ className="group relative h-[112px] w-[112px] shrink-0 cursor-pointer rounded-full outline-none transition-transform duration-150 ease-out focus-visible:ring-2 focus-visible:ring-purple-400 focus-visible:ring-offset-2 active:scale-[0.97] disabled:cursor-wait"+ >+ <Avatar className="h-[112px] w-[112px] shadow-[0_8px_28px_-12px_rgba(15,15,20,0.18)] ring-2 ring-white">+ <AvatarImage+ src={avatarUrl}+ alt={name || "Profile"}+ width={224}+ height={224}+ />+ <AvatarFallback className="bg-gradient-to-br from-zinc-100 to-zinc-200 text-zinc-500">+ <UserIcon size={48} weight="regular" />+ </AvatarFallback>+ </Avatar>++ <motion.div+ initial={false}+ animate={{+ opacity: isUploading || isHovered ? 1 : 0,+ }}+ transition={{ duration: 0.18, ease: EASE_OUT }}+ className="pointer-events-none absolute inset-0 flex items-center justify-center rounded-full bg-black/45 text-white backdrop-blur-[2px]"+ >+ {isUploading ? (+ <CircleNotchIcon size={26} weight="bold" className="animate-spin" />+ ) : (+ <CameraIcon size={26} weight="regular" />+ )}+ </motion.div>++ <motion.span+ aria-hidden+ initial={false}+ animate={{ rotate: !reduceMotion && isHovered ? -90 : 0 }}+ transition={{+ duration: reduceMotion ? 0 : 0.32,+ ease: BADGE_ARC_EASE,+ }}+ className="pointer-events-none absolute inset-0"+ style={{ transformOrigin: "center" }}+ >+ <motion.span+ initial={false}+ animate={{ rotate: !reduceMotion && isHovered ? 90 : 0 }}+ transition={{+ duration: reduceMotion ? 0 : 0.32,+ ease: BADGE_ARC_EASE,+ }}+ className="absolute bottom-1 right-1 flex h-9 w-9 items-center justify-center rounded-full border-2 border-white bg-white text-black shadow-[0_3px_10px_-2px_rgba(15,15,20,0.25)]"+ style={{ transformOrigin: "center" }}+ >+ <PencilSimpleIcon size={16} weight="bold" />+ </motion.span>+ </motion.span>++ <input+ ref={fileRef}+ type="file"+ accept="image/png,image/jpeg,image/webp,image/gif"+ className="hidden"+ onChange={handleChange}+ />+ </button>++ <div className="grid w-full gap-4 sm:grid-cols-2">+ <label htmlFor="profile-name" className="flex w-full flex-col gap-2">+ <Text variant="body-medium" as="span" className="px-4 text-black">+ Display name+ </Text>+ <Input+ id="profile-name"+ label="Display name"+ hideLabel+ placeholder="Jane Doe"+ value={name}+ error={errors.name}+ onChange={(e) => onChange("name", e.target.value)}+ />+ </label>++ <label+ htmlFor="profile-username"+ className="flex w-full flex-col gap-2"+ >+ <div className="flex items-center justify-between px-4">+ <Text variant="body-medium" as="span" className="text-black">+ Handle+ </Text>+ <Text variant="small" as="span" className="!text-zinc-400">+ autogpt.com/@your-handle+ </Text>+ </div>+ <Input+ id="profile-username"+ label="Handle"+ hideLabel+ placeholder="jane_doe"+ value={username}+ error={errors.username}+ onChange={(e) => onChange("username", e.target.value)}+ />+ </label>+ </div>+ </motion.div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileSkeleton/ProfileSkeleton.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileSkeleton/ProfileSkeleton.tsxnew file mode 100644index 0000000000..0586d366da--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/ProfileSkeleton/ProfileSkeleton.tsx@@ -0,0 +1,40 @@+import { Skeleton } from "@/components/atoms/Skeleton/Skeleton";++export function ProfileSkeleton() {+ return (+ <div className="flex flex-col gap-6">+ <div className="flex flex-col pb-2">+ <Skeleton className="h-7 w-32" />+ <Skeleton className="mt-4 h-4 w-72" />+ </div>++ <div className="flex flex-col items-center gap-5 sm:flex-row sm:items-start sm:gap-6">+ <Skeleton className="h-[112px] w-[112px] shrink-0 rounded-full" />+ <div className="grid w-full gap-4 sm:grid-cols-2">+ <div className="flex flex-col gap-2">+ <Skeleton className="h-4 w-24" />+ <Skeleton className="h-[46px] w-full rounded-3xl" />+ </div>+ <div className="flex flex-col gap-2">+ <Skeleton className="h-4 w-24" />+ <Skeleton className="h-[46px] w-full rounded-3xl" />+ </div>+ </div>+ </div>++ <div className="flex flex-col gap-2">+ <Skeleton className="h-4 w-12" />+ <Skeleton className="h-[120px] w-full rounded-3xl" />+ </div>++ <div className="flex flex-col gap-3">+ <Skeleton className="h-4 w-24" />+ <div className="grid grid-cols-1 gap-3 sm:grid-cols-2">+ <Skeleton className="h-[46px] w-full rounded-3xl" />+ <Skeleton className="h-[46px] w-full rounded-3xl" />+ <Skeleton className="h-[46px] w-full rounded-3xl" />+ </div>+ </div>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/SaveBar/SaveBar.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/SaveBar/SaveBar.tsxnew file mode 100644index 0000000000..e349213820--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/components/SaveBar/SaveBar.tsx@@ -0,0 +1,35 @@+"use client";++import { Button } from "@/components/atoms/Button/Button";++interface Props {+ dirty: boolean;+ saving: boolean;+ canSave: boolean;+ onDiscard: () => void;+ onSave: () => void;+}++export function SaveBar({ dirty, saving, canSave, onDiscard, onSave }: Props) {+ return (+ <div className="flex items-center justify-start gap-2">+ <Button+ variant="outline"+ size="large"+ onClick={onDiscard}+ disabled={!dirty || saving}+ >+ Discard+ </Button>+ <Button+ variant="primary"+ size="large"+ onClick={onSave}+ loading={saving}+ disabled={!canSave || saving}+ >+ Save changes+ </Button>+ </div>+ );+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/helpers.ts b/autogpt_platform/frontend/src/app/(platform)/settings/profile/helpers.tsnew file mode 100644index 0000000000..59b0603366--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/helpers.ts@@ -0,0 +1,105 @@+import type { ProfileDetails } from "@/app/api/__generated__/models/profileDetails";++export const MAX_LINKS = 5;+export const INITIAL_LINK_SLOTS = 3;+export const MAX_BIO_LENGTH = 280;+export const HANDLE_REGEX = /^[a-zA-Z0-9_-]{2,30}$/;++export type LinkRow = {+ id: string;+ value: string;+};++let linkIdCounter = 0;+function nextLinkId(): string {+ linkIdCounter += 1;+ return `link-${linkIdCounter}`;+}++export function makeLinkRow(value = ""): LinkRow {+ return { id: nextLinkId(), value };+}++function padLinks(links: string[]): LinkRow[] {+ const capped = links.slice(0, MAX_LINKS).map((value) => makeLinkRow(value));+ if (capped.length >= INITIAL_LINK_SLOTS) return capped;+ return [+ ...capped,+ ...Array.from({ length: INITIAL_LINK_SLOTS - capped.length }, () =>+ makeLinkRow(""),+ ),+ ];+}++export type ProfileFormState = {+ name: string;+ username: string;+ description: string;+ avatar_url: string;+ links: LinkRow[];+};++export function profileToFormState(profile: ProfileDetails): ProfileFormState {+ return {+ name: profile.name ?? "",+ username: profile.username ?? "",+ description: profile.description ?? "",+ avatar_url: profile.avatar_url ?? "",+ links: padLinks(profile.links ?? []),+ };+}++export function isFormDirty(+ initial: ProfileFormState,+ current: ProfileFormState,+): boolean {+ if (+ initial.name !== current.name ||+ initial.username !== current.username ||+ initial.description !== current.description ||+ initial.avatar_url !== current.avatar_url+ ) {+ return true;+ }+ const a = initial.links.map((l) => l.value).filter(Boolean);+ const b = current.links.map((l) => l.value).filter(Boolean);+ if (a.length !== b.length) return true;+ return a.some((value, idx) => value !== b[idx]);+}++export function validateForm(state: ProfileFormState): {+ valid: boolean;+ errors: Partial<Record<"name" | "username" | "description", string>>;+} {+ const errors: Partial<Record<"name" | "username" | "description", string>> =+ {};++ if (!state.name.trim()) {+ errors.name = "Display name is required";+ } else if (state.name.length > 50) {+ errors.name = "Display name must be under 50 characters";+ }++ if (!state.username.trim()) {+ errors.username = "Handle is required";+ } else if (!HANDLE_REGEX.test(state.username)) {+ errors.username = "Use 2–30 letters, numbers, underscores or dashes";+ }++ if (state.description.length > MAX_BIO_LENGTH) {+ errors.description = `Bio must be under ${MAX_BIO_LENGTH} characters`;+ }++ return { valid: Object.keys(errors).length === 0, errors };+}++export function getInitials(name: string): string {+ const parts = name.trim().split(/\s+/).filter(Boolean);+ if (parts.length === 0) return "?";+ const first = Array.from(parts[0]!);+ if (parts.length === 1) {+ return first.slice(0, 2).join("").toUpperCase();+ }+ const last = Array.from(parts[parts.length - 1]!);+ return (first[0]! + last[0]!).toUpperCase();+}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/page.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/profile/page.tsxindex 69e32e4016..aca7328550 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/profile/page.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/page.tsx@@ -1,16 +1,94 @@"use client";import { Text } from "@/components/atoms/Text/Text";+import { ErrorCard } from "@/components/molecules/ErrorCard/ErrorCard";++import { LinksSection } from "./components/LinksSection/LinksSection";+import { ProfileForm } from "./components/ProfileForm/ProfileForm";+import { ProfileHeader } from "./components/ProfileHeader/ProfileHeader";+import { ProfileSkeleton } from "./components/ProfileSkeleton/ProfileSkeleton";+import { SaveBar } from "./components/SaveBar/SaveBar";+import { useProfilePage } from "./useProfilePage";export default function SettingsProfilePage() {+ const {+ user,+ isLoading,+ isError,+ error,+ refetch,+ formState,+ patchField,+ setLink,+ addLink,+ removeLink,+ discardChanges,+ uploadAvatar,+ isUploading,+ saveProfile,+ isSaving,+ dirty,+ validation,+ } = useProfilePage();++ if (isError) {+ return (+ <ErrorCard+ context="profile"+ responseError={error ? { detail: error.detail } : undefined}+ onRetry={() => {+ void refetch();+ }}+ />+ );+ }++ if (isLoading || !user) {+ return <ProfileSkeleton />;+ }+return (- <>- <Text variant="h4" className="text-[#1F1F20]">- Profile- </Text>- <Text variant="large" className="mt-2 text-zinc-600">- Coming soon.- </Text>- </>+ <div className="flex w-full flex-col gap-6">+ <div className="flex flex-col pb-2">+ <Text variant="h4" as="h1" className="leading-[28px] text-textBlack">+ Profile+ </Text>+ <Text variant="body" className="mt-4 max-w-[600px] text-zinc-700">+ Manage how you appear on the marketplace — your photo, handle, bio,+ and links.+ </Text>+ </div>++ <ProfileHeader+ avatarUrl={formState.avatar_url}+ name={formState.name}+ username={formState.username}+ errors={validation.errors}+ onChange={patchField}+ isUploading={isUploading}+ onUpload={uploadAvatar}+ />++ <ProfileForm+ formState={formState}+ errors={validation.errors}+ onChange={patchField}+ />++ <LinksSection+ links={formState.links}+ onChange={setLink}+ onAdd={addLink}+ onRemove={removeLink}+ />++ <SaveBar+ dirty={dirty}+ saving={isSaving}+ canSave={validation.valid && dirty}+ onDiscard={discardChanges}+ onSave={saveProfile}+ />+ </div>);}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/profile/useProfilePage.ts b/autogpt_platform/frontend/src/app/(platform)/settings/profile/useProfilePage.tsnew file mode 100644index 0000000000..93cd23504d--- /dev/null+++ b/autogpt_platform/frontend/src/app/(platform)/settings/profile/useProfilePage.ts@@ -0,0 +1,188 @@+"use client";++import { useEffect, useMemo, useState } from "react";+import { useQueryClient } from "@tanstack/react-query";++import {+ getGetV2GetUserProfileQueryKey,+ useGetV2GetUserProfile,+ usePostV2UpdateUserProfile,+ usePostV2UploadSubmissionMedia,+} from "@/app/api/__generated__/endpoints/store/store";+import type { ProfileDetails } from "@/app/api/__generated__/models/profileDetails";+import { toast } from "@/components/molecules/Toast/use-toast";+import { isLogoutInProgress } from "@/lib/autogpt-server-api/helpers";+import { useSupabase } from "@/lib/supabase/hooks/useSupabase";++import {+ isFormDirty,+ makeLinkRow,+ MAX_LINKS,+ profileToFormState,+ validateForm,+ type ProfileFormState,+} from "./helpers";++const EMPTY_FORM: ProfileFormState = {+ name: "",+ username: "",+ description: "",+ avatar_url: "",+ links: [],+};++export function useProfilePage() {+ const { user } = useSupabase();+ const queryClient = useQueryClient();+ const logoutInProgress = isLogoutInProgress();++ const profileQuery = useGetV2GetUserProfile<ProfileDetails | null>({+ query: {+ enabled: !!user && !logoutInProgress,+ select: (res) => {+ if (res.status === 200) {+ return { ...res.data, avatar_url: res.data.avatar_url ?? "" };+ }+ return null;+ },+ },+ });++ const initialState: ProfileFormState = useMemo(+ () =>+ profileQuery.data ? profileToFormState(profileQuery.data) : EMPTY_FORM,+ [profileQuery.data],+ );++ const [formState, setFormState] = useState<ProfileFormState>(EMPTY_FORM);++ useEffect(+ function syncFormStateOnDataLoad() {+ if (profileQuery.data) {+ setFormState(profileToFormState(profileQuery.data));+ }+ },+ [profileQuery.data],+ );++ const validation = useMemo(() => validateForm(formState), [formState]);+ const dirty = useMemo(+ () => isFormDirty(initialState, formState),+ [initialState, formState],+ );++ function patchField<K extends keyof ProfileFormState>(+ key: K,+ value: ProfileFormState[K],+ ) {+ setFormState((prev) => ({ ...prev, [key]: value }));+ }++ function setLink(index: number, value: string) {+ setFormState((prev) => {+ const next = prev.links.map((row, i) =>+ i === index ? { ...row, value } : row,+ );+ return { ...prev, links: next };+ });+ }++ function addLink() {+ setFormState((prev) =>+ prev.links.length >= MAX_LINKS+ ? prev+ : { ...prev, links: [...prev.links, makeLinkRow("")] },+ );+ }++ function removeLink(index: number) {+ setFormState((prev) => ({+ ...prev,+ links: prev.links.filter((_, i) => i !== index),+ }));+ }++ function discardChanges() {+ setFormState(initialState);+ }++ const uploadMutation = usePostV2UploadSubmissionMedia({+ mutation: {+ onError: (err) => {+ toast({+ title: "Failed to upload photo",+ description: err instanceof Error ? err.message : undefined,+ variant: "destructive",+ });+ },+ },+ });++ async function uploadAvatar(file: File): Promise<string | null> {+ try {+ const res = await uploadMutation.mutateAsync({ data: { file } });+ if (res.status !== 200) return null;+ const url = String(res.data ?? "").trim();+ if (!url) return null;+ patchField("avatar_url", url);+ return url;+ } catch {+ return null;+ }+ }++ const updateMutation = usePostV2UpdateUserProfile({+ mutation: {+ onSuccess: () => {+ void queryClient.invalidateQueries({+ queryKey: getGetV2GetUserProfileQueryKey(),+ });+ toast({ title: "Profile saved", variant: "success" });+ },+ onError: (err) => {+ toast({+ title: "Failed to save profile",+ description: err instanceof Error ? err.message : undefined,+ variant: "destructive",+ });+ },+ },+ });++ function saveProfile() {+ if (!validation.valid || updateMutation.isPending) return;+ updateMutation.mutate({+ data: {+ name: formState.name.trim(),+ username: formState.username.trim(),+ description: formState.description.trim(),+ avatar_url: formState.avatar_url,+ links: formState.links+ .map((l) => l.value.trim())+ .filter(Boolean)+ .slice(0, MAX_LINKS),+ },+ });+ }++ return {+ user,+ isLoading: profileQuery.isLoading,+ isError: profileQuery.isError,+ error: profileQuery.error,+ refetch: profileQuery.refetch,+ formState,+ initialState,+ patchField,+ setLink,+ addLink,+ removeLink,+ discardChanges,+ uploadAvatar,+ isUploading: uploadMutation.isPending,+ saveProfile,+ isSaving: updateMutation.isPending,+ dirty,+ validation,+ };+}diff --git a/autogpt_platform/frontend/src/components/atoms/Input/Input.tsx b/autogpt_platform/frontend/src/components/atoms/Input/Input.tsxindex ee2caa39af..b159f58c18 100644--- a/autogpt_platform/frontend/src/components/atoms/Input/Input.tsx+++ b/autogpt_platform/frontend/src/components/atoms/Input/Input.tsx@@ -4,11 +4,13 @@ import {} from "@/components/__legacy__/ui/input";import { cn } from "@/lib/utils";import { Eye, EyeSlash } from "@phosphor-icons/react";-import { ReactNode, useState } from "react";+import { forwardRef, ReactNode, useState } from "react";import CurrencyInput from "react-currency-input-field";import { Text } from "../Text/Text";import { useInput } from "./useInput";+type InputElement = HTMLInputElement | HTMLTextAreaElement;+export interface TextFieldProps extends Omit<InputProps, "size"> {label: string;id: string;@@ -35,20 +37,23 @@ export interface TextFieldProps extends Omit<InputProps, "size"> {amountSuffix?: string;}-export function Input({- className,- label,- placeholder,- hideLabel = false,- decimalCount,- hint,- error,- size = "medium",- wrapperClassName,- amountPrefix,- amountSuffix,- ...props-}: TextFieldProps) {+export const Input = forwardRef<InputElement, TextFieldProps>(function Input(+ {+ className,+ label,+ placeholder,+ hideLabel = false,+ decimalCount,+ hint,+ error,+ size = "medium",+ wrapperClassName,+ amountPrefix,+ amountSuffix,+ ...props+ },+ ref,+) {const { handleInputChange, handleTextareaChange, handleAmountValueChange } =useInput({type: props.type,@@ -89,6 +94,7 @@ export function Input({if (props.type === "textarea") {return (<textarea+ ref={ref as React.Ref<HTMLTextAreaElement>}className={cn(baseStyles,errorStyles,@@ -161,6 +167,7 @@ export function Input({return (<BaseInput+ ref={ref as React.Ref<HTMLInputElement>}className={cn(baseStyles,errorStyles,@@ -239,4 +246,4 @@ export function Input({{inputWithError}</label>);-}+});