fix(agents): pick the model from the list and set its options from one chip (#5012)

The composer's model controls had three ways into the same settings: a "High" detail next to the model chip with a half divider and no chevron, a "Low ›" entry on model list rows leading to a settings page with a back arrow, and inside it a dropdown for Codex's six effort levels — two steps to change effort. While a model's settings loaded, a "Loading model settings…" text broke the row's alignment.

Now the model chip only picks (and pins) models, and the chip next to it opens every option of the current model — effort, context size, fast mode — in one popup, each a click away: on/off as a switch, up to five values as a segmented control, more listed. A model with a single option closes the popup on a choice. The chip has a chevron like the other composer chips, and a spinner takes its place while settings load. Configuring a model other than the current one from its list row is gone.
This commit is contained in:
l0ng-ai
2026-11-21 20:46:14 +08:00
committed by GitHub
parent a9971905dc
commit 5e6a59eae8
11 changed files with 144 additions and 291 deletions
+8 -14
View File
@@ -285,7 +285,7 @@ async function expectNoSubmission(page: Page) {
}
for (const surface of ["new", "task"] as const) {
test(`${surface}: configure another model from its row, then edit its context from the composer`, async ({
test(`${surface}: switch models from the list, then set effort and context from the settings chip`, async ({
workbench: page,
}) => {
const context = option(
@@ -306,22 +306,16 @@ for (const surface of ["new", "task"] as const) {
await modelButton(page).click();
const row = page.getByRole("option", { name: /^Swift\b/ });
await row.hover();
const configure = row.getByRole("button", { name: "Configure Swift…" });
if (surface === "task") await configure.press("Enter");
else await configure.click();
await expect(modelButton(page)).toHaveText("Atlas");
await expect(page.getByRole("radio", { name: "Gentle" })).toHaveCount(0);
await page.getByRole("radio", { name: "Thorough" }).click();
await expect(row.getByRole("button", { name: /^Configure/ })).toHaveCount(0);
if (surface === "task") await row.press("Enter");
else await row.click();
await expect(modelButton(page)).toHaveText("Swift");
await expect(page.getByRole("radio", { name: "Thorough" })).toBeChecked();
await page.keyboard.press("Escape");
const settings = page.getByRole("button", { name: /^Model settings:/ });
await expect(settings).toHaveText("Thorough · 200K");
await settings.click();
await expect(page.getByRole("button", { name: "Back to models" })).toHaveCount(0);
await page.getByRole("radio", { name: "Thorough" }).click();
await page.getByRole("radio", { name: "1M" }).click();
await expect(settings).toHaveText("Thorough · 1M");
await page.getByRole("button", { name: "Back to models" }).click();
await expect(page.getByRole("listbox", { name: "Model", exact: true })).toBeVisible();
await page.keyboard.press("Escape");
await expect(box(page)).toHaveText("Review the project structure");
await expectNoSubmission(page);
@@ -642,7 +636,7 @@ test("New Task discovers uncached model effort before the first prompt", async (
await expect
.poll(async () => (await ipcCalls(page, "agent_refresh_models")).filter((call) => call.model === "swift"))
.toEqual([{ provider: provider.id, force: false, model: "swift" }]);
await expect(page.getByRole("status").filter({ hasText: "Loading model settings…" })).toBeVisible();
await expect(page.getByRole("status", { name: "Loading model settings…" })).toBeVisible();
await expect(effortLabel(page)).toHaveCount(0);
await page.screenshot({ path: testInfo.outputPath("model-settings-loading.png") });
await page.evaluate(() => document.dispatchEvent(new Event("test:model-settings-ready")));
@@ -671,7 +665,7 @@ test("an existing chat can choose effort for a refreshed model before sending",
await page.getByRole("button", { name: "Refresh models", exact: true }).click();
await swiftModel.click();
const loading = page.getByRole("status").filter({ hasText: "Loading model settings…" });
const loading = page.getByRole("status", { name: "Loading model settings…" });
const send = page.getByRole("button", { name: "Send", exact: true });
await expect(loading).toBeVisible();
await expect(send).toBeDisabled();
+6 -33
View File
@@ -121,10 +121,6 @@
.modelControl {
align-items: center;
}
.modelDetail {
box-shadow: inset 1px 0 var(--border);
color: var(--fg-muted);
}
.configPicker > button {
max-width: 100%;
}
@@ -164,6 +160,11 @@
white-space: nowrap;
transition: background var(--dur-fast) var(--ease);
}
.chip.chipLoading,
.chip.chipLoading:hover {
color: var(--fg-muted);
background: none;
}
.chip:hover,
.chip[aria-expanded="true"] {
background: var(--bg-toolbar-hover);
@@ -233,16 +234,6 @@
gap: var(--space-3);
padding: 4px 12px 10px;
}
.modelSettingsHeader {
display: flex;
align-items: center;
gap: var(--space-2);
}
.modelSettingsHeader strong {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.quickRow {
display: flex;
flex-direction: column;
@@ -258,8 +249,7 @@
}
.modelEffortPopup [role="option"]:hover .modelRowConfigure,
.modelEffortPopup [role="option"][aria-selected="true"] .modelRowConfigure,
.modelEffortPopup [role="option"]:focus-within .modelRowConfigure,
.modelEffortPopup [role="option"] .currentRowSettings {
.modelEffortPopup [role="option"]:focus-within .modelRowConfigure {
opacity: 1;
}
.modelRowConfigure {
@@ -274,23 +264,6 @@
color: var(--fg-muted);
cursor: pointer;
}
.modelRowSettings {
display: inline-flex;
align-items: center;
gap: var(--space-0-5);
width: auto;
max-width: 120px;
padding-inline: 4px;
font-size: var(--fs-small);
}
.modelRowSettings span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.modelRowSettings svg {
flex: none;
}
.modelRowConfigure:hover,
.modelRowConfigure:focus-visible {
outline: none;
+30 -23
View File
@@ -350,7 +350,7 @@ describe("model settings", () => {
expect(onChange).toHaveBeenCalledExactlyOnceWith("reasoning_effort", "xhigh");
});
it("offers more effort levels than fit the segmented control as a dropdown", () => {
it("lists more effort levels than fit the segmented control, one click away", () => {
const onChange = vi.fn();
const config = copilotConfig().map((o) =>
o.category === "thought_level"
@@ -367,9 +367,13 @@ describe("model settings", () => {
fireEvent.click(screen.getByRole("button", { name: "Model settings: Max" }));
const dialog = screen.getByRole("dialog", { name: "Model settings" });
expect(within(dialog).queryByRole("radiogroup", { name: "Effort Level" })).not.toBeInTheDocument();
fireEvent.click(within(dialog).getByRole("button", { name: /Reasoning Effort/ }));
fireEvent.click(screen.getByRole("option", { name: /Extra high/ }));
expect(onChange).toHaveBeenCalledWith("reasoning_effort", "extra-high");
expect(within(dialog).queryByRole("button", { name: /Reasoning Effort/ })).not.toBeInTheDocument();
const levels = within(dialog).getByRole("listbox", { name: "Effort Level" });
expect(within(levels).getByRole("option", { name: /Max/ })).toHaveAttribute("aria-selected", "true");
fireEvent.click(within(levels).getByRole("option", { name: /Extra high/ }));
expect(onChange).toHaveBeenCalledExactlyOnceWith("reasoning_effort", "extra-high");
// The only setting: choosing it is done.
expect(screen.queryByRole("dialog", { name: "Model settings" })).not.toBeInTheDocument();
});
it("tucks Fast into the model popup", () => {
@@ -392,7 +396,7 @@ describe("model settings", () => {
expect(within(dialog).getByRole("switch", { name: "Fast" })).toHaveAttribute("aria-checked", "false");
});
it("opens settings from the selected row without choosing it and returns to a pinnable model list", () => {
it("keeps the model list to models and the settings chip to every model setting", () => {
const onChange = vi.fn();
const cfg = copilotConfig().map((o) =>
o.id === "model"
@@ -417,32 +421,35 @@ describe("model settings", () => {
render(<ConfigPickers config={cfg} onChange={onChange} />);
const model = screen.getByRole("button", { name: "Model" });
expect(model).toHaveTextContent("Claude Sonnet 5.5");
expect(screen.getByRole("button", { name: /^Model settings:/ })).toHaveTextContent("medium · 1M");
const settings = screen.getByRole("button", { name: /^Model settings:/ });
expect(settings).toHaveTextContent("medium · 1M");
fireEvent.click(model);
const dialog = screen.getByRole("dialog", { name: "Model" });
expect(within(dialog).queryByText("Balanced")).not.toBeInTheDocument();
expect(within(dialog).getByText("Medium cost")).toBeVisible();
expect(within(dialog).queryByRole("radio")).not.toBeInTheDocument();
fireEvent.click(within(dialog).getByRole("button", { name: "Configure Claude Sonnet 5.5…" }));
expect(onChange).not.toHaveBeenCalled();
const models = screen.getByRole("dialog", { name: "Model" });
expect(within(models).queryByText("Balanced")).not.toBeInTheDocument();
expect(within(models).getByText("Medium cost")).toBeVisible();
expect(within(models).queryByRole("radio")).not.toBeInTheDocument();
expect(within(models).queryByRole("button", { name: /^Configure/ })).not.toBeInTheDocument();
fireEvent.click(within(models).getAllByRole("button", { name: "Pin model" })[0]!);
const listbox = within(models).getByRole("listbox", { name: "Model" });
expect(within(listbox).getByText("Pinned")).toBeVisible();
expect(within(listbox).getByText("Models")).toBeVisible();
fireEvent.click(within(models).getByRole("option", { name: /GPT-6 Sol/ }));
expect(onChange).toHaveBeenCalledExactlyOnceWith("model", "gpt-6-sol");
expect(screen.queryByRole("dialog", { name: "Model" })).not.toBeInTheDocument();
onChange.mockClear();
fireEvent.click(settings);
const dialog = screen.getByRole("dialog", { name: "Model settings" });
expect(within(dialog).queryByRole("button", { name: "Back to models" })).not.toBeInTheDocument();
const effortGroup = within(dialog).getByRole("radiogroup", { name: "Effort Level" });
expect(within(effortGroup).getByRole("radio", { name: "medium" })).toHaveAttribute("aria-checked", "true");
const contextGroup = within(dialog).getByRole("radiogroup", { name: "Context Size" });
expect(within(contextGroup).getByRole("radio", { name: "1M" })).toHaveAttribute("aria-checked", "true");
fireEvent.click(within(contextGroup).getByRole("radio", { name: "200K" }));
expect(onChange).toHaveBeenCalledWith("contextTier", "default");
fireEvent.click(within(dialog).getByRole("button", { name: "Back to models" }));
fireEvent.click(within(dialog).getAllByRole("button", { name: "Pin model" })[0]!);
const listbox = within(dialog).getByRole("listbox", { name: "Model" });
expect(within(listbox).getByText("Pinned")).toBeVisible();
expect(within(listbox).getByText("Models")).toBeVisible();
fireEvent.click(within(dialog).getByRole("option", { name: /GPT-6 Sol/ }));
expect(onChange).toHaveBeenCalledWith("model", "gpt-6-sol");
expect(screen.queryByRole("dialog", { name: "Model" })).not.toBeInTheDocument();
expect(onChange).toHaveBeenCalledExactlyOnceWith("contextTier", "default");
// Several settings: the popup stays for the next one.
expect(screen.getByRole("dialog", { name: "Model settings" })).toBeInTheDocument();
});
it("filters the model list and picks the highlighted model with the keyboard", () => {
+92 -139
View File
@@ -7,6 +7,7 @@ import type { AgentConfigOption } from "@/bindings";
import { useTx } from "@/platform/i18n";
import { Icon, IconButton, Popup, Select, T, Toggle } from "@/ui";
import { SelectListbox, type SelectOption } from "@/ui/Select";
import { Spinner } from "@/ui/Spinner";
import { isContextOption, mainOptions, modelConfigOptions, modeIcon } from "./composerModel";
import { togglePinnedModel, useAgents } from "./store";
import styles from "./Composer.module.css";
@@ -76,7 +77,7 @@ function switchValues(option: AgentConfigOption): { on: string; off: string } |
const selected = (option: AgentConfigOption, value: string | null) =>
option.values.find((v) => v.value === value) ?? null;
type ChangeOption = (option: string, value: string, forModel?: string) => void;
type ChangeOption = (option: string, value: string) => void;
interface ModelRefresh {
draft?: boolean;
@@ -86,12 +87,6 @@ interface ModelRefresh {
error: string | null;
onOpen?: () => void;
onRefresh: () => void;
preview?: {
/** Undefined until discovery; an empty array means the agent reported no settings. */
settingsFor: (model: string) => AgentConfigOption[] | undefined;
load: (model: string) => void;
errorFor: (model: string) => string | null | undefined;
};
}
export function ConfigPickers({
@@ -168,11 +163,7 @@ export function ConfigPickers({
) : (
<ConfigPicker option={o} value={valueOf(o)} onChange={onChange} />
)}
{o === model && modelRefresh?.loadingSettings && (
<span className={styles.pickerValue} role="status">
<T>Loading model settings…</T>
</span>
)}
{o === model && !combinedModel && modelRefresh?.loadingSettings && <LoadingSettingsChip />}
</span>
))}
{secondary.length > 0 && (
@@ -261,8 +252,8 @@ function ConfigPicker({
);
}
/** Effort levels that fit the popup's segmented control; more (Codex has six) get a dropdown. */
const SEGMENTED_EFFORT_MAX = 5;
/** Values a setting shows as a segmented control; a longer list (Codex has six effort levels) is listed. */
const SEGMENTED_MAX = 5;
function settingName(option: AgentConfigOption) {
return option.category === "thought_level"
@@ -299,7 +290,8 @@ function ModelPicker({
modelRefresh?: ModelRefresh;
}) {
const tx = useTx();
const [page, setPage] = useState<"models" | { model: string | null } | null>(null);
// The model chip picks a model; the settings chip next to it holds the model's settings.
const [open, setOpen] = useState<"models" | "settings" | null>(null);
const pinnedModels = useAgents((s) => s.pinnedModels);
const anchor = useRef<HTMLSpanElement>(null);
const selectedModel = selected(model, modelValue);
@@ -307,15 +299,12 @@ function ModelPicker({
const modelName = unavailable
? tx`${modelValue} (unavailable)`
: (selectedModel?.name ?? (modelRefresh ? modelValue : null) ?? tx("Default"));
const summary = settingsSummary(settings, tx);
const settingsFor = (id: string | null) =>
id === modelValue ? settings : id ? modelRefresh?.preview?.settingsFor(id) : undefined;
const details = page && page !== "models" && (page.model === modelValue || selected(model, page.model)) ? page : null;
const inspectedModel = details ? selected(model, details.model) : null;
const openModels = () => {
modelRefresh?.onOpen?.();
setPage("models");
const shown = settings.filter((o) => o.values.length > 0);
const summary = settingsSummary(shown, tx);
const toggle = (which: "models" | "settings") => {
if (open === which) return setOpen(null);
if (which === "models") modelRefresh?.onOpen?.();
setOpen(which);
};
return (
@@ -325,46 +314,41 @@ function ModelPicker({
className={styles.chip}
aria-label={tx(model.name)}
aria-haspopup="dialog"
aria-expanded={!!page && !details}
aria-expanded={open === "models"}
title={`${tx(model.name)}: ${modelName}`}
onClick={() => (page && !details ? setPage(null) : openModels())}
onClick={() => toggle("models")}
>
<span className={styles.chipValue}>{modelName}</span>
<Icon name="chevron-down" size={14} className={styles.chipChevron} />
</button>
{summary && !unavailable && (
<button
type="button"
className={clsx(styles.chip, styles.modelDetail)}
aria-label={tx`Model settings: ${summary}`}
title={tx`Configure ${modelName}…`}
aria-haspopup="dialog"
aria-expanded={!!details && details.model === modelValue}
onClick={() => setPage(details && details.model === modelValue ? null : { model: modelValue })}
>
<span className={styles.chipValue}>{summary}</span>
</button>
{!unavailable && modelRefresh?.loadingSettings ? (
<LoadingSettingsChip />
) : (
summary &&
!unavailable && (
<button
type="button"
className={clsx(styles.chip, styles.modelDetail)}
aria-label={tx`Model settings: ${summary}`}
title={tx`Configure ${modelName}…`}
aria-haspopup="dialog"
aria-expanded={open === "settings"}
onClick={() => toggle("settings")}
>
<span className={styles.chipValue}>{summary}</span>
<Icon name="chevron-down" size={14} className={styles.chipChevron} />
</button>
)
)}
<Popup
open={!!page}
open={!!open}
anchor={anchor}
onClose={() => setPage(null)}
aria-label={tx(details ? "Model settings" : "Model")}
onClose={() => setOpen(null)}
aria-label={tx(open === "settings" ? "Model settings" : "Model")}
className={styles.modelEffortPopup}
>
{details ? (
<ModelSettings
key={details.model}
id={details.model}
name={inspectedModel?.name ?? modelName}
settings={settingsFor(details.model)}
modelRefresh={modelRefresh}
onBack={openModels}
onChange={(option, value) => {
if (details.model && details.model !== modelValue) onChange(option, value, details.model);
else onChange(option, value);
}}
/>
{open === "settings" ? (
<ModelSettings settings={shown} onChange={onChange} onDone={() => setOpen(null)} />
) : (
<>
{unavailable && (
@@ -381,16 +365,12 @@ function ModelPicker({
listClassName={styles.modelList}
onChoose={(v) => {
onChange(model.id, v);
setPage(null);
setOpen(null);
}}
renderAction={(opt) => {
const raw = model.values.find((v) => v.value === opt.value);
if (!raw) return null;
const pinned = pinnedModels.includes(raw.value);
const rowSettings = settingsFor(raw.value);
const configurable = rowSettings
? rowSettings.some((o) => o.values.length > 0)
: !!modelRefresh?.preview;
return (
<>
<CostBadge category={raw.costCategory} />
@@ -404,23 +384,6 @@ function ModelPicker({
>
<Icon name="pin" size={12} />
</button>
{configurable && (
<button
type="button"
className={clsx(
styles.modelRowConfigure,
styles.modelRowSettings,
raw.value === modelValue && styles.currentRowSettings,
)}
title={tx`Configure ${opt.label}…`}
aria-label={tx`Configure ${opt.label}…`}
aria-haspopup="dialog"
onClick={() => setPage({ model: raw.value })}
>
{rowSettings && <span>{settingsSummary(rowSettings, tx)}</span>}
<Icon name="chevron-right" size={14} />
</button>
)}
</>
);
}}
@@ -438,82 +401,72 @@ function ModelPicker({
);
}
/**
* The current model's settings (effort, context size, fast mode…), each a click away: an on/off
* setting as a switch, a short list as a segmented control, a longer one listed. A model with
* one setting closes on a choice.
*/
function ModelSettings({
id,
name,
settings,
modelRefresh,
onBack,
onChange,
onDone,
}: {
id: string | null;
name: string;
settings: AgentConfigOption[] | undefined;
modelRefresh?: ModelRefresh;
onBack: () => void;
settings: AgentConfigOption[];
onChange: ChangeOption;
onDone: () => void;
}) {
const tx = useTx();
const attempted = useRef(false);
const lookup = modelRefresh?.preview;
const refreshing = modelRefresh?.refreshing;
useEffect(() => {
if (!id || settings || !lookup || refreshing || attempted.current) return;
attempted.current = true;
lookup.load(id);
}, [id, settings, lookup, refreshing]);
const loading = modelRefresh?.loadingSettings || (!settings && refreshing);
const error = !settings && id && lookup?.errorFor(id);
const only = settings.length === 1;
return (
<div className={styles.quickSettings}>
<div className={styles.modelSettingsHeader}>
<IconButton autoFocus icon="arrow-left" title="Back to models" size="small" onClick={onBack} />
<strong>{name}</strong>
</div>
{loading ? (
<p role="status">
<T>Loading model settings…</T>
</p>
) : error ? (
<p role="alert" className={styles.catalogError}>{tx`Could not refresh models: ${error}`}</p>
) : !settings?.some((o) => o.values.length) ? (
<p role="status">
<T>No settings reported for this model.</T>
</p>
) : (
settings
.filter((o) => o.values.length > 0)
.map((o) => {
const label = tx(settingName(o));
const segmented =
isContextOption(o.id) || (o.category === "thought_level" && o.values.length <= SEGMENTED_EFFORT_MAX);
return (
<div key={o.id} className={styles.quickRow}>
<span className={styles.quickLabel} title={o.description ?? undefined}>
{label}
</span>
{segmented ? (
<SegmentedControl
ariaLabel={label}
options={o.values.map((v) => ({
value: v.value,
label: v.name,
description: v.description ?? undefined,
}))}
value={settingValue(o)!.value}
onChange={(v) => onChange(o.id, v)}
/>
) : (
<ConfigPicker option={o} value={o.current} onChange={onChange} framed />
)}
</div>
);
})
)}
{settings.map((o) => {
const label = tx(settingName(o));
const control = switchValues(o) ? (
<ConfigPicker option={o} value={o.current} onChange={onChange} framed />
) : o.values.length <= SEGMENTED_MAX ? (
<SegmentedControl
ariaLabel={label}
options={o.values.map((v) => ({ value: v.value, label: v.name, description: v.description ?? undefined }))}
value={settingValue(o)!.value}
onChange={(v) => {
onChange(o.id, v);
if (only) onDone();
}}
/>
) : (
<SelectListbox
aria-label={label}
value={settingValue(o)?.value ?? null}
options={o.values.map((v) => ({ value: v.value, label: v.name, detail: v.description ?? undefined }))}
onChoose={(v) => {
onChange(o.id, v);
if (only) onDone();
}}
/>
);
return (
<div key={o.id} className={styles.quickRow}>
<span className={styles.quickLabel} title={o.description ?? undefined}>
{label}
</span>
{control}
</div>
);
})}
</div>
);
}
/** Where the model's settings chip appears once they arrive. */
function LoadingSettingsChip() {
const tx = useTx();
return (
<span className={clsx(styles.chip, styles.chipLoading)} title={tx("Loading model settings…")}>
<Spinner size={12} label={tx("Loading model settings…")} />
</span>
);
}
function ModelRefreshFooter({ refreshing, retryAtMs, error, onRefresh }: ModelRefresh) {
const tx = useTx();
const [now, setNow] = useState(Date.now);
+1 -15
View File
@@ -24,7 +24,6 @@ import {
HOME,
NO_COMMANDS,
draftConfig,
draftModelSettings,
refreshProviders,
refreshModels,
setDraftMcpOverrides,
@@ -243,10 +242,7 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
<ConfigPickers
key={provider?.id}
config={config}
onChange={(option, value, forModel) => {
if (forModel && model) setDraftOption(model.id, forModel);
setDraftOption(option, value);
}}
onChange={setDraftOption}
modelRefresh={
provider?.installed
? {
@@ -259,16 +255,6 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
: null,
error: !requestingModels && currentModelRequest ? (catalog?.error ?? null) : null,
onRefresh: () => void executeAction("agents.refreshModels", null),
preview: {
settingsFor: (id) =>
draftModelSettings(
(catalog ?? provider).thoughtLevels?.[id],
draft.thoughtLevels?.[id],
providerDefaults,
),
load: (id) => void refreshModels(provider.id, false, id),
errorFor: (id) => (requestTarget === id ? catalog?.error : null),
},
}
: undefined
}
+4 -35
View File
@@ -511,7 +511,7 @@ it("discovers an uncached model's own settings before its first task and restore
fireEvent.click(screen.getByRole("button", { name: "Model" }));
fireEvent.click(screen.getByRole("option", { name: "small" }));
await waitFor(() => expect(backend.refresh).toHaveBeenLastCalledWith("first", false, "small"));
expect(screen.getByText("Loading model settings…")).toHaveAttribute("role", "status");
expect(screen.getByRole("status", { name: "Loading model settings…" })).toBeVisible();
expect(screen.queryByRole("dialog", { name: "Model" })).not.toBeInTheDocument();
expect(backend.create).not.toHaveBeenCalled();
await act(async () =>
@@ -529,14 +529,14 @@ it("discovers an uncached model's own settings before its first task and restore
),
),
);
expect(screen.queryByText("Loading model settings…")).not.toBeInTheDocument();
expect(screen.queryByRole("status", { name: "Loading model settings…" })).not.toBeInTheDocument();
const settings = screen.getByRole("button", { name: /^Model settings:/ });
expect(settings).toHaveTextContent("medium");
fireEvent.click(settings);
fireEvent.click(screen.getByRole("radio", { name: "max" }));
expect(screen.getByRole("radio", { name: "long_context" })).toBeVisible();
fireEvent.click(screen.getByRole("radio", { name: "long_context" }));
fireEvent.click(screen.getByRole("button", { name: "Back to models" }));
fireEvent.click(screen.getByRole("button", { name: "Model" }));
fireEvent.click(screen.getByTitle("big"));
expect(settings).toHaveTextContent("high");
fireEvent.click(screen.getByRole("button", { name: "Model" }));
@@ -562,41 +562,10 @@ it("does not rediscover a model that explicitly reports no per-model controls",
fireEvent.click(screen.getByTitle(model));
}
expect(backend.refresh).toHaveBeenCalledExactlyOnceWith("first", false, "big");
expect(screen.queryByText("Loading model settings…")).not.toBeInTheDocument();
expect(screen.queryByRole("status", { name: "Loading model settings…" })).not.toBeInTheDocument();
expect(screen.queryByRole("button", { name: "Reasoning" })).not.toBeInTheDocument();
});
it("inspects uncached settings without switching models or borrowing the current model's levels", async () => {
delete backend.providers[0]!.thoughtLevels!.small;
await connect();
render(<HomeEditor />);
await waitFor(() => expect(useAgents.getState().modelRequests.size).toBe(0));
const pending = deferred<CatalogReply>();
backend.refresh.mockReturnValueOnce(pending.promise);
fireEvent.click(screen.getByRole("button", { name: "Model" }));
fireEvent.click(screen.getByRole("button", { name: "Configure small…" }));
expect(backend.refresh).toHaveBeenLastCalledWith("first", false, "small");
expect(screen.getByRole("status")).toHaveTextContent("Loading model settings…");
expect(screen.queryByRole("radio")).not.toBeInTheDocument();
await act(async () =>
pending.resolve(
ok(
catalog("first", {
thoughtLevels: {
...catalog().thoughtLevels,
small: [option("effort", "thought_level", ["quick", "thorough"])],
},
}),
),
),
);
expect(screen.getByRole("radio", { name: "quick" })).toBeVisible();
fireEvent.click(screen.getByRole("button", { name: "Back to models" }));
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("big");
expect(backend.setConfig).not.toHaveBeenCalled();
expect(backend.create).not.toHaveBeenCalled();
});
it("waits for an unrelated lookup and discovers only the latest selected model", async () => {
backend.providers[0]!.config = [option("model", "model", ["big", "small", "latest"])];
await connect();
@@ -162,7 +162,6 @@ export function SessionComposer({
const provider = useAgents((s) => s.providers.find((p) => p.id === task.provider));
const catalog = useAgents((s) => s.modelCatalogs.get(task.provider));
const requestingModels = useAgents((s) => s.modelRequests.has(task.provider));
const requestTarget = useAgents((s) => s.modelRequestTargets.get(task.provider));
const model = task.config.find((o) => o.category === "model");
const catalogModel = (catalog?.config ?? provider?.config)?.find((o) => o.category === "model");
const canRefreshModels =
@@ -230,28 +229,17 @@ export function SessionComposer({
)
.finally(() => setSending(false));
};
const setOption = (id: string, value: string, forModel?: string) => {
const setOption = (id: string, value: string) => {
const pickerModel = pickerConfig.find((o) => o.category === "model");
const changingModel = id === pickerModel?.id;
const loadingModel = !!forModel || (changingModel && !model?.values.some((v) => v.value === value));
const loadingModel = changingModel && !model?.values.some((v) => v.value === value);
const pendingModel = model?.current != null && model.current !== task.model;
const change = loadingModel || (changingModel && configChange.current) || pendingModel ? { loadingModel } : null;
if (change) {
configChange.current = change;
setConfiguring(change);
}
const apply = async () => {
if (forModel && pickerModel) {
await setTaskConfig(task.id, pickerModel.id, forModel);
// A later model choice supersedes both halves of this edit.
const latest = useAgents.getState().tasks.get(task.id);
const selected = latest?.config.find((o) => o.category === "model")?.current ?? latest?.model;
if (configChange.current !== change) return;
if (selected !== forModel) throw new Error(tx("The model changed before its setting could be applied."));
}
await setTaskConfig(task.id, id, value);
};
void apply()
void setTaskConfig(task.id, id, value)
.catch((e: unknown) =>
notifications().notify({
level: "error",
@@ -333,11 +321,6 @@ export function SessionComposer({
error: requestingModels ? null : (catalog?.error ?? null),
onOpen: () => void refreshTaskModels(task.id, false),
onRefresh: () => void executeAction("agents.refreshModels", task.id),
preview: {
settingsFor: (id) => (catalog ?? provider)?.thoughtLevels?.[id],
load: (id) => void refreshTaskModels(task.id, false, id),
errorFor: (id) => (requestTarget === id ? catalog?.error : null),
},
}
: undefined
}
-3
View File
@@ -192,9 +192,6 @@
"Effort Level": "Effort Level",
"Model settings": "Model settings",
"Model settings: {summary}": "Model settings: {summary}",
"Back to models": "Back to models",
"No settings reported for this model.": "No settings reported for this model.",
"The model changed before its setting could be applied.": "The model changed before its setting could be applied.",
"Context Size": "Context Size",
"Free": "Free",
"Low cost": "Low cost",
-3
View File
@@ -175,9 +175,6 @@
"Effort Level": "Düşünme Düzeyi",
"Model settings": "Model ayarları",
"Model settings: {summary}": "Model ayarları: {summary}",
"Back to models": "Modellere dön",
"No settings reported for this model.": "Bu model için bildirilen ayar bulunmuyor.",
"The model changed before its setting could be applied.": "Ayar uygulanamadan model değişti.",
"Context Size": "Bağlam Boyutu",
"Free": "Ücretsiz",
"Low cost": "Düşük maliyet",
-3
View File
@@ -156,9 +156,6 @@
"Effort Level": "思考強度",
"Model settings": "模型設定",
"Model settings: {summary}": "模型設定:{summary}",
"Back to models": "返回模型清單",
"No settings reported for this model.": "此模型未提供可設定的設定。",
"The model changed before its setting could be applied.": "應用設定前,所選模型已發生變化。",
"Context Size": "上下文大小",
"Free": "免費",
"Low cost": "低開銷",
-3
View File
@@ -158,9 +158,6 @@
"Effort Level": "思考强度",
"Model settings": "模型设置",
"Model settings: {summary}": "模型设置:{summary}",
"Back to models": "返回模型列表",
"No settings reported for this model.": "此模型未提供可配置的设置。",
"The model changed before its setting could be applied.": "应用设置前,所选模型已发生变化。",
"Context Size": "上下文大小",
"Free": "免费",
"Low cost": "低开销",