show fast header status only for chatgpt auth

This commit is contained in:
pash
2026-03-04 15:03:48 -08:00
parent 859e94bad2
commit 65e99c76ed
6 changed files with 79 additions and 57 deletions
+4 -1
View File
@@ -801,7 +801,8 @@ impl App {
history_cell::SessionHeaderHistoryCell::new(
self.chat_widget.current_model().to_string(),
self.chat_widget.current_reasoning_effort(),
self.chat_widget.current_service_tier(),
self.chat_widget
.should_show_fast_status(self.chat_widget.current_service_tier()),
self.config.cwd.clone(),
version,
)
@@ -4394,6 +4395,7 @@ mod tests {
is_first,
None,
None,
false,
)) as Arc<dyn HistoryCell>
};
@@ -5032,6 +5034,7 @@ mod tests {
is_first,
None,
None,
false,
)) as Arc<dyn HistoryCell>
};
+12 -1
View File
@@ -1189,6 +1189,7 @@ impl ChatWidget {
self.sync_fast_command_enabled();
self.sync_personality_command_enabled();
let startup_tooltip_override = self.startup_tooltip_override.take();
let show_fast_status = self.should_show_fast_status(event.service_tier);
let session_info_cell = history_cell::new_session_info(
&self.config,
&model_for_header,
@@ -1198,6 +1199,7 @@ impl ChatWidget {
self.auth_manager
.auth_cached()
.and_then(|auth| auth.account_plan_type()),
show_fast_status,
);
self.apply_session_info_cell(session_info_cell);
@@ -7060,6 +7062,15 @@ impl ChatWidget {
self.config.service_tier
}
pub(crate) fn should_show_fast_status(&self, service_tier: Option<ServiceTier>) -> bool {
matches!(service_tier, Some(ServiceTier::Fast))
&& self
.auth_manager
.auth_cached()
.as_ref()
.is_some_and(|auth| auth.is_chatgpt_auth())
}
fn fast_mode_enabled(&self) -> bool {
self.config.features.enabled(Feature::FastMode)
}
@@ -7394,7 +7405,7 @@ impl ChatWidget {
DEFAULT_MODEL_DISPLAY_NAME.to_string(),
placeholder_style,
None,
config.service_tier,
false,
config.cwd.clone(),
CODEX_CLI_VERSION,
))
+20
View File
@@ -7264,6 +7264,26 @@ async fn user_turn_carries_service_tier_after_fast_toggle() {
}
}
#[tokio::test]
async fn fast_status_indicator_requires_chatgpt_auth() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(Some("gpt-5.3-codex")).await;
chat.set_service_tier(Some(ServiceTier::Fast));
assert!(!chat.should_show_fast_status(chat.current_service_tier()));
set_chatgpt_auth(&mut chat);
assert!(chat.should_show_fast_status(chat.current_service_tier()));
}
#[tokio::test]
async fn fast_status_indicator_is_hidden_when_fast_mode_is_off() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(Some("gpt-5.3-codex")).await;
set_chatgpt_auth(&mut chat);
assert!(!chat.should_show_fast_status(chat.current_service_tier()));
}
#[tokio::test]
async fn approvals_popup_shows_disabled_presets() {
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None).await;
+37 -45
View File
@@ -44,7 +44,6 @@ use codex_core::plugins::PluginsManager;
use codex_core::web_search::web_search_detail;
use codex_otel::RuntimeMetricsSummary;
use codex_protocol::account::PlanType;
use codex_protocol::config_types::ServiceTier;
use codex_protocol::mcp::Resource;
use codex_protocol::mcp::ResourceTemplate;
use codex_protocol::models::WebSearchAction;
@@ -1047,6 +1046,7 @@ pub(crate) fn new_session_info(
is_first_event: bool,
tooltip_override: Option<String>,
auth_plan: Option<PlanType>,
show_fast_status: bool,
) -> SessionInfoCell {
let SessionConfiguredEvent {
model,
@@ -1057,7 +1057,7 @@ pub(crate) fn new_session_info(
let header = SessionHeaderHistoryCell::new(
model.clone(),
reasoning_effort,
config.service_tier,
show_fast_status,
config.cwd.clone(),
CODEX_CLI_VERSION,
);
@@ -1139,7 +1139,7 @@ pub(crate) struct SessionHeaderHistoryCell {
model: String,
model_style: Style,
reasoning_effort: Option<ReasoningEffortConfig>,
service_tier: Option<ServiceTier>,
show_fast_status: bool,
directory: PathBuf,
}
@@ -1147,7 +1147,7 @@ impl SessionHeaderHistoryCell {
pub(crate) fn new(
model: String,
reasoning_effort: Option<ReasoningEffortConfig>,
service_tier: Option<ServiceTier>,
show_fast_status: bool,
directory: PathBuf,
version: &'static str,
) -> Self {
@@ -1155,7 +1155,7 @@ impl SessionHeaderHistoryCell {
model,
Style::default(),
reasoning_effort,
service_tier,
show_fast_status,
directory,
version,
)
@@ -1165,7 +1165,7 @@ impl SessionHeaderHistoryCell {
model: String,
model_style: Style,
reasoning_effort: Option<ReasoningEffortConfig>,
service_tier: Option<ServiceTier>,
show_fast_status: bool,
directory: PathBuf,
version: &'static str,
) -> Self {
@@ -1174,7 +1174,7 @@ impl SessionHeaderHistoryCell {
model,
model_style,
reasoning_effort,
service_tier,
show_fast_status,
directory,
}
}
@@ -1216,13 +1216,6 @@ impl SessionHeaderHistoryCell {
ReasoningEffortConfig::None => "none",
})
}
fn speed_label(&self) -> &'static str {
match self.service_tier {
Some(ServiceTier::Fast) => "fast",
_ => "standard",
}
}
}
impl HistoryCell for SessionHeaderHistoryCell {
@@ -1243,8 +1236,6 @@ impl HistoryCell for SessionHeaderHistoryCell {
const CHANGE_MODEL_HINT_COMMAND: &str = "/model";
const CHANGE_MODEL_HINT_EXPLANATION: &str = " to change";
const CHANGE_SPEED_HINT_COMMAND: &str = "/fast";
const CHANGE_SPEED_HINT_EXPLANATION: &str = " to change";
const DIR_LABEL: &str = "directory:";
let label_width = DIR_LABEL.len();
@@ -1254,12 +1245,6 @@ impl HistoryCell for SessionHeaderHistoryCell {
label_width = label_width
);
let reasoning_label = self.reasoning_label();
let model_value_width = UnicodeWidthStr::width(self.model.as_str())
+ reasoning_label
.map(|reasoning| 1 + UnicodeWidthStr::width(reasoning))
.unwrap_or_default();
let speed_value_width = UnicodeWidthStr::width(self.speed_label());
let hint_column_width = model_value_width.max(speed_value_width) + 3;
let model_spans: Vec<Span<'static>> = {
let mut spans = vec![
Span::from(format!("{model_label} ")).dim(),
@@ -1269,7 +1254,11 @@ impl HistoryCell for SessionHeaderHistoryCell {
spans.push(Span::from(" "));
spans.push(Span::from(reasoning));
}
spans.push(" ".repeat(hint_column_width - model_value_width).dim());
if self.show_fast_status {
spans.push(" ".into());
spans.push(Span::styled("fast", self.model_style));
}
spans.push(" ".dim());
spans.push(CHANGE_MODEL_HINT_COMMAND.cyan());
spans.push(CHANGE_MODEL_HINT_EXPLANATION.dim());
spans
@@ -1282,24 +1271,10 @@ impl HistoryCell for SessionHeaderHistoryCell {
let dir = self.format_directory(Some(dir_max_width));
let dir_spans = vec![Span::from(dir_prefix).dim(), Span::from(dir)];
let speed_label = format!(
"{speed_label:<label_width$}",
speed_label = "speed:",
label_width = label_width
);
let speed_spans = vec![
Span::from(format!("{speed_label} ")).dim(),
Span::styled(self.speed_label(), self.model_style),
" ".repeat(hint_column_width - speed_value_width).dim(),
CHANGE_SPEED_HINT_COMMAND.cyan(),
CHANGE_SPEED_HINT_EXPLANATION.dim(),
];
let lines = vec![
make_row(title_spans),
make_row(Vec::new()),
make_row(model_spans),
make_row(speed_spans),
make_row(dir_spans),
];
@@ -2627,6 +2602,7 @@ mod tests {
false,
Some("Model just became available".to_string()),
Some(PlanType::Free),
false,
);
let rendered = render_transcript(&cell).join("\n");
@@ -2644,6 +2620,7 @@ mod tests {
false,
Some("Model just became available".to_string()),
Some(PlanType::Free),
false,
);
let rendered = render_transcript(&cell).join("\n");
@@ -2660,6 +2637,7 @@ mod tests {
true,
Some("Model just became available".to_string()),
Some(PlanType::Free),
false,
);
let rendered = render_transcript(&cell).join("\n");
@@ -2678,6 +2656,7 @@ mod tests {
false,
Some("Model just became available".to_string()),
Some(PlanType::Free),
false,
);
let rendered = render_transcript(&cell).join("\n");
@@ -3310,7 +3289,7 @@ mod tests {
let cell = SessionHeaderHistoryCell::new(
"gpt-4o".to_string(),
Some(ReasoningEffortConfig::High),
Some(ServiceTier::Fast),
true,
std::env::temp_dir(),
"test",
);
@@ -3320,16 +3299,29 @@ mod tests {
.iter()
.find(|line| line.contains("model:"))
.expect("model line");
let speed_line = lines
assert!(model_line.contains("gpt-4o high fast"));
assert!(model_line.contains("/model to change"));
}
#[test]
fn session_header_hides_fast_status_when_disabled() {
let cell = SessionHeaderHistoryCell::new(
"gpt-4o".to_string(),
Some(ReasoningEffortConfig::High),
false,
std::env::temp_dir(),
"test",
);
let lines = render_lines(&cell.display_lines(80));
let model_line = lines
.iter()
.find(|line| line.contains("speed:"))
.expect("speed line");
.find(|line| line.contains("model:"))
.expect("model line");
assert!(model_line.contains("gpt-4o high"));
assert!(model_line.contains("/model to change"));
assert!(speed_line.contains("fast"));
assert!(speed_line.contains("/fast to change"));
assert_eq!(model_line.find("/model"), speed_line.find("/fast"));
assert!(!model_line.contains("fast"));
}
#[test]
@@ -1,12 +1,10 @@
---
source: tui/src/app.rs
assertion_line: 4441
expression: rendered
---
╭─────────────────────────────────────────────╮
│ >_ OpenAI Codex (v<VERSION>) │
│ │
│ model: gpt-test high /model to change │
│ speed: standard /fast to change │
│ directory: /tmp/project │
╰─────────────────────────────────────────────╯
@@ -1,14 +1,12 @@
---
source: tui/src/history_cell.rs
assertion_line: 2650
expression: rendered
---
╭────────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-5 /model to change │
│ speed: standard /fast to change │
│ directory: /tmp/project │
╰────────────────────────────────────────╯
╭─────────────────────────────────────╮
│ >_ OpenAI Codex (v0.0.0) │
│ │
│ model: gpt-5 /model to change │
│ directory: /tmp/project │
╰─────────────────────────────────────╯
Tip: Model just became available