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:
chengyongru authored and GitHub committed 2026-11-18 15:46:16 +08:00
1 parent 2b232c9133
commit 0f45d74fec
82 files changed
+2289 -113

No files matched your search

+7 -1
View File
@@ -10,6 +10,7 @@ import type {
ChannelConnectPayload,
ChannelValidationPayload,
ChatSummary,
SessionModelOptions,
ContextGraph,
CliAppsPayload,
FilePreviewPayload,
@@ -204,6 +205,7 @@ export async function listSessions(
title?: string;
preview?: string;
model_preset?: string | null;
model_options?: SessionModelOptions;
run_started_at?: number | null;
recovery_state?: RecoveryState | null;
workspace_scope?: WorkspaceScopePayload | null;
@@ -226,6 +228,7 @@ export async function listSessions(
title: s.title ?? "",
preview: s.preview ?? "",
modelPreset: s.model_preset ?? null,
modelOptions: s.model_options ?? { reasoning_effort: null, codex_fast_mode: null },
runStartedAt: s.run_started_at ?? null,
recoveryState: s.recovery_state ?? null,
workspaceScope: s.workspace_scope ?? null,
@@ -1417,7 +1420,7 @@ export async function fetchSidebarState(
function modelGenerationSettingsPayload(
configuration: Pick<
ModelConfigurationCreate,
"maxTokens" | "contextWindowTokens" | "temperature" | "reasoningEffort" | "supportsImages" | "api" | "extraHeaders" | "extraQuery" | "extraBody"
"maxTokens" | "contextWindowTokens" | "temperature" | "reasoningEffort" | "codexFastMode" | "supportsImages" | "api" | "extraHeaders" | "extraQuery" | "extraBody"
>,
): Record<string, unknown> {
const payload: Record<string, unknown> = {};
@@ -1436,6 +1439,9 @@ function modelGenerationSettingsPayload(
if (configuration.reasoningEffort !== undefined) {
payload.reasoning_effort = configuration.reasoningEffort ?? "";
}
if (configuration.codexFastMode !== undefined) {
payload.codex_fast_mode = configuration.codexFastMode ?? "";
}
if (configuration.api !== undefined) {
payload.api = configuration.api;
}
+10
View File
@@ -9,6 +9,7 @@ import type {
OutboundMcpPresetMention,
OutboundMedia,
SessionMention,
SessionModelOptions,
SidebarStatePayload,
GoalStateWsPayload,
WorkspaceScopePayload,
@@ -288,6 +289,12 @@ export class NanobotClient {
return this.readyChatId;
}
/** Stable browser preference namespace without authentication or query parameters. */
get preferenceScope(): string {
const url = new URL(this.currentUrl, window.location.href);
return `${url.protocol}//${url.host}${url.pathname}`;
}
/** Swap the URL (e.g. after fetching a fresh token) then reconnect. */
updateUrl(url: string, socketFactory?: (url: string) => WebSocket): void {
this.currentUrl = url;
@@ -819,6 +826,7 @@ export class NanobotClient {
quotedContext?: string;
intent?: "create_automation";
userShell?: boolean;
modelOptions?: SessionModelOptions;
workspaceScope?: WorkspaceScopePayload | null;
turnId?: string;
/** False for side-channel or injected messages that do not own a lifecycle. */
@@ -841,6 +849,8 @@ export class NanobotClient {
...(options?.quotedContext?.trim() ? { quoted_context: options.quotedContext.trim() } : {}),
...(options?.intent === "create_automation" ? { intent: options.intent } : {}),
...(options?.userShell ? { user_shell: true } : {}),
...(!temporary && !options?.userShell && options?.modelOptions
? { model_options: options.modelOptions } : {}),
...(options?.workspaceScope ? { workspace_scope: options.workspaceScope } : {}),
...(options?.turnId ? { turn_id: options.turnId } : {}),
webui: true,
+5
View File
@@ -77,3 +77,8 @@ export function getProviderModelCatalog(revision: object, token: string, provide
}
return catalog;
}
/** Shared recommendations for both the settings picker and current-chat controls. */
export function reasoningEffortValues(payload: ProviderModelsPayload | null, model: string, savedValues?: string[]): string[] {
return [...new Set((payload?.models.find((entry) => entry.id === model)?.reasoning_efforts ?? savedValues ?? []).filter(Boolean))];
}
+21
View File
@@ -488,6 +488,19 @@ export interface UIFileEdit {
diff?: UIFileDiff;
}
export type CodexFastMode = boolean | "ultrafast";
export interface SessionModelOptions {
/** Null explicitly inherits the preset/provider value. */
reasoning_effort: string | null;
codex_fast_mode: CodexFastMode | null;
}
export interface ModelOptionsCapability {
reasoning_effort: { default: string | null; values: string[] };
codex_fast_mode?: { default: CodexFastMode; ultrafast_supported?: boolean };
}
export interface ChatSummary {
/** Server-side session key, e.g. ``websocket:abcd-...``. */
key: string;
@@ -500,6 +513,7 @@ export interface ChatSummary {
preview: string;
/** Model preset persisted for this session; null means it still follows the global default. */
modelPreset?: string | null;
modelOptions?: SessionModelOptions;
/** Unix epoch seconds when this session currently has a turn in flight. */
runStartedAt?: number | null;
/** Durable recovery state that needs attention after an interrupted turn. */
@@ -773,6 +787,8 @@ export interface SettingsPayload {
temperature: number;
reasoning_effort: string | null;
reasoning_effort_values?: string[];
codex_fast_mode?: CodexFastMode | null;
model_options?: ModelOptionsCapability;
supports_images?: boolean;
api?: ModelAPIConfig | null;
extra_headers?: Record<string, string> | null;
@@ -806,6 +822,8 @@ export interface SettingsPayload {
request_apis?: ProviderRequestAPI[];
adapter_request_apis?: ProviderRequestAPI[];
provider_api_configurable?: boolean;
codex_fast_mode_supported?: boolean;
codex_ultrafast_models?: string[];
api?: ModelAPIConfig | null;
oauth_account?: string | null;
oauth_expires_at?: number | null;
@@ -1410,6 +1428,7 @@ export interface ModelConfigurationCreate {
contextWindowTokens?: number;
temperature?: number;
reasoningEffort?: string | null;
codexFastMode?: CodexFastMode | null;
supportsImages?: boolean;
api?: ModelAPIConfig | null;
extraHeaders?: string;
@@ -1426,6 +1445,7 @@ export interface ModelConfigurationUpdate {
contextWindowTokens?: number;
temperature?: number;
reasoningEffort?: string | null;
codexFastMode?: CodexFastMode | null;
supportsImages?: boolean;
api?: ModelAPIConfig | null;
extraHeaders?: string;
@@ -1887,6 +1907,7 @@ export type Outbound =
quoted_context?: string;
intent?: "create_automation";
user_shell?: true;
model_options?: SessionModelOptions;
workspace_scope?: WorkspaceScopePayload;
turn_id?: string;
/** Marks messages sent by the embedded WebUI, without changing the