mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-21 14:22:14 +03:00
Merged as part of the 39-PR owner batch of 2026-09-11, validated as a unit. Boarded into one consolidated worktree cut from `release/v3.8.51` with the other 38 — zero conflicts between them. - ESLint over every changed file: no errors (the only finding was one suppression entry the batch emptied, pruned on #13243) - `typecheck:core` clean; `check:dashboard-typecheck` OK (206 pre-existing, within baseline); `check:changelog-integrity` OK - complexity 2821 / baseline 3218 and cognitive-complexity 1272 / baseline 1437 — both under baseline - 256 assertions green: 246 under node:test and 10 under vitest, which is where `tests/unit/**/*.test.tsx` actually runs - `check-file-size`: `chatCore.ts` rebaselined 6144 → 6146 for #13278 and #13276, annotated and landed on #13243 ⚠️ base-red inherited: #12732 — the provider count (356 in the docs vs the 358 the modules define) and `open-sse/utils/stream.ts` at 3115 > frozen 3098 both reproduce on the pure tip with zero contribution from this batch.
34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import type { CompressionConfig, CompressionPipelineStep } from "./types.ts";
|
|
import { deriveDefaultPlan, type DerivedPlan } from "./deriveDefaultPlan.ts";
|
|
|
|
/** Named-combo map: combo id -> its stacked pipeline (operator-defined profiles). */
|
|
export type NamedCombos = Record<string, CompressionPipelineStep[]>;
|
|
|
|
/**
|
|
* Derives the plan a live request would actually run, for STATIC preview surfaces (the
|
|
* Settings-page "Effective pipeline" text — issue #12063). Mirrors resolveBasePlan's
|
|
* precedence for the two layers that apply to an at-rest preview — the master switch, then an
|
|
* explicit active profile — but skips the request-scoped layers that don't apply outside a
|
|
* live call (request header, routing-combo override, auto-trigger): those need per-request
|
|
* context this static preview does not have.
|
|
*
|
|
* Precedence (mirrors strategySelector.ts's resolveBasePlan):
|
|
* 1. masterEnabled=false -> off
|
|
* 2. activeComboId resolves in combos -> that profile's stacked pipeline (an explicit
|
|
* operator choice, which resolveBasePlan gives precedence over the plain engines-derived
|
|
* default)
|
|
* 3. otherwise -> deriveDefaultPlan(engines, enabled)
|
|
*/
|
|
export function deriveEffectivePreviewPlan(
|
|
config: Pick<CompressionConfig, "engines" | "enabled" | "activeComboId">,
|
|
combos: NamedCombos = {}
|
|
): DerivedPlan {
|
|
if (!config.enabled) return { mode: "off", stackedPipeline: [] };
|
|
|
|
if (config.activeComboId && combos[config.activeComboId]) {
|
|
return { mode: "stacked", stackedPipeline: combos[config.activeComboId] };
|
|
}
|
|
|
|
return deriveDefaultPlan(config.engines, config.enabled);
|
|
}
|