Use standard service tier conversions in TUI

This commit is contained in:
Ahmed Ibrahim
2026-05-04 01:15:49 +03:00
parent 9691d7b865
commit 2044ce2434
6 changed files with 41 additions and 38 deletions
+4 -4
View File
@@ -71,8 +71,8 @@ use codex_protocol::ThreadId;
use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::CollaborationModeMask;
use codex_protocol::config_types::ModeKind;
use codex_protocol::config_types::SERVICE_TIER_PRIORITY;
use codex_protocol::config_types::Settings;
use codex_protocol::config_types::priority_service_tier;
use codex_protocol::models::AdditionalPermissionProfile as CoreAdditionalPermissionProfile;
use codex_protocol::models::FileSystemPermissions;
use codex_protocol::models::NetworkPermissions;
@@ -3705,7 +3705,7 @@ async fn clear_ui_header_shows_fast_status_for_fast_capable_models() {
app.chat_widget
.set_reasoning_effort(Some(ReasoningEffortConfig::XHigh));
app.chat_widget
.set_service_tier(Some(priority_service_tier()));
.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
set_chatgpt_auth(&mut app.chat_widget);
set_fast_mode_test_catalog(&mut app.chat_widget);
@@ -4325,11 +4325,11 @@ fn active_turn_steer_race_extracts_actual_turn_id_from_mismatch() {
async fn fresh_session_config_uses_current_service_tier() {
let mut app = make_test_app().await;
app.chat_widget
.set_service_tier(Some(priority_service_tier()));
.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
let config = app.fresh_session_config();
assert_eq!(config.service_tier, Some(priority_service_tier()));
assert_eq!(config.service_tier, Some(SERVICE_TIER_PRIORITY.into()));
}
#[tokio::test]
@@ -6,8 +6,8 @@
use std::collections::HashSet;
use std::str::FromStr;
use codex_protocol::config_types::SERVICE_TIER_PRIORITY;
use codex_protocol::config_types::ServiceTier;
use codex_protocol::config_types::priority_service_tier;
use codex_protocol::openai_models::ModelPreset;
use codex_protocol::openai_models::ModelServiceTier;
use codex_utils_fuzzy_match::fuzzy_match;
@@ -291,7 +291,7 @@ mod tests {
#[test]
fn service_tier_command_is_hidden_when_disabled() {
let service_tier_commands = vec![ServiceTierCommand {
service_tier: priority_service_tier(),
service_tier: SERVICE_TIER_PRIORITY.into(),
command: "fast".to_string(),
name: "Fast".to_string(),
description: "Fast tier".to_string(),
@@ -382,7 +382,7 @@ mod tests {
supports_personality: false,
service_tiers: vec![
ModelServiceTier {
id: priority_service_tier(),
id: SERVICE_TIER_PRIORITY.into(),
name: "Fast".to_string(),
description: "Fast tier".to_string(),
},
@@ -406,7 +406,7 @@ mod tests {
commands,
vec![
ServiceTierCommand {
service_tier: priority_service_tier(),
service_tier: SERVICE_TIER_PRIORITY.into(),
command: "fast".to_string(),
name: "Fast".to_string(),
description: "Fast tier".to_string(),
+4 -2
View File
@@ -150,11 +150,11 @@ use codex_protocol::config_types::CollaborationMode;
use codex_protocol::config_types::CollaborationModeMask;
use codex_protocol::config_types::ModeKind;
use codex_protocol::config_types::Personality;
use codex_protocol::config_types::SERVICE_TIER_PRIORITY;
use codex_protocol::config_types::ServiceTier;
use codex_protocol::config_types::Settings;
#[cfg(target_os = "windows")]
use codex_protocol::config_types::WindowsSandboxLevel;
use codex_protocol::config_types::is_priority_service_tier;
use codex_protocol::items::AgentMessageContent;
use codex_protocol::items::AgentMessageItem;
use codex_protocol::models::MessagePhase;
@@ -9268,7 +9268,9 @@ impl ChatWidget {
service_tier: Option<ServiceTier>,
) -> bool {
model_supports_fast_mode(self, model)
&& service_tier.as_ref().is_some_and(is_priority_service_tier)
&& service_tier
.as_ref()
.is_some_and(|tier| tier.as_ref() == SERVICE_TIER_PRIORITY)
&& self.has_chatgpt_account
}
+2 -2
View File
@@ -1,5 +1,5 @@
use codex_protocol::config_types::SERVICE_TIER_PRIORITY;
use codex_protocol::config_types::ServiceTier;
use codex_protocol::config_types::priority_service_tier;
use codex_protocol::openai_models::ModelPreset;
use codex_protocol::openai_models::model_service_tier;
use codex_protocol::openai_models::model_supports_service_tier;
@@ -44,6 +44,6 @@ pub(crate) fn current_service_tier_status_label(chat: &ChatWidget) -> String {
pub(crate) fn model_supports_fast_mode(chat: &ChatWidget, model: &str) -> bool {
model_preset(chat, model)
.map(|preset| model_supports_service_tier(&preset, &priority_service_tier()))
.map(|preset| model_supports_service_tier(&preset, &SERVICE_TIER_PRIORITY.into()))
.unwrap_or(false)
}
@@ -1,7 +1,8 @@
use super::*;
use crate::bottom_pane::slash_commands::ServiceTierCommand;
use crate::bottom_pane::slash_commands::SlashCommandAction;
use codex_protocol::config_types::priority_service_tier;
use codex_protocol::config_types::SERVICE_TIER_PRIORITY;
use codex_protocol::config_types::ServiceTier;
use pretty_assertions::assert_eq;
fn complete_turn_with_message(chat: &mut ChatWidget, turn_id: &str, message: Option<&str>) {
@@ -32,7 +33,7 @@ fn queue_composer_text_with_tab(chat: &mut ChatWidget, text: &str) {
fn fast_service_tier_command() -> SlashCommandAction {
SlashCommandAction::ServiceTier(ServiceTierCommand {
service_tier: priority_service_tier(),
service_tier: SERVICE_TIER_PRIORITY.into(),
command: "fast".to_string(),
name: "Fast".to_string(),
description: "Fast tier".to_string(),
@@ -1709,7 +1710,7 @@ async fn fast_slash_command_updates_and_persists_local_service_tier() {
chat.dispatch_command(fast_service_tier_command());
let events = std::iter::from_fn(|| rx.try_recv().ok()).collect::<Vec<_>>();
let priority_tier = priority_service_tier();
let priority_tier = ServiceTier::from(SERVICE_TIER_PRIORITY);
assert!(
events.iter().any(|event| matches!(
event,
@@ -1752,7 +1753,7 @@ async fn user_turn_carries_service_tier_after_fast_toggle() {
Op::UserTurn {
service_tier: Some(Some(tier)),
..
} if tier == priority_service_tier() => {}
} if tier == SERVICE_TIER_PRIORITY.into() => {}
other => panic!("expected Op::UserTurn with fast service tier, got {other:?}"),
}
}
@@ -1771,7 +1772,7 @@ async fn queued_fast_slash_applies_before_next_queued_message() {
complete_turn_with_message(&mut chat, "turn-1", Some("done"));
let events = std::iter::from_fn(|| rx.try_recv().ok()).collect::<Vec<_>>();
let priority_tier = priority_service_tier();
let priority_tier = ServiceTier::from(SERVICE_TIER_PRIORITY);
assert!(
events.iter().any(|event| matches!(
event,
@@ -1788,7 +1789,7 @@ async fn queued_fast_slash_applies_before_next_queued_message() {
items,
service_tier: Some(Some(tier)),
..
} if tier == priority_service_tier() => assert_eq!(
} if tier == SERVICE_TIER_PRIORITY.into() => assert_eq!(
items,
vec![UserInput::Text {
text: "hello after fast".to_string(),
@@ -1,6 +1,6 @@
use super::*;
use crate::bottom_pane::goal_status_indicator_line;
use codex_protocol::config_types::priority_service_tier;
use codex_protocol::config_types::SERVICE_TIER_PRIORITY;
use codex_protocol::openai_models::model_supports_service_tier;
use pretty_assertions::assert_eq;
@@ -1020,9 +1020,9 @@ async fn fast_status_indicator_requires_chatgpt_auth() {
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.set_service_tier(Some(priority_service_tier()));
chat.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
assert!(!chat.should_show_fast_status(chat.current_model(), chat.current_service_tier(),));
@@ -1030,7 +1030,7 @@ async fn fast_status_indicator_requires_chatgpt_auth() {
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
assert!(chat.should_show_fast_status(chat.current_model(), chat.current_service_tier(),));
@@ -1042,14 +1042,14 @@ async fn fast_status_indicator_is_hidden_for_models_without_fast_support() {
set_fast_mode_test_catalog(&mut chat);
assert!(!model_supports_service_tier(
&get_available_model(&chat, "gpt-5.3-codex"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.set_service_tier(Some(priority_service_tier()));
chat.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
set_chatgpt_auth(&mut chat);
set_fast_mode_test_catalog(&mut chat);
assert!(!model_supports_service_tier(
&get_available_model(&chat, "gpt-5.3-codex"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
assert!(!chat.should_show_fast_status(chat.current_model(), chat.current_service_tier(),));
@@ -1061,13 +1061,13 @@ async fn fast_status_indicator_is_hidden_when_fast_mode_is_off() {
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
set_chatgpt_auth(&mut chat);
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
assert!(!chat.should_show_fast_status(chat.current_model(), chat.current_service_tier(),));
@@ -1385,7 +1385,7 @@ async fn status_line_fast_mode_renders_on_and_off() {
chat.refresh_status_line();
assert_eq!(status_line_text(&chat), Some("Tier default".to_string()));
chat.set_service_tier(Some(priority_service_tier()));
chat.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
chat.refresh_status_line();
assert_eq!(status_line_text(&chat), Some("Tier Fast".to_string()));
}
@@ -1398,7 +1398,7 @@ async fn status_line_fast_mode_footer_snapshot() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.show_welcome_banner = false;
chat.config.tui_status_line = Some(vec!["fast-mode".to_string()]);
chat.set_service_tier(Some(priority_service_tier()));
chat.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
chat.refresh_status_line();
let width = 80;
@@ -1419,7 +1419,7 @@ async fn status_line_model_with_reasoning_includes_fast_for_fast_capable_models(
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.config.cwd = test_project_path().abs();
chat.config.tui_status_line = Some(vec![
@@ -1428,12 +1428,12 @@ async fn status_line_model_with_reasoning_includes_fast_for_fast_capable_models(
"current-dir".to_string(),
]);
chat.set_reasoning_effort(Some(ReasoningEffortConfig::XHigh));
chat.set_service_tier(Some(priority_service_tier()));
chat.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
set_chatgpt_auth(&mut chat);
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.refresh_status_line();
let test_cwd = test_path_display("/tmp/project");
@@ -1572,7 +1572,7 @@ async fn status_line_model_with_reasoning_fast_footer_snapshot() {
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.show_welcome_banner = false;
chat.config.cwd = test_project_path().abs();
@@ -1582,12 +1582,12 @@ async fn status_line_model_with_reasoning_fast_footer_snapshot() {
"current-dir".to_string(),
]);
chat.set_reasoning_effort(Some(ReasoningEffortConfig::XHigh));
chat.set_service_tier(Some(priority_service_tier()));
chat.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
set_chatgpt_auth(&mut chat);
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.refresh_status_line();
@@ -1612,7 +1612,7 @@ async fn status_line_model_with_reasoning_context_remaining_footer_snapshot() {
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.show_welcome_banner = false;
chat.config.cwd = test_project_path().abs();
@@ -1622,12 +1622,12 @@ async fn status_line_model_with_reasoning_context_remaining_footer_snapshot() {
"current-dir".to_string(),
]);
chat.set_reasoning_effort(Some(ReasoningEffortConfig::XHigh));
chat.set_service_tier(Some(priority_service_tier()));
chat.set_service_tier(Some(SERVICE_TIER_PRIORITY.into()));
set_chatgpt_auth(&mut chat);
set_fast_mode_test_catalog(&mut chat);
assert!(model_supports_service_tier(
&get_available_model(&chat, "gpt-5.4"),
&priority_service_tier()
&SERVICE_TIER_PRIORITY.into()
));
chat.refresh_status_line();