fix: prefer account email over generic profile name in picker

Chrome profiles signed into a Google account often have generic display
names like "Person 2". Check account_info[0].email first for a more
readable label, falling back to profile.name as before.

Addresses review feedback from @ngurney.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Max Li
2026-03-20 12:16:55 -07:00
parent 8a27c35729
commit 4d00241549
+11 -4
View File
@@ -152,15 +152,22 @@ export function listProfiles(browserName: string): ProfileEntry[] {
const cookiePath = path.join(browserDir, entry.name, 'Cookies');
if (!fs.existsSync(cookiePath)) continue;
// Try to read display name from Preferences
// Try to read display name from Preferences.
// Prefer account email — signed-in Chrome profiles often have generic
// names like "Person 2" while the email is far more readable.
let displayName = entry.name;
try {
const prefsPath = path.join(browserDir, entry.name, 'Preferences');
if (fs.existsSync(prefsPath)) {
const prefs = JSON.parse(fs.readFileSync(prefsPath, 'utf-8'));
const profileName = prefs?.profile?.name;
if (profileName && typeof profileName === 'string') {
displayName = profileName;
const email = prefs?.account_info?.[0]?.email;
if (email && typeof email === 'string') {
displayName = email;
} else {
const profileName = prefs?.profile?.name;
if (profileName && typeof profileName === 'string') {
displayName = profileName;
}
}
}
} catch {