feat(quick-pane): polish compact chat controls

This commit is contained in:
2026-08-27 17:18:16 +02:00
parent 60fb91f375
commit 880cddf3cf
11 changed files with 317 additions and 40 deletions
+28 -1
View File
@@ -1,6 +1,9 @@
import type { Model } from "./workspace/types";
export type ModelIdentity = { provider: string; modelId: string };
export type ThinkingLevelOption = { value: string; label: string };
const OFF_THINKING_LEVEL: ThinkingLevelOption = { value: "off", label: "Off" };
export function modelIdentity(model: Model): ModelIdentity | undefined {
if (!model.provider || !model.id) return undefined;
@@ -45,6 +48,25 @@ export function reconcileModelIdentity(
);
}
export function thinkingLevelOptions(model?: Model): ThinkingLevelOption[] {
const map = model?.thinkingLevelMap;
if (!map || typeof map !== "object") return [OFF_THINKING_LEVEL];
const options = Object.keys(map)
.filter((level) => level.trim() && typeof map[level] === "string")
.map((level) => ({
value: level,
label: level === "off" ? "Off" : level[0].toUpperCase() + level.slice(1),
}));
return options.length ? options : [OFF_THINKING_LEVEL];
}
export function reconcileThinkingLevel(model: Model | undefined, level: string) {
const options = thinkingLevelOptions(model);
return options.some((option) => option.value === level)
? level
: options.find((option) => option.value === "off")?.value ?? options[0].value;
}
export function catalogModels(
models: Model[],
configured: ModelIdentity[],
@@ -60,7 +82,12 @@ export function catalogModels(
if (!identity.provider || !identity.modelId) continue;
const key = modelIdentityValue(identity);
if (keys.has(key)) continue;
available.unshift({ provider: identity.provider, id: identity.modelId });
available.unshift({
provider: identity.provider,
id: identity.modelId,
// Configured/local models are not catalog-confirmed. Do not imply thinking support.
thinkingLevelMap: { off: "off" },
});
keys.add(key);
}
return available;