Allow choosing the default provider for new chats in the TUI (#59722)

## What changed

- Add Space to set the default provider from Model providers settings, persisting `model_provider` on the connected server. Keep provider details available and disable selection when server configuration or client launch settings fix the provider.
- Apply the choice to `/new` while preserving the current chat. Refresh account details for new chats and reject account data that does not match the started provider.
- Block stale `/model` choices during saves and after confirmed or uncertain provider changes, including across reconnects. Tell users to restart the app server and TUI to refresh the model list, and discard queued picker actions from another backend or chat.

## Testing

Add coverage for provider saves, retry after disconnection, concurrent-save prevention, stale model choices, and account/provider matching, with updated provider-picker snapshots.

GitOrigin-RevId: af6d149f7de7a2eaa09a31935f7088faa64d6a59
This commit is contained in:
alexsong-oai
2026-11-05 19:11:18 +00:00
committed by copyberry
parent be765f1ade
commit b2a8e68c74
29 changed files with 1103 additions and 137 deletions
+12 -3
View File
@@ -3,6 +3,8 @@
use super::ChatWidget;
use super::session_model_selection::AstraModelPickerAction;
use super::slash_command_args;
use crate::app_event::AppEvent;
use crate::history_cell;
use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE;
use codex_protocol::openai_models::ModelPreset;
use codex_protocol::openai_models::ReasoningEffort;
@@ -124,6 +126,9 @@ fn resolve_model_command(chat: &ChatWidget, args: &str) -> Result<ModelCommand,
.into(),
);
}
if let Some(message) = chat.model_picker_unavailable() {
return Err(message);
}
let model_name = args
.model
.clone()
@@ -161,15 +166,19 @@ impl ChatWidget {
let warning = self.ultra_reasoning_concurrency_warning(&effort);
let thread_id = self.sparkle_thread_for_picker_action(&model);
self.set_queue_autosend_suppressed(/*suppressed*/ true);
self.app_event_tx.send(
let scoped = self.scope_model_picker_event();
self.app_event_tx.send(scoped(
AstraModelPickerAction::SelectSessionModel {
effort: Some(effort),
service_tier,
}
.into_picker_event(thread_id, model),
);
));
if let Some(warning) = warning {
self.add_warning_message(warning);
self.app_event_tx
.send(scoped(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_warning_event(warning),
))));
}
}
}