mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(web): only show Codex Fast badge for effective fast tier (#1007)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { shouldShowComposerStatusBar } from './StatusBar'
|
||||
import { shouldShowCodexFastBadge, shouldShowComposerStatusBar } from './StatusBar'
|
||||
|
||||
describe('shouldShowComposerStatusBar', () => {
|
||||
it('hides the composer status bar for Cursor sessions', () => {
|
||||
@@ -12,3 +12,13 @@ describe('shouldShowComposerStatusBar', () => {
|
||||
expect(shouldShowComposerStatusBar(null)).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('shouldShowCodexFastBadge', () => {
|
||||
it('uses only the effective service tier', () => {
|
||||
expect(shouldShowCodexFastBadge('codex', undefined)).toBe(false)
|
||||
expect(shouldShowCodexFastBadge('codex', 'standard')).toBe(false)
|
||||
expect(shouldShowCodexFastBadge('codex', 'fast')).toBe(true)
|
||||
expect(shouldShowCodexFastBadge('codex', 'priority')).toBe(true)
|
||||
expect(shouldShowCodexFastBadge('claude', 'fast')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -125,14 +125,11 @@ function formatTokenCount(value: number): string {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
function isCodexFastMode(model?: string | null, effort?: string | null): boolean {
|
||||
const normalizedEffort = effort?.trim().toLowerCase()
|
||||
if (normalizedEffort === 'none' || normalizedEffort === 'minimal' || normalizedEffort === 'low') {
|
||||
return true
|
||||
}
|
||||
|
||||
const normalizedModel = model?.trim().toLowerCase() ?? ''
|
||||
return normalizedModel.includes('mini') || normalizedModel.includes('fast')
|
||||
export function shouldShowCodexFastBadge(
|
||||
agentFlavor: string | null | undefined,
|
||||
serviceTier: string | null | undefined
|
||||
): boolean {
|
||||
return agentFlavor === 'codex' && isFastServiceTier(serviceTier)
|
||||
}
|
||||
|
||||
/** Cursor native ACP does not emit usage_update; hide the bar to avoid empty/misleading UI. */
|
||||
@@ -210,13 +207,7 @@ export function StatusBar(props: {
|
||||
const codexReasoningLabel = shouldShowCodexReasoningLabel(props.agentFlavor)
|
||||
? formatCodexReasoningLabel(props.modelReasoningEffort)
|
||||
: null
|
||||
// Prefer the explicit service tier (the real Fast-mode toggle) when set;
|
||||
// fall back to the effort/model heuristic only when the tier is unknown.
|
||||
const codexFastMode = props.agentFlavor === 'codex'
|
||||
? (props.serviceTier != null
|
||||
? isFastServiceTier(props.serviceTier)
|
||||
: isCodexFastMode(props.model, props.modelReasoningEffort))
|
||||
: false
|
||||
const codexFastMode = shouldShowCodexFastBadge(props.agentFlavor, props.serviceTier)
|
||||
const goalLabel = props.agentFlavor === 'codex' && props.threadGoal
|
||||
? props.threadGoal.status === 'active'
|
||||
? 'goal'
|
||||
|
||||
Reference in New Issue
Block a user