feat: account aliases + fix Pro/Max plan detection#1
Open
vvedantb wants to merge 1 commit into
Open
Conversation
Adds a `cc-switch --rename <index> <name>` command to set a custom label for a stored account, and fixes a plan-detection bug. Plan detection: - inferPlanType only special-cased `team`/`enterprise` subscriptionType, then fell back to an org-scope heuristic. A Pro account whose user is an org admin (organizationRole) was misreported as "Teams". Now `pro`/`max` subscriptionType is honored before the heuristic, so it correctly reports "Pro"/"Max". Aliases: - New `--rename <index> <name>` (also `rename`) sets entry.alias; omit the name to clear it. Multi-word names work without quoting. - getEntryLabel() prefers entry.alias, falling back to the account display name; used in list, switch, and remove output. - syncStoreFromLive now preserves `alias` across syncs (like lastUsedAt/ usageSnapshot), so it isn't wiped when metadata is refreshed. - Useful when several accounts share the same Claude display name. README documents the new flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related improvements for users who manage multiple Claude accounts:
1. Fix: Pro/Max plan misdetection
inferPlanTypeonly special-casedteam/enterprisesubscriptionType, then fell back to an org-scope heuristic. A Pro account whose user is an admin of their own org (organizationRole: "admin") hit that heuristic and was mislabeled "Teams".The OAuth
subscriptionTypeis the authoritative signal, sopro/maxare now honored before the heuristic:2. Feature: custom account aliases (
--rename)When several stored accounts share the same Claude display name (e.g. the same person's work + personal accounts), the list is ambiguous — every row shows the same name. There was no built-in way to label them, and hand-editing the store JSON didn't survive because
syncStoreFromLiveoverwritesmetadatawholesale on each sync.This adds:
cc-switch --rename <index> <name>(alsorename) — setsentry.alias. Omit<name>to clear it. Multi-word names work without quoting.getEntryLabel(entry)— prefersentry.alias, falling back to the account's display name. Used in list, switch, and remove output.syncStoreFromLivenow preservesaliasacross syncs (alongsidelastUsedAt/usageSnapshot), so the label is stable.cli.cjsneeds no change — itsswitchcommand already forwards extra args through tocc-switch.cjs.Example
Testing
node --checkon all modified files.organizationRole: adminnow reports Pro instead of Teams. Alias persists across--sync.Files changed
lib/output/accounts.cjs—pro/maxdetection +getEntryLabellib/store/accounts.cjs— preservealiason synclib/actions/rename.cjs— new actionlib/actions/switch.cjs,lib/actions/remove.cjs— usegetEntryLabelcc-switch.cjs— wire--renameaction and arg parsingREADME.md— document the flag