fix: use codex quota refresh for account checks

This commit is contained in:
fawney19
2026-05-16 20:16:23 +08:00
parent 56994d4c29
commit 3a5922d4ee
16 changed files with 150 additions and 144 deletions

View File

@@ -82,4 +82,16 @@ describe('oauthRefreshFeedback', () => {
message: 'Token 刷新成功,已重新检查额度/账号状态',
})
})
it('includes the recheck failure detail after a successful token refresh', () => {
expect(
getOAuthRefreshFeedback({
accountStateRecheckAttempted: true,
accountStateRecheckError: 'wham/usage API 返回状态码 401',
}),
).toEqual({
tone: 'warning',
message: 'Token 刷新成功,但额度/账号状态复检失败wham/usage API 返回状态码 401',
})
})
})

View File

@@ -20,6 +20,13 @@ function normalizeText(value: unknown): string | null {
return text || null
}
function formatRecheckError(value: string): string {
const collapsed = value.replace(/\s+/g, ' ').trim()
const maxLength = 180
if (collapsed.length <= maxLength) return collapsed
return `${collapsed.slice(0, maxLength - 3).trimEnd()}...`
}
export function resolveOAuthAccountBlockDisplay(
snapshot: ProviderKeyStatusCarrier,
): OAuthAccountBlockDisplay {
@@ -45,7 +52,7 @@ export function getOAuthRefreshFeedback(
if (recheckError) {
return {
tone: 'warning',
message: 'Token 刷新成功,但额度/账号状态复检失败',
message: `Token 刷新成功,但额度/账号状态复检失败${formatRecheckError(recheckError)}`,
}
}
if (blockedLabel) {