mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Trim TUI legacy core helper usage (#22695)
## Why The TUI still had a few low-risk dependencies flowing through the transitional `legacy_core` namespace after the app-server migration. These helpers either already have clearer non-core owners or are presentation logic that does not belong in `codex-core`, so moving them out reduces the compatibility surface without changing product behavior. ## What changed This is a low-risk change, almost completely mechanical in nature. - Route TUI Codex-home lookup through `codex-utils-home-dir`, use `Config::log_dir` directly, and call `codex-sandboxing::system_bwrap_warning` without going through `legacy_core`. - Move shared `codex resume` hint formatting from `codex-core` into `codex-utils-cli`. - Update CLI and TUI call sites to use the shared CLI utility, and keep the resume-command behavior covered by tests in its new home. ## Verification - `cargo test -p codex-utils-cli` - `cargo test -p codex-utils-cli resume_command`
This commit is contained in:
@@ -397,8 +397,7 @@ fn session_summary(
|
||||
let usage_line = (!token_usage.is_zero()).then(|| token_usage.to_string());
|
||||
let thread_id =
|
||||
resumable_thread(thread_id, thread_name, rollout_path).map(|thread| thread.thread_id);
|
||||
let resume_command =
|
||||
crate::legacy_core::util::resume_command(/*thread_name*/ None, thread_id);
|
||||
let resume_command = codex_utils_cli::resume_command(/*thread_name*/ None, thread_id);
|
||||
|
||||
if usage_line.is_none() && resume_command.is_none() {
|
||||
return None;
|
||||
|
||||
@@ -66,9 +66,9 @@ pub(super) fn emit_project_config_warnings(app_event_tx: &AppEventSender, config
|
||||
}
|
||||
|
||||
pub(super) fn emit_system_bwrap_warning(app_event_tx: &AppEventSender, config: &Config) {
|
||||
let Some(message) = crate::legacy_core::config::system_bwrap_warning(
|
||||
config.permissions.permission_profile.get(),
|
||||
) else {
|
||||
let Some(message) =
|
||||
codex_sandboxing::system_bwrap_warning(config.permissions.permission_profile.get())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
@@ -165,6 +165,7 @@ use codex_terminal_detection::TerminalInfo;
|
||||
use codex_terminal_detection::TerminalName;
|
||||
use codex_terminal_detection::terminal_info;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_cli::resume_command;
|
||||
use crossterm::event::KeyCode;
|
||||
use crossterm::event::KeyEvent;
|
||||
use crossterm::event::KeyEventKind;
|
||||
@@ -1433,8 +1434,8 @@ impl ChatWidget {
|
||||
}
|
||||
|
||||
fn rename_confirmation_cell(name: &str, thread_id: Option<ThreadId>) -> PlainHistoryCell {
|
||||
let resume_cmd = crate::legacy_core::util::resume_command(Some(name), thread_id)
|
||||
.unwrap_or_else(|| format!("codex resume {name}"));
|
||||
let resume_cmd =
|
||||
resume_command(Some(name), thread_id).unwrap_or_else(|| format!("codex resume {name}"));
|
||||
let name = name.to_string();
|
||||
let line = vec![
|
||||
"• ".into(),
|
||||
|
||||
@@ -7,7 +7,7 @@ use super::*;
|
||||
|
||||
impl ChatWidget {
|
||||
pub(super) fn open_theme_picker(&mut self) {
|
||||
let codex_home = crate::legacy_core::config::find_codex_home().ok();
|
||||
let codex_home = codex_utils_home_dir::find_codex_home().ok();
|
||||
let terminal_width = self
|
||||
.last_rendered_width
|
||||
.get()
|
||||
|
||||
@@ -7,7 +7,6 @@ use crate::legacy_core::check_execpolicy_for_warnings;
|
||||
use crate::legacy_core::config::Config;
|
||||
use crate::legacy_core::config::ConfigBuilder;
|
||||
use crate::legacy_core::config::ConfigOverrides;
|
||||
use crate::legacy_core::config::find_codex_home;
|
||||
use crate::legacy_core::config::load_config_as_toml_with_cli_and_load_options;
|
||||
use crate::legacy_core::config::resolve_oss_provider;
|
||||
use crate::legacy_core::config::resolve_profile_v2_config_path;
|
||||
@@ -56,6 +55,7 @@ use codex_rollout::state_db;
|
||||
use codex_state::log_db;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use codex_utils_absolute_path::canonicalize_existing_preserving_symlinks;
|
||||
use codex_utils_home_dir::find_codex_home;
|
||||
use codex_utils_oss::ensure_oss_provider_ready;
|
||||
use codex_utils_oss::get_default_model_for_oss_provider;
|
||||
use color_eyre::eyre::WrapErr;
|
||||
@@ -1073,7 +1073,7 @@ pub async fn run_main(
|
||||
}
|
||||
}
|
||||
|
||||
let log_dir = crate::legacy_core::config::log_dir(&config)?;
|
||||
let log_dir = config.log_dir.clone();
|
||||
std::fs::create_dir_all(&log_dir)?;
|
||||
// Open (or create) your log file, appending to it.
|
||||
let mut log_file_opts = OpenOptions::new();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use clap::Parser;
|
||||
use codex_app_server_client::legacy_core;
|
||||
use codex_arg0::Arg0DispatchPaths;
|
||||
use codex_arg0::arg0_dispatch_or_else;
|
||||
use codex_config::LoaderOverrides;
|
||||
@@ -8,6 +7,7 @@ use codex_tui::Cli;
|
||||
use codex_tui::ExitReason;
|
||||
use codex_tui::run_main;
|
||||
use codex_utils_cli::CliConfigOverrides;
|
||||
use codex_utils_cli::resume_command;
|
||||
use supports_color::Stream;
|
||||
|
||||
fn format_exit_messages(exit_info: AppExitInfo, color_enabled: bool) -> Vec<String> {
|
||||
@@ -22,9 +22,7 @@ fn format_exit_messages(exit_info: AppExitInfo, color_enabled: bool) -> Vec<Stri
|
||||
lines.push(token_usage.to_string());
|
||||
}
|
||||
|
||||
if let Some(resume_cmd) =
|
||||
legacy_core::util::resume_command(/*thread_name*/ None, thread_id)
|
||||
{
|
||||
if let Some(resume_cmd) = resume_command(/*thread_name*/ None, thread_id) {
|
||||
let command = if color_enabled {
|
||||
format!("\u{1b}[36m{resume_cmd}\u{1b}[39m")
|
||||
} else {
|
||||
|
||||
@@ -88,10 +88,7 @@ pub(crate) fn maybe_init(config: &Config) {
|
||||
let path = if let Ok(path) = std::env::var("CODEX_TUI_SESSION_LOG_PATH") {
|
||||
PathBuf::from(path)
|
||||
} else {
|
||||
let mut p = match crate::legacy_core::config::log_dir(config) {
|
||||
Ok(dir) => dir,
|
||||
Err(_) => std::env::temp_dir(),
|
||||
};
|
||||
let mut p = config.log_dir.clone();
|
||||
let filename = format!(
|
||||
"session-{}.jsonl",
|
||||
chrono::Utc::now().format("%Y%m%dT%H%M%SZ")
|
||||
|
||||
Reference in New Issue
Block a user