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.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-07-15 11:17:06 -03:00
parent 004883090f
commit ca7c55b764
4 changed files with 21 additions and 18 deletions

View File

@@ -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<string, unknown>)
: {};
const raw = record.chatgptPlanType;
return typeof raw === "string" ? raw.trim() : "";
}

View File

@@ -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)

View File

@@ -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<string, unknown>)
: {};
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.

View File

@@ -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", () => {