fix(grok): don't tell users to re-run grok login on refreshable token expiry (#8508)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-07-13 17:55:47 -07:00
committed by GitHub
co-authored by Orca
parent 6c489a4379
commit 1450db85ba
3 changed files with 23 additions and 1 deletions
@@ -159,6 +159,10 @@ describe('fetchGrokRateLimits', () => {
const result = await fetchGrokRateLimits()
expect(result.status).toBe('error')
expect(result.error).toMatch(/expired/i)
// Why: a stored-but-expired access token is refreshed by Grok CLI on next
// use (a genuine sign-out returns 'missing'), so the message must not tell
// users to re-run `grok login` (#8497).
expect(result.error).not.toMatch(/grok login/i)
expect(netFetchMock).not.toHaveBeenCalled()
})
})
+4 -1
View File
@@ -145,7 +145,10 @@ export async function fetchGrokRateLimits(
}
const session = readResult.session
if (!isGrokAccessTokenFresh(session)) {
return result('error', 'Grok session expired — run grok login to refresh')
// Why: a genuine sign-out returns 'missing' earlier, so reaching here always
// means a stored, refreshable session — Grok CLI refreshes the access token
// on its next run, so don't tell users to re-run `grok login` (#8497).
return result('error', 'Grok access token expired — Grok CLI will refresh it on next use')
}
try {
@@ -135,6 +135,21 @@ describe('provider usage error copy', () => {
)
})
it('keeps the reworded Grok expired-token error classified as an auth failure (#8497)', () => {
// Why: the fix (grok-fetcher.ts) dropped the "run grok login" wording that
// used to trigger auth classification; this pins that the new copy still
// resolves to the softer refresh message instead of leaking the raw string.
const grok = provider({
provider: 'grok',
error: 'Grok access token expired — Grok CLI will refresh it on next use'
})
expect(getProviderUsageStatusLabel(grok)).toBe('Refresh failed')
expect(getProviderUsageErrorMessage(grok)).toBe(
'Grok usage could not be refreshed. Agent sessions may still be signed in.'
)
})
it('frames known Codex auth refresh failures as auth-shaped usage failures', () => {
const cases = [
'Please reauthenticate before checking usage.',