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

+15 -7
View File
@@ -1,8 +1,13 @@
from datetime import datetime
from nanobot.providers.base import ProviderConversationState
from nanobot.providers.model_options import ModelOptions
from nanobot.session.manager import Session, SessionManager
from nanobot.session.model_selection import SESSION_MODEL_PRESET_METADATA_KEY
from nanobot.session.model_selection import (
SESSION_MODEL_OPTIONS_METADATA_KEY,
SESSION_MODEL_PRESET_METADATA_KEY,
SessionModelPreset,
)
from nanobot.session.types import PARENT_SESSION_KEY, SESSION_TYPE_KEY
@@ -22,22 +27,25 @@ def test_manager_roundtrips_full_history_and_private_state(tmp_path):
def test_rename_model_preset_is_atomic(tmp_path, monkeypatch):
manager = SessionManager(tmp_path)
for key in ("cli:one", "cli:two"):
manager.save(Session(key=key, metadata={SESSION_MODEL_PRESET_METADATA_KEY: "old"}))
original = manager._store.update_metadata
choices = ModelOptions("low", False)
manager.save(Session(key="cli:one", metadata={
SESSION_MODEL_PRESET_METADATA_KEY: "old", SESSION_MODEL_OPTIONS_METADATA_KEY: choices.to_dict(),
}))
manager.save(Session(key="cli:two", metadata=SessionModelPreset("old", choices).metadata_update()))
original = manager._store.replace_metadata
def fail_second(key, values, **kwargs):
if key == "cli:two":
raise OSError("disk full")
return original(key, values, **kwargs)
import pytest
with monkeypatch.context() as patch:
patch.setattr(manager._store, "update_metadata", fail_second)
patch.setattr(manager._store, "replace_metadata", fail_second)
with pytest.raises(OSError):
manager.rename_model_preset("old", "new")
assert all(manager.get_or_create(key).metadata[SESSION_MODEL_PRESET_METADATA_KEY] == "old"
assert all(SessionModelPreset.from_metadata(manager.get_or_create(key).metadata) == SessionModelPreset("old", choices)
for key in ("cli:one", "cli:two"))
assert manager.rename_model_preset("old", "new") == 2
assert all(manager.get_or_create(key).metadata[SESSION_MODEL_PRESET_METADATA_KEY] == "new"
assert all(SessionModelPreset.from_metadata(manager.get_or_create(key).metadata) == SessionModelPreset("new", choices)
for key in ("cli:one", "cli:two"))