Skip to content

Conversation

@MasakiMu319
Copy link
Contributor

  • Summary
    • Treat multiple auth files with the same account email as a single account by deduplicating rotation/switching to the latest auth
      index.
    • Add a manual cleanup action to delete duplicate auth files (keep highest index per email), with English logs and UI i18n support.
  • Key Changes
    • Deduplicate account rotation indices by normalized email (accountName), keeping the highest auth-N index per email.
    • Redirect manual “switch to specific index” requests to the canonical (latest) index when the target is a duplicate.
    • Startup and “switch next” logic now use deduped rotation indices.
    • Add POST /api/accounts/deduplicate (session-authenticated) to remove duplicate auth files; logs are in English and include the
      index-ordering assumption.
    • Enhance /api/status payload with rotationIndicesRaw and duplicateIndicesRaw; UI displays deduped/duplicate counts, marks duplicates,
      and adds a “Deduplicate Auth” button with i18n strings (EN/ZH).
  • How to Test
    • Create configs/auth/auth-0.json and auth-1.json with the same accountName email.
    • Check Status page: “Available Accounts (Deduped)” only includes [1], and “Duplicate Auth” includes [0].
    • Try switching to #0 auth json: it should redirect to #1 auth json (latest).
    • Click “Deduplicate Auth”: auth-0.json is deleted, logs show keep/delete in English, and status updates accordingly.
  • Notes / Assumptions
    • “Latest” is determined by the highest auth index, assuming indices are created in chronological order for the same account.

@bbbugg bbbugg self-assigned this Jan 12, 2026
@bbbugg
Copy link
Member

bbbugg commented Jan 12, 2026

Thanks for the PR! The core logic for email-based deduplication is solid, and the code quality is great 👍

After testing and reviewing the code, I think there are a few areas we can refine further. I'll make these changes after merging this PR:

1. Manual Account Switching Should Not Auto-Redirect

When a user manually selects a specific account to switch to, we should respect their choice rather than auto-redirecting to the latest index of the same email. Reasons:

  • The user is making a deliberate choice
  • The UI already shows a duplicate indicator (e.g., "duplicate of #X")
  • Auto-redirecting may confuse users (selected #0, but ended up on #5)

2. New Auth Index Strategy

I'm also planning to change the new auth index allocation to always be greater than the current maximum index, instead of searching for gaps starting from 0. This simplifies the assumption that higher index = newer auth.


Thanks again for the contribution! 🙏

@MasakiMu319
Copy link
Contributor Author

I’d be happy to see that. 🤗

@bbbugg bbbugg merged commit 1aecd65 into iBUHub:main Jan 12, 2026
1 check passed
@MasakiMu319 MasakiMu319 deleted the fix/dedupe-auth-rotation branch January 13, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants