Files
codex/codex-rs/tui/src/chatwidget/activity_groups.rs
T
Eric Traut d7d9f2b9b5 Add selection and copying to the transcript viewer (#46732)
## What changed

- Add mouse selection, word and line selection, drag autoscrolling, and keyboard selection with `Ctrl+Space`. Support copying selected text and opening links with a modified click.
- Anchor reading positions and selections to source text so resizing, streaming completion, and history pagination preserve the displayed content. Preserve hard line breaks, indentation, tabs, and graphemes when copying, while excluding display gutters and soft wraps.
- Rejoin activity groups split across history pages while retaining the reader's displayed revision.
- Distinguish confirmed clipboard writes from unconfirmed terminal requests, and retain native clipboard ownership after the transcript overlay closes.
- Manage mouse capture and keyboard modes across overlay transitions, editor handoffs, and suspend/resume.

## Testing

Add regression tests for selection during live updates and pagination, source-text copying across resize, clipboard confirmation and lifetime, and terminal mode restoration.

GitOrigin-RevId: 6b2438f576567cbba755b2405915a25acf009b8d
2026-09-20 00:04:04 +00:00

62 lines
2.1 KiB
Rust

//! Keep hidden reasoning and terminal bookkeeping inside compatible activity groups.
//! Detailed output retains the original order while compact activity avoids artificial breaks.
use super::*;
impl ChatWidget {
pub(super) fn absorb_activity_detail(
&mut self,
cell: Box<dyn HistoryCell>,
) -> Result<(), Box<dyn HistoryCell>> {
let hidden_reasoning = cell
.as_any()
.downcast_ref::<history_cell::ReasoningSummaryCell>()
.is_some_and(history_cell::ReasoningSummaryCell::is_transcript_only);
if !hidden_reasoning
&& !cell
.as_any()
.is::<history_cell::UnifiedExecInteractionCell>()
{
return Err(cell);
}
let Some(active) = self.transcript.active_cell.as_mut() else {
return Err(cell);
};
if let Some(computer) = active
.as_any_mut()
.downcast_mut::<history_cell::ComputerActivityCell>()
{
computer.group.push_detail(Arc::from(cell));
self.bump_active_cell_revision();
return Ok(());
}
if let Some(exploration) = active.as_any_mut().downcast_mut::<ExecCell>()
&& exploration.is_exploring_cell()
{
exploration.group.push_detail(Arc::from(cell));
self.bump_active_cell_revision();
return Ok(());
}
Err(cell)
}
/// Hydrate only the validated older portion, leaving current calls and their clocks intact.
pub(crate) fn prepend_active_exploration_history(
&mut self,
older: &dyn HistoryCell,
turns: &[Turn],
) -> Option<(u64, u64)> {
let previous_revision = self.transcript.active_cell_revision;
let active = self
.transcript
.active_cell
.as_mut()?
.as_any_mut()
.downcast_mut::<ExecCell>()?;
let older = crate::thread_transcript::older_exploration_group(older, active, turns)?;
active.prepend(older);
self.bump_active_cell_revision();
Some((previous_revision, self.transcript.active_cell_revision))
}
}