This commit is contained in:
Gabriel Peal
2025-06-25 08:36:16 -04:00
parent 8edbd6e99e
commit 675e99329e
4 changed files with 9 additions and 41 deletions
+2 -6
View File
@@ -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<ResponseItem>,
) -> CodexResult<Vec<ProcessedResponseItem>> {
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,
+5 -5
View File
@@ -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 { .. } => {}
},
+1 -1
View File
@@ -122,7 +122,7 @@ pub fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> std::io::
// Channel that carries formatted log lines to the UI.
let (log_tx, log_rx) = tokio::sync::mpsc::unbounded_channel::<String>();
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)
+1 -29
View File
@@ -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<String>,
max_len: usize,
}
impl TuiLogLayer {
pub fn new(tx: UnboundedSender<String>, max_len: usize) -> Self {
pub fn new(tx: UnboundedSender<String>) -> 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);
}