Files
codex/codex-rs/tui/src/chatwidget/activity_presentation.rs
T
Felipe Coury e75b6b1e0c Show hidden output line counts in compact terminal activity (#48761)
## What changed

Replace generic output disclosure labels with counts such as `+ 5 lines (ctrl+t to expand)` for compact command activity, both live and in history. Count retained output lines hidden or clipped by the preview, excluding output discarded by storage limits.

Use the configured `open_transcript` shortcut and omit the hint when it does not fit or the action is unbound. Invalidate cached layouts when keybindings change. Keep generic `Show details` labels for other hidden details and keep disclosure controls outside copyable and searchable text.

## Testing

Add regression tests for live/history consistency, remapped and disabled shortcuts, and exclusion of hints from source text. Add snapshot coverage for fully visible output, hidden and clipped lines, command-only details, and storage-truncated output.

GitOrigin-RevId: c468be9b88b69dc3ca1abdb6b7be023244d32a57
2026-09-27 18:09:34 +00:00

66 lines
2.4 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 cell.as_any().is::<history_cell::SessionInfoCell>() {
history_cell::fullscreen_session_lines(cell, width, /*detailed*/ false, mode)
} else 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 disclosure = active
.filter(|_| has_activity)
.and_then(|cell| cell.activity_disclosure(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,
disclosure,
})
}
}