* fix(status-bar): hide footer usage bars for unconfigured providers
The footer rendered greyed-out "--" usage bars for Gemini and OpenCode Go
even when they weren't configured. Unconfigured providers don't return
null — they return a non-null object with status 'unavailable' (Gemini
OAuth off, OpenCode Go cookie unset, Claude on API-key billing), which
slipped past the bare `!== null` show-gates.
Add isProviderConfigured(), a type-guard that treats 'unavailable' as
not-configured while keeping transiently-failing ('error') configured
providers visible for layout stability. Wire it into all four show-gates.
* fix(status-bar): hide unconfigured providers while fetching
---------
Co-authored-by: Trevin Chow <trevin@trevinchow.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import { UpdateStatusSegment } from './UpdateStatusSegment'
|
||||
import { ResourceUsageStatusSegment } from './ResourceUsageStatusSegment'
|
||||
import { PortsStatusSegment } from './PortsStatusSegment'
|
||||
import { isStatusBarItemAvailable } from './status-bar-agent-gating'
|
||||
import { isProviderConfigured } from './status-bar-provider-visibility'
|
||||
import { shouldOpenStatusBarContextMenu } from './status-bar-context-menu-policy'
|
||||
import { PetStatusSegment } from './PetStatusSegment'
|
||||
import { TOGGLE_FLOATING_TERMINAL_EVENT } from '@/lib/floating-terminal'
|
||||
@@ -1542,31 +1543,27 @@ function StatusBarInner({ floatingTerminalOpen }: StatusBarProps): React.JSX.Ele
|
||||
|
||||
const { claude, codex, gemini, opencodeGo } = rateLimits
|
||||
|
||||
// Why: hiding `unavailable` providers makes the status bar appear to lose a
|
||||
// provider at random after refreshes or wake/resume. Keeping the slot visible
|
||||
// preserves layout stability and makes it obvious that the provider is still
|
||||
// configured but currently unavailable. Detection-gating (see
|
||||
// status-bar-agent-gating) hides the per-CLI bars when the agent isn't
|
||||
// installed on PATH — this is what stops a fresh install from showing
|
||||
// "Gemini Usage" when Gemini isn't installed.
|
||||
// Why: a provider only earns a bar once it's configured (isProviderConfigured
|
||||
// drops the `unavailable` state — Gemini OAuth off, OpenCode Go cookie unset,
|
||||
// Claude on API-key billing). A configured provider that fails transiently
|
||||
// (`error`) keeps its slot so the bar doesn't flap on refresh hiccups.
|
||||
// Detection-gating (see status-bar-agent-gating) additionally hides per-CLI
|
||||
// bars when the agent isn't installed on PATH.
|
||||
const showClaude =
|
||||
!!claude &&
|
||||
isProviderConfigured(claude) &&
|
||||
statusBarItems.includes('claude') &&
|
||||
isStatusBarItemAvailable('claude', detectedAgentIds)
|
||||
const showCodex =
|
||||
!!codex &&
|
||||
isProviderConfigured(codex) &&
|
||||
statusBarItems.includes('codex') &&
|
||||
isStatusBarItemAvailable('codex', detectedAgentIds)
|
||||
// Why: hide only when the state hasn't loaded yet (null), not when unavailable.
|
||||
// Gemini shows if credentials exist; OpenCode Go shows always so users can see
|
||||
// the provider and know to configure the cookie in Settings.
|
||||
const showGemini =
|
||||
gemini !== null &&
|
||||
isProviderConfigured(gemini) &&
|
||||
statusBarItems.includes('gemini') &&
|
||||
isStatusBarItemAvailable('gemini', detectedAgentIds)
|
||||
// Why: OpenCode Go is a web/cookie-auth provider, not a CLI on PATH, so
|
||||
// detection-gating doesn't apply.
|
||||
const showOpencodeGo = opencodeGo !== null && statusBarItems.includes('opencode-go')
|
||||
const showOpencodeGo = isProviderConfigured(opencodeGo) && statusBarItems.includes('opencode-go')
|
||||
const showSsh = statusBarItems.includes('ssh')
|
||||
const showResourceUsage = statusBarItems.includes('resource-usage')
|
||||
const showPorts = statusBarItems.includes('ports')
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type {
|
||||
ProviderRateLimits,
|
||||
ProviderRateLimitStatus
|
||||
} from '../../../../shared/rate-limit-types'
|
||||
import { isProviderConfigured } from './status-bar-provider-visibility'
|
||||
|
||||
function provider(
|
||||
status: ProviderRateLimitStatus,
|
||||
overrides: Partial<ProviderRateLimits> = {}
|
||||
): ProviderRateLimits {
|
||||
return {
|
||||
provider: 'gemini',
|
||||
session: null,
|
||||
weekly: null,
|
||||
updatedAt: 0,
|
||||
error: null,
|
||||
status,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
describe('isProviderConfigured', () => {
|
||||
it('hides a provider whose state has not loaded yet', () => {
|
||||
expect(isProviderConfigured(null)).toBe(false)
|
||||
})
|
||||
|
||||
it('hides an unconfigured (unavailable) provider', () => {
|
||||
// The bug: Gemini OAuth off / OpenCode Go cookie unset returns a non-null
|
||||
// `unavailable` object, which previously slipped past the `!== null` gate
|
||||
// and rendered a "--" bar for a provider the user never configured.
|
||||
expect(isProviderConfigured(provider('unavailable'))).toBe(false)
|
||||
})
|
||||
|
||||
it('hides a first-load fetching provider until it has proven usage data', () => {
|
||||
// The initial fetch marks every provider as `fetching`; without prior data
|
||||
// that state is not proof the user configured Gemini or OpenCode Go.
|
||||
expect(isProviderConfigured(provider('fetching'))).toBe(false)
|
||||
})
|
||||
|
||||
it('shows configured providers, including ones failing transiently', () => {
|
||||
expect(isProviderConfigured(provider('ok'))).toBe(true)
|
||||
expect(isProviderConfigured(provider('error'))).toBe(true)
|
||||
expect(
|
||||
isProviderConfigured(
|
||||
provider('fetching', {
|
||||
session: {
|
||||
usedPercent: 25,
|
||||
windowMinutes: 300,
|
||||
resetsAt: null,
|
||||
resetDescription: null
|
||||
}
|
||||
})
|
||||
)
|
||||
).toBe(true)
|
||||
expect(isProviderConfigured(provider('idle'))).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { ProviderRateLimits } from '../../../../shared/rate-limit-types'
|
||||
|
||||
function hasUsageData(provider: ProviderRateLimits): boolean {
|
||||
return Boolean(
|
||||
provider.session ||
|
||||
provider.weekly ||
|
||||
provider.monthly ||
|
||||
(provider.buckets && provider.buckets.length > 0)
|
||||
)
|
||||
}
|
||||
|
||||
// Why: a provider that returns `unavailable` is explicitly not configured
|
||||
// (Gemini OAuth off, OpenCode Go cookie unset, Claude on API-key billing). Its
|
||||
// fetch object is non-null, so a bare `!== null` check still renders a "--"
|
||||
// bar for a provider the user never set up. `error` is kept visible on purpose
|
||||
// — that's a *configured* provider failing transiently, and hiding it would
|
||||
// make the bar flap on every refresh hiccup.
|
||||
export function isProviderConfigured(
|
||||
provider: ProviderRateLimits | null
|
||||
): provider is ProviderRateLimits {
|
||||
if (provider === null || provider.status === 'unavailable') {
|
||||
return false
|
||||
}
|
||||
if (provider.status === 'fetching' && !hasUsageData(provider)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user