mirror of
https://github.com/openai/codex.git
synced 2026-11-28 07:32:19 +00:00
Refine hook activity rendering in the TUI (#42118)
## What changed - Show revealed running hooks in the bottom activity area instead of the conversation viewport or transcript overlay. Fold the hook message into the active status row when space permits and reflow it below the row without displacing background-process controls or status details. - Keep fast hooks hidden, collapse concurrent hooks to a shared summary when needed, and support hook activity outside an active agent turn. - Simplify durable hook output into user-facing messages and actionable failure, block, and stop states. Suppress model-facing context and quiet successful completions from all TUI history surfaces. ## Testing - Add lifecycle, layout, narrow-width, multi-width Unicode, transcript, restart, and completion-output coverage for hook status and history rendering. GitOrigin-RevId: 4c52b7a736e9e466e109107eb3c04a39d089597f
This commit is contained in:
1 parent
ea7e0714da
commit
bc39b0ed59
35 files changed
+903
-945
No files matched your search
@@ -0,0 +1,32 @@
|
||||
//! Transient hook activity, independent of whether an agent turn owns a status row.
|
||||
|
||||
use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
|
||||
use crate::motion::MotionMode;
|
||||
use crate::motion::shimmer_text;
|
||||
use crate::render::renderable::Renderable;
|
||||
use crate::text_formatting::capitalize_first;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::Stylize;
|
||||
use ratatui::text::Line;
|
||||
|
||||
pub(super) struct HookStatus<'a> {
|
||||
pub message: &'a str,
|
||||
pub animations_enabled: bool,
|
||||
}
|
||||
|
||||
impl Renderable for HookStatus<'_> {
|
||||
fn render(&self, area: Rect, buf: &mut Buffer) {
|
||||
let mut spans = vec!["• ".dim()];
|
||||
spans.extend(shimmer_text(
|
||||
&capitalize_first(self.message),
|
||||
MotionMode::from_animations_enabled(self.animations_enabled),
|
||||
));
|
||||
truncate_line_with_ellipsis_if_overflow(Line::from(spans).dim(), usize::from(area.width))
|
||||
.render(area, buf);
|
||||
}
|
||||
|
||||
fn desired_height(&self, _width: u16) -> u16 {
|
||||
1
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ mod actionable_banner;
|
||||
mod app_link_view;
|
||||
mod apply_patch_header;
|
||||
mod approval_overlay;
|
||||
mod hook_status;
|
||||
mod mcp_server_elicitation;
|
||||
mod multi_select_picker;
|
||||
mod request_user_input;
|
||||
@@ -248,6 +249,8 @@ pub(crate) struct BottomPane {
|
||||
|
||||
/// Inline status indicator shown above the composer while a task is running.
|
||||
status: Option<StatusIndicatorWidget>,
|
||||
/// Running-hook summary supplied by the lifecycle owner after its reveal delay.
|
||||
hook_status_message: Option<String>,
|
||||
inline_banner: Option<actionable_banner::InlineBanner>,
|
||||
/// Streaming may drop the row without losing its elapsed time or modal pause.
|
||||
status_timer: crate::status_indicator_widget::StatusTimer,
|
||||
@@ -321,6 +324,7 @@ impl BottomPane {
|
||||
disable_paste_burst,
|
||||
is_task_running: false,
|
||||
status: None,
|
||||
hook_status_message: None,
|
||||
inline_banner: None,
|
||||
status_timer: crate::status_indicator_widget::StatusTimer::default(),
|
||||
unified_exec_footer: UnifiedExecFooter::new(),
|
||||
@@ -1434,13 +1438,29 @@ impl BottomPane {
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy unified-exec summary text into the active status row, if any.
|
||||
/// Update hook activity after the lifecycle reveal delay, even outside a turn.
|
||||
pub(crate) fn set_hook_status_message(&mut self, message: Option<String>) {
|
||||
if self.hook_status_message == message {
|
||||
return;
|
||||
}
|
||||
|
||||
self.hook_status_message = message;
|
||||
if self.hook_status_message.is_some() && self.status.is_none() && self.is_task_running() {
|
||||
self.ensure_status_indicator();
|
||||
} else {
|
||||
self.sync_status_inline_message();
|
||||
self.request_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy background activity and hook text into the active status row, if any.
|
||||
///
|
||||
/// This keeps status-line inline text synchronized without forcing the
|
||||
/// standalone unified-exec footer row to be visible.
|
||||
fn sync_status_inline_message(&mut self) {
|
||||
if let Some(status) = self.status.as_mut() {
|
||||
status.update_inline_message(self.unified_exec_footer.summary_text());
|
||||
status.update_hook_status_message(self.hook_status_message.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1877,6 +1897,17 @@ impl BottomPane {
|
||||
RenderableItem::Owned(Box::new(status.with_timer(&self.status_timer))),
|
||||
);
|
||||
}
|
||||
if self.status.is_none()
|
||||
&& let Some(message) = &self.hook_status_message
|
||||
{
|
||||
flex.push(
|
||||
/*flex*/ 0,
|
||||
RenderableItem::Owned(Box::new(hook_status::HookStatus {
|
||||
message,
|
||||
animations_enabled: self.animations_enabled,
|
||||
})),
|
||||
);
|
||||
}
|
||||
// Avoid double-surfacing the same summary and avoid adding an extra
|
||||
// row while the status line is already visible.
|
||||
if self.status_widget().is_none() && !self.unified_exec_footer.is_empty() {
|
||||
@@ -1889,8 +1920,9 @@ impl BottomPane {
|
||||
let has_pending_input = !self.pending_input_preview.queued_messages.is_empty()
|
||||
|| !self.pending_input_preview.pending_steers.is_empty()
|
||||
|| !self.pending_input_preview.rejected_steers.is_empty();
|
||||
let has_status_or_footer =
|
||||
self.status_widget().is_some() || !self.unified_exec_footer.is_empty();
|
||||
let has_status_or_footer = self.status_widget().is_some()
|
||||
|| self.hook_status_message.is_some()
|
||||
|| !self.unified_exec_footer.is_empty();
|
||||
let has_inline_previews = has_pending_thread_approvals || has_pending_input;
|
||||
if has_inline_previews && has_status_or_footer {
|
||||
flex.push(/*flex*/ 0, RenderableItem::Owned("".into()));
|
||||
|
||||
Reference in new issue
Block a user