Add opt-in side conversation panes to the TUI (#58992)

## What changed

- Add the disabled-by-default `tui_workspace` feature for the owned transcript view. At terminal widths of at least 100 columns, show the parent conversation beside its side conversation, with only the focused composer accepting input.
- Retain the inactive conversation's transcript, draft, and status, and restore reading and search state when switching focus.
- Keep drawing and input paused until history replay completes, while refreshing skills in the background.

## Testing

Add snapshots and regression tests for pane resizing and composer styling, retained streaming output, history search after replay, pending skills refreshes, and modal input protection.

GitOrigin-RevId: 68938f263353b0cd3a9e9562e06293bfc8251cc6
This commit is contained in:
Felipe Coury
2026-11-02 21:47:45 +00:00
committed by copyberry
parent 23bc6e5f2a
commit db227aed42
37 changed files with 1197 additions and 60 deletions
+15 -10
View File
@@ -3,6 +3,7 @@
use std::ops::Range;
use super::*;
use crate::history_cell::is_session_history_prefix_cell;
impl TranscriptView {
/// Rebuild the layout of an observed revision without counting the reflow as new output.
@@ -183,9 +184,12 @@ impl TranscriptView {
&mut self,
cells: &[Arc<dyn HistoryCell>],
inserted: Range<usize>,
) {
) -> Range<usize> {
if inserted.is_empty() {
return inserted;
}
let Some(snapshot) = self.snapshot_mut() else {
return;
return inserted;
};
let existing = snapshot
.cells
@@ -198,21 +202,22 @@ impl TranscriptView {
.cloned()
.collect::<Vec<_>>();
if older.is_empty() {
return;
return 0..0;
}
let index = cells[..inserted.start]
let preceding = &cells[..inserted.start];
let index = snapshot
.cells
.iter()
.rev()
.find_map(|cell| {
snapshot
.cells
.iter()
.position(|retained| Arc::ptr_eq(retained, cell))
.rposition(|retained| {
is_session_history_prefix_cell(retained.as_ref())
|| preceding.iter().any(|cell| Arc::ptr_eq(retained, cell))
})
.map_or(/*default*/ 0, |index| index + 1);
let retained = index..index + older.len();
let mut extended = snapshot.cells.to_vec();
extended.splice(index..index, older);
snapshot.cells = extended.into();
retained
}
}
+1 -1
View File
@@ -598,7 +598,7 @@ impl TranscriptView {
{
self.last_tail = cells.last().map(EntryKey::cell);
}
self.prepend_snapshot_history(cells, inserted.clone());
let inserted = self.prepend_snapshot_history(cells, inserted);
if let Position::Reading(anchor) = self.position {
let index = self.resolve(cells, anchor);
self.position = Position::Reading(Anchor {
@@ -918,6 +918,52 @@ fn search_scans_a_page_inserted_after_the_retained_session_header() {
assert!(Arc::ptr_eq(&cells[0], &header));
}
#[test]
fn search_finds_the_first_older_entry_after_replaying_the_session_header() {
let header = || -> Arc<dyn HistoryCell> {
Arc::new(crate::history_cell::SessionHeaderHistoryCell::new(
"test model".to_string(),
/*reasoning_effort*/ None,
std::path::PathBuf::from("/project"),
"test",
))
};
let parked = vec![header(), cell("recent needle")];
let mut view = TranscriptView {
history: TranscriptHistoryState::Partial,
..TranscriptView::default()
};
view.begin_search();
view.paste_search("needle");
finish_scan(&mut view, &parked);
view.handle_key(KeyCode::Enter.into(), &parked);
let mut replayed = vec![header(), cell("recent needle")];
view.restore_after_replay(
&parked, &replayed, /*replay_may_have_output*/ false, /*replayed_live*/ None,
);
view.handle_key(
KeyEvent::new(KeyCode::Char('p'), KeyModifiers::CONTROL),
&replayed,
);
finish_scan(&mut view, &replayed);
assert!(view.needs_history(&replayed));
let oldest = cell("oldest needle");
replayed.splice(1..1, [Arc::clone(&oldest), cell("older messages")]);
view.history = TranscriptHistoryState::Complete;
view.history_loaded(&replayed, 1..3);
assert!(Arc::ptr_eq(
&view.snapshot().expect("held reading").cells[0],
&parked[0]
));
finish_scan(&mut view, &replayed);
assert_eq!(
view.search.current.as_ref().map(|found| found.anchor.key),
Some(EntryKey::cell(&oldest)),
);
}
#[test]
fn next_previous_highlight_and_cancel_share_the_transcript_position() {
let cells = vec![cell("Needle one"), cell("Needle two")];
+22 -1
View File
@@ -1,4 +1,4 @@
//! Retain displayed revisions while selecting or reading a live tail or a replaced tool group.
//! Retain displayed revisions while selecting or reading across live updates and history replay.
//! Pinned layouts respect manual disclosures; Find's expansion is applied only at display time.
use std::collections::HashMap;
@@ -81,6 +81,27 @@ impl TranscriptView {
}
}
/// Keep the parked reading revision and rebind a quiet tail to its replayed identity.
pub(crate) fn restore_after_replay(
&mut self,
parked: &[Arc<dyn HistoryCell>],
replayed: &[Arc<dyn HistoryCell>],
replay_may_have_output: bool,
replayed_live: Option<ActiveCellTranscriptKey>,
) {
if matches!(self.position, Position::Reading(_)) && self.snapshot().is_none() {
self.held_reading = Some(self.capture_snapshot(parked));
}
if !replay_may_have_output {
self.last_tail = replayed.last().map(EntryKey::cell);
// The parked display and replayed widget may represent the same stream differently.
self.live_key = replayed_live.map(|mut key| {
key.cacheable = false;
(self.area.width, key)
});
}
}
/// Keep a live, mutable, or replaced cell revision while reading inside it. Navigation
/// rejoins current history when it reaches a surviving cell.
pub(super) fn hold_live_reading(