fix(bar): show the active default ccs login as the leading Claude account

The multi-profile path enumerated only named ccs auth profiles, dropping the
bare ~/.claude default login that the shipped Bar showed. Re-add it as the
DEFAULT_PROFILE account read through the standard global credential lookup
(file, falling back to the single global 'Claude Code-credentials' Keychain
item Claude Code itself maintains) -- the one pre-existing global read, not a
per-profile Keychain scan. It leads the Claude carousel as 'ccs' + 'default'.
This commit is contained in:
Tam Nhu Tran committed 2026-06-23 23:16:36 -04:00
1 parent 4e6fe6ffbb
commit 54ef5406ce
1 file changed
+24 -4
+24 -4
View File
@@ -489,6 +489,15 @@ function serveCached(state: ProviderState): BarSummaryRow | null {
* Never calls security/Keychain — zero new keychain access from this feature.
*/
function readClaudeCredentialsForProfileFromDisk(profile: string): ClaudeNativeCredentials | null {
// The bare `ccs` default login uses the standard global credential lookup:
// ~/.claude/.credentials.json, falling back to the single global
// "Claude Code-credentials" Keychain item that Claude Code itself maintains.
// This is the ONE pre-existing global read the shipped Bar already performs --
// NOT a per-profile Keychain scan. Isolated `ccs auth` profiles below stay
// file-only and never touch the Keychain.
if (profile === DEFAULT_PROFILE) {
return readClaudeCredentials();
}
try {
const instanceDir = path.join(getCcsDir(), 'instances', profile);
const credFile = path.join(instanceDir, '.credentials.json');
@@ -557,14 +566,22 @@ function listClaudeProfilesFromDisk(): string[] {
};
};
const registry = new ProfileRegistry();
return Object.keys(registry.getAllProfilesMerged());
const profiles = Object.keys(registry.getAllProfilesMerged());
// Add the bare `ccs` default login (DEFAULT_PROFILE) when ~/.claude exists --
// the default way of running `ccs`, distinct from named `ccs <profile>`
// profiles. unshift so it leads before alphabetical sorting downstream.
if (fs.existsSync(path.join(os.homedir(), '.claude'))) {
if (!profiles.includes(DEFAULT_PROFILE)) profiles.unshift(DEFAULT_PROFILE);
}
return profiles;
} catch {
return [];
}
}
/**
* Resolve the default Claude profile. Returns null when none is set.
* Resolve the default Claude profile. A registry-designated default wins;
* otherwise the bare ~/.claude login (DEFAULT_PROFILE) is the default `ccs`.
*/
function getDefaultClaudeProfileFromDisk(): string | null {
try {
@@ -574,10 +591,13 @@ function getDefaultClaudeProfileFromDisk(): string | null {
};
};
const registry = new ProfileRegistry();
return registry.getDefaultResolved();
const reg = registry.getDefaultResolved();
if (reg) return reg;
} catch {
return null;
// fall through to the bare default below
}
if (fs.existsSync(path.join(os.homedir(), '.claude'))) return DEFAULT_PROFILE;
return null;
}
/**