mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-15 16:40:44 +00:00
Merged via squash.
Prepared head SHA: f027bd640a
Co-authored-by: dutifulbob <261991368+dutifulbob@users.noreply.github.com>
Co-authored-by: osolmaz <2453968+osolmaz@users.noreply.github.com>
Reviewed-by: @osolmaz
26 lines
965 B
TypeScript
26 lines
965 B
TypeScript
import type { SessionEntry } from "../config/sessions.js";
|
|
import { normalizeOptionalString } from "../shared/string-coerce.js";
|
|
|
|
export type FallbackNoticeState = Pick<
|
|
SessionEntry,
|
|
"fallbackNoticeSelectedModel" | "fallbackNoticeActiveModel" | "fallbackNoticeReason"
|
|
>;
|
|
|
|
export function resolveActiveFallbackState(params: {
|
|
selectedModelRef: string;
|
|
activeModelRef: string;
|
|
state?: FallbackNoticeState;
|
|
}): { active: boolean; reason?: string } {
|
|
const selected = normalizeOptionalString(params.state?.fallbackNoticeSelectedModel);
|
|
const active = normalizeOptionalString(params.state?.fallbackNoticeActiveModel);
|
|
const reason = normalizeOptionalString(params.state?.fallbackNoticeReason);
|
|
const fallbackActive =
|
|
params.selectedModelRef !== params.activeModelRef &&
|
|
selected === params.selectedModelRef &&
|
|
active === params.activeModelRef;
|
|
return {
|
|
active: fallbackActive,
|
|
reason: fallbackActive ? reason : undefined,
|
|
};
|
|
}
|