From a156c118b2f84445d7aab8dae7e76e5128b6f8b4 Mon Sep 17 00:00:00 2001 From: mmarabel Date: Fri, 11 Sep 2026 18:45:29 +0200 Subject: [PATCH 1/7] fix(status-bar): surface signed-out Claude usage instead of hiding the segment --- .../rate-limits/claude-active-usage-fetch.ts | 14 ++++++ ...laude-fetcher-keychain-credentials.test.ts | 50 +++++++++++++++++++ .../rate-limits/claude-oauth-credentials.ts | 30 +++++++++-- .../claude-usage-error-classification.test.ts | 14 ++++++ .../claude-usage-error-classification.ts | 4 ++ .../status-bar-provider-visibility.test.ts | 12 +++++ .../status-bar/usage-error-copy.test.ts | 28 ++++++++++- .../components/status-bar/usage-error-copy.ts | 2 + .../status-bar/usage-roster-row-state.test.ts | 10 ++++ .../status-bar/usage-roster-row-state.ts | 5 +- src/shared/rate-limit-types.ts | 3 ++ 11 files changed, 165 insertions(+), 7 deletions(-) diff --git a/src/main/rate-limits/claude-active-usage-fetch.ts b/src/main/rate-limits/claude-active-usage-fetch.ts index f285ba13ce93..c95ea1e5ca7d 100644 --- a/src/main/rate-limits/claude-active-usage-fetch.ts +++ b/src/main/rate-limits/claude-active-usage-fetch.ts @@ -139,6 +139,7 @@ export async function fetchActiveClaudeRateLimits( const credentialClassification = classifyClaudeCredentialAbsence({ hasRefreshableCredentials: oauthCredentials.hasRefreshableCredentials, + hasEmptyStoredEntry: oauthCredentials.hasEmptyStoredEntry, keychainUnavailable: oauthCredentials.keychainUnavailable, managedRefreshDeferredByLivePty: options?.authPreparation?.managedRefreshDeferredByLivePty }) @@ -237,6 +238,19 @@ export async function fetchActiveClaudeRateLimits( } } + // Why: an emptied credential store means signed-out, not never-configured — + // surface it as an error so the status bar shows a sign-in state instead of hiding. + if (credentialClassification.failureKind === 'signed-out') { + return makeClaudeUsageResult('error', 'Claude sign-in expired', { + ...metadataForClaudeUsageAttempt({ + attemptedSources: attempts.attemptedSources, + oauthCredentials, + authPreparation: options?.authPreparation, + failureKind: 'signed-out' + }) + }) + } + return makeClaudeUsageResult('unavailable', 'No subscription plan — API key billing', { ...metadataForClaudeUsageAttempt({ attemptedSources: attempts.attemptedSources, diff --git a/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts b/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts index 9a75d3826e5c..8e6817dc385a 100644 --- a/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts +++ b/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts @@ -452,6 +452,56 @@ describe('fetchClaudeRateLimits', () => { ) }) + it('reports signed-out instead of unavailable when the Keychain entry holds no tokens', async () => { + const configDir = '/Users/test/.claude' + const authPreparation: ClaudeRuntimeAuthPreparation = { + configDir, + runtime: 'host', + envPatch: {}, + stripAuthEnv: false, + provenance: 'system' + } + vi.mocked(readActiveClaudeKeychainCredentialsStrict) + .mockResolvedValueOnce(null) + .mockResolvedValueOnce( + JSON.stringify({ + claudeAiOauth: { accessToken: '', refreshToken: '', expiresAt: 0 } + }) + ) + + await expect( + fetchClaudeRateLimits({ authPreparation, allowPtyFallback: false }) + ).resolves.toMatchObject({ + provider: 'claude', + status: 'error', + error: 'Claude sign-in expired', + usageMetadata: { + failureKind: 'signed-out', + credentialSource: 'legacy-keychain', + authProvenance: 'system' + } + }) + + expect(netFetchMock).not.toHaveBeenCalled() + expect(fetchViaPty).not.toHaveBeenCalled() + }) + + it('reports signed-out when only the credentials file holds an emptied entry', async () => { + readFileMock.mockResolvedValue( + JSON.stringify({ claudeAiOauth: { accessToken: '', refreshToken: '' } }) + ) + + await expect(fetchClaudeRateLimits({ allowPtyFallback: false })).resolves.toMatchObject({ + provider: 'claude', + status: 'error', + error: 'Claude sign-in expired', + usageMetadata: { failureKind: 'signed-out', credentialSource: 'credentials-file' } + }) + + expect(netFetchMock).not.toHaveBeenCalled() + expect(fetchViaPty).not.toHaveBeenCalled() + }) + it('tries OAuth usage even when local credential metadata is expired', async () => { const configDir = '/Users/test/.claude' const authPreparation: ClaudeRuntimeAuthPreparation = { diff --git a/src/main/rate-limits/claude-oauth-credentials.ts b/src/main/rate-limits/claude-oauth-credentials.ts index 3e14fb2909e7..3baa4db4146c 100644 --- a/src/main/rate-limits/claude-oauth-credentials.ts +++ b/src/main/rate-limits/claude-oauth-credentials.ts @@ -26,6 +26,9 @@ export type ClaudeOAuthCredentialReadResult = { hasRefreshableCredentials: boolean source: ClaudeOAuthCredentialSource keychainUnavailable?: boolean + // Why: a stored entry with blank tokens means signed-out, not + // never-configured — the status bar shows a sign-in state instead of hiding. + hasEmptyStoredEntry?: boolean } type ClaudeOAuthCredentialReadOptions = { @@ -42,7 +45,14 @@ export function parseClaudeOAuthCredentialsJson( const hasRefreshableCredentials = typeof oauth?.refreshToken === 'string' && oauth.refreshToken.trim() !== '' if (!oauth?.accessToken || typeof oauth.accessToken !== 'string') { - return { token: null, hasRefreshableCredentials, source } + return { + token: null, + hasRefreshableCredentials, + source, + ...(oauth != null && !hasRefreshableCredentials + ? { hasEmptyStoredEntry: true as const } + : {}) + } } // Why: expiresAt is not authoritative for the usage endpoint; let the server decide. return { token: oauth.accessToken, hasRefreshableCredentials, source } @@ -86,9 +96,10 @@ async function readFromKeychain(configDir?: string): Promise { }) }) + it('classifies a stored-but-empty entry as signed-out, not missing', () => { + expect( + classifyClaudeCredentialAbsence({ + hasRefreshableCredentials: false, + hasEmptyStoredEntry: true + }) + ).toMatchObject({ + failureKind: 'signed-out', + shouldAttemptCliFallback: false, + shouldAttemptDelegatedRefresh: false, + terminal: true + }) + }) + it('classifies live Claude ownership as a deferred state', () => { expect( classifyClaudeCredentialAbsence({ diff --git a/src/main/rate-limits/claude-usage-error-classification.ts b/src/main/rate-limits/claude-usage-error-classification.ts index 71c88c242bd8..b77e5ef28618 100644 --- a/src/main/rate-limits/claude-usage-error-classification.ts +++ b/src/main/rate-limits/claude-usage-error-classification.ts @@ -41,12 +41,16 @@ export function classifyClaudeOAuthUsageError(error: unknown): ClaudeUsageErrorC export function classifyClaudeCredentialAbsence(input: { hasRefreshableCredentials: boolean + hasEmptyStoredEntry?: boolean keychainUnavailable?: boolean managedRefreshDeferredByLivePty?: boolean }): ClaudeUsageErrorClassification { if (input.managedRefreshDeferredByLivePty) { return terminal('deferred-by-live-session') } + if (input.hasEmptyStoredEntry) { + return terminal('signed-out') + } if (input.keychainUnavailable) { return fallbackOnly('keychain-unavailable') } diff --git a/src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts b/src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts index e833bce7fa4c..095afc56f4e8 100644 --- a/src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts +++ b/src/renderer/src/components/status-bar/status-bar-provider-visibility.test.ts @@ -259,6 +259,18 @@ describe('getVisibleUsageProvider', () => { ).toBe(unavailable) }) + it('keeps a signed-out provider visible without any managed account', () => { + // Why: an emptied credential store reports status error (not unavailable) + // so the bar shows a sign-in state instead of vanishing with no affordance. + const signedOut = provider('error', { + provider: 'claude', + error: 'Claude sign-in expired', + usageMetadata: { failureKind: 'signed-out' } + }) + + expect(getVisibleUsageProvider('claude', signedOut, usageSettings())).toBe(signedOut) + }) + it('hides providers with no live data or durable configuration', () => { expect(getVisibleUsageProvider('codex', null, usageSettings())).toBe(null) expect(getVisibleUsageProvider('grok', undefined, usageSettings())).toBe(null) diff --git a/src/renderer/src/components/status-bar/usage-error-copy.test.ts b/src/renderer/src/components/status-bar/usage-error-copy.test.ts index c91d0704ace3..bca57ca5d660 100644 --- a/src/renderer/src/components/status-bar/usage-error-copy.test.ts +++ b/src/renderer/src/components/status-bar/usage-error-copy.test.ts @@ -4,7 +4,25 @@ vi.mock('@/i18n/i18n', () => ({ translate: (_key: string, fallback: string) => fallback })) -import { getProviderDisplayName } from './usage-error-copy' +import type { ProviderRateLimits } from '../../../../shared/rate-limit-types' +import { + getProviderDisplayName, + getProviderUsageErrorMessage, + getProviderUsageStatusLabel +} from './usage-error-copy' + +function claudeError(overrides: Partial = {}): ProviderRateLimits { + return { + provider: 'claude', + session: null, + weekly: null, + updatedAt: 0, + error: 'Claude sign-in expired', + status: 'error', + usageMetadata: { failureKind: 'signed-out' }, + ...overrides + } +} describe('getProviderDisplayName', () => { it('returns the Antigravity brand name', () => { @@ -24,6 +42,14 @@ describe('getProviderDisplayName', () => { expect(getProviderDisplayName('grok')).toBe('Grok') }) + it('labels a signed-out Claude snapshot as not signed in', () => { + expect(getProviderUsageStatusLabel(claudeError())).toBe('not signed in') + }) + + it('surfaces the signed-out message instead of generic auth copy', () => { + expect(getProviderUsageErrorMessage(claudeError())).toBe('Claude sign-in expired') + }) + it('falls back to the raw provider id when no mapping exists', () => { // Why: provider id is a closed union, but TypeScript may not enforce // exhaustiveness on dynamic callers. Fallback keeps logging safe. diff --git a/src/renderer/src/components/status-bar/usage-error-copy.ts b/src/renderer/src/components/status-bar/usage-error-copy.ts index 39032ab5e2c3..f6b36e0b81ac 100644 --- a/src/renderer/src/components/status-bar/usage-error-copy.ts +++ b/src/renderer/src/components/status-bar/usage-error-copy.ts @@ -85,6 +85,8 @@ export function getProviderUsageStatusLabel(p: ProviderRateLimits): string { } if (p.provider === 'claude') { switch (p.usageMetadata?.failureKind) { + case 'signed-out': + return translate('auto.components.status.bar.UsageRosterPanel.notSignedIn', 'not signed in') case 'deferred-by-live-session': return translate( 'auto.components.status.bar.tooltip.0d8d7cfe15', diff --git a/src/renderer/src/components/status-bar/usage-roster-row-state.test.ts b/src/renderer/src/components/status-bar/usage-roster-row-state.test.ts index b63a9a3ad5b1..7d9e7205fd47 100644 --- a/src/renderer/src/components/status-bar/usage-roster-row-state.test.ts +++ b/src/renderer/src/components/status-bar/usage-roster-row-state.test.ts @@ -57,6 +57,16 @@ describe('getUsageRosterRowState', () => { false ) ).toEqual({ kind: 'sign-in', statusLabel: 'not signed in' }) + expect( + getUsageRosterRowState( + provider({ + status: 'error', + error: 'Claude sign-in expired', + usageMetadata: { failureKind: 'signed-out' } + }), + false + ) + ).toEqual({ kind: 'sign-in', statusLabel: 'not signed in' }) expect( getUsageRosterRowState( provider({ diff --git a/src/renderer/src/components/status-bar/usage-roster-row-state.ts b/src/renderer/src/components/status-bar/usage-roster-row-state.ts index 687623275994..3c339f054073 100644 --- a/src/renderer/src/components/status-bar/usage-roster-row-state.ts +++ b/src/renderer/src/components/status-bar/usage-roster-row-state.ts @@ -18,7 +18,10 @@ const CONFIRMED_SIGN_OUT_PATTERNS = [ ] function isConfirmedSignedOut(provider: ProviderRateLimits): boolean { - if (provider.usageMetadata?.failureKind === 'missing-credentials') { + if ( + provider.usageMetadata?.failureKind === 'missing-credentials' || + provider.usageMetadata?.failureKind === 'signed-out' + ) { return true } // Why: credential refresh and network failures can mention auth while live diff --git a/src/shared/rate-limit-types.ts b/src/shared/rate-limit-types.ts index 83210fba2ccb..eb63a0db9500 100644 --- a/src/shared/rate-limit-types.ts +++ b/src/shared/rate-limit-types.ts @@ -19,6 +19,9 @@ export type UsageRateLimitSource = 'oauth' | 'cli' | 'web' | 'live-session' export type UsageRateLimitFailureKind = | 'missing-credentials' + // Why: a stored-but-empty credential entry proves the CLI was set up and + // lost its tokens (signed out), unlike never-configured (hide the bar). + | 'signed-out' | 'stale-token' | 'refreshable-credentials-without-token' | 'delegated-refresh-required' From 0078b9cbf02372f0ec09bab2ed27461549f17bbf Mon Sep 17 00:00:00 2001 From: mmarabel Date: Fri, 11 Sep 2026 18:56:30 +0200 Subject: [PATCH 2/7] fix(status-bar): return signed-out before CLI fallback; trim blank tokens --- .../rate-limits/claude-active-usage-fetch.ts | 26 +++++++++---------- ...laude-fetcher-keychain-credentials.test.ts | 6 ++--- .../rate-limits/claude-oauth-credentials.ts | 10 +++++-- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/main/rate-limits/claude-active-usage-fetch.ts b/src/main/rate-limits/claude-active-usage-fetch.ts index c95ea1e5ca7d..e469c08f9e5b 100644 --- a/src/main/rate-limits/claude-active-usage-fetch.ts +++ b/src/main/rate-limits/claude-active-usage-fetch.ts @@ -144,6 +144,19 @@ export async function fetchActiveClaudeRateLimits( managedRefreshDeferredByLivePty: options?.authPreparation?.managedRefreshDeferredByLivePty }) + // Why: terminal signed-out means there is no token to try and no CLI + // fallback is sanctioned — return before any refresh or PTY attempts. + if (credentialClassification.failureKind === 'signed-out') { + return makeClaudeUsageResult('error', 'Claude sign-in expired', { + ...metadataForClaudeUsageAttempt({ + attemptedSources: attempts.attemptedSources, + oauthCredentials, + authPreparation: options?.authPreparation, + failureKind: 'signed-out' + }) + }) + } + if (shouldDeferClaudeUsageForLiveSession(options?.authPreparation, credentialClassification)) { return makeLiveClaudeUsageDeferredResult({ attempts, @@ -238,19 +251,6 @@ export async function fetchActiveClaudeRateLimits( } } - // Why: an emptied credential store means signed-out, not never-configured — - // surface it as an error so the status bar shows a sign-in state instead of hiding. - if (credentialClassification.failureKind === 'signed-out') { - return makeClaudeUsageResult('error', 'Claude sign-in expired', { - ...metadataForClaudeUsageAttempt({ - attemptedSources: attempts.attemptedSources, - oauthCredentials, - authPreparation: options?.authPreparation, - failureKind: 'signed-out' - }) - }) - } - return makeClaudeUsageResult('unavailable', 'No subscription plan — API key billing', { ...metadataForClaudeUsageAttempt({ attemptedSources: attempts.attemptedSources, diff --git a/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts b/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts index 8e6817dc385a..11851d3d9273 100644 --- a/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts +++ b/src/main/rate-limits/claude-fetcher-keychain-credentials.test.ts @@ -469,9 +469,9 @@ describe('fetchClaudeRateLimits', () => { }) ) - await expect( - fetchClaudeRateLimits({ authPreparation, allowPtyFallback: false }) - ).resolves.toMatchObject({ + // Why: no allowPtyFallback override — signed-out must return before the + // generic CLI plan step even when the caller allows PTY fallback. + await expect(fetchClaudeRateLimits({ authPreparation })).resolves.toMatchObject({ provider: 'claude', status: 'error', error: 'Claude sign-in expired', diff --git a/src/main/rate-limits/claude-oauth-credentials.ts b/src/main/rate-limits/claude-oauth-credentials.ts index 3baa4db4146c..f80a649d196f 100644 --- a/src/main/rate-limits/claude-oauth-credentials.ts +++ b/src/main/rate-limits/claude-oauth-credentials.ts @@ -44,7 +44,13 @@ export function parseClaudeOAuthCredentialsJson( const oauth = (JSON.parse(raw) as ClaudeCredentials)?.claudeAiOauth const hasRefreshableCredentials = typeof oauth?.refreshToken === 'string' && oauth.refreshToken.trim() !== '' - if (!oauth?.accessToken || typeof oauth.accessToken !== 'string') { + // Why: a whitespace-only token is unusable — treat it as absent so the + // entry counts as emptied (signed-out) instead of reaching the OAuth path. + const accessToken = + typeof oauth?.accessToken === 'string' && oauth.accessToken.trim() !== '' + ? oauth.accessToken.trim() + : null + if (accessToken == null) { return { token: null, hasRefreshableCredentials, @@ -55,7 +61,7 @@ export function parseClaudeOAuthCredentialsJson( } } // Why: expiresAt is not authoritative for the usage endpoint; let the server decide. - return { token: oauth.accessToken, hasRefreshableCredentials, source } + return { token: accessToken, hasRefreshableCredentials, source } } catch { return emptyClaudeOAuthCredentialReadResult() } From 58326fbe3d6f543910fbf98f9a4226b8ff83c5cc Mon Sep 17 00:00:00 2001 From: mmarabel Date: Fri, 11 Sep 2026 21:04:11 +0200 Subject: [PATCH 3/7] fix(status-bar): surface signed-out message verbatim with documented intent --- src/renderer/src/components/status-bar/usage-error-copy.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/renderer/src/components/status-bar/usage-error-copy.ts b/src/renderer/src/components/status-bar/usage-error-copy.ts index f6b36e0b81ac..1d456cefa008 100644 --- a/src/renderer/src/components/status-bar/usage-error-copy.ts +++ b/src/renderer/src/components/status-bar/usage-error-copy.ts @@ -174,6 +174,10 @@ export function getProviderUsageErrorMessage(p: ProviderRateLimits): string { 'auto.components.status.bar.tooltip.a7517cccb6', 'Claude usage is unavailable right now.' ) + // Why: the main-process 'Claude sign-in expired' string is intentionally + // pattern-safe (matches no auth-error rewrite), so it surfaces verbatim. + case 'signed-out': + return p.error ?? fallback case 'missing-credentials': case 'rate-limited': case 'unknown': From 42cb83c0399cc1d507179bda84f0614f4d005a36 Mon Sep 17 00:00:00 2001 From: mmarabel Date: Fri, 11 Sep 2026 20:21:12 +0200 Subject: [PATCH 4/7] fix(accounts): flag signed-out system-default Claude login in Accounts pane --- .../src/components/settings/AccountsPane.tsx | 12 +++ .../settings/accounts-pane-claude-section.tsx | 23 +++- .../settings/accounts-pane-types.ts | 1 + .../claude-account-auth-warning.test.ts | 100 ++++++++++++++++++ .../settings/claude-account-auth-warning.ts | 39 +++++++ 5 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 src/renderer/src/components/settings/claude-account-auth-warning.test.ts create mode 100644 src/renderer/src/components/settings/claude-account-auth-warning.ts diff --git a/src/renderer/src/components/settings/AccountsPane.tsx b/src/renderer/src/components/settings/AccountsPane.tsx index 82e2b1c3683f..1ae898422417 100644 --- a/src/renderer/src/components/settings/AccountsPane.tsx +++ b/src/renderer/src/components/settings/AccountsPane.tsx @@ -27,6 +27,7 @@ import { import { getRemoteAccountsPaneScope } from './provider-account-scope' import { ProviderHostScopeControl } from './ProviderHostScopeControl' import { matchesSettingsSearch } from './settings-search' +import { getClaudeSystemDefaultSignInWarning } from './claude-account-auth-warning' import { getCodexAccountAuthWarning } from './codex-account-auth-warning' import { getCodexConfigSyncWarning } from './codex-config-sync-warning' import { @@ -72,6 +73,8 @@ export function AccountsPane({ accountOwnerPlatform = null }: AccountsPaneProps): React.JSX.Element { const searchQuery = useAppStore((s) => s.settingsSearchQuery) + const claudeRateLimits = useAppStore((s) => s.rateLimits.claude) + const claudeRateLimitTarget = useAppStore((s) => s.rateLimits.claudeTarget) const codexRateLimits = useAppStore((s) => s.rateLimits.codex) const codexRateLimitTarget = useAppStore((s) => s.rateLimits.codexTarget) const miniMaxRateLimits = useAppStore((s) => s.rateLimits.minimax) @@ -209,6 +212,14 @@ export function AccountsPane({ const codexConfigSyncWarning = getCodexConfigSyncWarning(codexConfigSync) const systemCodexMissingSignIn = activeCodexAuthWarning === 'missing-sign-in' const systemCodexNeedsSignIn = activeCodexAccountId === null && Boolean(activeCodexAuthWarning) + // Why: remote snapshots own their system-default login, but the desktop's + // usage poll must not be misattributed to a remote account owner (#7973). + const systemClaudeNeedsSignIn = getClaudeSystemDefaultSignInWarning({ + limits: isRemoteAccountScope ? null : claudeRateLimits, + target: claudeRateLimitTarget, + runtime: accountRuntime, + systemActive: systemClaudeActive + }) const accountRuntimeUnavailable = accountRuntime.runtime === 'wsl' && !wslAvailable && !wslCapabilitiesLoading @@ -316,6 +327,7 @@ export function AccountsPane({ claudeAction, visibleClaudeAccounts, systemClaudeActive, + systemClaudeNeedsSignIn, setRemoveClaudeTarget, runClaudeAccountAction, codexAccounts, diff --git a/src/renderer/src/components/settings/accounts-pane-claude-section.tsx b/src/renderer/src/components/settings/accounts-pane-claude-section.tsx index e99758f0db54..b4359daab1d8 100644 --- a/src/renderer/src/components/settings/accounts-pane-claude-section.tsx +++ b/src/renderer/src/components/settings/accounts-pane-claude-section.tsx @@ -27,6 +27,7 @@ export function renderClaudeAccountsSection(model: AccountsPaneSectionModel): Re setRemoveClaudeTarget, settings, systemClaudeActive, + systemClaudeNeedsSignIn, visibleClaudeAccounts, wslCapabilitiesLoading } = model @@ -131,9 +132,11 @@ export function renderClaudeAccountsSection(model: AccountsPaneSectionModel): Re } disabled={claudeAction !== 'idle' || accountRuntimeUnavailable} className={`flex w-full items-center justify-between gap-3 rounded-md border px-3 py-2.5 text-left transition-colors ${ - systemClaudeActive - ? 'border-foreground/20 bg-accent/15' - : 'border-border/70 hover:border-border hover:bg-accent/8' + systemClaudeNeedsSignIn + ? 'border-destructive/50 bg-destructive/5' + : systemClaudeActive + ? 'border-foreground/20 bg-accent/15' + : 'border-border/70 hover:border-border hover:bg-accent/8' } disabled:cursor-default disabled:opacity-100`} >
@@ -149,8 +152,20 @@ export function renderClaudeAccountsSection(model: AccountsPaneSectionModel): Re {translate('auto.components.settings.AccountsPane.e74831fb6b', 'Active')} ) : null} + {systemClaudeNeedsSignIn ? ( + + {translate('auto.components.settings.AccountsPane.93c47b333a', 'Needs sign-in')} + + ) : null}
- + {translate( 'auto.components.settings.AccountsPane.e05d0ff737', 'Use your current {{value0}} Claude login.', diff --git a/src/renderer/src/components/settings/accounts-pane-types.ts b/src/renderer/src/components/settings/accounts-pane-types.ts index c4ea87bf4bfb..02ccd54c65b6 100644 --- a/src/renderer/src/components/settings/accounts-pane-types.ts +++ b/src/renderer/src/components/settings/accounts-pane-types.ts @@ -81,6 +81,7 @@ export type AccountsPaneSectionModel = { claudeAction: ClaudeAccountAction visibleClaudeAccounts: ClaudeRateLimitAccountsState['accounts'] systemClaudeActive: boolean + systemClaudeNeedsSignIn: boolean setRemoveClaudeTarget: Dispatch> runClaudeAccountAction: ClaudeAccountActionRunner codexAccounts: CodexRateLimitAccountsState diff --git a/src/renderer/src/components/settings/claude-account-auth-warning.test.ts b/src/renderer/src/components/settings/claude-account-auth-warning.test.ts new file mode 100644 index 000000000000..54dd4fa7ac5d --- /dev/null +++ b/src/renderer/src/components/settings/claude-account-auth-warning.test.ts @@ -0,0 +1,100 @@ +import { describe, expect, it } from 'vitest' +import type { + ProviderRateLimits, + UsageRateLimitFailureKind +} from '../../../../shared/rate-limit-types' +import { + claudeRateLimitTargetMatchesAccountRuntime, + getClaudeSystemDefaultSignInWarning +} from './claude-account-auth-warning' + +function claudeLimits( + status: ProviderRateLimits['status'], + failureKind: UsageRateLimitFailureKind = 'signed-out' +): ProviderRateLimits { + return { + provider: 'claude', + session: null, + weekly: null, + updatedAt: 1, + error: 'Claude sign-in expired', + status, + usageMetadata: { failureKind } + } +} + +const hostTarget = { runtime: 'host', wslDistro: null } as const + +describe('claude system default sign-in warning', () => { + it('warns when the host snapshot reports signed-out', () => { + expect( + getClaudeSystemDefaultSignInWarning({ + limits: claudeLimits('error'), + target: hostTarget, + runtime: { runtime: 'host' }, + systemActive: true + }) + ).toBe(true) + }) + + it('stays quiet when a managed account is selected', () => { + expect( + getClaudeSystemDefaultSignInWarning({ + limits: claudeLimits('error'), + target: hostTarget, + runtime: { runtime: 'host' }, + systemActive: false + }) + ).toBe(false) + }) + + it('stays quiet for other failure kinds and non-error snapshots', () => { + const base = { + target: hostTarget, + runtime: { runtime: 'host' }, + systemActive: true + } as const + expect( + getClaudeSystemDefaultSignInWarning({ + ...base, + limits: claudeLimits('error', 'missing-credentials') + }) + ).toBe(false) + expect( + getClaudeSystemDefaultSignInWarning({ + ...base, + limits: claudeLimits('unavailable', 'signed-out') + }) + ).toBe(false) + expect(getClaudeSystemDefaultSignInWarning({ ...base, limits: null })).toBe(false) + }) + + it('stays quiet when the snapshot target does not match the viewed runtime', () => { + expect( + getClaudeSystemDefaultSignInWarning({ + limits: claudeLimits('error'), + target: hostTarget, + runtime: { runtime: 'wsl', wslDistro: 'Ubuntu' }, + systemActive: true + }) + ).toBe(false) + expect( + getClaudeSystemDefaultSignInWarning({ + limits: claudeLimits('error'), + target: { runtime: 'wsl', wslDistro: 'Ubuntu' }, + runtime: { runtime: 'wsl', wslDistro: 'Ubuntu' }, + systemActive: true + }) + ).toBe(true) + }) + + it('matches targets the same way the Codex warning does', () => { + expect(claudeRateLimitTargetMatchesAccountRuntime(hostTarget, { runtime: 'host' })).toBe(true) + expect( + claudeRateLimitTargetMatchesAccountRuntime(hostTarget, { + runtime: 'wsl', + wslDistro: 'Ubuntu' + }) + ).toBe(false) + }) +}) diff --git a/src/renderer/src/components/settings/claude-account-auth-warning.ts b/src/renderer/src/components/settings/claude-account-auth-warning.ts new file mode 100644 index 000000000000..2849edb347e7 --- /dev/null +++ b/src/renderer/src/components/settings/claude-account-auth-warning.ts @@ -0,0 +1,39 @@ +import type { + ProviderRateLimits, + RateLimitRuntimeTarget +} from '../../../../shared/rate-limit-types' + +type AccountRuntime = { + runtime: 'host' | 'wsl' + wslDistro?: string | null +} + +export function claudeRateLimitTargetMatchesAccountRuntime( + target: RateLimitRuntimeTarget, + runtime: AccountRuntime +): boolean { + if (target.runtime !== runtime.runtime) { + return false + } + if (runtime.runtime === 'host') { + return true + } + return !runtime.wslDistro || target.wslDistro === runtime.wslDistro +} + +// Why: the desktop usage snapshot describes the viewed login only when its +// target matches; otherwise the warning would blame the wrong environment. +export function getClaudeSystemDefaultSignInWarning(args: { + limits: ProviderRateLimits | null + target: RateLimitRuntimeTarget + runtime: AccountRuntime + systemActive: boolean +}): boolean { + if (!args.systemActive) { + return false + } + if (!claudeRateLimitTargetMatchesAccountRuntime(args.target, args.runtime)) { + return false + } + return args.limits?.status === 'error' && args.limits.usageMetadata?.failureKind === 'signed-out' +} From a1084c4025c31e69cfede19610076017c9c89017 Mon Sep 17 00:00:00 2001 From: mmarabel Date: Fri, 11 Sep 2026 20:33:29 +0200 Subject: [PATCH 5/7] fix(accounts): gate Claude sign-in warning on loaded roster --- .../src/components/settings/AccountsPane.tsx | 21 +++++++++++++------ .../settings/accounts-pane-account-actions.ts | 3 +++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/components/settings/AccountsPane.tsx b/src/renderer/src/components/settings/AccountsPane.tsx index 1ae898422417..6363223eb658 100644 --- a/src/renderer/src/components/settings/AccountsPane.tsx +++ b/src/renderer/src/components/settings/AccountsPane.tsx @@ -142,6 +142,7 @@ export function AccountsPane({ const [codexAction, setCodexAction] = useState('idle') const [claudeAccounts, setClaudeAccounts] = useState(emptyClaudeAccountsState) + const [claudeAccountsLoaded, setClaudeAccountsLoaded] = useState(false) const [claudeAction, setClaudeAction] = useState('idle') // Why: capture the account's runtime slot when the dialog opens; the roster // can change underneath an open dialog and lose the slot to diff for restarts. @@ -214,12 +215,14 @@ export function AccountsPane({ const systemCodexNeedsSignIn = activeCodexAccountId === null && Boolean(activeCodexAuthWarning) // Why: remote snapshots own their system-default login, but the desktop's // usage poll must not be misattributed to a remote account owner (#7973). - const systemClaudeNeedsSignIn = getClaudeSystemDefaultSignInWarning({ - limits: isRemoteAccountScope ? null : claudeRateLimits, - target: claudeRateLimitTarget, - runtime: accountRuntime, - systemActive: systemClaudeActive - }) + const systemClaudeNeedsSignIn = + claudeAccountsLoaded && + getClaudeSystemDefaultSignInWarning({ + limits: isRemoteAccountScope ? null : claudeRateLimits, + target: claudeRateLimitTarget, + runtime: accountRuntime, + systemActive: systemClaudeActive + }) const accountRuntimeUnavailable = accountRuntime.runtime === 'wsl' && !wslAvailable && !wslCapabilitiesLoading @@ -251,6 +254,10 @@ export function AccountsPane({ }, []) useEffect(() => { + // Why: a runtime switch replaces the roster underneath; keep the loaded + // gate shut until the new owner's snapshot arrives so empty-roster + // derivations (like the system-default warning) cannot flash stale state. + setClaudeAccountsLoaded(false) // Why: remote snapshots stream usage refreshes after the synchronous ready // message, so the watcher stays open for the pane's lifetime; the local // path resolves once and the close() is a no-op. @@ -266,6 +273,7 @@ export function AccountsPane({ } if (!snapshot.failedProviders?.includes('claude')) { setClaudeAccounts(snapshot.claude) + setClaudeAccountsLoaded(true) } }, onError: (error) => { @@ -301,6 +309,7 @@ export function AccountsPane({ isRemoteAccountScope, claudeAccounts, setClaudeAccounts, + setClaudeAccountsLoaded, setClaudeAction, fetchSettings, recordFeatureInteraction diff --git a/src/renderer/src/components/settings/accounts-pane-account-actions.ts b/src/renderer/src/components/settings/accounts-pane-account-actions.ts index 09be1ce001ba..25989e824df8 100644 --- a/src/renderer/src/components/settings/accounts-pane-account-actions.ts +++ b/src/renderer/src/components/settings/accounts-pane-account-actions.ts @@ -138,6 +138,7 @@ type ClaudeActionContext = { isRemoteAccountScope: boolean claudeAccounts: ClaudeRateLimitAccountsState setClaudeAccounts: Dispatch> + setClaudeAccountsLoaded: Dispatch> setClaudeAction: Dispatch> fetchSettings: () => Promise recordFeatureInteraction: (featureId: FeatureInteractionId) => void @@ -153,10 +154,12 @@ export function createClaudeAccountActionRunner( isRemoteAccountScope, recordFeatureInteraction, setClaudeAccounts, + setClaudeAccountsLoaded, setClaudeAction } = context const syncClaudeAccounts = async (next: ClaudeRateLimitAccountsState): Promise => { setClaudeAccounts(next) + setClaudeAccountsLoaded(true) if (!isRemoteAccountScope) { await fetchSettings() } From 609fe6be1dbde44c4ae6a5f20f48cbf61ed2447c Mon Sep 17 00:00:00 2001 From: mmarabel Date: Fri, 11 Sep 2026 21:05:12 +0200 Subject: [PATCH 6/7] fix(accounts): replace Active badge with sign-in warning when signed out --- .../src/components/settings/accounts-pane-claude-section.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/settings/accounts-pane-claude-section.tsx b/src/renderer/src/components/settings/accounts-pane-claude-section.tsx index b4359daab1d8..ec28f38a91c7 100644 --- a/src/renderer/src/components/settings/accounts-pane-claude-section.tsx +++ b/src/renderer/src/components/settings/accounts-pane-claude-section.tsx @@ -144,7 +144,8 @@ export function renderClaudeAccountsSection(model: AccountsPaneSectionModel): Re {translate('auto.components.settings.AccountsPane.f2a265f8c7', 'System default')} - {systemClaudeActive ? ( + {/* Why: a row cannot read as both selected-healthy and broken — the warning replaces Active, not joins it. */} + {systemClaudeActive && !systemClaudeNeedsSignIn ? ( Date: Fri, 25 Sep 2026 18:41:40 +0200 Subject: [PATCH 7/7] fix(accounts): restore compact Claude sign-in badge with a Badge size The upstream merge dropped the square chip classes from the Needs sign-in badge because the design-system gate rejects restyling Badge through className. Add a compact size to the Badge primitive and use it, so the badge again matches the Codex mirror without a restyle. --- .../settings/accounts-pane-claude-section.tsx | 2 +- src/renderer/src/components/ui/badge.test.tsx | 34 +++++++++++++++++++ src/renderer/src/components/ui/badge.tsx | 11 ++++-- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/renderer/src/components/ui/badge.test.tsx diff --git a/src/renderer/src/components/settings/accounts-pane-claude-section.tsx b/src/renderer/src/components/settings/accounts-pane-claude-section.tsx index b3f777e81a26..70b202460115 100644 --- a/src/renderer/src/components/settings/accounts-pane-claude-section.tsx +++ b/src/renderer/src/components/settings/accounts-pane-claude-section.tsx @@ -154,7 +154,7 @@ export function renderClaudeAccountsSection(model: AccountsPaneSectionModel): Re ) : null} {systemClaudeNeedsSignIn ? ( - + {translate('auto.components.settings.AccountsPane.93c47b333a', 'Needs sign-in')} ) : null} diff --git a/src/renderer/src/components/ui/badge.test.tsx b/src/renderer/src/components/ui/badge.test.tsx new file mode 100644 index 000000000000..0c213725a286 --- /dev/null +++ b/src/renderer/src/components/ui/badge.test.tsx @@ -0,0 +1,34 @@ +import { renderToStaticMarkup } from 'react-dom/server' +import { describe, expect, it } from 'vitest' +import { Badge } from './badge' + +function classTokens(html: string): string[] { + return /class="([^"]*)"/.exec(html)?.[1].split(' ') ?? [] +} + +describe('Badge', () => { + it('keeps the pill geometry by default', () => { + const classes = classTokens(renderToStaticMarkup(Label)) + + expect(classes).toEqual(expect.arrayContaining(['rounded-full', 'px-2', 'text-xs'])) + expect(classes).not.toContain('h-4') + }) + + it('replaces the pill geometry with the compact square chip', () => { + const classes = classTokens( + renderToStaticMarkup( + + Label + + ) + ) + + expect(classes).toEqual( + expect.arrayContaining(['h-4', 'rounded', 'px-1.5', 'text-[10px]', 'leading-none']) + ) + expect(classes).not.toContain('rounded-full') + expect(classes).not.toContain('px-2') + expect(classes).not.toContain('text-xs') + expect(classes).toContain('bg-destructive') + }) +}) diff --git a/src/renderer/src/components/ui/badge.tsx b/src/renderer/src/components/ui/badge.tsx index 2d2d0027e5c9..9fab03185e39 100644 --- a/src/renderer/src/components/ui/badge.tsx +++ b/src/renderer/src/components/ui/badge.tsx @@ -22,10 +22,16 @@ const badgeVariants = cva( * so it reads as context beside a workspace name rather than as a status of its own. */ hostContext: 'h-4 rounded border-border bg-accent px-1.5 text-[10px] leading-none text-muted-foreground dark:border-border/50 dark:bg-accent/80' + }, + size: { + default: '', + /** Square 16px status chip that sits inline beside a row title (e.g. "Needs sign-in"). */ + compact: 'h-4 rounded px-1.5 text-[10px] leading-none' } }, defaultVariants: { - variant: 'default' + variant: 'default', + size: 'default' } } ) @@ -33,6 +39,7 @@ const badgeVariants = cva( function Badge({ className, variant = 'default', + size = 'default', asChild = false, ...props }: React.ComponentProps<'span'> & VariantProps & { asChild?: boolean }) { @@ -42,7 +49,7 @@ function Badge({ )