Skip to content

fix: restore admin add-tag button for users without tags - #1045

Merged
boomzero merged 6 commits into
devfrom
codex/fix-profile-missing-tag
Oct 5, 2026
Merged

boomzero merged 6 commits into
devfrom
codex/fix-profile-missing-tag

Conversation

@boomzero

@boomzero boomzero commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Profiles for users without tags currently show “标签暂不可用” and a retry button, leaving admins unable to add a tag. Treat the backend’s missing-tag response as an empty state, restoring the “添加标签” button for admins and hiding the error for other visitors. Account settings hides tag editing when no tag exists, preventing invalid EditBadge requests.

Both pages share detection of the missing-tag phrase, tolerating changes to the surrounding message. Actual load failures retain their error and retry behavior.

Regression coverage includes missing tags on both pages, admin creation and deletion, retry recovery, message variants, and preserving account submission.

Validation: all 99 tests pass with npm test; JavaScript syntax and git diff --check pass.

Summary by Sourcery

Restore correct empty-state handling for users without tags across profile and account pages.

Bug Fixes:

  • Treat missing backend tags as an empty state so administrators can add tags while other visitors see no error or retry prompt.
  • Hide account tag editing when no tag exists and prevent invalid tag update requests.
  • Preserve error and retry behavior for genuine tag-loading failures.

Enhancements:

  • Share tolerant detection of backend missing-tag responses across profile and account pages.

Tests:

  • Add regression coverage for missing tags, message variants, administrator tag creation and deletion, retry recovery, and preserving account submission.

Chores:

  • Bump the project and userscript versions to 3.8.5.

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

Sorry @boomzero, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Restores the admin add-tag flow by distinguishing the backend’s known missing-tag response from genuine GetBadge failures, while preserving retry behavior for actual errors and adding regression coverage for visitor/admin empty states and delete/re-create workflows.

Sequence diagram for profile badge empty-state handling

sequenceDiagram
    participant Visitor
    participant Admin
    participant Profile
    participant Backend

    Visitor->>Profile: InitializeProfileBadge()
    Profile->>Backend: GetBadge(UserID)
    Backend-->>Profile: missing-tag response
    Profile-->>Visitor: Hide error and add-tag controls

    Admin->>Profile: InitializeProfileBadge()
    Profile->>Backend: GetBadge(UserID)
    Backend-->>Profile: missing-tag response
    Profile-->>Admin: Show 添加标签 button
    Admin->>Profile: CreateBadge()
    Profile->>Backend: CreateBadge(UserID)
    Backend-->>Profile: badge data
    Profile-->>Admin: Display badge

    Profile->>Backend: GetBadge(UserID)
    Backend-->>Profile: request failure
    Profile-->>Admin: Show retry button
    Admin->>Profile: Retry
Loading

File-Level Changes

Change Details Files
Treat the backend’s known “tag does not exist” response as a valid empty badge state instead of an error.
  • Recognize the exact missing-row response from GetBadge.
  • Initialize badge content from an empty object for that response.
  • Continue routing all other unsuccessful responses through the existing retry/error handling.
XMOJ.user.js
Expand browser regression coverage for missing badges, admin actions, and failure recovery.
  • Model deletion as a subsequent missing-tag response and creation as restoration of badge data.
  • Verify missing tags hide errors and retry controls while exposing the add control only to admins.
  • Verify admin add failures remain recoverable and successful retry creates the badge.
  • Retain coverage that genuine request failures show retry and do not expose add controls.
tests/profile-page.test.cjs

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

@hendragon-bot hendragon-bot Bot added the user-script This issue or pull request is related to the main user script label Oct 5, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Deploying xmoj-script-dev-channel with  Cloudflare Pages  Cloudflare Pages

Latest commit: b4ef6b3
Status: ✅  Deploy successful!
Preview URL: https://281bbfd0.xmoj-script-dev-channel.pages.dev
Branch Preview URL: https://codex-fix-profile-missing-ta.xmoj-script-dev-channel.pages.dev

View logs

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Oct 5, 2026

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

Sourcery assessment

Approved.

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread XMOJ.user.js Outdated
Comment thread XMOJ.user.js Outdated

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 4 files

Requires human review: Auto-approval blocked because this review re-detected 2 unresolved issues already reported by Cubic.

Re-trigger cubic

Comment thread Update.json Outdated
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Oct 5, 2026
@sourcery-ai
sourcery-ai Bot dismissed their stale review October 5, 2026 12:04

Sourcery withdrew this approval because the latest commits introduced blocking findings.

@boomzero
boomzero merged commit 8ca86c2 into dev Oct 5, 2026
7 checks passed
@boomzero
boomzero deleted the codex/fix-profile-missing-tag branch October 5, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L user-script This issue or pull request is related to the main user script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant