feat(webui): add session-scoped reasoning effort (#6441)
* feat(webui): add session-scoped model options Extend the composer preset menu with inherited reasoning effort and Codex Fast mode overrides. Persist choices with ordinary inputs, isolate captured runtimes, and restore browser preferences without changing shared presets. Add regression coverage for pending preset ordering, settings initialization, session and host isolation, queue edits, Codex request mapping, and narrow-screen controls. * feat(webui): refine session model options and add Codex Ultrafast Fit the composer options into a compact single row and preview reasoning effort only during a drag. Add Fast/Ultrafast controls for eligible Codex models, preserve explicit session choices across reloads, and document the speed tiers. * fix(webui): add Codex speed control to the component gallery * fix(webui): preserve saved model options after preset rename Use the session options for display when a browser preference no longer matches the preset. Omit model options from the next message unless the browser has a matching choice, so stale preferences cannot overwrite options the gateway already saved.
This commit is contained in:
1 parent
2b232c9133
commit
0f45d74fec
82 files changed
+2289
-113
No files matched your search
@@ -66,6 +66,7 @@ function makeClient() {
|
||||
return status;
|
||||
},
|
||||
defaultChatId: null as string | null,
|
||||
preferenceScope: lifecycle.preferenceScope,
|
||||
onStatus: (handler: (nextStatus: ConnectionStatus) => void) => {
|
||||
statusHandlers.add(handler);
|
||||
handler(status);
|
||||
@@ -466,6 +467,87 @@ function settingsWithFastPreset(): SettingsPayload {
|
||||
}
|
||||
|
||||
describe("ThreadShell", () => {
|
||||
function optionsSettings() {
|
||||
const settings = settingsWithFastPreset();
|
||||
for (const preset of settings.model_presets) preset.model_options = {
|
||||
reasoning_effort: { default: "low", values: ["low", "high"] }, codex_fast_mode: { default: true },
|
||||
};
|
||||
settings.providers = settings.providers.map((provider) => ({ ...provider, model_catalog: "unsupported" }));
|
||||
return settings;
|
||||
}
|
||||
|
||||
async function changeOptions() {
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Default" }));
|
||||
fireEvent.change(screen.getByRole("slider", { name: "Reasoning effort" }), { target: { value: "1" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Fast" }));
|
||||
fireEvent.keyDown(screen.getByRole("dialog", { name: "Switch model" }), { key: "Escape" });
|
||||
}
|
||||
|
||||
it("keeps model option choices local until sending, includes explicit false, and clears them on preset switch", async () => {
|
||||
localStorage.clear();
|
||||
const client = makeClient();
|
||||
render(wrap(client, <ThreadShell session={session("model-options")} title="Options" onToggleSidebar={() => {}}
|
||||
settingsSnapshot={optionsSettings()} />, null, "tok", ["webui.model-options.v1"]));
|
||||
await changeOptions();
|
||||
expect(client.sendMessage).not.toHaveBeenCalled();
|
||||
expect(client.sendSystemCommand).not.toHaveBeenCalled();
|
||||
fireEvent.change(screen.getByLabelText("Message input"), { target: { value: "selected options" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
await waitFor(() => expect(client.sendMessage).toHaveBeenCalledWith("model-options", "selected options", undefined,
|
||||
expect.objectContaining({ modelOptions: { reasoning_effort: "high", codex_fast_mode: false } })));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Default" }));
|
||||
fireEvent.click(await screen.findByRole("option", { name: "fast" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "fast" }));
|
||||
expect(screen.getByRole("slider", { name: "Reasoning effort" })).toHaveAttribute("aria-valuetext", "low");
|
||||
expect(screen.getByRole("button", { name: "Fast" })).toHaveAttribute("aria-pressed", "true");
|
||||
expect(client.sendSystemCommand).toHaveBeenCalledWith("model-options", "/model fast");
|
||||
expect(client.sendMessage).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("sends and migrates the landing selection with the first ordinary message", async () => {
|
||||
localStorage.clear();
|
||||
const client = makeClient();
|
||||
const settings = optionsSettings();
|
||||
const view = (currentSession: ReturnType<typeof session> | null) => wrap(client, <ThreadShell session={currentSession}
|
||||
title="Options" onToggleSidebar={() => {}} settingsSnapshot={settings} onCreateChat={async () => "options-created"} />,
|
||||
null, "tok", ["webui.model-options.v1"]);
|
||||
const rendered = render(view(null));
|
||||
await changeOptions();
|
||||
fireEvent.change(screen.getByLabelText("Message input"), { target: { value: "first selection" } });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send message" }));
|
||||
await act(async () => {});
|
||||
rendered.rerender(view(session("options-created")));
|
||||
await waitFor(() => expect(client.sendMessage).toHaveBeenCalledWith("options-created", "first selection", undefined,
|
||||
expect.objectContaining({ modelOptions: { reasoning_effort: "high", codex_fast_mode: false } })));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Default" }));
|
||||
expect(screen.getByRole("slider", { name: "Reasoning effort" })).toHaveAttribute("aria-valuetext", "high");
|
||||
expect(screen.getByRole("button", { name: "Fast" })).toHaveAttribute("aria-pressed", "false");
|
||||
});
|
||||
|
||||
it("sends edited queued prompts using current options, while cancelling the queue sends nothing", async () => {
|
||||
localStorage.clear();
|
||||
const client = makeClient();
|
||||
const chatId = "options-queue";
|
||||
render(wrap(client, <ThreadShell session={session(chatId)} title="Options" onToggleSidebar={() => {}}
|
||||
settingsSnapshot={optionsSettings()} />, null, "tok", ["webui.model-options.v1"]));
|
||||
await screen.findByLabelText("Message input");
|
||||
act(() => client._emitChat(chatId, { event: "goal_status", chat_id: chatId, turn_id: "owner", status: "running", started_at: 1_000 }));
|
||||
const input = screen.getByLabelText("Message input");
|
||||
fireEvent.change(input, { target: { value: "queued options" } });
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Delete message" }));
|
||||
expect(client.sendMessage).not.toHaveBeenCalled();
|
||||
fireEvent.change(input, { target: { value: "queued options again" } });
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
await changeOptions();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Edit message" }));
|
||||
fireEvent.change(input, { target: { value: "edited options" } });
|
||||
fireEvent.keyDown(input, { key: "Enter" });
|
||||
fireEvent.click(screen.getByRole("button", { name: "Send now" }));
|
||||
await waitFor(() => expect(client.sendMessage).toHaveBeenCalledWith(chatId, "edited options", undefined,
|
||||
expect.objectContaining({ modelOptions: { reasoning_effort: "high", codex_fast_mode: false } })));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
webuiThreadCache.clear();
|
||||
clearStoredComposerDrafts();
|
||||
|
||||
Reference in new issue
Block a user