Skip to content

fix(frontend): use consistent marble avatar fallback in navbar (#13411)#13426

Open
Chessing234 wants to merge 1 commit into
Significant-Gravitas:devfrom
Chessing234:fix/13411-avatar-fallback-consistency
Open

fix(frontend): use consistent marble avatar fallback in navbar (#13411)#13426
Chessing234 wants to merge 1 commit into
Significant-Gravitas:devfrom
Chessing234:fix/13411-avatar-fallback-consistency

Conversation

@Chessing234

Copy link
Copy Markdown

Summary

  • Replace the navbar account menu's custom letter-on-purple avatar fallback with the shared AvatarFallback component (boring-avatars marble gradient)
  • Ensures the same user sees a consistent avatar treatment in the navbar and across profile/creator displays

Fixes #13411

Root cause

InitialAvatar in the account menu rendered a hardcoded initial letter on a solid violet background, while the design-system Avatar component uses a marble gradient fallback seeded by the user's name everywhere else.

Test plan

  • pnpm exec vitest run src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • Manually verify navbar avatar shows marble gradient when no profile image is set
  • Manually verify profile/creator avatars still match navbar fallback style

Made with Cursor

Replace the navbar account menu's letter-on-purple fallback with the shared AvatarFallback component so user avatars match profile/creator displays.

Fixes Significant-Gravitas#13411

Co-authored-by: Cursor <cursoragent@cursor.com>
@Chessing234 Chessing234 requested a review from a team as a code owner June 24, 2026 12:44
@Chessing234 Chessing234 requested review from Pwuts and majdyz and removed request for a team June 24, 2026 12:44
@github-project-automation github-project-automation Bot moved this to 🆕 Needs initial review in AutoGPT development kanban Jun 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR targets the master branch but does not come from dev or a hotfix/* branch.

Automatically setting the base branch to dev.

@github-actions github-actions Bot added the platform/frontend AutoGPT Platform - Front end label Jun 24, 2026
@github-actions github-actions Bot changed the base branch from master to dev June 24, 2026 12:44
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

InitialAvatar is refactored to accept an optional src prop and use AvatarImage/AvatarFallback from the Avatar module. The fallback text changes from a computed name initial to name?.trim() or "User". Tests are updated to assert SVG-based marble gradient fallback rendering and image accessibility when src is provided.

Changes

InitialAvatar AvatarImage/Fallback refactor

Layer / File(s) Summary
Component: src prop and AvatarImage/AvatarFallback rendering
...AccountMenu/components/InitialAvatar.tsx
Imports updated to include AvatarFallback and AvatarImage. Props gains optional src?: string. Render logic replaces the initial-letter <div> with AvatarImage (driven by src) and AvatarFallback (using name?.trim() or "User").
Tests: fallback and src rendering assertions
...AccountMenu/components/__tests__/InitialAvatar.test.tsx
Fallback tests switch from asserting extracted initial characters to checking for SVG-based marble gradient presence across four cases. A new async test asserts that src renders an img with accessible name "ada's avatar".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

size/m, platform/frontend

Suggested reviewers

  • kcze
  • 0ubbe
  • autogpt-pr-reviewer

Poem

🐇 No more lonely letter "A" on purple ground,
A marble gradient swirls without a sound.
The src prop arrives, the fallback blooms in style,
Consistent avatars everywhere — now that's worthwhile!
✨ Hop hop hooray, the navbar joins the crew!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly reflects the navbar avatar fallback consistency change and is specific enough.
Description check ✅ Passed The description matches the PR by explaining the avatar fallback refactor and related test plan.
Linked Issues check ✅ Passed The navbar avatar now uses the shared Avatar fallback, matching the issue's consistency objective.
Out of Scope Changes check ✅ Passed The changes stay focused on the avatar fallback refactor and tests, with no unrelated edits evident.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

className="relative z-10"
/>
<AvatarImage src={src} alt={name ? `${name}'s avatar` : "User avatar"} />
<AvatarFallback>{name?.trim() || "User"}</AvatarFallback>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The InitialAvatar's fallback BoringAvatar is always rendered at 40px, causing it to be cropped when the component is used at a smaller size, like 32px.
Severity: LOW

Suggested Fix

Pass the className prop from InitialAvatar down to the AvatarFallback component. This will allow AvatarFallback to correctly calculate the required size for the BoringAvatar SVG based on the Tailwind CSS classes, ensuring it matches the container size.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx#L17

Potential issue: The `AvatarFallback` component within `InitialAvatar` defaults to
rendering its `BoringAvatar` SVG at a fixed size of 40px. This occurs because it's
invoked without a `size` or `className` prop, causing its internal size calculation to
fall back to a hardcoded `40`. When `InitialAvatar` is used with a `className` that
specifies a smaller size (e.g., `h-8 w-8` for 32px), the outer container shrinks but the
inner SVG does not. This results in the 40px SVG being clipped by the smaller
container's `overflow-hidden` style, making the fallback avatar appear cropped instead
of scaled correctly.

Did we get this right? 👍 / 👎 to inform future reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx (1)

34-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a whitespace-name + src regression test.

This block covers the normal src case, but not whitespace-only names. Add one case asserting the image accessible name falls back to "User avatar" after normalization.

Suggested test addition
+  test("uses 'User avatar' alt text when name is whitespace and src is provided", async () => {
+    render(<InitialAvatar name="   " src="https://example.com/avatar.png" />);
+
+    await waitFor(() => {
+      expect(screen.getByRole("img", { name: "User avatar" })).toBeDefined();
+    });
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx`
around lines 34 - 39, The InitialAvatar tests currently cover the normal src
rendering path but miss the whitespace-only name regression. Add a new case in
InitialAvatar.test.tsx alongside the existing “shows image when src is provided”
test that renders InitialAvatar with a whitespace-only name and a src, then
assert via getByRole("img") that the accessible name falls back to “User avatar”
after name normalization.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx`:
- Around line 16-17: The avatar name handling in InitialAvatar should normalize
the `name` value once and reuse that normalized result for both `AvatarImage`
alt text and `AvatarFallback`, since raw `name` can produce invalid
whitespace-only strings while the fallback already trims it. Update the
`InitialAvatar` component to derive a single trimmed name value before
rendering, then use that same value for the alt message and fallback so both
behave consistently.

---

Nitpick comments:
In
`@autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx`:
- Around line 34-39: The InitialAvatar tests currently cover the normal src
rendering path but miss the whitespace-only name regression. Add a new case in
InitialAvatar.test.tsx alongside the existing “shows image when src is provided”
test that renders InitialAvatar with a whitespace-only name and a src, then
assert via getByRole("img") that the accessible name falls back to “User avatar”
after name normalization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 86dca489-dd63-4469-83b5-27544314497b

📥 Commits

Reviewing files that changed from the base of the PR and between 150514f and 390da1d.

📒 Files selected for processing (2)
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (8)
  • GitHub Check: check API types
  • GitHub Check: integration_test
  • GitHub Check: lint
  • GitHub Check: Seer Code Review
  • GitHub Check: Check PR Status
  • GitHub Check: end-to-end tests
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (typescript)
🧰 Additional context used
📓 Path-based instructions (15)
autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Use Node.js 21+ with pnpm package manager for frontend development
Always run 'pnpm format' for formatting and linting code in frontend development

Format frontend code using pnpm format

autogpt_platform/frontend/**/*.{ts,tsx,js,jsx}: Fully capitalize acronyms in symbols, e.g. graphID, useBackendAPI
No linter suppressors (// @ts-ignore``, // eslint-disable) — fix the actual issue

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{tsx,ts}: Use function declarations for components and handlers (not arrow functions) in React components
Only use arrow functions for small inline lambdas (map, filter, etc.) in React components
Use PascalCase for component names and camelCase with 'use' prefix for hook names in React
Use Tailwind CSS utilities only for styling in frontend components
Use design system components from 'src/components/' (atoms, molecules, organisms) in frontend development
Never use 'src/components/legacy/' in frontend code
Only use Phosphor Icons (@phosphor-icons/react) for icons in frontend components
Use generated API hooks from '@/app/api/__generated__/endpoints/' instead of deprecated 'BackendAPI' or 'src/lib/autogpt-server-api/
'
Use React Query for server state (via generated hooks) in frontend development
Default to client components ('use client') in Next.js; only use server components for SEO or extreme TTFB needs
Use '' component for rendering errors in frontend UI; use toast notifications for mutation errors; use 'Sentry.captureException()' for manual exceptions
Separate render logic from data/behavior in React components; keep comments minimal (code should be self-documenting)

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/frontend/**/*.{ts,tsx}: No barrel files or 'index.ts' re-exports in frontend code
Regenerate API hooks with 'pnpm generate:api' after backend OpenAPI spec changes in frontend development

autogpt_platform/frontend/**/*.{ts,tsx}: Use function declarations (not arrow functions) for components/handlers
No any types unless the value genuinely can be anything
Keep render functions and hooks under ~50 lines; extract named helpers or sub-components when they grow longer

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/src/components/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Structure React components as: ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts (exception: small 3-4 line components can be inline; render-only components can be direct files)

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/src/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts, use design system components from src/components/ (atoms, molecules, organisms), and never use src/components/__legacy__/*

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/src/**/*.{ts,tsx}: Use generated API hooks from @/app/api/__generated__/endpoints/ following the pattern use{Method}{Version}{OperationName}, and regenerate with pnpm generate:api
Separate render logic from business logic using component.tsx + useComponent.ts + helpers.ts pattern, colocate state when possible and avoid creating large components, use sub-components in local /components folder
Use function declarations for components and handlers, use arrow functions only for callbacks
Do not use useCallback or useMemo unless asked to optimise a given function

autogpt_platform/frontend/src/**/*.{ts,tsx}: Keep files under ~200 lines; extract sub-components or hooks into their own files when a file grows beyond this
Use generated API hooks from @/app/api/__generated__/endpoints/ with pattern use{Method}{Version}{OperationName}
Always import the -Icon-suffixed alias from @phosphor-icons/react (e.g. TrashIcon, PlusIcon, SquareIcon) — bare exports are deprecated
Do not use useCallback or useMemo unless asked to optimize a given function
Never use src/components/__legacy__/* — use design system components from src/components/

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/**/*.{tsx,css}

📄 CodeRabbit inference engine (AGENTS.md)

Use Tailwind CSS only for styling, use design tokens, and use Phosphor Icons only

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/src/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Component props should use interface Props { ... } (not exported) unless the interface needs to be used outside the component

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never type with any, if no types available use unknown

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

autogpt_platform/frontend/**/*.{test,spec}.{ts,tsx}: Use Vitest + RTL + MSW for integration tests as the primary testing approach (~90%, page-level), use Playwright for E2E critical flows, and use Storybook for design system components
Run frontend integration tests with pnpm test:unit (Vitest + RTL + MSW)

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
autogpt_platform/frontend/**/*.{tsx,jsx}

📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)

autogpt_platform/frontend/**/*.{tsx,jsx}: No dark: Tailwind classes — the design system handles dark mode
Use Next.js <Link> for internal navigation — never raw <a> tags
Use Tailwind CSS only for styling with design tokens and Phosphor Icons only

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/src/**/components/**/*.{tsx,jsx}

📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)

Put sub-components in local components/ folder; component props should be type Props = { ... } (not exported) unless used outside the component

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/src/**/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)

