mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
## 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
106 lines
3.7 KiB
Rust
106 lines
3.7 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);
|
|
let scoped = self.scope_model_picker_event();
|
|
Some(SelectionSecondaryAction {
|
|
key,
|
|
footer_hint: hints.into(),
|
|
action: Box::new(move |tx| {
|
|
tx.send(scoped(
|
|
AstraModelPickerAction::SelectSessionModel {
|
|
effort: effort.clone(),
|
|
service_tier: None,
|
|
}
|
|
.into_picker_event(sparkle_thread, model.clone()),
|
|
));
|
|
if let Some(warning) = warning.clone() {
|
|
tx.send(scoped(AppEvent::InsertHistoryCell(Box::new(
|
|
history_cell::new_warning_event(warning),
|
|
))));
|
|
}
|
|
}),
|
|
})
|
|
}
|
|
}
|