refactor(ui): move nonReasoningTierFields into its own module

Upstream grew ClassificationMethodConfig.tsx to 783 lines, so the 14 lines this
PR added there pushed the merge result past the 800-line max-lines cap. The
helper is standalone logic with its own unit tests, so it moves out rather than
the cap moving up.
This commit is contained in:
moe-berri 2026-09-08 15:57:08 -07:00
parent c7b80f1966
commit 17e3dc1c79
3 changed files with 16 additions and 14 deletions

View file

@ -17,6 +17,7 @@ import ClassifierReasoningEffortSelect from "./ClassifierReasoningEffortSelect";
import ClassifierCircuitBreakerConfig from "./ClassifierCircuitBreakerConfig";
import ClassifierVisionConfig from "./ClassifierVisionConfig";
import type { ReasoningEffort } from "./complexity_router_tiers";
import { nonReasoningTierFields } from "./nonReasoningTierFields";
import { useComplexityScorerDefaults } from "@/app/(dashboard)/hooks/autoRouter/useComplexityScorerDefaults";
import {
ClassificationFrequency,
@ -237,19 +238,6 @@ const ClassifierTypeRadios: React.FC<{
);
};
/** The NON_REASONING keys a classifier switch carries forward, or clears for a classifier that
* cannot emit the tier. Leaving them set there is a config the backend refuses on save. */
export const nonReasoningTierFields = (
classifierType: ClassifierType,
value: ComplexityRouterConfigValue,
): Pick<ComplexityRouterConfigValue, "enable_non_reasoning_tier" | "tiers"> => {
if (classifierType === "llm") {
return { enable_non_reasoning_tier: value.enable_non_reasoning_tier, tiers: value.tiers };
}
const { NON_REASONING: _cleared, ...keptTiers } = value.tiers;
return { enable_non_reasoning_tier: undefined, tiers: keptTiers };
};
const ClassificationMethodConfig: React.FC<ClassificationMethodConfigProps> = ({
value,
onChange,

View file

@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import type { ComplexityRouterConfigValue } from "./ComplexityRouterConfig";
import { nonReasoningTierFields } from "./ClassificationMethodConfig";
import { nonReasoningTierFields } from "./nonReasoningTierFields";
const enabledValue: ComplexityRouterConfigValue = {
classifier_type: "llm",

View file

@ -0,0 +1,14 @@
import type { ClassifierType, ComplexityRouterConfigValue } from "./ComplexityRouterConfig";
/** The NON_REASONING keys a classifier switch carries forward, or clears for a classifier that
* cannot emit the tier. Leaving them set there is a config the backend refuses on save. */
export const nonReasoningTierFields = (
classifierType: ClassifierType,
value: ComplexityRouterConfigValue,
): Pick<ComplexityRouterConfigValue, "enable_non_reasoning_tier" | "tiers"> => {
if (classifierType === "llm") {
return { enable_non_reasoning_tier: value.enable_non_reasoning_tier, tiers: value.tiers };
}
const { NON_REASONING: _cleared, ...keptTiers } = value.tiers;
return { enable_non_reasoning_tier: undefined, tiers: keptTiers };
};