Skip to content

[WIP] feat: add switch account to oauth page#9838

Closed
rdmclin2 wants to merge 4 commits into
nextfrom
feat/support-switch-account
Closed

[WIP] feat: add switch account to oauth page#9838
rdmclin2 wants to merge 4 commits into
nextfrom
feat/support-switch-account

Conversation

@rdmclin2

@rdmclin2 rdmclin2 commented Oct 22, 2025

Copy link
Copy Markdown
Collaborator

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔀 Description of Change

📝 Additional Information

Summary by Sourcery

Enable users to log out and switch to a different account from the OAuth consent login page

New Features:

  • Add switch account button with loading state and logout handling on OAuth login page
  • Introduce "使用其他账户" translation for the switch account action in the OAuth locale

@vercel

vercel Bot commented Oct 22, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
lobehub-database Ready Ready Preview Comment Oct 23, 2025 8:36am
lobehub-lite Ready Ready Preview Comment Oct 23, 2025 8:36am

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Oct 22, 2025
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR introduces a “Switch Account” feature on the OAuth consent login page by adding the necessary UI, state management, logout handling, and translation support.

Sequence diagram for Switch Account interaction on OAuth consent page

sequenceDiagram
  actor User
  participant "OAuth Consent Page"
  participant "UserStore (logout)"
  User->>"OAuth Consent Page": Clicks 'Switch Account'
  "OAuth Consent Page"->>"UserStore (logout)": Call logout()
  "UserStore (logout)"-->>"OAuth Consent Page": Logout complete
  "OAuth Consent Page"-->>User: Redirect to login page
Loading

Class diagram for updated LoginConfirmClient component with Switch Account feature

classDiagram
  class LoginConfirmClient {
    +uid
    +clientMetadata
    +isSwitching : boolean
    +handleSwitchAccount()
    +logout()
  }
  class UserStore {
    +isUserStateInit
    +userAvatar
    +nickName
    +logout()
  }
  LoginConfirmClient --> UserStore : uses
Loading

Class diagram for updated OAuth translation keys

classDiagram
  class OAuthTranslations {
    +button : string
    +description : string
    +switchAccount : string
    +title : string
    +userWelcome : string
  }
Loading

File-Level Changes

Change Details Files
Add switch account UI and logic to the OAuth login component
  • Introduced isSwitching state to manage loading status
  • Retrieved logout action from user store
  • Implemented handleSwitchAccount callback to trigger logout and manage loading state
  • Added a text button with loading indicator for switching accounts
src/app/[variants]/oauth/consent/[uid]/Login.tsx
Add translation key for switch account button
  • Added switchAccount entry under the login section in OAuth locale
src/locales/default/oauth.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gru-agent

gru-agent Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

TestGru Assignment

Summary

Link CommitId Status Reason
Detail e862cace8b33375af2ee1c498a6d5cced37e6cbb 🚫 Skipped No files need to be tested {"src/app/[variants]/oauth/consent/[uid]/Login.tsx":"File path does not match include patterns.","src/locales/default/oauth.ts":"File path does not match include patterns."}

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@lobehubbot

Copy link
Copy Markdown
Member

👍 @rdmclin2

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.

@sourcery-ai sourcery-ai 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.

Hey there - I've reviewed your changes - here's some feedback:

  • After logout completes, make sure to redirect or refresh the page to bring the user back to the sign-in flow, since calling logout alone won’t update the UI.
  • While switching accounts, disable or hide the primary “Confirm Login” button to prevent overlapping actions during the logout process.
  • Add error handling in handleSwitchAccount to catch logout failures and surface an appropriate user-facing notification.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- After logout completes, make sure to redirect or refresh the page to bring the user back to the sign-in flow, since calling logout alone won’t update the UI.
- While switching accounts, disable or hide the primary “Confirm Login” button to prevent overlapping actions during the logout process.
- Add error handling in handleSwitchAccount to catch logout failures and surface an appropriate user-facing notification.

## Individual Comments

### Comment 1
<location> `src/app/[variants]/oauth/consent/[uid]/Login.tsx:132-134` </location>
<code_context>
                 {buttonText}
               </Button>
             </form>
+            <Button loading={isSwitching} onClick={handleSwitchAccount} type="text">
+              {switchButtonText}
+            </Button>
</code_context>

<issue_to_address>
**suggestion:** Review the use of type="text" for the Button component.

If the Button is not meant for form submission, use type="button" or omit the type for better semantics and accessibility.

```suggestion
            <Button loading={isSwitching} onClick={handleSwitchAccount} type="button">
              {switchButtonText}
            </Button>
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +132 to +134
<Button loading={isSwitching} onClick={handleSwitchAccount} type="text">
{switchButtonText}
</Button>

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.

suggestion: Review the use of type="text" for the Button component.

If the Button is not meant for form submission, use type="button" or omit the type for better semantics and accessibility.

Suggested change
<Button loading={isSwitching} onClick={handleSwitchAccount} type="text">
{switchButtonText}
</Button>
<Button loading={isSwitching} onClick={handleSwitchAccount} type="button">
{switchButtonText}
</Button>

@codecov

codecov Bot commented Oct 22, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.55%. Comparing base (f723b38) to head (146fc58).
⚠️ Report is 798 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff            @@
##             next    #9838    +/-   ##
========================================
  Coverage   84.55%   84.55%            
========================================
  Files         944      944            
  Lines       64537    64537            
  Branches     9585     9299   -286     
========================================
  Hits        54567    54567            
  Misses       9970     9970            
Flag Coverage Δ
app 80.21% <ø> (ø)
database 98.40% <ø> (ø)
packages/agent-runtime 99.63% <ø> (ø)
packages/context-engine 93.51% <ø> (ø)
packages/electron-server-ipc 93.76% <ø> (ø)
packages/file-loaders 92.21% <ø> (ø)
packages/model-bank 100.00% <ø> (ø)
packages/model-runtime 92.16% <ø> (ø)
packages/prompts 77.21% <ø> (ø)
packages/python-interpreter 96.50% <ø> (ø)
packages/utils 94.50% <ø> (ø)
packages/web-crawler 97.07% <ø> (ø)

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

Components Coverage Δ
Store 74.88% <ø> (ø)
Services 61.69% <ø> (ø)
Server 77.39% <ø> (ø)
Libs 50.82% <ø> (ø)
Utils 75.00% <ø> (ø)
🚀 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants