Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(frontend): add Give feedback to the account menu

Claude98b2eceb330a
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenuNewLayout.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenuNewLayout.tsx
index 2ef91339d9..bedf8c8249 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenuNewLayout.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/AccountMenuNewLayout.tsx
@@ -7,6 +7,7 @@ import * as React from "react";
import { MenuItemGroup } from "../../helpers";
import { AccountLogoutOption } from "./components/AccountLogoutOption";
import { AccountMenuActivityRow } from "./components/AccountMenuActivityRow";
+import { AccountMenuFeedbackRow } from "./components/AccountMenuFeedbackRow";
import { AccountMenuHeader } from "./components/AccountMenuHeader";
import { AccountMenuRow } from "./components/AccountMenuRow";
import { InitialAvatar } from "./components/InitialAvatar";
@@ -124,9 +125,14 @@ export function AccountMenuNewLayout({
);
})}
{groupIndex === 0 && (
- <li>
- <AccountMenuActivityRow />
- </li>
+ <>
+ <li>
+ <AccountMenuActivityRow />
+ </li>
+ <li>
+ <AccountMenuFeedbackRow />
+ </li>
+ </>
)}
</ul>
</div>
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/AccountMenu.test.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/AccountMenu.test.tsx
index affa57f6a3..8b655b0891 100644
--- a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/AccountMenu.test.tsx
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/__tests__/AccountMenu.test.tsx
@@ -20,6 +20,14 @@ vi.mock("next/link", () => ({
useLinkStatus: () => ({ pending: false }),
}));
+vi.mock("@/lib/auth/actions", () => ({
+ getCurrentUser: vi.fn().mockResolvedValue({ user: null }),
+}));
+
+vi.mock("@sentry/nextjs", () => ({
+ getReplay: vi.fn(),
+}));
+
vi.mock("@/components/molecules/Popover/Popover", () => {
function Popover({ children }: { children: React.ReactNode }) {
return <div>{children}</div>;
@@ -184,6 +192,25 @@ describe("AccountMenu", () => {
expect(screen.getByText("Activity")).toBeDefined();
});
+ test("new layout renders Give feedback right after Activity", () => {
+ render(
+ <AccountMenu
+ userName="Ada"
+ userEmail="[email protected]"
+ menuItemGroups={baseGroups}
+ newLayout
+ />,
+ );
+
+ const activity = screen.getByTestId("account-menu-activity-trigger");
+ const feedback = screen.getByTestId("account-menu-feedback-trigger");
+
+ expect(feedback.getAttribute("data-tally-open")).toBe("3yx2L0");
+ expect(activity.closest("li")?.nextElementSibling).toBe(
+ feedback.closest("li"),
+ );
+ });
+
test("classic layout does not render org/activity triggers", () => {
render(
<AccountMenu
@@ -195,5 +222,6 @@ describe("AccountMenu", () => {
expect(screen.queryByTestId("account-menu-org-trigger")).toBeNull();
expect(screen.queryByTestId("account-menu-activity-trigger")).toBeNull();
+ expect(screen.queryByTestId("account-menu-feedback-trigger")).toBeNull();
});
});
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountMenuFeedbackRow.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountMenuFeedbackRow.tsx
new file mode 100644
index 0000000000..35db160c19
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/AccountMenuFeedbackRow.tsx
@@ -0,0 +1,44 @@
+"use client";
+
+import { Icon } from "@/components/atoms/Icon/Icon";
+import { useTallyPopup } from "@/components/molecules/TallyPoup/useTallyPopup";
+import { HelpCircleIcon } from "@hugeicons/core-free-icons";
+
+const FEEDBACK_TALLY_FORM_ID = "3yx2L0";
+
+const rowClasses =
+ "group relative flex w-full items-center gap-3 rounded-lg py-2 pl-3 pr-2 text-left text-sm font-normal text-neutral-700 outline-none transition-colors duration-200 ease-out hover:bg-neutral-100 focus-visible:bg-neutral-100 focus-visible:outline-none";
+
+export function AccountMenuFeedbackRow() {
+ const { state } = useTallyPopup();
+
+ return (
+ <button
+ type="button"
+ className={rowClasses}
+ data-testid="account-menu-feedback-trigger"
+ data-tally-open={FEEDBACK_TALLY_FORM_ID}
+ data-tally-emoji-text="👋"
+ data-tally-emoji-animation="wave"
+ data-sentry-replay-id={state.sentryReplayId || "not-initialized"}
+ data-sentry-replay-url={state.replayUrl || "not-initialized"}
+ data-page-url={
+ state.pageUrl ? state.pageUrl.split("?")[0] : "not-initialized"
+ }
+ data-is-authenticated={
+ state.isAuthenticated === null
+ ? "unknown"
+ : String(state.isAuthenticated)
+ }
+ >
+ <span
+ className="absolute left-0 top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-full bg-neutral-900 opacity-0 transition-opacity duration-200 group-hover:opacity-100 group-focus-visible:opacity-100"
+ aria-hidden="true"
+ />
+ <span className="relative z-10 flex shrink-0 items-center">
+ <Icon icon={HelpCircleIcon} className="h-[18px] w-[18px] shrink-0" />
+ </span>
+ <span className="relative z-10 flex-1 truncate">Give feedback</span>
+ </button>
+ );
+}
diff --git a/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountMenuFeedbackRow.test.tsx b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountMenuFeedbackRow.test.tsx
new file mode 100644
index 0000000000..138b565ddd
--- /dev/null
+++ b/autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/AccountMenuFeedbackRow.test.tsx
@@ -0,0 +1,31 @@
+import { act, render, screen } from "@/tests/integrations/test-utils";
+import { describe, expect, test, vi } from "vitest";
+import { AccountMenuFeedbackRow } from "../AccountMenuFeedbackRow";
+
+vi.mock("@/lib/auth/actions", () => ({
+ getCurrentUser: vi
+ .fn()
+ .mockResolvedValue({ user: { email: "[email protected]" } }),
+}));
+
+vi.mock("@sentry/nextjs", () => ({
+ getReplay: vi.fn(() => ({ getReplayId: () => "replay-123" })),
+}));
+
+describe("AccountMenuFeedbackRow", () => {
+ test("renders a Give feedback button wired to the Tally feedback form", async () => {
+ render(<AccountMenuFeedbackRow />);
+ await act(async () => {});
+
+ const button = screen.getByRole("button", { name: "Give feedback" });
+
+ expect(button.getAttribute("data-tally-open")).toBe("3yx2L0");
+ expect(button.getAttribute("data-tally-emoji-text")).toBe("👋");
+ expect(button.getAttribute("data-tally-emoji-animation")).toBe("wave");
+ expect(button.getAttribute("data-sentry-replay-id")).toBe("replay-123");
+ expect(button.getAttribute("data-sentry-replay-url")).toBe(
+ "https://significant-gravitas.sentry.io/replays/replay-123/",
+ );
+ expect(button.getAttribute("data-is-authenticated")).toBe("true");
+ });
+});