Skip to content

fix(web): render custom OAuth provider icons - #5720

Open
lin-hongkuan wants to merge 1 commit into
QuantumNous:mainfrom
lin-hongkuan:fix/custom-oauth-provider-icons
Open

fix(web): render custom OAuth provider icons#5720
lin-hongkuan wants to merge 1 commit into
QuantumNous:mainfrom
lin-hongkuan:fix/custom-oauth-provider-icons

Conversation

@lin-hongkuan

@lin-hongkuan lin-hongkuan commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Render configured custom OAuth provider icons in the new auth UI.

Motivation

Custom OAuth provider metadata already includes an icon field, but the new UI did not pass it into the provider button, so custom providers were rendered without their configured icons.

Refs #5639

Changes

  • Add a small CustomProviderIcon component for custom OAuth provider buttons.
  • Render provider.icon as a safe <img> React node when present.
  • Preserve the existing no-icon fallback behavior.
  • Avoid raw HTML injection; broken images hide themselves via onError.

Testing

  • corepack pnpm --dir web/default exec tsc --noEmit --project tsconfig.app.json --pretty false
  • corepack pnpm --dir web/default exec oxlint -c .oxlintrc.json src/features/auth/components/oauth-providers.tsx
  • corepack pnpm --dir web/default exec oxfmt --check src/features/auth/components/oauth-providers.tsx
  • corepack pnpm --dir web/default run typecheck
  • corepack pnpm --dir web/default run build
  • git diff --check
  • Secret scan on diff: clean

Note: the full project lint has pre-existing unrelated warnings/errors; the modified file passes targeted lint cleanly.

Summary by CodeRabbit

  • New Features
    • Custom OAuth providers can now display their own icons in the sign-in flow.
    • Added a fallback so provider icons are hidden if they fail to load, helping keep the login screen clean and polished.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

A new internal CustomProviderIcon React helper is added to oauth-providers.tsx that renders a lazy-loaded <img> for custom OAuth provider icons and hides itself on load error. Custom OAuth provider buttons are updated to pass this component as an icon prop.

Changes

Custom OAuth Provider Icon Display

Layer / File(s) Summary
CustomProviderIcon component and button wiring
web/default/src/features/auth/components/oauth-providers.tsx
Adds the CustomProviderIcon internal helper rendering a lazy-loaded <img> with alt, styling, and onError hide behavior; updates custom provider button construction to pass icon={<CustomProviderIcon .../>}. Import block is also reordered for grouping.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related issues

Possibly related PRs

  • QuantumNous/new-api#2983: Both PRs add custom OAuth provider icon support by wiring the provider's icon field into the UI in oauth-providers.tsx.

Poem

🐇 Hop hop, a tiny icon blooms,
A lazy image loads and zooms,
If it fails, it hides away—
No broken icons ruin the day!
Custom auth now wears its face,
Each provider takes its place. ✨

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: rendering custom OAuth provider icons in the web auth UI.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@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

🤖 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 `@web/default/src/features/auth/components/oauth-providers.tsx`:
- Around line 54-57: The OAuth provider icon in the icon-rendering component is
being announced redundantly by assistive tech because the provider name is
already conveyed by the button label. Update the <img> in oauth-providers.tsx
(the icon used by the OAuth provider button) to be decorative by using an empty
alt text and hiding it from screen readers, while keeping the existing provider
label in the button component unchanged.
🪄 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: d6aa9aea-cfc0-4d47-9d97-0fb96992b6df

📥 Commits

Reviewing files that changed from the base of the PR and between b191f47 and 7bc1793.

📒 Files selected for processing (1)
  • web/default/src/features/auth/components/oauth-providers.tsx

Comment on lines +54 to +57
<img
src={props.icon}
alt={props.name}
className='h-4 w-4 rounded-sm object-contain'

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

Make the icon decorative for assistive tech.

On Line 56, alt={props.name} duplicates the provider name already announced by the button label (Line 149). Use an empty alt and hide the icon from screen readers.

Suggested patch
-      alt={props.name}
+      alt=''
+      aria-hidden='true'

As per coding guidelines, “Use ARIA attributes (aria-label, aria-expanded, aria-hidden) as needed … provide text equivalents for important information.”

📝 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
<img
src={props.icon}
alt={props.name}
className='h-4 w-4 rounded-sm object-contain'
<img
src={props.icon}
alt=''
aria-hidden='true'
className='h-4 w-4 rounded-sm object-contain'
🤖 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 `@web/default/src/features/auth/components/oauth-providers.tsx` around lines 54
- 57, The OAuth provider icon in the icon-rendering component is being announced
redundantly by assistive tech because the provider name is already conveyed by
the button label. Update the <img> in oauth-providers.tsx (the icon used by the
OAuth provider button) to be decorative by using an empty alt text and hiding it
from screen readers, while keeping the existing provider label in the button
component unchanged.

Source: Coding guidelines

@Calcium-Ion
Calcium-Ion force-pushed the main branch 2 times, most recently from 51fdfc5 to 2b6f1df Compare August 30, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant