Files
codex/codex-rs/tui/src/chatwidget/activity_presentation.rs
T
Eric Traut de6ae71ad4 Stabilize transcript and composer interactions in the TUI (#46749)
## Why

Composer suggestions and transient hints should preserve the draft and transcript context. Submitting a local command while reading older history should reveal its output.

## What changed

- Separate persistent status from transient footer hints in the owned transcript, sharing layout calculations for rendering, measurement, and cursor placement.
- Overlay command and mention suggestions on history without moving the composer; hide retained suggestions while transcript interactions own input.
- Show responsive, grouped shortcut help above the composer and let `Esc` dismiss it before interrupting a task or navigating history.
- Resume transcript following for submissions, slash commands, and last-response copy results while preserving the reading position during background updates.
- Reset transcript interaction state after prompt reverts and refresh retained usage information without rewriting terminal history.

## Testing

Add regression tests and snapshots for popup placement, clipped layouts, footer focus, shortcut dismissal, local-command scrolling, prompt reverts, and pagination while browsing prompts.

GitOrigin-RevId: 890147313d53f050503165a57610c381ffb93ef5
2026-09-20 02:59:37 +00:00

63 lines
2.3 KiB
Rust

//! Expose live activity identity and local detail rendering to the owned transcript.
//! Canonical cells retain all available data; presentation does not modify tool execution.
use super::*;
use crate::transcript_view::ActivityTranscriptLines;
impl ChatWidget {
pub(crate) fn active_activity_ids(&self) -> Vec<String> {
self.transcript
.active_cell
.as_ref()
.map_or_else(Vec::new, |cell| cell.activity_ids())
}
/// Render only the chosen activity presentation, before any auxiliary live text.
pub(crate) fn active_cell_owned_transcript_lines(
&self,
width: u16,
expanded: bool,
) -> Option<ActivityTranscriptLines> {
let active = self.transcript.active_cell.as_deref();
let mode = self.history_render_mode();
let render_compact = |cell: &dyn HistoryCell, width| {
if mode == HistoryRenderMode::Raw {
cell.display_hyperlink_lines_for_mode(width, mode)
} else {
cell.compact_hyperlink_lines(width)
}
};
let has_activity = mode == HistoryRenderMode::Rich
&& active.is_some_and(|cell| !cell.activity_ids().is_empty());
let activity = active.map_or_else(Vec::new, |cell| {
if expanded && has_activity {
cell.expanded_hyperlink_lines(width)
} else {
render_compact(cell, width)
}
});
let has_hidden_details =
has_activity && active.is_some_and(|cell| cell.has_hidden_activity_details(width));
let mut auxiliary = self
.active_cell_hyperlink_lines_with(width, |cell, width| {
if active.is_some_and(|active| std::ptr::eq(active, cell)) {
Vec::new()
} else {
render_compact(cell, width)
}
})
.unwrap_or_default();
if activity.is_empty() && auxiliary.is_empty() {
return None;
}
if !activity.is_empty() && !auxiliary.is_empty() {
auxiliary.insert(/*index*/ 0, HyperlinkLine::from(""));
}
Some(ActivityTranscriptLines {
activity,
auxiliary,
has_hidden_details,
})
}
}