Skip to content

fix:Account Management Status - #1769

Merged
seefs001 merged 1 commit into
QuantumNous:alphafrom
QAbot-zh:fix/account-status
Sep 22, 2025
Merged

fix:Account Management Status#1769
seefs001 merged 1 commit into
QuantumNous:alphafrom
QAbot-zh:fix/account-status

Conversation

@QAbot-zh

@QAbot-zh QAbot-zh commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

修复状态提示,避免出现未配置微信但显示已绑定状态

image

Summary by CodeRabbit

  • New Features
    • WeChat and Telegram bindings now display the linked ID (truncated) with a hover label; shows “未绑定” when not linked.
  • Improvements
    • Unified account binding display across services for a more consistent experience.
    • Clearer button labels that switch between “绑定”, “修改绑定”, and “未启用” based on status.
  • Bug Fixes
    • Improved resilience to missing user data, reducing chances of display errors when account info hasn’t loaded.

@coderabbitai

coderabbitai Bot commented Sep 10, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Updated AccountManagement.jsx to display WeChat and Telegram binding info via a unified renderAccountInfo helper with optional chaining. Shows truncated IDs with a popover when present, otherwise 未绑定. Adjusted button logic to reflect presence of IDs and feature enablement via status flags.

Changes

Cohort / File(s) Summary
Settings UI: Account bindings
web/src/components/settings/personal/cards/AccountManagement.jsx
Replaced direct binding text with renderAccountInfo for WeChat/Telegram; added optional chaining for safe user access; updated button labels/logic (modify/bind/disabled) based on userState.user?.wechat_id/telegram_id and status.wechat_login; unified display showing truncated IDs with hover popover or 未绑定.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant C as AccountManagement.jsx
  participant H as renderAccountInfo()
  participant P as Popover

  U->>C: Open Account Management
  C->>C: Read userState.user?.wechat_id / telegram_id
  alt ID present
    C->>H: renderAccountInfo(id, label)
    H-->>C: Truncated ID + label
    C->>P: Wrap with hover popover
    P-->>U: Show full label on hover
  else No ID
    C-->>U: Display 未绑定
  end

  U->>C: Click Bind/Modify
  alt WeChat enabled (status.wechat_login)
    C-->>U: Show Bind or Modify action
  else Not enabled
    C-->>U: Show 未启用
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “fix:Account Management Status” directly references the primary change of correcting the account management status display and is concise enough to convey its purpose.
Description Check ✅ Passed The description clearly explains that the PR fixes incorrect status prompts for unconfigured WeChat bindings and includes a screenshot to illustrate the change, which directly relates to the modifications in the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

A nibble of code, a twitch of an ear,
IDs now whisper when users draw near.
WeChat, Telegram, tidy and bright—
Popovers hover, trimming the byte.
Optional chains keep errors at bay;
Happy hops for a safer display. 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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.

@QAbot-zh
QAbot-zh changed the base branch from main to alpha September 10, 2025 02:44

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
web/src/components/settings/personal/cards/AccountManagement.jsx (3)

223-226: Bug: buttons disabled when ID is undefined (GitHub).

userState.user.github_id !== '' evaluates true for undefined, wrongly disabling the button. Use truthiness with optional chaining.

-                      disabled={
-                        (userState.user && userState.user.github_id !== '') ||
-                        !status.github_oauth
-                      }
+                      disabled={
+                        !!userState.user?.github_id || !status.github_oauth
+                      }

268-270: Same bug pattern here (OIDC).

Undefined oidc_id leads to a disabled button. Align with truthiness check.

-                      disabled={
-                        (userState.user && userState.user.oidc_id !== '') ||
-                        !status.oidc_enabled
-                      }
+                      disabled={
+                        !!userState.user?.oidc_id || !status.oidc_enabled
+                      }

354-356: Same bug pattern here (LinuxDO).

Fix the disable logic to avoid treating undefined as bound.

-                      disabled={
-                        (userState.user && userState.user.linux_do_id !== '') ||
-                        !status.linuxdo_oauth
-                      }
+                      disabled={
+                        !!userState.user?.linux_do_id || !status.linuxdo_oauth
+                      }
🧹 Nitpick comments (3)
web/src/components/settings/personal/cards/AccountManagement.jsx (3)

183-188: Simplify the ternary; drop redundant check.

userState.user && userState.user?.wechat_id is redundant. Use a single truthy check for readability.

-                      {userState.user && userState.user?.wechat_id
+                      {userState.user?.wechat_id
                         ? t('修改绑定')
                         : status.wechat_login
                           ? t('绑定')
                           : t('未启用')}

62-86: Optionally show ‘未启用’ when feature is off.

Today renderAccountInfo always shows ‘未绑定’. To better align with the WeChat button state, consider allowing a custom empty text or a disabled flag.

-  const renderAccountInfo = (accountId, label) => {
+  const renderAccountInfo = (accountId, label, { emptyText = t('未绑定') } = {}) => {
     if (!accountId || accountId === '') {
-      return <span className='text-gray-500'>{t('未绑定')}</span>;
+      return <span className='text-gray-500'>{emptyText}</span>;
     }

Example usage for WeChat:

{renderAccountInfo(userState.user?.wechat_id, t('微信 ID'), {
  emptyText: status.wechat_login ? t('未绑定') : t('未启用'),
})}

395-403: Prop casing: use readOnly.

Semi/React expects readOnly, not readonly.

-                            <Input
-                              readonly
+                            <Input
+                              readOnly
                               value={systemToken}
                               onClick={handleSystemTokenClick}
                               size='large'
                               prefix={<IconKey />}
                             />
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 041782c and 99a8b5e.

📒 Files selected for processing (1)
  • web/src/components/settings/personal/cards/AccountManagement.jsx (3 hunks)
🔇 Additional comments (2)
web/src/components/settings/personal/cards/AccountManagement.jsx (2)

168-171: Good fix: safer access + unified display for WeChat.

Optional chaining + renderAccountInfo avoids the “未配置却显示已绑定” confusion and handles undefined cleanly.


302-314: Telegram condition is now robust.

Switching to userState.user?.telegram_id avoids false “已绑定” when the field is undefined.

@seefs001
seefs001 merged commit b692452 into QuantumNous:alpha Sep 22, 2025
3 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Nov 22, 2025
2 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Mar 26, 2026
9 tasks
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
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.

2 participants