Skip to content

Fix UI break in Recent Pull Request#3742

Merged
kasya merged 5 commits intoOWASP:mainfrom
anurag2787:fix/pr-ui-break
Feb 3, 2026
Merged

Fix UI break in Recent Pull Request#3742
kasya merged 5 commits intoOWASP:mainfrom
anurag2787:fix/pr-ui-break

Conversation

@anurag2787
Copy link
Contributor

@anurag2787 anurag2787 commented Feb 2, 2026

Proposed change

This fixes the UI break in the Recent Pull Requests card so it renders correctly even when the PR is opened by GitHub Copilot or other agent.

Resolves #3733

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Avatar fallback now shows a fallback icon when author info is missing, avoiding empty/incorrect avatar rendering.
  • Improvements
    • Avatar alt text now reflects author name or login; avatars link to member profiles when a login exists. Tooltip behavior unchanged.
  • Tests
    • Unit tests updated to reflect the new avatar rendering behavior.

Walkthrough

Introduced an internal AuthorAvatar component in ItemCardList that centralizes avatar rendering: renders a linked Image when author.login exists, an unlinked Image when author.name/login exists without login, and a FaUser icon when author name and login are missing. Updated tests to assert avatar absence and fallback icon behavior.

Changes

Cohort / File(s) Summary
Avatar Rendering Component
frontend/src/components/ItemCardList.tsx
Added AuthorAvatar and AuthorAvatarProps; replaced inline avatar rendering with AuthorAvatar. Behavior: image with alt from author.name or author.login; wrap image in /members/{login} link if author.login; render FaUser icon when no author info.
Avatar Fallback Tests
frontend/__tests__/unit/components/ItemCardList.test.tsx, frontend/__tests__/unit/components/RecentIssues.test.tsx
Updated test names and assertions to expect absence of avatar images when author name/login are missing (use queryByTestId + not.toBeInTheDocument) and to assert fallback icon behavior instead of expecting a fallback avatar alt text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main issue being fixed: the UI break in Recent Pull Requests when GitHub Copilot opens PRs.
Description check ✅ Passed The description is related to the changeset, explaining the fix for the UI break in Recent Pull Requests when opened by GitHub Copilot or other agents.
Linked Issues check ✅ Passed The code changes properly address issue #3733 by handling cases where author information is missing (e.g., GitHub Copilot) through the new AuthorAvatar component that renders a fallback icon.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the UI break in Recent Pull Requests, including the AuthorAvatar component and related test updates, with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@frontend/src/components/ItemCardList.tsx`:
- Around line 64-80: The current conditional in ItemCardList allows rendering
the Link when item.author.name exists but item.author.login is missing, causing
a broken href; change the condition to require item?.author?.login before
rendering the Link (e.g., render Link + Image only when item?.author?.login is
truthy), and otherwise render a non-link avatar/fallback (use Image or FaUser)
with the same alt/text fallback (item.author.name || item.author.login) so no
/members/undefined is produced; update usages of Link, Image and FaUser
accordingly.
🧹 Nitpick comments (1)
frontend/__tests__/unit/components/ItemCardList.test.tsx (1)

718-758: Assert the fallback icon is rendered (not just avatar absence).

The test names say “shows fallback icon,” but the assertions only verify that the avatar image is missing. Consider asserting the icon’s presence by adding a data-testid or aria-label to the icon in the component.

✅ Suggested test assertion + small component hook
-      const avatarImage = screen.queryByTestId('avatar-image')
-      expect(avatarImage).not.toBeInTheDocument()
+      const avatarImage = screen.queryByTestId('avatar-image')
+      expect(avatarImage).not.toBeInTheDocument()
+      expect(screen.getByTestId('avatar-fallback-icon')).toBeInTheDocument()
-                        <FaUser className="mr-2 h-6 w-6 text-gray-400 dark:text-gray-500" />
+                        <FaUser
+                          className="mr-2 h-6 w-6 text-gray-400 dark:text-gray-500"
+                          data-testid="avatar-fallback-icon"
+                          aria-label="Unknown author"
+                        />

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 2, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 2, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 2, 2026
@anurag2787 anurag2787 marked this pull request as ready for review February 2, 2026 12:03
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 3 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="frontend/src/components/ItemCardList.tsx">

