From ca7c55b76448052e76ecb5ff67cc4dbbf05b30b9 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Wed, 15 Jul 2026 11:17:06 -0300 Subject: [PATCH] fix(dashboard): extract getCodexPlanLabel to unfreeze providerPageHelpers.ts The Fast Quality Gates file-size ratchet froze providerPageHelpers.ts at 1053 lines; adding getCodexPlanLabel inline pushed it to 1067. Move the self-contained helper into its own codexPlanLabel.ts module instead of growing the frozen file, and repoint ConnectionRow.tsx + the regression test at the new location. No behavior change. --- .../providers/[id]/codexPlanLabel.ts | 19 +++++++++++++++++++ .../[id]/components/ConnectionRow.tsx | 2 +- .../providers/[id]/providerPageHelpers.ts | 16 ---------------- tests/unit/codex-plan-label-2570.test.ts | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 src/app/(dashboard)/dashboard/providers/[id]/codexPlanLabel.ts diff --git a/src/app/(dashboard)/dashboard/providers/[id]/codexPlanLabel.ts b/src/app/(dashboard)/dashboard/providers/[id]/codexPlanLabel.ts new file mode 100644 index 0000000000..767bd651cd --- /dev/null +++ b/src/app/(dashboard)/dashboard/providers/[id]/codexPlanLabel.ts @@ -0,0 +1,19 @@ +/** + * Codex subscription plan label (e.g. "Plus", "Pro", "Team"), persisted on the + * connection's providerSpecificData.chatgptPlanType at OAuth import time (see + * src/lib/oauth/services/codexImport.ts). Returns "" when the connection is + * not Codex or the value is missing/blank — callers gate rendering on that. + * + * Kept in its own module (not providerPageHelpers.ts) because that file is + * frozen at its file-size ratchet cap (config/quality/file-size-baseline.json) + * and this helper is fully self-contained. + */ +export function getCodexPlanLabel(isCodex: boolean, providerSpecificData: unknown): string { + if (!isCodex) return ""; + const record = + providerSpecificData && typeof providerSpecificData === "object" + ? (providerSpecificData as Record) + : {}; + const raw = record.chatgptPlanType; + return typeof raw === "string" ? raw.trim() : ""; +} diff --git a/src/app/(dashboard)/dashboard/providers/[id]/components/ConnectionRow.tsx b/src/app/(dashboard)/dashboard/providers/[id]/components/ConnectionRow.tsx index 2f93c1d275..72e9229c02 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/components/ConnectionRow.tsx +++ b/src/app/(dashboard)/dashboard/providers/[id]/components/ConnectionRow.tsx @@ -17,10 +17,10 @@ import { } from "@/lib/providers/codexFastTier"; import { normalizeCodexLimitPolicy, - getCodexPlanLabel, providerText, ERROR_TYPE_LABELS, } from "../providerPageHelpers"; +import { getCodexPlanLabel } from "../codexPlanLabel"; // --------------------------------------------------------------------------- // Types (exported so the client can reference them without re-importing) diff --git a/src/app/(dashboard)/dashboard/providers/[id]/providerPageHelpers.ts b/src/app/(dashboard)/dashboard/providers/[id]/providerPageHelpers.ts index 28941716e4..4345d11962 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/providerPageHelpers.ts +++ b/src/app/(dashboard)/dashboard/providers/[id]/providerPageHelpers.ts @@ -735,22 +735,6 @@ export function normalizeCodexLimitPolicy(policy: unknown): { use5h: boolean; us }; } -/** - * Codex subscription plan label (e.g. "Plus", "Pro", "Team"), persisted on the - * connection's providerSpecificData.chatgptPlanType at OAuth import time (see - * src/lib/oauth/services/codexImport.ts). Returns "" when the connection is - * not Codex or the value is missing/blank — callers gate rendering on that. - */ -export function getCodexPlanLabel(isCodex: boolean, providerSpecificData: unknown): string { - if (!isCodex) return ""; - const record = - providerSpecificData && typeof providerSpecificData === "object" - ? (providerSpecificData as Record) - : {}; - const raw = record.chatgptPlanType; - return typeof raw === "string" ? raw.trim() : ""; -} - /** * UI adapter around the canonical getCodexRequestDefaults from requestDefaults.ts. * Adds the "medium" fallback for reasoningEffort required by the connection form. diff --git a/tests/unit/codex-plan-label-2570.test.ts b/tests/unit/codex-plan-label-2570.test.ts index e18a423c72..2b22445266 100644 --- a/tests/unit/codex-plan-label-2570.test.ts +++ b/tests/unit/codex-plan-label-2570.test.ts @@ -17,7 +17,7 @@ // instead of the plan captured at login. import { test } from "node:test"; import assert from "node:assert/strict"; -import { getCodexPlanLabel } from "@/app/(dashboard)/dashboard/providers/[id]/providerPageHelpers"; +import { getCodexPlanLabel } from "@/app/(dashboard)/dashboard/providers/[id]/codexPlanLabel"; import { resolvePlanValue } from "@/app/(dashboard)/dashboard/usage/components/ProviderLimits/utils"; test("getCodexPlanLabel returns the trimmed chatgptPlanType for codex connections", () => {