From 675e99329e2c5457bb899023324d39296df53d16 Mon Sep 17 00:00:00 2001 From: Gabriel Peal Date: Wed, 25 Jun 2025 08:24:23 -0400 Subject: [PATCH] Cleanup --- codex-rs/core/src/codex.rs | 8 ++------ codex-rs/tui/src/app.rs | 10 +++++----- codex-rs/tui/src/lib.rs | 2 +- codex-rs/tui/src/log_layer.rs | 30 +----------------------------- 4 files changed, 9 insertions(+), 41 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 0afbc1e18e..989c6a506f 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -565,7 +565,7 @@ async fn submission_loop( notify, cwd, } => { - info!("Configuring session: model={model}; provider={provider:?}"); + debug!("Configuring session: model={model}; provider={provider:?}"); if !cwd.is_absolute() { let message = format!("cwd is not absolute: {cwd:?}"); error!(message); @@ -989,10 +989,6 @@ async fn run_turn( sub_id: String, input: Vec, ) -> CodexResult> { - debug!("[GABE] codex#run_turn"); - info!("[GABE] codex#run_turn"); - error!("[GABE] codex#run_turn"); - // Decide whether to use server-side storage (previous_response_id) or disable it let (prev_id, store) = { let state = sess.state.lock().unwrap(); @@ -1139,7 +1135,7 @@ async fn handle_response_item( action, } => { let LocalShellAction::Exec(action) = action; - tracing::info!("LocalShellCall: {action:?}"); + debug!("LocalShellCall: {action:?}"); let params = ShellToolCallParams { command: action.command, workdir: action.working_directory, diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 06201ce406..9d6dee34c8 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -9,7 +9,9 @@ use crate::scroll_event_helper::ScrollEventHelper; use crate::slash_command::SlashCommand; use crate::tui; use codex_core::config::Config; -use codex_core::protocol::{Event, EventMsg, LogEvent}; +use codex_core::protocol::Event; +use codex_core::protocol::EventMsg; +use codex_core::protocol::LogEvent; use codex_core::protocol::Op; use color_eyre::eyre::Result; use crossterm::event::KeyCode; @@ -229,10 +231,8 @@ impl<'a> App<'a> { }, AppEvent::LatestLog(line) => match &mut self.app_state { AppState::Chat { widget } => widget.handle_codex_event(Event { - id: "123".to_string(), - msg: EventMsg::Log(LogEvent { - line: line.clone(), - }) + id: String::new(), + msg: EventMsg::Log(LogEvent { line: line.clone() }), }), AppState::Login { .. } | AppState::GitWarning { .. } => {} }, diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs index 5f3e2d69b5..e0e7e53e8d 100644 --- a/codex-rs/tui/src/lib.rs +++ b/codex-rs/tui/src/lib.rs @@ -122,7 +122,7 @@ pub fn run_main(cli: Cli, codex_linux_sandbox_exe: Option) -> std::io:: // Channel that carries formatted log lines to the UI. let (log_tx, log_rx) = tokio::sync::mpsc::unbounded_channel::(); - let tui_layer = TuiLogLayer::new(log_tx.clone(), 120).with_filter(env_filter()); + let tui_layer = TuiLogLayer::new(log_tx.clone()).with_filter(env_filter()); let _ = tracing_subscriber::registry() .with(file_layer) diff --git a/codex-rs/tui/src/log_layer.rs b/codex-rs/tui/src/log_layer.rs index 5815b04fab..15a2c52ee1 100644 --- a/codex-rs/tui/src/log_layer.rs +++ b/codex-rs/tui/src/log_layer.rs @@ -19,21 +19,14 @@ use tracing_subscriber::Layer; use tracing_subscriber::layer::Context; use tracing_subscriber::registry::LookupSpan; -/// Maximum characters forwarded to the TUI. Longer messages are truncated so the -/// single‑line status indicator cannot overflow the viewport. -#[allow(dead_code)] -const _DEFAULT_MAX_LEN: usize = 120; - pub struct TuiLogLayer { tx: UnboundedSender, - max_len: usize, } impl TuiLogLayer { - pub fn new(tx: UnboundedSender, max_len: usize) -> Self { + pub fn new(tx: UnboundedSender) -> Self { Self { tx, - max_len: max_len.max(8), } } } @@ -67,27 +60,6 @@ where event.record(&mut Visitor { buf: &mut buf }); - // `String::truncate` operates on UTF‑8 code‑point boundaries and will - // panic if the provided index is not one. Because we limit the log - // line by its **byte** length we can not guarantee that the index we - // want to cut at happens to be on a boundary. Therefore we fall back - // to a simple, boundary‑safe loop that pops complete characters until - // the string is within the designated size. - - if buf.len() > self.max_len { - // Attempt direct truncate at the byte index. If that is not a - // valid boundary we advance to the next one ( ≤3 bytes away ). - if buf.is_char_boundary(self.max_len) { - buf.truncate(self.max_len); - } else { - let mut idx = self.max_len; - while idx < buf.len() && !buf.is_char_boundary(idx) { - idx += 1; - } - buf.truncate(idx); - } - } - let sanitized = buf.replace(['\n', '\r'], " "); let _ = self.tx.send(sanitized); }