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')}