mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
## Why When ordinary included usage is exhausted, eligible users need a way to keep working with the backend-provided Luna Reserve quota and return to their previous model once ordinary usage recovers. ## What changed - Automatically switch eligible TUI tasks to Luna Reserve after an authoritative account usage read, preserving the prior model and reasoning effort per task. - Restrict model selection while on Reserve to its supported reasoning levels, keep queued turns on the accepted model, and restore the saved model after a fresh read confirms recovery. - Surface Reserve usage in the composer and `/status`, and expose `normalModelSlug` in app-server rate-limit snapshots so clients can use the associated model's display metadata without changing the request model. - Poll account limits more frequently near exhaustion and retain compatibility with app servers that only accept the legacy null request parameters. ## Testing - Added coverage for Reserve entry, queued-turn handling, task reconstruction, recovery authorization, account changes, model selection, usage rendering, and banner dismissal. GitOrigin-RevId: 46a435e9531051f8cec3f6a46c4b9f7cfa479747
63 lines
2.5 KiB
Rust
63 lines
2.5 KiB
Rust
//! The Reserve-only /model picker uses normal-model metadata while keeping Reserve routing.
|
|
|
|
use super::*;
|
|
use crate::model_catalog::LUNA_MODEL;
|
|
use crate::model_catalog::LUNA_RESERVE_MODEL;
|
|
|
|
impl ChatWidget {
|
|
pub(super) fn open_luna_reserve_model_popup(
|
|
&mut self,
|
|
presets: Vec<ModelPreset>,
|
|
view_id: &'static str,
|
|
) {
|
|
let normal_model_slug = self
|
|
.rate_limit_snapshots_by_limit_id
|
|
.values()
|
|
.find(|snapshot| snapshot.limit_name == LUNA_RESERVE_MODEL)
|
|
.and_then(|snapshot| snapshot.normal_model_slug.as_deref());
|
|
let preset = normal_model_slug
|
|
.and_then(|slug| presets.iter().find(|preset| preset.model == slug))
|
|
.or_else(|| presets.iter().find(|preset| preset.model == LUNA_MODEL));
|
|
let Some(mut preset) = preset.cloned() else {
|
|
self.bottom_pane.dismiss_view_by_id(view_id);
|
|
self.add_info_message(
|
|
"Luna model settings are unavailable; please try /model again in a moment."
|
|
.to_string(),
|
|
/*hint*/ None,
|
|
);
|
|
return;
|
|
};
|
|
|
|
// Only borrow the normal model's presentation and supported efforts. Selecting an
|
|
// effort must keep the authorized Reserve model and the saved ordinary return target.
|
|
preset.model = LUNA_RESERVE_MODEL.to_string();
|
|
let single_supported_effort = preset.supported_reasoning_efforts.len() == 1;
|
|
let name = preset.display_name.clone();
|
|
let description = (!preset.description.is_empty()).then_some(preset.description.clone());
|
|
let actions: Vec<SelectionAction> = vec![Box::new(move |tx| {
|
|
tx.send(AppEvent::OpenReasoningPopup {
|
|
model: preset.clone(),
|
|
});
|
|
})];
|
|
let header = self.model_menu_header(
|
|
"Select Model",
|
|
"Other models return when ordinary usage is available again.",
|
|
);
|
|
self.show_model_selection_view(SelectionViewParams {
|
|
view_id: Some(view_id),
|
|
header,
|
|
footer_hint: Some(self.bottom_pane.standard_popup_hint_line()),
|
|
items: vec![SelectionItem {
|
|
name,
|
|
description,
|
|
is_current: true,
|
|
actions,
|
|
dismiss_on_select: single_supported_effort,
|
|
dismiss_parent_on_child_accept: !single_supported_effort,
|
|
..Default::default()
|
|
}],
|
|
..Default::default()
|
|
});
|
|
}
|
|
}
|