fix: treat gh CLI token as GitHub account

This commit is contained in:
Bohdan Triapitsyn
2026-06-11 19:30:19 +03:00
parent 465732858f
commit f26950fa4e
25 changed files with 196 additions and 65 deletions
+8 -3
View File
@@ -187,11 +187,14 @@ const DesktopGitHubControl = React.memo(function DesktopGitHubControl({
{githubAccounts.map((account) => {
const accountUser = account.user;
const isCurrent = Boolean(account.current);
const sourceLabel = account.source === 'gh-cli'
? t('header.github.accountSource.cli')
: t('header.github.accountSource.oauth');
return (
<DropdownMenuItem
key={account.id}
className="gap-2"
disabled={isCurrent || isSwitchingGitHubAccount}
disabled={isSwitchingGitHubAccount}
onSelect={() => {
if (!isCurrent) {
void handleGitHubAccountSwitch(account.id);
@@ -216,8 +219,10 @@ const DesktopGitHubControl = React.memo(function DesktopGitHubControl({
{accountUser?.name?.trim() || accountUser?.login || 'GitHub'}
</span>
{accountUser?.login ? (
<span className="truncate typography-micro font-mono text-muted-foreground">
{accountUser.login}
<span className="truncate typography-micro text-muted-foreground">
<span className="font-mono">{accountUser.login}</span>
<span className="mx-1 opacity-50">·</span>
<span>{sourceLabel}</span>
</span>
) : null}
</span>
@@ -263,7 +263,11 @@ export const GitHubSettings: React.FC = () => {
const connected = Boolean(status?.connected);
const user = status?.user;
const accounts = status?.accounts ?? [];
const otherAccounts = accounts.filter((account) => !account.current);
const ghCli = status?.ghCli ?? null;
const activeAccountSourceLabel = ghCli?.active
? t('settings.github.page.accountSource.cli')
: t('settings.github.page.accountSource.oauth');
return (
<div className="mb-8">
@@ -306,6 +310,8 @@ export const GitHubSettings: React.FC = () => {
<span className="font-mono">{user?.login || t('settings.github.page.label.unknownUser')}</span>
{user?.email && <span className="opacity-50"></span>}
{user?.email && <span>{user.email}</span>}
<span className="opacity-50"></span>
<span>{activeAccountSourceLabel}</span>
</div>
{status?.scope && (
<div className="typography-micro text-muted-foreground/70 mt-0.5">
@@ -341,15 +347,17 @@ export const GitHubSettings: React.FC = () => {
</div>
)}
{accounts.length > 1 && (
{otherAccounts.length > 0 && (
<div className="mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1">
<div className="typography-micro text-muted-foreground mb-2 px-1">
{t('settings.github.page.label.otherAccounts')}
</div>
<div className="space-y-1">
{accounts.map((account) => {
{otherAccounts.map((account) => {
const accountUser = account.user;
const isCurrent = Boolean(account.current);
const sourceLabel = account.source === 'gh-cli'
? t('settings.github.page.accountSource.cli')
: t('settings.github.page.accountSource.oauth');
return (
<div
key={account.id}
@@ -374,25 +382,21 @@ export const GitHubSettings: React.FC = () => {
{accountUser?.name?.trim() || accountUser?.login || 'GitHub'}
</span>
{accountUser?.login && (
<span className="typography-micro text-muted-foreground truncate font-mono">
{accountUser.login}
<span className="typography-micro text-muted-foreground truncate">
<span className="font-mono">{accountUser.login}</span>
<span className="mx-1 opacity-50">·</span>
<span>{sourceLabel}</span>
</span>
)}
</div>
</div>
{isCurrent ? (
<span className="typography-micro text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-1.5 py-0.5 rounded">
{t('settings.github.page.status.active')}
</span>
) : (
<Button size="sm"
variant="ghost"
onClick={() => activateAccount(account.id)}
disabled={isBusy}
>
{t('settings.github.page.actions.switchTo')}
</Button>
)}
<Button size="sm"
variant="ghost"
onClick={() => activateAccount(account.id)}
disabled={isBusy}
>
{t('settings.github.page.actions.switchTo')}
</Button>
</div>
);
})}
@@ -449,7 +453,7 @@ export const GitHubSettings: React.FC = () => {
</div>
)}
{ghCli?.available && !ghCli?.active && (
{ghCli?.available && !ghCli?.active && (!ghCli.user || ghCli.disabled) && (
<div className="mt-6">
<h3 className="typography-ui-header font-semibold text-foreground mb-3 px-1">
{t('settings.github.page.ghCli.title')}
+1
View File
@@ -1052,6 +1052,7 @@ export type GitHubAuthAccount = {
user: GitHubUserSummary;
scope?: string;
current?: boolean;
source?: 'oauth' | 'gh-cli';
};
export type GitHubDeviceFlowStart = {
@@ -1390,6 +1390,8 @@ export const settingsDict = {
'settings.github.page.label.unknownUser': 'unknown',
'settings.github.page.label.scopes': 'Scopes: {value}',
'settings.github.page.label.otherAccounts': 'Other Accounts',
'settings.github.page.accountSource.oauth': 'OAuth',
'settings.github.page.accountSource.cli': 'CLI',
'settings.github.page.actions.disconnect': 'Disconnect',
'settings.github.page.actions.connect': 'Connect GitHub',
'settings.github.page.actions.switchTo': 'Switch to',
+2
View File
@@ -1273,6 +1273,8 @@ export const dict = {
'header.github.avatarWithLogin': '{login} avatar',
'header.github.avatar': 'GitHub avatar',
'header.github.accountsTitle': 'GitHub Accounts',
'header.github.accountSource.oauth': 'OAuth',
'header.github.accountSource.cli': 'CLI',
'header.services.openWithCurrent': 'Open instance, usage and MCP (current: {current})',
'header.services.open': 'Open services, usage and MCP',
'header.services.tooltip.currentInstanceWithShortcuts': 'Current instance: {current} ({toggle}; next tab {nextTab})',
@@ -1357,6 +1357,8 @@ export const settingsDict = {
"settings.github.page.label.unknownUser": "desconocido",
"settings.github.page.label.scopes": "Alcances: {value}",
"settings.github.page.label.otherAccounts": "Cuentas adicionales",
"settings.github.page.accountSource.oauth": "OAuth",
"settings.github.page.accountSource.cli": "CLI",
"settings.github.page.actions.disconnect": "Desconectar",
"settings.github.page.actions.connect": "Conectar GitHub",
"settings.github.page.actions.switchTo": "Cambiar a",
+2
View File
@@ -1239,6 +1239,8 @@ export const dict: Record<I18nKey, string> = {
"header.github.avatarWithLogin": "Avatar de {login}",
"header.github.avatar": "Avatar de GitHub",
"header.github.accountsTitle": "Cuentas de GitHub",
"header.github.accountSource.oauth": "OAuth",
"header.github.accountSource.cli": "CLI",
"header.services.openWithCurrent": "Abrir instancia, uso y MCP (actual: {current})",
"header.services.open": "Abrir servicios, uso y MCP",
"header.services.tooltip.currentInstanceWithShortcuts": "Instancia actual: {current} ({toggle}; siguiente pestaña {nextTab})",
@@ -1346,6 +1346,8 @@ export const settingsDict = {
'settings.github.page.label.unknownUser': 'inconnu',
'settings.github.page.label.scopes': 'Portées : {value}',
'settings.github.page.label.otherAccounts': 'Autres comptes',
'settings.github.page.accountSource.oauth': 'OAuth',
'settings.github.page.accountSource.cli': 'CLI',
'settings.github.page.actions.disconnect': 'Déconnecter',
'settings.github.page.actions.connect': 'Connectez GitHub',
'settings.github.page.actions.switchTo': 'Passer à',
+2
View File
@@ -1145,6 +1145,8 @@ export const dict = {
'header.github.avatarWithLogin': 'Avatar {login}',
'header.github.avatar': 'Avatar GitHub',
'header.github.accountsTitle': 'Comptes GitHub',
'header.github.accountSource.oauth': 'OAuth',
'header.github.accountSource.cli': 'CLI',
'header.services.openWithCurrent': 'Instance ouverte, utilisation et MCP (actuel : {current})',
'header.services.open': 'Services ouverts, utilisation et MCP',
'header.services.tooltip.currentInstanceWithShortcuts': 'Instance actuelle : {current} ({toggle} ; onglet suivant {nextTab})',
@@ -1357,6 +1357,8 @@ export const settingsDict = {
'settings.github.page.label.unknownUser': '알 수 없음',
'settings.github.page.label.scopes': 'Scopes: {value}',
'settings.github.page.label.otherAccounts': '다른 계정',
'settings.github.page.accountSource.oauth': 'OAuth',
'settings.github.page.accountSource.cli': 'CLI',
'settings.github.page.actions.disconnect': '연결 해제',
'settings.github.page.actions.connect': 'GitHub 연결',
'settings.github.page.actions.switchTo': '전환',
+2
View File
@@ -1276,6 +1276,8 @@ export const dict: Record<I18nKey, string> = {
'header.github.avatarWithLogin': '{login} 아바타',
'header.github.avatar': 'GitHub 아바타',
'header.github.accountsTitle': 'GitHub 계정',
'header.github.accountSource.oauth': 'OAuth',
'header.github.accountSource.cli': 'CLI',
'header.services.openWithCurrent': '인스턴스, 사용량, MCP 열기(현재: {current})',
'header.services.open': '서비스, 사용량, MCP 열기',
'header.services.tooltip.currentInstanceWithShortcuts': '현재 인스턴스: {current} ({toggle}; 다음 탭 {nextTab})',
@@ -235,6 +235,8 @@ export const settingsDict = {
'settings.github.page.flow.title': 'Autoryzuj OpenChamber',
'settings.github.page.flow.waiting': 'Oczekiwanie na zatwierdzenie... (automatyczne odświeżanie)',
'settings.github.page.label.otherAccounts': 'Inne konta',
'settings.github.page.accountSource.oauth': 'OAuth',
'settings.github.page.accountSource.cli': 'CLI',
'settings.github.page.label.scopes': 'Zakresy: {value}',
'settings.github.page.label.unknownUser': 'nieznany',
'settings.github.page.status.active': 'Aktywne',
+2
View File
@@ -1960,6 +1960,8 @@ export const dict: Record<I18nKey, string> = {
'header.actions.toggleTerminalPanelAria': 'Przełącz panel terminala',
'header.changes.availableAria': 'Dostępne zmiany',
'header.github.accountsTitle': 'Konta GitHub',
'header.github.accountSource.oauth': 'OAuth',
'header.github.accountSource.cli': 'CLI',
'header.github.avatar': 'Awatar GitHub',
'header.github.avatarWithLogin': 'Awatar {login}',
'header.github.connected': 'GitHub połączony',
@@ -1357,6 +1357,8 @@ export const settingsDict = {
"settings.github.page.label.unknownUser": "desconhecido",
"settings.github.page.label.scopes": "Alcances: {value}",
"settings.github.page.label.otherAccounts": "Contas adicionales",
"settings.github.page.accountSource.oauth": "OAuth",
"settings.github.page.accountSource.cli": "CLI",
"settings.github.page.actions.disconnect": "Desconectar",
"settings.github.page.actions.connect": "Conectar GitHub",
"settings.github.page.actions.switchTo": "Alternar para",
@@ -1239,6 +1239,8 @@ export const dict: Record<I18nKey, string> = {
"header.github.avatarWithLogin": "Avatar de {login}",
"header.github.avatar": "Avatar de GitHub",
"header.github.accountsTitle": "Contas de GitHub",
"header.github.accountSource.oauth": "OAuth",
"header.github.accountSource.cli": "CLI",
"header.services.openWithCurrent": "Abrir instância, uso e MCP (atual: {current})",
"header.services.open": "Abrir serviços, uso e MCP",
"header.services.tooltip.currentInstanceWithShortcuts": "Instância atual: {current} ({toggle}; próxima aba {nextTab})",
@@ -1357,6 +1357,8 @@ export const settingsDict = {
"settings.github.page.label.unknownUser": "невідомий",
"settings.github.page.label.scopes": "Області застосування: {value}",
"settings.github.page.label.otherAccounts": "Інші облікові записи",
"settings.github.page.accountSource.oauth": "OAuth",
"settings.github.page.accountSource.cli": "CLI",
"settings.github.page.actions.disconnect": "Відключити",
"settings.github.page.actions.connect": "Підключити GitHub",
"settings.github.page.actions.switchTo": "Перемкнутися на",
+2
View File
@@ -1239,6 +1239,8 @@ export const dict: Record<I18nKey, string> = {
"header.github.avatarWithLogin": "Аватар {login}",
"header.github.avatar": "Аватар GitHub",
"header.github.accountsTitle": "Облікові записи GitHub",
"header.github.accountSource.oauth": "OAuth",
"header.github.accountSource.cli": "CLI",
"header.services.openWithCurrent": "Відкрити інстанс, використання та MCP (поточний: {current})",
"header.services.open": "Відкрити сервіси, використання та MCP",
"header.services.tooltip.currentInstanceWithShortcuts": "Поточний інстанс: {current} ({toggle}; наступна вкладка {nextTab})",
@@ -1357,6 +1357,8 @@ export const settingsDict = {
'settings.github.page.label.unknownUser': '未知',
'settings.github.page.label.scopes': '作用域:{value}',
'settings.github.page.label.otherAccounts': '其他账号',
'settings.github.page.accountSource.oauth': 'OAuth',
'settings.github.page.accountSource.cli': 'CLI',
'settings.github.page.actions.disconnect': '断开连接',
'settings.github.page.actions.connect': '连接 GitHub',
'settings.github.page.actions.switchTo': '切换到',
@@ -1239,6 +1239,8 @@ export const dict: Record<I18nKey, string> = {
'header.github.avatarWithLogin': '{login} 头像',
'header.github.avatar': 'GitHub 头像',
'header.github.accountsTitle': 'GitHub 账户',
'header.github.accountSource.oauth': 'OAuth',
'header.github.accountSource.cli': 'CLI',
'header.services.openWithCurrent': '打开实例、用量和 MCP(当前:{current}',
'header.services.open': '打开服务、用量和 MCP',
'header.services.tooltip.currentInstanceWithShortcuts': '当前实例:{current}{toggle};下一标签 {nextTab}',
@@ -1278,6 +1278,8 @@
'settings.github.page.label.unknownUser': '未知',
'settings.github.page.label.scopes': '作用域:{value}',
'settings.github.page.label.otherAccounts': '其他帳號',
'settings.github.page.accountSource.oauth': 'OAuth',
'settings.github.page.accountSource.cli': 'CLI',
'settings.github.page.actions.disconnect': '中斷連線',
'settings.github.page.actions.connect': '連線 GitHub',
'settings.github.page.actions.switchTo': '切換到',
@@ -1249,6 +1249,8 @@ export const dict: Record<I18nKey, string> = {
'header.github.avatarWithLogin': '{login} 頭像',
'header.github.avatar': 'GitHub 頭像',
'header.github.accountsTitle': 'GitHub 帳戶',
'header.github.accountSource.oauth': 'OAuth',
'header.github.accountSource.cli': 'CLI',
'header.services.openWithCurrent': '開啟實例、用量和 MCP(目前:{current}',
'header.services.open': '開啟服務、用量和 MCP',
'header.services.tooltip.currentInstanceWithShortcuts': '目前實例:{current}{toggle};下一分頁 {nextTab}',