Fix 155 Added small profile popup on hovering profile icon#167
Fix 155 Added small profile popup on hovering profile icon#167DeveloperAmrit wants to merge 2 commits intoAOSSIE-Org:mainfrom
Conversation
📝 WalkthroughWalkthroughThe Header component now includes a user profile popover that displays user information (avatar, name, email, ID, rating) fetched from global state and auth context, with a sign-out button. The avatar is interactive and replaces the previously static implementation while preserving existing layout for notifications and responsive drawer. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
frontend/src/components/Header.tsx (1)
115-122: Add error handling and loading state for logout action.The logout button currently has no error handling or loading state. Consider:
- Adding a loading spinner or disabled state while logout is in progress
- Handling and displaying errors if logout fails
- Adding user feedback (e.g., toast notification) on successful logout
🔎 Example enhancement with loading state
Add state for loading:
const [isLoggingOut, setIsLoggingOut] = useState(false);Update the button:
<button - onClick={() => auth?.logout()} + onClick={async () => { + try { + setIsLoggingOut(true); + await auth?.logout(); + } catch (error) { + console.error('Logout failed:', error); + // Show error toast/message + } finally { + setIsLoggingOut(false); + } + }} + disabled={isLoggingOut} - className="w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 rounded-md transition-colors" + className="w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed" > - <LogOut className="w-4 h-4" /> - Sign out + <LogOut className="w-4 h-4" /> + {isLoggingOut ? 'Signing out...' : 'Sign out'} </button>
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/Header.tsx
🔇 Additional comments (3)
frontend/src/components/Header.tsx (3)
1-11: LGTM! Clean imports.All new imports are properly utilized in the component for the user profile popover feature.
78-124: Note: Implementation differs from PR description (click vs hover).The PR title and commit message state "on hovering profile icon", but the implementation uses a click interaction via
Popovercomponent. While this is actually better UX (click provides more control, is mobile-friendly, and follows industry standards), the description should be updated to accurately reflect the implementation.
26-27: No action required. The code correctly accessesAuthContext.logout()and all user properties (avatarUrl,displayName,id,rating). These are properly defined inAuthContextTypeand theUsertype, with appropriate optional chaining used throughout for null safety.
| <Popover> | ||
| <PopoverTrigger asChild> | ||
| <button className="focus:outline-none"> | ||
| <img | ||
| src={user?.avatarUrl || avatarImage} | ||
| alt="User avatar" | ||
| className="w-8 h-8 rounded-full border-2 border-gray-300 object-cover cursor-pointer hover:opacity-80 transition-opacity" | ||
| /> | ||
| </button> | ||
| </PopoverTrigger> |
There was a problem hiding this comment.
Remove focus:outline-none or add custom focus indicator for accessibility.
The focus:outline-none class on line 80 removes the keyboard focus indicator, making it impossible for keyboard users to see which element is focused. This violates WCAG 2.4.7 (Focus Visible) and creates an accessibility barrier.
🔎 Proposed fix
- <button className="focus:outline-none">
+ <button className="focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 rounded-full">📝 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.
| <Popover> | |
| <PopoverTrigger asChild> | |
| <button className="focus:outline-none"> | |
| <img | |
| src={user?.avatarUrl || avatarImage} | |
| alt="User avatar" | |
| className="w-8 h-8 rounded-full border-2 border-gray-300 object-cover cursor-pointer hover:opacity-80 transition-opacity" | |
| /> | |
| </button> | |
| </PopoverTrigger> | |
| <Popover> | |
| <PopoverTrigger asChild> | |
| <button className="focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 rounded-full"> | |
| <img | |
| src={user?.avatarUrl || avatarImage} | |
| alt="User avatar" | |
| className="w-8 h-8 rounded-full border-2 border-gray-300 object-cover cursor-pointer hover:opacity-80 transition-opacity" | |
| /> | |
| </button> | |
| </PopoverTrigger> |
🤖 Prompt for AI Agents
In frontend/src/components/Header.tsx around lines 78 to 87, the button uses the
class "focus:outline-none" which removes the keyboard focus indicator; remove
that class or replace it with an accessible focus style (for example use
Tailwind focus-visible:ring/focus-visible:ring-offset and a visible ring color
or restore the default outline) so keyboard users can see focus; ensure the
chosen focus style has sufficient contrast and persists on keyboard navigation
(test with Tab) and keep the rest of the markup unchanged.
| <div className="flex justify-between text-sm"> | ||
| <span className="text-gray-500">User ID</span> | ||
| <span className="font-mono text-xs bg-gray-100 px-2 py-0.5 rounded text-gray-700 truncate max-w-[150px]" title={user?.id}> | ||
| {user?.id || "N/A"} | ||
| </span> | ||
| </div> |
There was a problem hiding this comment.
Consider privacy implications of displaying User ID.
Displaying the full user ID (line 104-106) in the profile popup might expose sensitive information. While users are viewing their own ID, consider whether this information needs to be prominently displayed or if it could be moved to a dedicated profile settings page.
🤖 Prompt for AI Agents
In frontend/src/components/Header.tsx around lines 102 to 107, the profile popup
currently displays the full user ID which may expose sensitive information;
remove or minimize exposure by replacing the visible full ID with either a
masked version (e.g., show first/last 4 chars with ellipsis) or move the full ID
out of the popup into a dedicated profile/settings page; keep an accessible
title or tooltip only if necessary and ensure the rendered value falls back to
"N/A" when absent.
Fixes #155 half part only, added a small popup to appear when clicked on profile icon. The popup contains disaplay name, user id, email, rating and logout option.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.