Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

clicking a compaction summary expands it again (#3322)

Sebastian Müllercfa84aee3bf3
diff --git a/.changes/fix-click-expand-custom-rows.md b/.changes/fix-click-expand-custom-rows.md
new file mode 100644
index 0000000000..de215d9564
--- /dev/null
+++ b/.changes/fix-click-expand-custom-rows.md
@@ -0,0 +1 @@
+- Clicking a compaction summary, a harness refinement notice, a skill invocation, or an injected prompt (heartbeat, goal, subagent status) in the transcript expands or collapses it again.
diff --git a/crates/pa-tui/src/view/click.rs b/crates/pa-tui/src/view/click.rs
index 61b7eb244b..798de27362 100644
--- a/crates/pa-tui/src/view/click.rs
+++ b/crates/pa-tui/src/view/click.rs
@@ -20,8 +20,8 @@ use crate::chat::ChatEntry;
/// vocabulary).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum ClickAction {
- /// Toggle the card at this chat-entry index (a tool card, a bash
- /// execution card, an agent-message row, or a shell-completion row).
+ /// Toggle the card at this chat-entry index (an expandable
+ /// transcript row).
ToggleCardExpansion(usize),
/// Place the editor caret at the clicked cell: `row` indexes the
/// editor's visible content rows, `col` is the column relative to
@@ -331,11 +331,11 @@ impl AgentView {
}
/// The click action for one transcript window row: a row inside a
- /// visible activity entry (a tool card, a bash card, an
- /// agent-message notice, a shell-completion row) toggles that
- /// card's own expansion. Plain text rows (user, assistant, status,
- /// panels) are not clickable — the TS components register no
- /// regions there either.
+ /// visible tool card, bash card, or TS `Clickable` custom row
+ /// (agent message, shell completion, compaction summary,
+ /// refinement outcome, skill invocation, injected prompt) toggles
+ /// that row's own expansion. Other rows (user, assistant, status,
+ /// slash, panels) are not clickable.
fn transcript_click_target(&self, window_row: usize) -> Option<ClickAction> {
let section = self
.click
@@ -349,6 +349,10 @@ impl AgentView {
| ChatEntry::BashExecution(_)
| ChatEntry::AgentMessage(_)
| ChatEntry::ShellCompletion(_)
+ | ChatEntry::CompactionSummary { .. }
+ | ChatEntry::RefinementOutcome(_)
+ | ChatEntry::SkillInvocation(_)
+ | ChatEntry::InjectedPrompt(_)
))
.then_some(ClickAction::ToggleCardExpansion(section.entry))
}
@@ -425,6 +429,65 @@ mod tests {
}
}
+ /// The TS click-to-expand custom rows (compaction, refinement, skill,
+ /// and injected prompt wrap their header in `Clickable`): a click
+ /// targets the row, and the toggle opens its own body.
+ #[test]
+ fn a_click_expands_the_custom_message_rows() {
+ use super::super::expansion::tests::transcript_text;
+ use crate::custom_message::{
+ InjectedPromptKind, InjectedPromptRow, RefinementOutcomeRow, SkillInvocationRow,
+ };
+ let rows = [
+ (
+ ChatEntry::CompactionSummary {
+ summary: "kept the plan".to_string(),
+ tokens_before: 1200,
+ custom_instructions: None,
+ },
+ "Compacted from",
+ ),
+ (
+ ChatEntry::RefinementOutcome(Box::new(RefinementOutcomeRow {
+ header: "Harness refined".to_string(),
+ summary: "added a memory".to_string(),
+ meta: "refinement meta".to_string(),
+ edits: Vec::new(),
+ })),
+ "refinement meta",
+ ),
+ (
+ ChatEntry::SkillInvocation(Box::new(SkillInvocationRow {
+ name: "websearch".to_string(),
+ content: "skill body".to_string(),
+ })),
+ "skill body",
+ ),
+ (
+ ChatEntry::InjectedPrompt(Box::new(InjectedPromptRow {
+ kind: InjectedPromptKind::Heartbeat { schedule: None },
+ body: Some("prompt body".to_string()),
+ })),
+ "prompt body",
+ ),
+ ];
+ for (entry, body) in rows {
+ let mut view = view();
+ view.push_entry(entry);
+ view.render_frame(60, 20);
+ assert_eq!(
+ view.click_target_at(section_screen_row(&view, 0), 2),
+ Some(ClickAction::ToggleCardExpansion(0)),
+ "{body}"
+ );
+ let collapsed = transcript_text(&mut view);
+ assert!(!collapsed.contains(body), "{body} starts collapsed");
+ view.toggle_card_expansion(0);
+ let expanded = transcript_text(&mut view);
+ assert!(expanded.contains(body), "{body} expands on click");
+ }
+ }
+
#[test]
fn a_click_on_plain_rows_is_inert() {
let view = frame_with_a_card();
diff --git a/crates/pa-tui/src/view/expansion.rs b/crates/pa-tui/src/view/expansion.rs
index 1aab500531..be4a5fb6bb 100644
--- a/crates/pa-tui/src/view/expansion.rs
+++ b/crates/pa-tui/src/view/expansion.rs
@@ -11,8 +11,8 @@ impl AgentView {
/// The detail one entry's card renders at: the conversation level,
/// flipped for the entries a click toggled away from it. Exact for
/// both sides: the never-toggled entries get `self.detail` (a click
- /// can only toggle the four card kinds `transcript_click_target`
- /// matches), and the card renderers read `Detail` only through
+ /// can only toggle the kinds `transcript_click_target` matches),
+ /// and the card renderers read `Detail` only through
/// `tool_output_expanded()` — the level's other readers (thinking
/// blocks, edit diffs) belong to rows no click can toggle, so the
/// flip never leaks into them.
@@ -97,7 +97,7 @@ pub(super) mod tests {
}))
}
- fn transcript_text(view: &mut AgentView) -> String {
+ pub(in crate::view) fn transcript_text(view: &mut AgentView) -> String {
view.render_transcript(80)
.iter()
.map(|line| line.iter().map(|span| span.content.as_str()).collect())