Structure components as ComponentName/ComponentName.tsx + useComponentName.ts + helpers.ts

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
autogpt_platform/frontend/src/**/__tests__/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)

Use Orval-generated MSW handlers from @/app/api/__generated__/endpoints/{tag}/{tag}.msw.ts for API mocking

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
autogpt_platform/frontend/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (autogpt_platform/frontend/AGENTS.md)

Avoid index and barrel files

Files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
🧠 Learnings (9)
📚 Learning: 2026-03-24T02:05:04.672Z
Learnt from: majdyz
Repo: Significant-Gravitas/AutoGPT PR: 12526
File: autogpt_platform/frontend/src/app/(platform)/copilot/CopilotPage.tsx:0-0
Timestamp: 2026-03-24T02:05:04.672Z
Learning: When gating React component logic on a React Query result (e.g., hooks like `useQuery` / `useGetV2GetCopilotUsage`), prefer destructuring and checking `isSuccess` (or aliasing it to a meaningful boolean like `isSuccess: hasUsage`) instead of relying on `!isLoading`. Reason: `isLoading` can be `false` in error/idle states where `data` may still be `undefined`, while `isSuccess` indicates the query completed successfully and `data` is populated.

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
📚 Learning: 2026-04-01T18:54:16.035Z
Learnt from: Bentlybro
Repo: Significant-Gravitas/AutoGPT PR: 12633
File: autogpt_platform/frontend/src/app/(platform)/library/components/AgentFilterMenu/AgentFilterMenu.tsx:3-10
Timestamp: 2026-04-01T18:54:16.035Z
Learning: In the frontend, the legacy Select component at `@/components/__legacy__/ui/select` is an intentional, codebase-wide visual-consistency pattern. During code reviews, do not flag or block PRs merely for continuing to use this legacy Select. If a migration to the newer design-system Select is desired, bundle it into a single dedicated cleanup/migration PR that updates all Select usages together (e.g., avoid piecemeal replacements).

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
📚 Learning: 2026-04-07T09:24:16.582Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12686
File: autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/__tests__/PainPointsStep.test.tsx:1-19
Timestamp: 2026-04-07T09:24:16.582Z
Learning: In Significant-Gravitas/AutoGPT’s `autogpt_platform/frontend` (Vite + `vitejs/plugin-react` with the automatic JSX transform), do not flag usages of React types/components (e.g., `React.ReactNode`) in `.ts`/`.tsx` files as missing `React` imports. Since the React namespace is made available by the project’s TS/Vite setup, an explicit `import React from 'react'` or `import type { ReactNode } ...` is not required; only treat it as missing if typechecking (e.g., `pnpm types`) would actually fail.

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
📚 Learning: 2026-04-02T05:43:49.128Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12640
File: autogpt_platform/frontend/src/app/(no-navbar)/onboarding/steps/WelcomeStep.tsx:13-13
Timestamp: 2026-04-02T05:43:49.128Z
Learning: Do not flag `import { Question } from "phosphor-icons/react"` as an invalid import. `Question` is a valid named export from `phosphor-icons/react` (as reflected in the package’s generated `.d.ts` files and re-exports via `dist/index.d.ts`), so it should be treated as a supported named export during code reviews.

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
📚 Learning: 2026-04-13T13:11:07.445Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12764
File: autogpt_platform/frontend/src/app/(platform)/library/components/SitrepItem/SitrepItem.tsx:143-145
Timestamp: 2026-04-13T13:11:07.445Z
Learning: In `autogpt_platform/frontend`, do not flag direct interpolation of `executionID` UUID strings into URL query parameters (e.g., `activeItem=${executionID}` in JSX/Next links). If the value is a UUID string matching `[0-9a-f-]`, it contains no reserved URL characters, so additional `encodeURIComponent` or Next.js object-based `href` encoding is unnecessary. Only treat it as an encoding issue if the query-param value is not guaranteed to be UUID-formatted (i.e., may include characters outside `[0-9a-f-]`).

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
📚 Learning: 2026-04-15T22:49:06.896Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11235
File: autogpt_platform/frontend/src/app/(platform)/admin/diagnostics/components/ExecutionsTable.tsx:0-0
Timestamp: 2026-04-15T22:49:06.896Z
Learning: In the AutoGPT frontend (React Query + toast/ErrorCard patterns), do not require `Sentry.captureException` in React Query mutation `catch` blocks. React Query handles error propagation for mutation paths, so follow the established pattern: show toast notifications for mutation errors and use `ErrorCard` for render/fetch errors. Only add `Sentry.captureException` for truly manual/unexpected exception paths that are outside React Query’s control (e.g., standalone async utilities or event handlers not wired through React Query).

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
📚 Learning: 2026-04-20T13:17:39.951Z
Learnt from: 0ubbe
Repo: Significant-Gravitas/AutoGPT PR: 12854
File: autogpt_platform/frontend/src/app/(platform)/library/__tests__/briefing.test.tsx:84-84
Timestamp: 2026-04-20T13:17:39.951Z
Learning: In the AutoGPT frontend, `testing-library/react` cleanup is already handled globally after each test via `src/tests/integrations/vitest.setup.tsx`. Therefore, for integration test files under `__tests__/`, do NOT add redundant `afterEach(() => cleanup())`. Only add local `afterEach` teardown for resources that are not covered globally—specifically, when using fake timers, add `afterEach(() => vi.useRealTimers())` (or equivalent) to restore real timers and prevent cross-test interference.

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
📚 Learning: 2026-04-20T20:07:22.981Z
Learnt from: ntindle
Repo: Significant-Gravitas/AutoGPT PR: 11235
File: autogpt_platform/frontend/src/app/(platform)/admin/diagnostics/__tests__/ExecutionsTable.test.tsx:27-76
Timestamp: 2026-04-20T20:07:22.981Z
Learning: In this codebase, Orval-generated API modules under `src/app/api/__generated__/` are not committed to git and must be generated via `pnpm generate:api` (requires a running backend). In integration tests, it’s acceptable—and expected—to stub generated hooks/modules by mocking them with `vi.mock("`@/app/api/__generated__/endpoints/`{tag}/{tag}")`. Do not treat `vi.mock` of these generated hook modules as a violation of the MSW handler guideline, since the corresponding MSW handlers cannot be imported at test time when generated files are absent.

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
📚 Learning: 2026-05-16T12:12:12.246Z
Learnt from: Abhi1992002
Repo: Significant-Gravitas/AutoGPT PR: 13138
File: autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/helpers.tsx:1-1
Timestamp: 2026-05-16T12:12:12.246Z
Learning: Code reviews for the Navbar component set should treat the `MenuItemGroup` contract as shared between `AccountMenu` (desktop) and `MobileNavbar`. If a PR attempts to migrate `AccountMenu` off the legacy `IconType` imported from `src/components/__legacy__/ui/icons.tsx`, require that the migration be coordinated with `MobileNavbar` as part of the same follow-up change (or explicitly defer the `MobileNavbar` side to a dedicated follow-up PR) to avoid leaving the shared contract in an inconsistent state. Do not block an otherwise-complete `AccountMenu` PR solely due to the pending cross-consumer legacy `IconType` dependency.

