Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Show completed hook warnings in TUI headers (#34416)

Abhinavcf821e8ec850
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__post_tool_use_hook_events_render_snapshot.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__post_tool_use_hook_events_render_snapshot.snap
index b00225f1cd..42861562ea 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__post_tool_use_hook_events_render_snapshot.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__post_tool_use_hook_events_render_snapshot.snap
@@ -2,6 +2,5 @@
source: tui/src/chatwidget/tests/helpers.rs
expression: combined
---
-• PostToolUse hook (completed)
- warning: Heads up from the hook
+• PostToolUse (completed) says: Heads up from the hook
hook context: Remember the startup checklist.
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__pre_tool_use_hook_events_render_snapshot.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__pre_tool_use_hook_events_render_snapshot.snap
index 311be2edf5..2cd5581cd0 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__pre_tool_use_hook_events_render_snapshot.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__pre_tool_use_hook_events_render_snapshot.snap
@@ -2,6 +2,5 @@
source: tui/src/chatwidget/tests/helpers.rs
expression: combined
---
-• PreToolUse hook (completed)
- warning: Heads up from the hook
+• PreToolUse (completed) says: Heads up from the hook
hook context: Remember the startup checklist.
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__session_start_hook_events_render_snapshot.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__session_start_hook_events_render_snapshot.snap
index 3d08e82937..49563b27f2 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__session_start_hook_events_render_snapshot.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__session_start_hook_events_render_snapshot.snap
@@ -2,6 +2,5 @@
source: tui/src/chatwidget/tests/helpers.rs
expression: combined
---
-• SessionStart hook (completed)
- warning: Heads up from the hook
+• SessionStart (completed) says: Heads up from the hook
hook context: Remember the startup checklist.
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__user_prompt_submit_app_server_hook_notifications_render_snapshot.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__user_prompt_submit_app_server_hook_notifications_render_snapshot.snap
index 43b9194141..ab6082fdea 100644
--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__user_prompt_submit_app_server_hook_notifications_render_snapshot.snap
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__user_prompt_submit_app_server_hook_notifications_render_snapshot.snap
@@ -2,6 +2,5 @@
source: tui/src/chatwidget/tests/status_and_layout.rs
expression: combined
---
-• UserPromptSubmit hook (stopped)
- warning: go-workflow must start from PlanMode
+• UserPromptSubmit (stopped) says: go-workflow must start from PlanMode
stop: prompt blocked
diff --git a/codex-rs/tui/src/history_cell/hook_cell.rs b/codex-rs/tui/src/history_cell/hook_cell.rs
index 379b6428ce..7b3868ed28 100644
--- a/codex-rs/tui/src/history_cell/hook_cell.rs
+++ b/codex-rs/tui/src/history_cell/hook_cell.rs
@@ -457,17 +457,39 @@ impl HookRunCell {
);
}
HookRunState::Completed { status, entries } => {
+ let system_message = entries
+ .iter()
+ .find(|entry| entry.kind == HookOutputEntryKind::Warning);
+ let mut system_message_lines = system_message.map(|entry| entry.text.split('\n'));
let status_text = format!("{status:?}").to_lowercase();
- let bullet = hook_completed_bullet(*status, entries);
+ let header_text = if let Some(first_line) =
+ system_message_lines.as_mut().and_then(Iterator::next)
+ {
+ format!("{label} ({status_text}) says: {first_line}")
+ } else {
+ format!("{label} hook ({status_text})")
+ };
lines.push(
vec![
- bullet,
+ hook_completed_bullet(*status, entries),
" ".into(),
- format!("{label} hook ({status_text})").into(),
+ header_text.into(),
]
.into(),
);
+ if let Some(system_message_lines) = system_message_lines {
+ for line in system_message_lines {
+ if line.is_empty() {
+ lines.push("".into());
+ } else {
+ lines.push(format!("{HOOK_OUTPUT_BODY_INDENT}{line}").into());
+ }
+ }
+ }
for entry in entries {
+ if entry.kind == HookOutputEntryKind::Warning {
+ continue;
+ }
if !render_full_context && entry.kind == HookOutputEntryKind::Context {
lines.extend(hook_context_preview_lines(&entry.text, width));
} else {
@@ -946,9 +968,9 @@ mod tests {
}
#[test]
- fn completed_hook_multiline_warning_prefixes_first_line_only() {
+ fn completed_stop_hook_multiline_system_message_prefixes_first_line_only() {
let cell = completed_hook_cell(
- HookEventName::PostToolUse,
+ HookEventName::Stop,
HookRunStatus::Completed,
vec![HookOutputEntry {
kind: HookOutputEntryKind::Warning,
@@ -959,8 +981,7 @@ mod tests {
assert_eq!(
line_texts(&cell.display_lines(/*width*/ 80)),
vec![
- "• PostToolUse hook (completed)".to_string(),
- " warning: Heads up".to_string(),
+ "• Stop (completed) says: Heads up".to_string(),
" Review generated files".to_string(),
]
);