





























@@ -5,7 +5,11 @@ import { icons } from "../icons.ts";
55import { pathForTab } from "../navigation.ts";
66import { formatSessionTokens } from "../presenter.ts";
77import { normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "../string-coerce.ts";
8-import { normalizeThinkLevel } from "../thinking.ts";
8+import {
9+formatInheritedThinkingLabel,
10+formatThinkingOverrideLabel,
11+normalizeThinkingOptionValue,
12+} from "../thinking-labels.ts";
913import type {
1014AgentIdentityResult,
1115GatewaySessionRow,
@@ -88,27 +92,42 @@ function getAgentIdentity(
8892 : null;
8993}
909491-function normalizeThinkingOptionValue(raw: string): string {
92-return normalizeThinkLevel(raw) ?? normalizeLowercaseStringOrEmpty(raw);
95+function rowMatchesSessionDefaults(
96+row: GatewaySessionRow,
97+defaults: SessionsListResult["defaults"] | undefined,
98+): boolean {
99+return (
100+(!row.modelProvider || row.modelProvider === defaults?.modelProvider) &&
101+(!row.model || row.model === defaults?.model)
102+);
93103}
9410495105function resolveThinkLevelOptions(
96106row: GatewaySessionRow,
107+defaults?: SessionsListResult["defaults"],
97108): readonly { value: string; label: string }[] {
98-const defaultLabel = row.thinkingDefault
99- ? t("sessionsView.defaultOption", { value: row.thinkingDefault })
100- : t("sessionsView.inherit");
109+const sessionModelMatchesDefaults = rowMatchesSessionDefaults(row, defaults);
110+const defaultLabel = formatInheritedThinkingLabel(
111+row.thinkingDefault ?? (sessionModelMatchesDefaults ? defaults?.thinkingDefault : undefined),
112+);
101113const options: readonly GatewayThinkingLevelOption[] = row.thinkingLevels?.length
102114 ? row.thinkingLevels
103- : (row.thinkingOptions?.length ? row.thinkingOptions : DEFAULT_THINK_LEVELS).map((label) => ({
104-id: normalizeThinkingOptionValue(label),
105- label,
106-}));
115+ : sessionModelMatchesDefaults && defaults?.thinkingLevels?.length
116+ ? defaults.thinkingLevels
117+ : (row.thinkingOptions?.length
118+ ? row.thinkingOptions
119+ : sessionModelMatchesDefaults && defaults?.thinkingOptions?.length
120+ ? defaults.thinkingOptions
121+ : DEFAULT_THINK_LEVELS
122+).map((label) => ({
123+id: normalizeThinkingOptionValue(label),
124+ label,
125+}));
107126return [
108127{ value: "", label: defaultLabel },
109128 ...options.map((option) => ({
110129value: normalizeThinkingOptionValue(option.id),
111-label: option.label,
130+label: formatThinkingOverrideLabel(option.id, option.label),
112131})),
113132];
114133}
@@ -133,10 +152,7 @@ function withCurrentLabeledOption(
133152if (options.some((option) => option.value === current)) {
134153return [...options];
135154}
136-return [
137- ...options,
138-{ value: current, label: t("sessionsView.customOption", { value: current }) },
139-];
155+return [...options, { value: current, label: formatThinkingOverrideLabel(current) }];
140156}
141157142158function buildVerboseLevelOptions(): Array<{ value: string; label: string }> {
@@ -689,7 +705,10 @@ function renderRows(row: GatewaySessionRow, props: SessionsProps) {
689705const updated = row.updatedAt ? formatRelativeTimestamp(row.updatedAt) : t("common.na");
690706const rawThinking = row.thinkingLevel ?? "";
691707const thinking = rawThinking ? normalizeThinkingOptionValue(rawThinking) : "";
692-const thinkLevels = withCurrentLabeledOption(resolveThinkLevelOptions(row), thinking);
708+const thinkLevels = withCurrentLabeledOption(
709+resolveThinkLevelOptions(row, props.result?.defaults),
710+thinking,
711+);
693712const fastMode = row.fastMode === true ? "on" : row.fastMode === false ? "off" : "";
694713const fastLevels = withCurrentLabeledOption(buildFastLevelOptions(), fastMode);
695714const verbose = row.verboseLevel ?? "";
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。