Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(providers): treat codex quota exhaustion as benched rather than needs setup
[._.]/ Adam Eivy4a25cfbf4d30
diff --git a/client/src/components/providers/ProviderCard.jsx b/client/src/components/providers/ProviderCard.jsxindex 7068335227..9f754f3923 100644--- a/client/src/components/providers/ProviderCard.jsx+++ b/client/src/components/providers/ProviderCard.jsx@@ -211,11 +211,11 @@ export default function ProviderCard({className={`text-xs px-2 py-0.5 rounded ${style.badge}`}title={cardState.state === PROVIDER_CARD_STATE.BLOCKED? missingSummary- : (status?.message || style.hint)}+ : (status?.message || (codexSubscription && codexAccount?.status === 'quota-exhausted' ? 'ChatGPT usage limit reached — calls route to the fallback.' : style.hint))}>{style.label}- {cardState.state === PROVIDER_CARD_STATE.BENCHED && status?.reason- ? ` · ${status.reason}`+ {cardState.state === PROVIDER_CARD_STATE.BENCHED && (status?.reason || (codexSubscription && codexAccount?.status === 'quota-exhausted' ? 'usage-limit' : ''))+ ? ` · ${status?.reason || 'usage-limit'}`: ''}</span>{/* A switched-off provider that would also need a CLI or a key saysdiff --git a/client/src/components/providers/ProviderCard.test.jsx b/client/src/components/providers/ProviderCard.test.jsxindex 1d8eb327f1..108a109793 100644--- a/client/src/components/providers/ProviderCard.test.jsx+++ b/client/src/components/providers/ProviderCard.test.jsx@@ -132,6 +132,31 @@ describe('ProviderCard ChatGPT subscription', () => {expect(screen.queryByRole('link', { name: 'Open ChatGPT sign-in' })).toBeNull();});++ it('badges quota-exhausted card as benched usage-limit with fallback routing explanation', () => {+ render(+ <MemoryRouter>+ <ProviderCard+ provider={{ id: 'codex', name: 'Codex', type: 'cli', command: 'codex', models: [], enabled: true }}+ cardState={{ state: PROVIDER_CARD_STATE.BENCHED, missing: [] }}+ runtime={null}+ status={null}+ isDefault={false}+ providersById={{}}+ runnerAllowedCommands={[]}+ testResult={null}+ codexAccount={{+ status: 'quota-exhausted',+ account: { planType: 'pro' },+ rateLimits: { primary: { usedPercent: 100 } },+ }}+ />+ </MemoryRouter>+ );++ expect(screen.getByText('BENCHED · usage-limit')).toBeInTheDocument();+ expect(screen.getByTitle('ChatGPT usage limit reached — calls route to the fallback.')).toBeInTheDocument();+ });});describe('ProviderCard model refresh', () => {diff --git a/client/src/pages/AIProviders.test.jsx b/client/src/pages/AIProviders.test.jsxindex 759df10e1b..2fc9de3d02 100644--- a/client/src/pages/AIProviders.test.jsx+++ b/client/src/pages/AIProviders.test.jsx@@ -1498,6 +1498,32 @@ describe('readiness grouping', () => {expect(screen.queryByRole('button', { name: new RegExp('^Needs setup') })).not.toBeInTheDocument();});+ it('badges a Codex provider whose ChatGPT quota is exhausted as Benched under Enabled', async () => {+ api.getCodexAccount.mockResolvedValue({+ readiness: {+ status: 'quota-exhausted',+ account: { planType: 'pro' },+ rateLimits: { primary: { usedPercent: 100 } },+ },+ });+ api.getProviders.mockResolvedValue({+ providers: [{+ id: 'codex',+ name: 'Codex',+ type: 'cli',+ command: 'codex',+ enabled: true,+ }],+ activeProvider: 'codex',+ });++ renderPage();++ expect(await screen.findByText('BENCHED · usage-limit')).toBeInTheDocument();+ expect(screen.getByRole('button', { name: new RegExp('^Enabled') })).toBeInTheDocument();+ expect(screen.queryByRole('button', { name: new RegExp('^Needs setup') })).not.toBeInTheDocument();+ });+it('folds a section away when its header is clicked', async () => {api.getProviders.mockResolvedValue({providers: [{ id: 'off', name: 'Switched Off', type: 'cli', command: 'claude', enabled: false }],diff --git a/client/src/utils/providerReadiness.js b/client/src/utils/providerReadiness.jsindex 3e03d815be..ad49174fb8 100644--- a/client/src/utils/providerReadiness.js+++ b/client/src/utils/providerReadiness.js@@ -382,7 +382,9 @@ export const providerCardState = (provider, {// is a real answer ("nothing missing"). Anything else (an older server, a// payload fetched before the field existed) means not published, and the// local derivation below stands in.- const published = Array.isArray(provider?.missingPrerequisites) ? provider.missingPrerequisites : null;+ const published = Array.isArray(provider?.missingPrerequisites)+ ? provider.missingPrerequisites.filter((entry) => entry?.code !== 'codexQuota')+ : null;const missing = published ? [...published] : [];const addMissing = (code, label) => {if (!missing.some((entry) => entry?.code === code && (code !== 'envVar' || entry?.label === label))) {@@ -428,8 +430,6 @@ export const providerCardState = (provider, {addMissing('codexAccount', 'No ChatGPT account is signed in');} else if (codexSubscription && accountStatus === 'reauth-required') {addMissing('codexAccount', 'ChatGPT sign-in has expired');- } else if (codexSubscription && accountStatus === 'quota-exhausted') {- addMissing('codexQuota', 'ChatGPT usage limit reached');}// Switched off wins over every finding — see the precedence note above. The@@ -438,6 +438,8 @@ export const providerCardState = (provider, {if (codexSubscription && codexAccount === null) return { state: PROVIDER_CARD_STATE.UNKNOWN, missing };if (codexSubscription && accountStatus === 'unknown') return { state: PROVIDER_CARD_STATE.UNKNOWN, missing };if (missing.length > 0) return { state: PROVIDER_CARD_STATE.BLOCKED, missing };- if (status?.available === false) return { state: PROVIDER_CARD_STATE.BENCHED, missing };+ if (status?.available === false || (codexSubscription && accountStatus === 'quota-exhausted')) {+ return { state: PROVIDER_CARD_STATE.BENCHED, missing };+ }return { state: PROVIDER_CARD_STATE.READY, missing };};diff --git a/client/src/utils/providers.test.js b/client/src/utils/providers.test.jsindex 6a501e284e..fc311bfab6 100644--- a/client/src/utils/providers.test.js+++ b/client/src/utils/providers.test.js@@ -1728,6 +1728,30 @@ describe('providerCardState', () => {state: PROVIDER_CARD_STATE.BLOCKED,missing: [{ code: 'codexAccount', label: 'No ChatGPT account is signed in' }],});+ expect(providerCardState(codex, { codexAccount: { status: 'reauth-required' } })).toEqual({+ state: PROVIDER_CARD_STATE.BLOCKED,+ missing: [{ code: 'codexAccount', label: 'ChatGPT sign-in has expired' }],+ });+ expect(providerCardState(codex, { codexAccount: { status: 'quota-exhausted' } })).toEqual({+ state: PROVIDER_CARD_STATE.BENCHED,+ missing: [],+ });+ // A legacy server payload carrying codexQuota finding is filtered out and benched+ expect(providerCardState({+ ...codex,+ missingPrerequisites: [{ code: 'codexQuota', label: 'ChatGPT usage limit reached' }],+ }, { codexAccount: { status: 'quota-exhausted' } })).toEqual({+ state: PROVIDER_CARD_STATE.BENCHED,+ missing: [],+ });+ // A missing runtime still blocks even if quota is also exhausted+ expect(providerCardState(codex, {+ runtime: { label: 'Codex CLI', installed: false },+ codexAccount: { status: 'quota-exhausted' },+ })).toEqual({+ state: PROVIDER_CARD_STATE.BLOCKED,+ missing: [{ code: 'runtime', label: 'Codex CLI is not installed' }],+ });expect(providerCardState(codex, { codexAccount: { status: 'unknown' } })).toEqual({ state: PROVIDER_CARD_STATE.UNKNOWN, missing: [] });expect(providerCardState(codex, { codexAccount: null }))diff --git a/server/lib/providerPrerequisites.js b/server/lib/providerPrerequisites.jsindex 16713ac1f2..872df0c66e 100644--- a/server/lib/providerPrerequisites.js+++ b/server/lib/providerPrerequisites.js@@ -106,8 +106,6 @@ const codexAccountFinding = (provider, readiness) => {return { code: 'codexAccount', label: 'No ChatGPT account is signed in' };case CODEX_ACCOUNT_STATUS.reauthRequired:return { code: 'codexAccount', label: 'ChatGPT sign-in has expired' };- case CODEX_ACCOUNT_STATUS.quotaExhausted:- return { code: 'codexQuota', label: 'ChatGPT usage limit reached' };default:return null;}diff --git a/server/lib/providerPrerequisites.test.js b/server/lib/providerPrerequisites.test.jsindex af13dd922d..9fd2904b1c 100644--- a/server/lib/providerPrerequisites.test.js+++ b/server/lib/providerPrerequisites.test.js@@ -237,3 +237,26 @@ describe('codex routing advisory', () => {.toEqual([]);});});++describe('codex account prerequisites', () => {+ const codex = { id: 'codex', type: 'cli', command: 'codex' };++ it('reports signed-out and reauth-required accounts as missing prerequisites', () => {+ expect(providerPrerequisites(codex, { codexAccount: { status: 'signed-out' } }).missing)+ .toEqual([{ code: 'codexAccount', label: 'No ChatGPT account is signed in' }]);+ expect(providerPrerequisites(codex, { codexAccount: { status: 'reauth-required' } }).missing)+ .toEqual([{ code: 'codexAccount', label: 'ChatGPT sign-in has expired' }]);+ });++ it('treats quota-exhausted as met with no missing prerequisites', () => {+ const result = providerPrerequisites(codex, { codexAccount: { status: 'quota-exhausted' } });+ expect(result.met).toBe(true);+ expect(result.missing).toEqual([]);+ });++ it('ignores codexAccount for non-codex providers', () => {+ const claude = { id: 'claude-code', type: 'cli', command: 'claude' };+ expect(providerPrerequisites(claude, { codexAccount: { status: 'signed-out' } }).missing).toEqual([]);+ });+});+diff --git a/server/routes/providers.codexAccount.test.js b/server/routes/providers.codexAccount.test.jsindex 7e1f29ce8e..526802beaf 100644--- a/server/routes/providers.codexAccount.test.js+++ b/server/routes/providers.codexAccount.test.js@@ -211,6 +211,18 @@ describe('GET /api/providers decorates the Codex cards', () => {expect(cards.codex.missingPrerequisites).toEqual([]);expect(cards.codex.prerequisitesMet).toBe(true);});++ it('does not treat quota exhaustion as a missing prerequisite', async () => {+ codexAppServer.peekCodexAccountReadiness.mockReturnValue({+ ...READY,+ status: CODEX_ACCOUNT_STATUS.quotaExhausted,+ });++ const cards = byId(await request(appWith()).get('/api/providers'));++ expect(cards.codex.missingPrerequisites).toEqual([]);+ expect(cards.codex.prerequisitesMet).toBe(true);+ });});describe('GET /api/providers/codex/models', () => {