mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
## Why Users need to change the active session's model and reasoning effort without replacing saved defaults for future threads. ## What changed - Add an `s` shortcut to final model and reasoning choices, with footer hints and a session-only confirmation. - Apply the selection to the active thread while preserving saved configuration, including separate Plan mode defaults. - Restore Plan mode reasoning effort with thread input state and suppress the shortcut when it conflicts with configured list bindings. ## Testing Add coverage for picker shortcuts, active-thread updates, unchanged configuration and fresh-thread defaults, Plan mode restoration, and shortcut conflicts. Update picker snapshots to show the new hints. GitOrigin-RevId: 07fd129021cc076e3a9bdee04b71979212788eb4
86 lines
3.5 KiB
Rust
86 lines
3.5 KiB
Rust
//! Apply session model choices separately from saved model defaults.
|
|
//!
|
|
//! A successful config write can still be overridden. Report that distinction without
|
|
//! replacing the active task's explicit selection with launch-time configuration.
|
|
|
|
use super::App;
|
|
use crate::app_server_session::AppServerSession;
|
|
use codex_app_server_client::AppServerRequestHandle;
|
|
use codex_app_server_protocol::ConfigEdit;
|
|
use codex_app_server_protocol::WriteStatus;
|
|
use codex_protocol::config_types::ModeKind;
|
|
use codex_protocol::openai_models::ReasoningEffort;
|
|
use color_eyre::eyre::Result;
|
|
|
|
impl App {
|
|
pub(super) async fn select_session_model(
|
|
&mut self,
|
|
app_server: &mut AppServerSession,
|
|
model: String,
|
|
effort: Option<ReasoningEffort>,
|
|
) {
|
|
let model_changed = self.chat_widget.current_model() != model
|
|
|| self.chat_widget.current_collaboration_mode().model() != model;
|
|
if model_changed
|
|
&& self
|
|
.active_thread_model_setting_update_params(model.clone())
|
|
.is_some_and(|params| params.permissions.is_some())
|
|
&& self.reject_pending_permission_change()
|
|
{
|
|
return;
|
|
}
|
|
let in_plan_mode = self.chat_widget.effective_collaboration_mode().mode == ModeKind::Plan;
|
|
let ultra = effort == Some(ReasoningEffort::Ultra);
|
|
let clear_default_ultra = self
|
|
.chat_widget
|
|
.current_collaboration_mode()
|
|
.reasoning_effort()
|
|
== Some(ReasoningEffort::Ultra)
|
|
&& self.config.model_reasoning_effort != Some(ReasoningEffort::Ultra);
|
|
let clear_plan_ultra = self.chat_widget.config_ref().plan_mode_reasoning_effort
|
|
== Some(ReasoningEffort::Ultra)
|
|
&& self.config.plan_mode_reasoning_effort != Some(ReasoningEffort::Ultra);
|
|
self.chat_widget.set_model(&model);
|
|
if !in_plan_mode || ultra || clear_default_ultra {
|
|
self.chat_widget.set_reasoning_effort(effort.clone());
|
|
}
|
|
if in_plan_mode || ultra || clear_plan_ultra {
|
|
self.chat_widget
|
|
.set_plan_mode_reasoning_effort(effort.clone());
|
|
}
|
|
if model_changed {
|
|
self.sync_active_thread_model_setting(app_server, model.clone(), effort.clone())
|
|
.await;
|
|
} else if let Some(mut params) =
|
|
self.active_thread_reasoning_setting_update_params(effort.clone())
|
|
{
|
|
params.collaboration_mode = Some(self.chat_widget.effective_collaboration_mode());
|
|
self.send_thread_settings_update(app_server, params).await;
|
|
}
|
|
self.sync_active_thread_service_tier_to_cached_session()
|
|
.await;
|
|
let mut message = format!("Model changed to {model}");
|
|
if let Some(label) = Self::reasoning_label_for(&model, effort.as_ref()) {
|
|
message.push(' ');
|
|
message.push_str(&label);
|
|
}
|
|
message.push_str(" for this session only");
|
|
self.chat_widget.add_info_message(message, /*hint*/ None);
|
|
}
|
|
|
|
pub(super) async fn persist_model_defaults(
|
|
&mut self,
|
|
request_handle: AppServerRequestHandle,
|
|
edits: Vec<ConfigEdit>,
|
|
setting: &str,
|
|
) -> Result<()> {
|
|
let response = crate::config_update::write_config_batch(request_handle, edits).await?;
|
|
if response.status == WriteStatus::OkOverridden {
|
|
self.chat_widget.add_warning_message(format!(
|
|
"Saved {setting}, but a higher-priority configuration layer overrides the saved value."
|
|
));
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|