Applied to files:

  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx
  • autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx
🔇 Additional comments (2)
autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx (1)

1-4: LGTM!

autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/__tests__/InitialAvatar.test.tsx (1)

6-23: LGTM!

Comment on lines +16 to +17
<AvatarImage src={src} alt={name ? `${name}'s avatar` : "User avatar"} />
<AvatarFallback>{name?.trim() || "User"}</AvatarFallback>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Normalize name once before using it in alt and fallback.

Line 16 uses raw name, but Line 17 uses trimmed/fallback logic. For whitespace-only names, alt becomes invalid (" 's avatar"), while fallback becomes "User".

Suggested fix
 export function InitialAvatar({ src, name, className }: Props) {
+  const normalizedName = name?.trim();
+
   return (
     <Avatar className={cn("h-10 w-10", className)}>
-      <AvatarImage src={src} alt={name ? `${name}'s avatar` : "User avatar"} />
-      <AvatarFallback>{name?.trim() || "User"}</AvatarFallback>
+      <AvatarImage
+        src={src}
+        alt={normalizedName ? `${normalizedName}'s avatar` : "User avatar"}
+      />
+      <AvatarFallback>{normalizedName || "User"}</AvatarFallback>
     </Avatar>
   );
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<AvatarImage src={src} alt={name ? `${name}'s avatar` : "User avatar"} />
<AvatarFallback>{name?.trim() || "User"}</AvatarFallback>
const normalizedName = name?.trim();
return (
<Avatar className={cn("h-10 w-10", className)}>
<AvatarImage
src={src}
alt={normalizedName ? `${normalizedName}'s avatar` : "User avatar"}
/>
<AvatarFallback>{normalizedName || "User"}</AvatarFallback>
</Avatar>
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@autogpt_platform/frontend/src/components/layout/Navbar/components/AccountMenu/components/InitialAvatar.tsx`
around lines 16 - 17, The avatar name handling in InitialAvatar should normalize
the `name` value once and reuse that normalized result for both `AvatarImage`
alt text and `AvatarFallback`, since raw `name` can produce invalid
whitespace-only strings while the fallback already trims it. Update the
`InitialAvatar` component to derive a single trimmed name value before
rendering, then use that same value for the alt message and fallback so both
behave consistently.
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.30%. Comparing base (150514f) to head (390da1d).
⚠️ Report is 11 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #13426      +/-   ##
==========================================
- Coverage   74.31%   74.30%   -0.01%     
==========================================
  Files        2528     2528              
  Lines      191018   191008      -10     
  Branches    18851    18848       -3     
==========================================
- Hits       141959   141936      -23     
- Misses      44974    44986      +12     
- Partials     4085     4086       +1     
Flag Coverage Δ
platform-frontend-e2e 30.90% <ø> (-0.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Platform Backend 81.78% <ø> (ø)
Platform Frontend 46.50% <ø> (-0.06%) ⬇️
AutoGPT Libs ∅ <ø> (∅)
Classic AutoGPT 28.43% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/frontend AutoGPT Platform - Front end size/m

2 participants