<violation number="1" location="frontend/src/components/ItemCardList.tsx:31">
P1: Missing check for `avatarUrl` before rendering the Image. If author has `name` or `login` but no `avatarUrl` (possible with GitHub Copilot or other agents), the Image component will receive undefined/empty src, causing a Next.js Image error. Consider checking `author.avatarUrl` exists before rendering the Image, or fall back to the FaUser icon.</violation>
</file>

<file name="frontend/__tests__/unit/components/RecentIssues.test.tsx">

<violation number="1" location="frontend/__tests__/unit/components/RecentIssues.test.tsx:210">
P2: This test is titled “shows fallback icon…” but only asserts the avatar image is absent. It doesn’t verify the fallback icon is rendered, so the test would still pass if nothing is shown. Add an assertion for the fallback icon within the avatar tooltip.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

}
render(<RecentIssues data={[issueWithEmptyAuthor]} />)
expect(screen.getByAltText("Author's avatar")).toBeInTheDocument()
const avatarImage = screen.queryByAltText("Author's avatar")
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Feb 3, 2026

Choose a reason for hiding this comment

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

P2: This test is titled “shows fallback icon…” but only asserts the avatar image is absent. It doesn’t verify the fallback icon is rendered, so the test would still pass if nothing is shown. Add an assertion for the fallback icon within the avatar tooltip.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/__tests__/unit/components/RecentIssues.test.tsx, line 210:

<comment>This test is titled “shows fallback icon…” but only asserts the avatar image is absent. It doesn’t verify the fallback icon is rendered, so the test would still pass if nothing is shown. Add an assertion for the fallback icon within the avatar tooltip.</comment>

<file context>
@@ -207,6 +207,7 @@ describe('<RecentIssues />', () => {
     }
     render(<RecentIssues data={[issueWithEmptyAuthor]} />)
-    expect(screen.getByAltText("Author's avatar")).toBeInTheDocument()
+    const avatarImage = screen.queryByAltText("Author's avatar")
+    expect(avatarImage).not.toBeInTheDocument()
   })
</file context>
Fix with Cubic

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@frontend/src/components/ItemCardList.tsx`:
- Around line 22-52: In AuthorAvatar, guard against a missing/empty avatarUrl
before rendering next/image: update the hasAuthorInfo logic (or add a new
condition) to verify author?.avatarUrl is truthy and only create/use
imageElement when avatarUrl exists; if avatarUrl is falsy, return the FaUser
fallback (wrapped in the same Link when author.login exists, or in a div
otherwise) so next/image is never called with an undefined/empty src (affecting
the AuthorAvatar component and the imageElement usage).

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.70%. Comparing base (8da4c96) to head (e6eaeec).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
frontend/src/components/ItemCardList.tsx 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3742   +/-   ##
=======================================
  Coverage   87.70%   87.70%           
=======================================
  Files         462      462           
  Lines       14277    14287   +10     
  Branches     1902     1905    +3     
=======================================
+ Hits        12521    12530    +9     
  Misses       1344     1344           
- Partials      412      413    +1     
Flag Coverage Δ
backend 87.45% <ø> (ø)
frontend 88.39% <91.66%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
frontend/src/components/ItemCardList.tsx 96.87% <91.66%> (-3.13%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8da4c96...e6eaeec. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

@anurag2787 thanks for updating this! 👍🏼

@kasya kasya enabled auto-merge February 3, 2026 02:48
@kasya kasya added this pull request to the merge queue Feb 3, 2026
Merged via the queue into OWASP:main with commit d7ad361 Feb 3, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI breaks when Copilot opens a Pull Request

2 participants