fix(tui): trim prompt fallback and reset upgrade flag

This commit is contained in:
James Peter
2025-09-29 18:34:45 +10:00
parent 4a4b70dd71
commit 79f02a1859
3 changed files with 22 additions and 11 deletions
+1 -1
View File
@@ -1874,7 +1874,7 @@ impl App<'_> {
SlashCommand::Plan | SlashCommand::Solve | SlashCommand::Code => {
// These should have been expanded already, but handle them anyway
if let AppState::Chat { widget } = &mut self.app_state {
let expanded = command.expand_prompt(&command_args);
let expanded = command.expand_prompt(command_args.trim());
if let Some(prompt) = expanded {
widget.submit_prompt_with_display(command_text.clone(), prompt);
}
+2
View File
@@ -1106,6 +1106,7 @@ fn slash_agents_opens_overview() {
#[test]
fn slash_upgrade_opens_guided_terminal() {
crate::updates::reset_force_upgrade_preview_for_tests();
let _npm_guard = EnvGuard::set("CODEX_MANAGED_BY_NPM", "1");
let _upgrade_guard = EnvGuard::set("SHOW_UPGRADE", "1");
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
@@ -1139,6 +1140,7 @@ fn slash_upgrade_opens_guided_terminal() {
}
assert!(saw_open_terminal, "expected guided upgrade terminal to open");
crate::updates::reset_force_upgrade_preview_for_tests();
}
#[test]
+19 -10
View File
@@ -1,8 +1,8 @@
use chrono::DateTime;
use chrono::Utc;
use once_cell::sync::Lazy;
use serde::Deserialize;
use serde::Serialize;
use std::sync::OnceLock;
use std::fs;
use std::io::ErrorKind;
use std::io::Write;
@@ -19,17 +19,26 @@ use codex_core::default_client::create_client;
use tokio::process::Command;
use tracing::{info, warn};
static FORCE_UPGRADE_PREVIEW: Lazy<bool> = Lazy::new(|| {
std::env::var("SHOW_UPGRADE")
.map(|value| {
let normalized = value.trim().to_ascii_lowercase();
matches!(normalized.as_str(), "1" | "true" | "yes" | "on")
})
.unwrap_or(false)
});
static FORCE_UPGRADE_PREVIEW: OnceLock<bool> = OnceLock::new();
fn force_upgrade_preview_enabled() -> bool {
*FORCE_UPGRADE_PREVIEW.get_or_init(|| {
std::env::var("SHOW_UPGRADE")
.map(|value| {
let normalized = value.trim().to_ascii_lowercase();
matches!(normalized.as_str(), "1" | "true" | "yes" | "on")
})
.unwrap_or(false)
})
}
#[cfg(test)]
pub(crate) fn reset_force_upgrade_preview_for_tests() {
FORCE_UPGRADE_PREVIEW.take();
}
pub fn upgrade_ui_enabled() -> bool {
!cfg!(debug_assertions) || *FORCE_UPGRADE_PREVIEW
!cfg!(debug_assertions) || force_upgrade_preview_enabled()
}
pub fn auto_upgrade_runtime_enabled() -> bool {