The terminal UI needs a discoverable model switch path that stays scriptable.
The default interactive path is a command-shaped autocomplete popup in the
composer; explicit /model <target> commands remain the only execution
contract.
- Typing
/modelor/modelin the composer opens a model popup above the input area. - Non-popup clients that submit
/modelshow the current session model and configured selectable models as text. /model listis the explicit list form./model mainswitches tomodel.main./model liteswitches tomodel.litewhen it is configured./model <provider/model>switches to a configured selectable model with that exact id.- The selectable set includes
model.main, optionalmodel.lite, and every model declared under every configuredprovider.*.models. - Picker rows are command-shaped. Selecting a row submits
/model <provider/model>through the normal command center path. - Picker rows prioritize the human model name on the left. The provider name is right-aligned and rendered with muted emphasis so users can scan models first while still seeing the provider boundary.
- Typing while the picker is open filters by model id, configured display name, alias, and generated command text.
- Up and Down move the highlighted model.
- Enter switches to the highlighted model.
- Tab completes the highlighted model into
/model <provider/model>without submitting, matching the existing slash command autocomplete behavior. - Esc cancels the picker and keeps the current model unchanged.
- Unknown models return a normal command response instead of being sent to the LLM.
- A model switch affects later turns only. Existing message history keeps the model metadata it was created with.
TUI 不拥有选型状态,只渲染 Bootstrap 的每会话 cliDefaultSelection。CLI 装配显式使用
modelSelectionMode: "cli-default";/model 和 /effort 修改并持久化下一条用户消息的默认选择,
不提前改变 Core Session Selection。CLI 用户消息在入口补齐 Selection,实际接受后成为 Session
续跑选择。App/Bot 的现有显式配置入口不因 CLI 装配改变语义。
新 CLI 会话从 Provider Config 的 config.defaultModelSelection 初始化默认值,恢复会话读现有
runtime/model_selection entry。全局保存继续复用现有命令路径,不引入新配置文件或迁移。
后台唤起和 Goal 直接使用 Session Selection;不会从 CLI 默认值补模型。闲时临时选择不写普通用户 entry。
Draft(deferred)会话在首条输入前还没有 session 行。此时 /model、/effort 及 App 的选型/档位命令
仍立即在内存生效,但写 runtime/model_selection entry 会因外键约束失败;这是已知时序,
不是持久化故障:首条输入或外部活动持久化会话时,runtime 以当时的 Session Selection 统一写入同一稳定 entry。
因此只有 runtime.isSessionPersisted() 仍为 false 时,这次写入失败记 debug
(session.model_selection.persist_deferred);会话已持久化后的写入失败仍记 warn
(session.model_selection.persist_failed)。写入仍先尝试,不按“未持久化就跳过”处理,
避免与进行中的首次持久化竞态而漏写较新的选择。
The TUI sends /model ... through the same submit callback as other slash commands. The command center asks the app/server for current model state, available model options, and applies the selected model through an explicit app-level method. The TUI renders the returned command text and updates its session metadata projection from the returned model and thoughtLevel fields.
For composer autocomplete, the CLI passes a read-only list of selectable models
into TUI options. The TUI may recognize the draft shape /model... only to
filter and render local suggestions. It owns only the popup filter, highlighted
index, and completion behavior; it does not cache model catalog state or apply
model switches directly.
- The sidebar
Runsection rendersProviderandModelas separate rows. - The projection is derived from the canonical formatted model ref by splitting
on the first
/, matching the runtimeprovider/modelcontract where model ids may themselves contain/. - If the current model projection is a bare model id, the
Providerrow renders-and theModelrow renders the bare id. - A
model_selectedsession event withmodelRef.providerIdandmodelRef.modelIdrefreshes the same display projection as a/modelcommand result. The TUI still does not store provider and model as authoritative state.
- TUI does not execute
/model. It receives optionalinitialModel,initialThoughtLevel, and read-only model options from the CLI bootstrap path before the first render and later updates active model display only fromTuiSubmitPromptResultor live model request events. - CLI command-center parses
/modeland dispatches to the app-level model contract. - Config parsing materializes provider-declared models into a server-side
model.availableruntime catalog. It must preserve provider connection fields so switching to a model from another provider can run without TUI state. - Bootstrap exposes
getModel,getThoughtLevel,listModels, andsetModelas narrow server-side APIs. - Core owns the active
ModelRefthroughAgentRuntime.updateConfig({ modelRef, modelProviderOptions }). - Runtime startup must also seed
modelProviderOptionsfrom the configured main model target, or from the catalog default thought level when the target does not declare explicit options, so the first turn and first render reflect the same model provider settings as later/modelswitches.
- If model switching is not available in the client,
/modelreturns a command response. - If
model.liteis not configured,/model litereports the available model ids and aliases. - If no selectable models are configured, no composer model popup is shown and
/modelor/model listreports the condition in text. - Model ids are case-sensitive after the
provider/separator; command parsing must not lowercase full model refs. - Switching clears or replaces model request provider options with the selected target's options, so stale options do not leak across models.
- Provider-declared models are only selectable when the provider connection is configured in the same merged runtime config. Catalog metadata alone still does not make a model runnable.
- Command-center parses
/model. - Command-center lists and switches models without calling
submitPrompt. - CLI TUI wiring routes
/modelto the app/server contract. - CLI TUI wiring passes read-only model options into the TUI.
- TUI model popup filters model options by id, alias, name, and command text.
- TUI model popup supports Up/Down navigation, Enter submission through
/model <id>, Tab completion into the draft, and Esc dismissal. - CLI TUI wiring passes the initial model and thought level into the first TUI render when they can be resolved.
- TUI sidebar tests assert that
provider/modelrenders as separateProviderandModelrows, including model ids that contain/. - TUI event tests assert
model_selectedpayloads withproviderIdandmodelIdupdate the current model projection. - Config parsing turns multiple providers and multiple provider models into
model.available. - Bootstrap startup and
setModelupdate runtimemodelRefand clear/replacemodelProviderOptions, including catalog default thought provider options when a model has selectable reasoning but no explicit target options. npm run lintandnpm testpass before completion.