Files
codex/codex-rs/tui/src/chatwidget/session_model_selection.rs
T
Benjamin Carlsson 654b2ec1f5 Keep cloud conversation settings server-owned in the TUI (#57267)
## Why

Cloud conversations own their execution settings and workspace. TUI requests must preserve those settings instead of overriding them with local configuration.

## What changed

- Add a distinct cloud parameter mode that omits local execution settings from thread start, resume, and turn requests, including misalignment continuations.
- Route cloud model and reasoning selections through `thread/settings/update`, requiring server acceptance rather than falling back to local changes or saved defaults.
- Use server model defaults and tolerate an unavailable `configRequirements/read` method during cloud bootstrap.
- Skip local tool setup and TUI-generated titles, and report that permission selection, forking, and conversation recaps are unavailable for cloud conversations.

## Testing

Add regression coverage for cloud request parameters, bootstrap without configuration requirements, rejected model changes, and suppression of unsupported requests.

GitOrigin-RevId: a2dafb6c8a6b0db8607575e2291fee739c2fb2b1
2026-10-26 21:28:54 +00:00

105 lines
3.6 KiB
Rust

//! Session-only model selections leave durable defaults untouched. Explicit Astra selections retain
//! their originating task and are checked against its effective model when the app applies them.
use super::*;
use crate::bottom_pane::SelectionSecondaryAction;
use crate::keymap::ListAction;
use crate::model_catalog::LUNA_RESERVE_MODEL;
/// A final Astra selection whose model transition must be checked while the app applies it.
#[derive(Debug)]
pub(crate) enum AstraModelPickerAction {
UpdateModel,
ApplyModelSelection {
effort: Option<ReasoningEffortConfig>,
},
ApplyAdvancedReasoning {
effort: ReasoningEffortConfig,
},
SelectSessionModel {
effort: Option<ReasoningEffortConfig>,
service_tier: Option<String>,
},
}
impl AstraModelPickerAction {
pub(super) fn into_picker_event(self, thread_id: Option<ThreadId>, model: String) -> AppEvent {
match thread_id {
Some(thread_id) => AppEvent::AstraSelectedFromModelPicker {
thread_id,
model,
action: self,
},
None => self.into_app_event(model),
}
}
pub(crate) fn into_app_event(self, model: String) -> AppEvent {
match self {
Self::UpdateModel => AppEvent::UpdateModel(model),
Self::ApplyModelSelection { effort } => AppEvent::ApplyModelSelection { model, effort },
Self::ApplyAdvancedReasoning { effort } => {
AppEvent::ApplyAdvancedReasoning { model, effort }
}
Self::SelectSessionModel {
effort,
service_tier,
} => AppEvent::SelectSessionModel {
model,
effort,
service_tier,
},
}
}
}
impl ChatWidget {
pub(super) fn session_model_selection_action(
&self,
model: String,
effort: Option<ReasoningEffortConfig>,
) -> Option<SelectionSecondaryAction> {
// Reserve selections are already session-only.
if model == LUNA_RESERVE_MODEL {
return None;
}
let key = key_hint::plain(KeyCode::Char('s'));
let keymap = self.bottom_pane.list_keymap();
let mut hints = Vec::new();
if let Some(accept) = keymap.primary_hint(ListAction::Accept) {
let label = if effort == Some(ReasoningEffortConfig::Ultra) {
" apply · "
} else {
" default · "
};
hints.extend([accept.into(), label.dim()]);
}
hints.extend([key.into(), " session".dim()]);
if let Some(cancel) = keymap.primary_hint(ListAction::Cancel) {
hints.extend([" · ".dim(), cancel.into(), " back".dim()]);
}
let warning = effort
.as_ref()
.and_then(|effort| self.ultra_reasoning_concurrency_warning(effort));
let sparkle_thread = self.sparkle_thread_for_picker_action(&model);
Some(SelectionSecondaryAction {
key,
footer_hint: hints.into(),
action: Box::new(move |tx| {
tx.send(
AstraModelPickerAction::SelectSessionModel {
effort: effort.clone(),
service_tier: None,
}
.into_picker_event(sparkle_thread, model.clone()),
);
if let Some(warning) = warning.clone() {
tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_warning_event(warning),
)));
}
}),
})
}
}