Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Show error message after panic (#1752)

easong-openai861ba8640356
diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs
index 351fab4df8..6b5fe7f7ae 100644
--- a/codex-rs/tui/src/lib.rs
+++ b/codex-rs/tui/src/lib.rs
@@ -176,9 +176,13 @@ fn run_ratatui_app(
color_eyre::install()?;
// Forward panic reports through tracing so they appear in the UI status
- // line instead of interleaving raw panic output with the interface.
- std::panic::set_hook(Box::new(|info| {
+ // line, but do not swallow the default/color-eyre panic handler.
+ // Chain to the previous hook so users still get a rich panic report
+ // (including backtraces) after we restore the terminal.
+ let prev_hook = std::panic::take_hook();
+ std::panic::set_hook(Box::new(move |info| {
tracing::error!("panic: {info}");
+ prev_hook(info);
}));
let mut terminal = tui::init(&config)?;
terminal.clear()?;