feat: dim the timestamp in the exec output (#1180)
This required changing `ts_println!()` to take `$self:ident`, which is a bit more verbose, but the usability improvement seems worth it. Also eliminated an unnecessary `.to_string()` while here.
This commit is contained in:
@@ -99,12 +99,13 @@ struct PatchApplyBegin {
|
|||||||
auto_approved: bool,
|
auto_approved: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Timestamped println helper. The timestamp is styled with self.dimmed.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! ts_println {
|
macro_rules! ts_println {
|
||||||
($($arg:tt)*) => {{
|
($self:ident, $($arg:tt)*) => {{
|
||||||
let now = chrono::Utc::now();
|
let now = chrono::Utc::now();
|
||||||
let formatted = now.format("%Y-%m-%dT%H:%M:%S").to_string();
|
let formatted = now.format("[%Y-%m-%dT%H:%M:%S]");
|
||||||
print!("[{}] ", formatted);
|
print!("{} ", formatted.style($self.dimmed));
|
||||||
println!($($arg)*);
|
println!($($arg)*);
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
@@ -114,7 +115,7 @@ impl EventProcessor {
|
|||||||
/// for the session. This mirrors the information shown in the TUI welcome
|
/// for the session. This mirrors the information shown in the TUI welcome
|
||||||
/// screen.
|
/// screen.
|
||||||
pub(crate) fn print_config_summary(&mut self, config: &Config, prompt: &str) {
|
pub(crate) fn print_config_summary(&mut self, config: &Config, prompt: &str) {
|
||||||
ts_println!("OpenAI Codex (research preview)\n--------");
|
ts_println!(self, "OpenAI Codex (research preview)\n--------");
|
||||||
|
|
||||||
let entries = vec![
|
let entries = vec![
|
||||||
("workdir", config.cwd.display().to_string()),
|
("workdir", config.cwd.display().to_string()),
|
||||||
@@ -134,6 +135,7 @@ impl EventProcessor {
|
|||||||
// transcript/logs before any events come in. Note the prompt may have been
|
// transcript/logs before any events come in. Note the prompt may have been
|
||||||
// read from stdin, so it may not be visible in the terminal otherwise.
|
// read from stdin, so it may not be visible in the terminal otherwise.
|
||||||
ts_println!(
|
ts_println!(
|
||||||
|
self,
|
||||||
"{}\n{}",
|
"{}\n{}",
|
||||||
"User instructions:".style(self.bold).style(self.cyan),
|
"User instructions:".style(self.bold).style(self.cyan),
|
||||||
prompt
|
prompt
|
||||||
@@ -145,16 +147,17 @@ impl EventProcessor {
|
|||||||
match msg {
|
match msg {
|
||||||
EventMsg::Error(ErrorEvent { message }) => {
|
EventMsg::Error(ErrorEvent { message }) => {
|
||||||
let prefix = "ERROR:".style(self.red);
|
let prefix = "ERROR:".style(self.red);
|
||||||
ts_println!("{prefix} {message}");
|
ts_println!(self, "{prefix} {message}");
|
||||||
}
|
}
|
||||||
EventMsg::BackgroundEvent(BackgroundEventEvent { message }) => {
|
EventMsg::BackgroundEvent(BackgroundEventEvent { message }) => {
|
||||||
ts_println!("{}", message.style(self.dimmed));
|
ts_println!(self, "{}", message.style(self.dimmed));
|
||||||
}
|
}
|
||||||
EventMsg::TaskStarted | EventMsg::TaskComplete(_) => {
|
EventMsg::TaskStarted | EventMsg::TaskComplete(_) => {
|
||||||
// Ignore.
|
// Ignore.
|
||||||
}
|
}
|
||||||
EventMsg::AgentMessage(AgentMessageEvent { message }) => {
|
EventMsg::AgentMessage(AgentMessageEvent { message }) => {
|
||||||
ts_println!(
|
ts_println!(
|
||||||
|
self,
|
||||||
"{}\n{message}",
|
"{}\n{message}",
|
||||||
"codex".style(self.bold).style(self.magenta)
|
"codex".style(self.bold).style(self.magenta)
|
||||||
);
|
);
|
||||||
@@ -172,6 +175,7 @@ impl EventProcessor {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
ts_println!(
|
ts_println!(
|
||||||
|
self,
|
||||||
"{} {} in {}",
|
"{} {} in {}",
|
||||||
"exec".style(self.magenta),
|
"exec".style(self.magenta),
|
||||||
escape_command(&command).style(self.bold),
|
escape_command(&command).style(self.bold),
|
||||||
@@ -207,11 +211,11 @@ impl EventProcessor {
|
|||||||
match exit_code {
|
match exit_code {
|
||||||
0 => {
|
0 => {
|
||||||
let title = format!("{call} succeeded{duration}:");
|
let title = format!("{call} succeeded{duration}:");
|
||||||
ts_println!("{}", title.style(self.green));
|
ts_println!(self, "{}", title.style(self.green));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let title = format!("{call} exited {exit_code}{duration}:");
|
let title = format!("{call} exited {exit_code}{duration}:");
|
||||||
ts_println!("{}", title.style(self.red));
|
ts_println!(self, "{}", title.style(self.red));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("{}", truncated_output.style(self.dimmed));
|
println!("{}", truncated_output.style(self.dimmed));
|
||||||
@@ -248,6 +252,7 @@ impl EventProcessor {
|
|||||||
);
|
);
|
||||||
|
|
||||||
ts_println!(
|
ts_println!(
|
||||||
|
self,
|
||||||
"{} {}",
|
"{} {}",
|
||||||
"tool".style(self.magenta),
|
"tool".style(self.magenta),
|
||||||
invocation.style(self.bold),
|
invocation.style(self.bold),
|
||||||
@@ -274,7 +279,7 @@ impl EventProcessor {
|
|||||||
let title_style = if is_success { self.green } else { self.red };
|
let title_style = if is_success { self.green } else { self.red };
|
||||||
let title = format!("{invocation} {status_str}{duration}:");
|
let title = format!("{invocation} {status_str}{duration}:");
|
||||||
|
|
||||||
ts_println!("{}", title.style(title_style));
|
ts_println!(self, "{}", title.style(title_style));
|
||||||
|
|
||||||
if let Ok(res) = result {
|
if let Ok(res) = result {
|
||||||
let val: serde_json::Value = res.into();
|
let val: serde_json::Value = res.into();
|
||||||
@@ -302,6 +307,7 @@ impl EventProcessor {
|
|||||||
);
|
);
|
||||||
|
|
||||||
ts_println!(
|
ts_println!(
|
||||||
|
self,
|
||||||
"{} auto_approved={}:",
|
"{} auto_approved={}:",
|
||||||
"apply_patch".style(self.magenta),
|
"apply_patch".style(self.magenta),
|
||||||
auto_approved,
|
auto_approved,
|
||||||
@@ -393,7 +399,7 @@ impl EventProcessor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let title = format!("{label} exited {exit_code}{duration}:");
|
let title = format!("{label} exited {exit_code}{duration}:");
|
||||||
ts_println!("{}", title.style(title_style));
|
ts_println!(self, "{}", title.style(title_style));
|
||||||
for line in output.lines() {
|
for line in output.lines() {
|
||||||
println!("{}", line.style(self.dimmed));
|
println!("{}", line.style(self.dimmed));
|
||||||
}
|
}
|
||||||
@@ -406,6 +412,7 @@ impl EventProcessor {
|
|||||||
}
|
}
|
||||||
EventMsg::AgentReasoning(agent_reasoning_event) => {
|
EventMsg::AgentReasoning(agent_reasoning_event) => {
|
||||||
ts_println!(
|
ts_println!(
|
||||||
|
self,
|
||||||
"{}\n{}",
|
"{}\n{}",
|
||||||
"thinking".style(self.italic).style(self.magenta),
|
"thinking".style(self.italic).style(self.magenta),
|
||||||
agent_reasoning_event.text
|
agent_reasoning_event.text
|
||||||
@@ -420,12 +427,13 @@ impl EventProcessor {
|
|||||||
} = session_configured_event;
|
} = session_configured_event;
|
||||||
|
|
||||||
ts_println!(
|
ts_println!(
|
||||||
|
self,
|
||||||
"{} {}",
|
"{} {}",
|
||||||
"codex session".style(self.magenta).style(self.bold),
|
"codex session".style(self.magenta).style(self.bold),
|
||||||
session_id.to_string().style(self.dimmed)
|
session_id.to_string().style(self.dimmed)
|
||||||
);
|
);
|
||||||
|
|
||||||
ts_println!("model: {}", model);
|
ts_println!(self, "model: {}", model);
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
EventMsg::GetHistoryEntryResponse(_) => {
|
EventMsg::GetHistoryEntryResponse(_) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user