>()
+ .join("\n")
+ };
+ let mut write = item("write", "tool", None);
+ write.input = Some(serde_json::json!({ "path": "big.txt", "content": lines(1000) }));
+ assert_eq!(diff_counts(&write), (1000, 0));
+
+ let mut edit = item("edit", "tool", None);
+ edit.input = Some(serde_json::json!({
+ "path": "big.txt",
+ "edits": [
+ { "oldText": lines(300), "newText": lines(2) },
+ { "oldText": "one", "newText": "one\ntwo" },
+ ],
+ }));
+ assert_eq!(diff_counts(&edit), (4, 301));
+ }
+
#[test]
fn test_markdown_cache_keys_on_revision() {
// Unattached: every parse is inline.
diff --git a/apps/maple-agent/app/src/ui/chat/transcript.rs b/apps/maple-agent/app/src/ui/chat/transcript.rs
index 0b4f420bc..a01c5c7ae 100644
--- a/apps/maple-agent/app/src/ui/chat/transcript.rs
+++ b/apps/maple-agent/app/src/ui/chat/transcript.rs
@@ -1707,6 +1707,26 @@ pub(super) fn diff_lines_for(item: &AgentTimelineItem) -> Vec<(char, SharedStrin
lines
}
+/// How many lines an edit or write adds and removes, counted from the
+/// whole input. `diff_lines_for` stops at the display cap; this does not.
+pub(super) fn diff_counts(item: &AgentTimelineItem) -> (usize, usize) {
+ let Some(serde_json::Value::Object(map)) = item.input.as_ref() else {
+ return (0, 0);
+ };
+ let lines = |text: Option<&serde_json::Value>| {
+ text.and_then(|text| text.as_str())
+ .map_or(0, |text| text.lines().count())
+ };
+ let (mut added, mut removed) = (lines(map.get("content")), 0);
+ if let Some(serde_json::Value::Array(edits)) = map.get("edits") {
+ for edit in edits {
+ removed += lines(edit.get("oldText"));
+ added += lines(edit.get("newText"));
+ }
+ }
+ (added, removed)
+}
+
/// The +/- lines of an edit or write, coloured.
fn render_diff(lines: &[(char, SharedString)]) -> Option {
if lines.is_empty() {
From d2c18bf9b552bd6b601d1bfa2d69d7e2ab75c427 Mon Sep 17 00:00:00 2001
From: Matthew Ball <13823657+matthewrball@users.noreply.github.com>
Date: Sun, 15 Nov 2026 20:44:22 -0800
Subject: [PATCH 3/5] Agent: Fold activity chunks independently
Keep assistant explanations visible between independently disclosed activity chunks. Retain the turn-wide clock, native sheen, label morphing, entrance motion and disclosure springs.
Constraint: Preserve native motion and individual tool disclosure state.
Scope-risk: Chat grouping, disclosure, keyboard navigation and localization only.
Not-tested: Full workspace suite; this Mac has the previously documented Swift child-process failures.
---
apps/maple-agent/app/locales/de/app.ftl | 6 +
apps/maple-agent/app/locales/en/app.ftl | 6 +
apps/maple-agent/app/locales/es/app.ftl | 6 +
apps/maple-agent/app/src/ui/chat/mod.rs | 27 +-
.../maple-agent/app/src/ui/chat/navigation.rs | 28 +-
apps/maple-agent/app/src/ui/chat/paging.rs | 2 +-
apps/maple-agent/app/src/ui/chat/tests.rs | 290 ++++++++---
.../maple-agent/app/src/ui/chat/transcript.rs | 92 ++--
apps/maple-agent/app/src/ui/chat/turn.rs | 453 ++++++++++++++----
.../app/translation-revisions/de.txt | 1 +
.../app/translation-revisions/es.txt | 1 +
apps/maple-agent/docs/motion.md | 8 +-
12 files changed, 714 insertions(+), 206 deletions(-)
diff --git a/apps/maple-agent/app/locales/de/app.ftl b/apps/maple-agent/app/locales/de/app.ftl
index 23fc3cd53..55895d6e6 100644
--- a/apps/maple-agent/app/locales/de/app.ftl
+++ b/apps/maple-agent/app/locales/de/app.ftl
@@ -1565,6 +1565,12 @@ chat-turn-worked = Gearbeitet
chat-turn-worked-seconds = { $seconds } s gearbeitet
# $minutes is a whole number of minutes; $seconds is the rest, under 60.
chat-turn-worked-minutes = { $minutes } min { $seconds } s gearbeitet
+# $count is the number of tool and thinking steps in one activity chunk.
+chat-activity-steps =
+ { $count ->
+ [one] { $count } Schritt
+ *[other] { $count } Schritte
+ }
chat-settings = Einstellungen
chat-usage = Nutzung
chat-usage-unavailable = Nutzung nicht verfügbar
diff --git a/apps/maple-agent/app/locales/en/app.ftl b/apps/maple-agent/app/locales/en/app.ftl
index ab94dad33..020f0361b 100644
--- a/apps/maple-agent/app/locales/en/app.ftl
+++ b/apps/maple-agent/app/locales/en/app.ftl
@@ -1565,6 +1565,12 @@ chat-turn-worked = Worked
chat-turn-worked-seconds = Worked for { $seconds }s
# $minutes is a whole number of minutes; $seconds is the rest, under 60.
chat-turn-worked-minutes = Worked for { $minutes }m { $seconds }s
+# $count is the number of tool and thinking steps in one activity chunk.
+chat-activity-steps =
+ { $count ->
+ [one] { $count } step
+ *[other] { $count } steps
+ }
chat-settings = Settings
chat-usage = Usage
chat-usage-unavailable = Usage unavailable
diff --git a/apps/maple-agent/app/locales/es/app.ftl b/apps/maple-agent/app/locales/es/app.ftl
index 87e39665e..7cbff7fa6 100644
--- a/apps/maple-agent/app/locales/es/app.ftl
+++ b/apps/maple-agent/app/locales/es/app.ftl
@@ -1452,6 +1452,12 @@ chat-turn-worked = Trabajó
chat-turn-worked-seconds = Trabajó { $seconds } s
# $minutes is a whole number of minutes; $seconds is the rest, under 60.
chat-turn-worked-minutes = Trabajó { $minutes } min { $seconds } s
+# $count is the number of tool and thinking steps in one activity chunk.
+chat-activity-steps =
+ { $count ->
+ [one] { $count } paso
+ *[other] { $count } pasos
+ }
chat-settings = Configuración
chat-usage = Uso
chat-usage-unavailable = Uso no disponible
diff --git a/apps/maple-agent/app/src/ui/chat/mod.rs b/apps/maple-agent/app/src/ui/chat/mod.rs
index 91ee86742..aa44e38b9 100644
--- a/apps/maple-agent/app/src/ui/chat/mod.rs
+++ b/apps/maple-agent/app/src/ui/chat/mod.rs
@@ -845,9 +845,8 @@ pub struct ChatScreen {
toggled_tools: HashSet,
/// Each row's place in its turn, rebuilt or extended with `timeline`.
turns: turn::Turns,
- /// Lead item ids of turns whose line was clicked; membership inverts
- /// the `tool_details` default for whether that turn's steps show.
- toggled_turns: HashSet,
+ /// Chunk lead ids whose disclosure differs from `tool_details`.
+ toggled_chunks: HashSet,
/// How long finished turns worked, by lead item id. Only turns this
/// window timed have one.
turn_worked: HashMap,
@@ -1686,7 +1685,7 @@ impl ChatScreen {
loading_since: None,
toggled_tools: HashSet::new(),
turns: turn::Turns::default(),
- toggled_turns: HashSet::new(),
+ toggled_chunks: HashSet::new(),
turn_worked: HashMap::new(),
run_clocks: HashMap::new(),
run_tick_pending: std::cell::Cell::new(false),
@@ -3763,7 +3762,7 @@ impl ChatScreen {
self.attachment_queue.clear();
self.attachment_viewport = 0..0;
self.toggled_tools.clear();
- self.toggled_turns.clear();
+ self.toggled_chunks.clear();
self.turn_worked.clear();
if let Some(composer) = self.composer.clone() {
composer.update(cx, |input, cx| input.reset_vim_context(cx));
@@ -6298,6 +6297,7 @@ impl ChatScreen {
} = item;
let existing = &mut self.timeline[index];
let part = turn::part(existing);
+ let step_before = turn::step_info(existing);
existing.revision = incoming_revision;
if let Some(label) = incoming_label {
match &mut existing.label {
@@ -6333,13 +6333,17 @@ impl ChatScreen {
existing.output = incoming_output.or_else(|| existing.output.take());
existing.merge = incoming_merge;
}
- // A row that became a step, or stopped being one, moves
- // every row after it to another place in its turn, and
- // changes whether the step before it runs the rail on.
if turn::part(&self.timeline[index]) != part {
self.turns.rebuild(&self.timeline);
- self.list_state
- .remeasure_items(index.saturating_sub(1)..self.timeline.len());
+ // A changed boundary can merge or split an earlier
+ // header. Remeasure without moving the scroll anchor.
+ self.list_state.remeasure_items(0..self.timeline.len());
+ } else if let Some(lead) = self.turns.update_step(
+ index,
+ step_before,
+ turn::step_info(&self.timeline[index]),
+ ) {
+ self.list_state.remeasure_items(lead..lead + 1);
}
index
}
@@ -6362,6 +6366,9 @@ impl ChatScreen {
{
self.list_state.remeasure_items(index - 1..index);
}
+ if let turn::TurnRow::Step(lead) = self.turns.row(index) {
+ self.list_state.remeasure_items(lead..lead + 1);
+ }
self.time_arrival(session_id, index);
index
}
diff --git a/apps/maple-agent/app/src/ui/chat/navigation.rs b/apps/maple-agent/app/src/ui/chat/navigation.rs
index e09ba6082..25c138a07 100644
--- a/apps/maple-agent/app/src/ui/chat/navigation.rs
+++ b/apps/maple-agent/app/src/ui/chat/navigation.rs
@@ -661,9 +661,9 @@ impl ChatScreen {
let Some(&(index, _)) = self.timeline_index.get(&item_id) else {
return;
};
- // On a turn's first step the selection is the turn's line.
- if self.turns.row(index) == TurnRow::Lead {
- self.toggle_turn(&item_id, cx);
+ // A chunk's first row selects its disclosure header.
+ if matches!(self.turns.row(index), TurnRow::Lead | TurnRow::Chunk) {
+ self.toggle_chunk(&item_id, cx);
return;
}
let Some(item) = self.timeline.get(index) else {
@@ -710,13 +710,13 @@ impl ChatScreen {
return;
}
let current = self.tool_details != self.toggled_tools.contains(item_id);
- // A turn's first step sits under the turn's line: the line opens
- // before the step's details do, and folds after them.
- if self.turns.row(index) == TurnRow::Lead
- && self.turn_open(index) != expanded
+ // Open the chunk before its first step's details, and fold it
+ // after those details have closed.
+ if matches!(self.turns.row(index), TurnRow::Lead | TurnRow::Chunk)
+ && self.chunk_open(index) != expanded
&& (expanded || !current)
{
- self.toggle_turn(item_id, cx);
+ self.toggle_chunk(item_id, cx);
return;
}
if current != expanded {
@@ -803,18 +803,16 @@ impl ChatScreen {
.collect()
}
- /// Whether the selection can rest on the row at `index`. A step under
- /// a folded line draws nothing, and a turn's first step always draws
- /// the line.
+ /// A folded chunk keeps its header navigable and hides its later steps.
fn timeline_row_navigable(&self, index: usize, item: &AgentTimelineItem) -> bool {
match self.turns.row(index) {
- TurnRow::Lead => true,
- TurnRow::Step(lead) => self.turn_open(lead) && timeline_item_is_navigable(item),
+ TurnRow::Lead | TurnRow::Chunk => true,
+ TurnRow::Step(lead) => self.chunk_open(lead) && timeline_item_is_navigable(item),
TurnRow::Plain => timeline_item_is_navigable(item),
}
}
- /// A turn folded: a selection on one of its steps moves to its line.
+ /// Folding a chunk moves a hidden selection to its header.
pub(super) fn keep_application_selection_shown(&mut self, lead: usize) {
if !self.application_vim_enabled {
return;
@@ -1228,7 +1226,7 @@ impl ChatScreen {
}
}
-fn timeline_item_is_navigable(item: &AgentTimelineItem) -> bool {
+pub(super) fn timeline_item_is_navigable(item: &AgentTimelineItem) -> bool {
if item.item_type == "internal" {
return false;
}
diff --git a/apps/maple-agent/app/src/ui/chat/paging.rs b/apps/maple-agent/app/src/ui/chat/paging.rs
index adb34c18e..dbbb13133 100644
--- a/apps/maple-agent/app/src/ui/chat/paging.rs
+++ b/apps/maple-agent/app/src/ui/chat/paging.rs
@@ -260,7 +260,7 @@ impl ChatScreen {
.map(|(i, item)| (item.id.clone(), (i, 0)))
.collect();
self.turns.rebuild(&self.timeline);
- self.toggled_turns
+ self.toggled_chunks
.retain(|id| self.timeline_index.contains_key(id));
self.turn_worked
.retain(|id, _| self.timeline_index.contains_key(id));
diff --git a/apps/maple-agent/app/src/ui/chat/tests.rs b/apps/maple-agent/app/src/ui/chat/tests.rs
index 181de3ea0..fad40bf42 100644
--- a/apps/maple-agent/app/src/ui/chat/tests.rs
+++ b/apps/maple-agent/app/src/ui/chat/tests.rs
@@ -12035,81 +12035,263 @@ mod state_tests {
});
}
- /// To the keyboard a folded turn is one row, its line. `l` shows the
- /// steps, which then take the selection one by one, and `h` on the
- /// line folds them again.
+ /// Each activity chunk is a keyboard row; assistant messages between
+ /// chunks remain readable regardless of either disclosure's state.
#[gpui::test]
- fn test_application_vim_opens_a_turn_from_its_line(cx: &mut TestAppContext) {
- struct ChatHost {
- chat: Entity,
- }
- impl Render for ChatHost {
- fn render(
- &mut self,
- _window: &mut Window,
- _cx: &mut Context,
- ) -> impl IntoElement {
- div().w(px(1200.)).h(px(800.)).child(self.chat.clone())
- }
- }
-
- cx.executor().allow_parking();
- let chat = cx.new(|cx| {
- let _guard = SETTINGS_LOCK.lock();
- let backend = std::sync::Arc::new(
- crate::backend::AgentBackend::for_test(
- "http://127.0.0.1:9".to_string(),
- String::new(),
- )
- .expect("backend"),
- );
- crate::desktop::register_key_bindings(cx);
- let mut chat = ChatScreen::new_inner_for_test(backend, "user".to_string(), cx);
- chat.selected_session = Some("s1".to_string());
- chat.application_vim_enabled = true;
- chat.application_focus = Some(cx.focus_handle());
- chat.screen_focus_pending = true;
- chat.booting = false;
+ fn test_application_vim_opens_chunks_independently_from_their_lines(cx: &mut TestAppContext) {
+ cx.update(|cx| cx.set_reduce_motion(true));
+ let (chat, cx) = chat_window(cx, |chat, cx| {
+ chat.set_application_vim_enabled(false, cx);
+ chat.tool_details = false;
chat.replace_timeline(vec![
user_item("u1", "question"),
- item("call", "tool", None),
+ AgentTimelineItem {
+ input: Some(serde_json::json!({"command": "ls"})),
+ ..item("call", "tool", None)
+ },
item("thought", "thinking", Some("reasoning")),
- item("a1", "message", Some("answer")),
+ item("a1", "message", Some("Interim answer")),
+ item("later", "tool", None),
+ item("later-thought", "thinking", Some("more reasoning")),
+ item("a2", "message", Some("Final answer")),
]);
- chat
+ chat.set_application_vim_enabled(true, cx);
});
- let (_host, cx) = cx.add_window_view(|_window, _cx| ChatHost { chat: chat.clone() });
- cx.simulate_resize(gpui::size(px(1200.), px(800.)));
let rows = |cx: &mut gpui::VisualTestContext| {
cx.update(|_window, app| chat.read(app).navigable_timeline_ids())
};
let selected = |cx: &mut gpui::VisualTestContext| {
cx.update(|_window, app| chat.read(app).selected_transcript_id().map(str::to_owned))
};
+ let messages_shown = |cx: &mut gpui::VisualTestContext| {
+ cx.run_until_parked();
+ for id in ["timeline-row-a1", "timeline-row-a2"] {
+ assert!(cx.debug_bounds(id).is_some(), "{id} stays visible");
+ }
+ };
- assert_eq!(rows(cx), ["u1", "call", "a1"], "folded steps are skipped");
+ assert_eq!(rows(cx), ["u1", "call", "a1", "later", "a2"]);
+ assert!(cx.debug_bounds("tool-card").is_none());
+ messages_shown(cx);
cx.simulate_keystrokes("g g j l");
- assert_eq!(rows(cx), ["u1", "call", "thought", "a1"]);
+ assert_eq!(rows(cx), ["u1", "call", "thought", "a1", "later", "a2"]);
+ cx.simulate_keystrokes("l");
+ cx.run_until_parked();
+ let detail_height = cx.debug_bounds("tool-card").unwrap().size.height;
+ chat.update(cx, |chat, _| {
+ assert!(chat.toggled_tools.contains("call"));
+ assert!(!chat.chunk_open(4));
+ });
cx.simulate_keystrokes("j");
assert_eq!(selected(cx).as_deref(), Some("thought"));
- // Folding from the pointer while a step is selected: the selection
- // moves to the line rather than staying on a row that is gone.
- chat.update(cx, |chat, cx| chat.toggle_turn("call", cx));
+ // A pointer fold moves a hidden selection to its own chunk header,
+ // and does not clear the individual tool's disclosure choice.
+ press(cx, "activity-chunk-call");
assert_eq!(selected(cx).as_deref(), Some("call"));
+ assert_eq!(rows(cx), ["u1", "call", "a1", "later", "a2"]);
+ assert!(cx.debug_bounds("tool-card").is_none());
+ messages_shown(cx);
+ press(cx, "activity-chunk-later");
+ assert_eq!(
+ rows(cx),
+ ["u1", "call", "a1", "later", "later-thought", "a2"]
+ );
+ chat.update(cx, |chat, _| {
+ assert!(!chat.chunk_open(1));
+ assert!(chat.chunk_open(4));
+ assert!(chat.toggled_tools.contains("call"));
+ assert!(!chat.toggled_tools.contains("later"));
+ });
+ messages_shown(cx);
- cx.simulate_keystrokes("l");
+ cx.simulate_keystrokes("g g 3 j h");
+ assert_eq!(selected(cx).as_deref(), Some("later"));
+ assert_eq!(rows(cx), ["u1", "call", "a1", "later", "a2"]);
+ press(cx, "activity-chunk-call");
+ chat.update(cx, |chat, _| {
+ assert!(chat.chunk_open(1));
+ assert!(!chat.chunk_open(4));
+ assert!(chat.toggled_tools.contains("call"));
+ });
+ cx.run_until_parked();
assert_eq!(
- rows(cx).len(),
- 4,
- "the line opens before its step's details"
+ cx.debug_bounds("tool-card").unwrap().size.height,
+ detail_height,
+ "reopening the chunk restores the tool's visible details"
);
- cx.simulate_keystrokes("h");
+ messages_shown(cx);
+ }
+
+ #[gpui::test]
+ fn folded_chunks_keep_live_rows_and_outcomes_under_one_turn_clock(cx: &mut TestAppContext) {
+ use std::time::{Duration, Instant};
+
+ use crate::ui::motion;
+ use maple_agent::agent::{AgentRunEvent, AgentRunTerminal};
+
+ struct ResetClock;
+ impl Drop for ResetClock {
+ fn drop(&mut self) {
+ motion::set_test_now(None);
+ }
+ }
+ let _reset_clock = ResetClock;
+ let began = Instant::now();
+ motion::set_test_now(Some(began));
+ cx.update(|cx| cx.set_reduce_motion(true));
+ let (chat, cx) = chat_window(cx, |chat, _| {
+ chat.tool_details = false;
+ chat.summaries_enabled = false;
+ chat.replace_timeline(vec![user_item("u1", "Run the checks")]);
+ });
+ let event = |event| AgentServiceEvent::Run {
+ session_id: "s1".into(),
+ run_id: "run-1".into(),
+ event,
+ };
+ chat.update(cx, |chat, cx| {
+ chat.handle_service_event(event(AgentRunEvent::Started), cx);
+ chat.handle_service_event(
+ event(AgentRunEvent::TimelineItem(item("call", "tool", None))),
+ cx,
+ );
+ });
+ motion::set_test_now(Some(began + Duration::from_secs(5)));
+ chat.update(cx, |chat, cx| {
+ chat.handle_service_event(
+ event(AgentRunEvent::TimelineItem(item(
+ "a1",
+ "message",
+ Some("The first check is done; checking the rest."),
+ ))),
+ cx,
+ );
+ chat.handle_service_event(
+ event(AgentRunEvent::TimelineItem(AgentTimelineItem {
+ status: Some("running".into()),
+ ..item("later", "tool", None)
+ })),
+ cx,
+ );
+ assert!(!chat.chunk_open(1));
+ assert!(!chat.chunk_open(3));
+ });
+ cx.run_until_parked();
+ assert!(cx.debug_bounds("activity-status-later").is_some());
+ assert!(cx.debug_bounds("timeline-row-a1").is_some());
+ assert!(cx.debug_bounds("tool-card").is_none());
+
+ motion::set_test_now(Some(began + Duration::from_secs(8)));
+ chat.update(cx, |chat, cx| {
+ chat.handle_service_event(
+ event(AgentRunEvent::TimelineItem(item(
+ "live-thought",
+ "thinking",
+ Some("Another row arrives while this chunk is folded."),
+ ))),
+ cx,
+ );
+ assert_eq!(chat.turns.tail(), Some(1));
+ assert!(!chat.chunk_open(3));
+ assert_eq!(chat.navigable_timeline_ids(), ["u1", "call", "a1", "later"]);
+ assert!(
+ chat.turn_worked.is_empty(),
+ "a new chunk does not end the turn"
+ );
+ });
+ cx.run_until_parked();
+ assert!(cx.debug_bounds("thinking-title").is_none());
+ assert!(cx.debug_bounds("timeline-row-a1").is_some());
+
+ motion::set_test_now(Some(began + Duration::from_secs(13)));
+ chat.update(cx, |chat, cx| {
+ for (id, status) in [("call", "failed"), ("later", "cancelled")] {
+ chat.handle_service_event(
+ event(AgentRunEvent::TimelineItem(AgentTimelineItem {
+ status: Some(status.into()),
+ ..item(id, "tool", None)
+ })),
+ cx,
+ );
+ }
+ chat.handle_service_event(
+ event(AgentRunEvent::TimelineItem(item(
+ "failure",
+ "error",
+ Some("One check failed."),
+ ))),
+ cx,
+ );
+ chat.handle_service_event(
+ event(AgentRunEvent::Finished(AgentRunTerminal::Cancelled)),
+ cx,
+ );
+ assert_eq!(chat.turn_worked.len(), 1);
+ assert_eq!(chat.turn_worked.get("call"), Some(&Duration::from_secs(13)));
+ assert!(!chat.chunk_open(1));
+ assert!(!chat.chunk_open(3));
+ assert_eq!(
+ chat.turns.chunk(1).unwrap().state(false),
+ Some(crate::ui::chat::step::StepState::Failed)
+ );
+ assert_eq!(
+ chat.turns.chunk(3).unwrap().state(false),
+ Some(crate::ui::chat::step::StepState::Stopped)
+ );
+ assert_eq!(
+ chat.navigable_timeline_ids(),
+ ["u1", "call", "a1", "later", "failure"]
+ );
+ });
+ cx.run_until_parked();
+ for selector in [
+ "activity-status-call",
+ "activity-status-later",
+ "timeline-row-a1",
+ "timeline-row-failure",
+ ] {
+ assert!(
+ cx.debug_bounds(selector).is_some(),
+ "{selector} remains visible"
+ );
+ }
+ assert!(cx.debug_bounds("tool-card").is_none());
+ assert!(cx.debug_bounds("thinking-title").is_none());
+ }
+
+ #[test]
+ fn chunk_disclosure_motion_is_independent_and_settles_with_reduced_motion() {
+ use std::time::Instant;
+
+ use crate::ui::chat::transcript::RowMotion;
+ use crate::ui::motion;
+
+ let began = Instant::now();
+ let midway = began + motion::REVEAL.duration / 2;
+ let mut rows = RowMotion::default();
+ rows.disclose("tool", true, began);
+ rows.disclose_chunk("first", true, began);
+ let progress = rows.chunk_disclosure("first", midway, false);
+ assert!(progress > 0. && progress < 1.);
+ assert_eq!(rows.chunk_disclosure("second", midway, false), 1.);
+ rows.disclose_chunk("second", true, midway);
+ assert_eq!(rows.chunk_disclosure("second", midway, false), 0.);
+ assert_eq!(rows.chunk_disclosure("first", midway, false), progress);
+ assert_eq!(rows.disclosure("tool", midway, false), progress);
+
+ rows.rekey("first", "persisted-first");
assert_eq!(
- rows(cx),
- ["u1", "call", "a1"],
- "h on the line folds the turn"
+ rows.chunk_disclosure("persisted-first", midway, false),
+ progress
);
+ rows.disclose_chunk("second", false, midway);
+ assert_eq!(rows.chunk_disclosure("second", midway, false), 1.);
+ assert_eq!(rows.disclosure("tool", midway, false), progress);
+ assert_eq!(rows.chunk_disclosure("persisted-first", midway, true), 1.);
+ assert!(!rows.settle(midway, true));
+ assert_eq!(rows.chunk_disclosure("persisted-first", midway, false), 1.);
+ assert_eq!(rows.disclosure("tool", midway, false), 1.);
}
#[gpui::test]
@@ -12884,7 +13066,7 @@ mod state_tests {
chat.tool_summaries
.insert("think-1".to_string(), SharedString::from(summary));
// The rows under test are the turn's steps: show them.
- chat.toggle_turn("tool-1", cx);
+ chat.toggle_chunk("tool-1", cx);
chat
});
@@ -12974,7 +13156,7 @@ mod state_tests {
..call("edit", "edit", "src/net/retry.rs")
},
]);
- chat.toggle_turn("run", cx);
+ chat.toggle_chunk("run", cx);
chat
});
diff --git a/apps/maple-agent/app/src/ui/chat/transcript.rs b/apps/maple-agent/app/src/ui/chat/transcript.rs
index d71e1cae5..f17f530cc 100644
--- a/apps/maple-agent/app/src/ui/chat/transcript.rs
+++ b/apps/maple-agent/app/src/ui/chat/transcript.rs
@@ -76,16 +76,12 @@ impl ChatScreen {
let Some(item) = chat.timeline.get(ix) else {
return div().into_any_element();
};
- // A turn's first step carries the turn's line. Folded, the line
- // is all of that row, and the later steps draw nothing.
+ // Each activity chunk has a disclosure; only the first also
+ // carries the overall turn's animated status line.
let turn = chat.turns.row(ix);
- let lead = match turn {
- TurnRow::Plain => None,
- TurnRow::Lead => Some(ix),
- TurnRow::Step(lead) => Some(lead),
- };
- let open = lead.is_none_or(|lead| chat.turn_open(lead));
- if !open && turn != TurnRow::Lead {
+ let lead = turn.lead(ix);
+ let open = lead.is_none_or(|lead| chat.chunk_open(lead));
+ if !open && matches!(turn, TurnRow::Step(_)) {
return div().into_any_element();
}
// A row that arrived live enters, timed from view state so
@@ -148,22 +144,31 @@ impl ChatScreen {
}),
);
}
- // Steps the line just showed fade in, like any details
- // the user opens.
+ // Each chunk keeps the existing details reveal timing.
let shown = lead.map_or(1., |lead| {
chat.row_motion
- .turn_disclosure(&chat.timeline[lead].id, now, reduced)
+ .chunk_disclosure(&chat.timeline[lead].id, now, reduced)
});
row.when(shown < 1., |row| row.opacity(motion::ease_out_quint(shown)))
});
- let line = (turn == TurnRow::Lead).then(|| {
- turn::render_line(
- chat.turn_line(ix, still),
- Some((&item.id, open)),
- &entity,
- &chat.messages,
+ let body = if let Some(chunk) = chat.turns.chunk(ix) {
+ Some(
+ div()
+ .child(turn::render_chunk(
+ &item.id,
+ chunk,
+ open,
+ chat.turn_runs(ix),
+ &entity,
+ &chat.messages,
+ ))
+ .children(body),
)
- });
+ } else {
+ body
+ };
+ let line = (turn == TurnRow::Lead)
+ .then(|| turn::render_line(chat.turn_line(ix, still), &item.id, &chat.messages));
let select = |row: Div| {
if !chat.application_vim_enabled {
return row;
@@ -433,8 +438,7 @@ impl ChatScreen {
let line = self.line_in_slot().then(|| {
turn::render_line(
self.live_line(motion::loops_paused(window, cx)),
- None,
- &cx.entity().downgrade(),
+ "slot",
&self.messages,
)
});
@@ -560,7 +564,7 @@ pub(super) struct RowMotion {
pub(super) heights: Rc>>,
/// Rows whose details the user just opened, by item id.
disclosed: HashMap,
- /// Turns whose steps the user just showed, by the id of their lead row.
+ /// Chunks whose steps the user just showed, by their lead row id.
unfolded: HashMap,
/// When another task's transcript landed.
switched: Option,
@@ -704,8 +708,8 @@ impl RowMotion {
}
}
- /// The user showed or folded a turn's steps. Folding is immediate.
- pub(super) fn disclose_turn(&mut self, lead: &str, open: bool, now: Instant) {
+ /// The user showed or folded a chunk. Folding is immediate.
+ pub(super) fn disclose_chunk(&mut self, lead: &str, open: bool, now: Instant) {
if open {
self.unfolded.insert(lead.to_owned(), now);
} else {
@@ -764,7 +768,7 @@ impl RowMotion {
}
/// Progress of the fade of steps the user just showed.
- pub(super) fn turn_disclosure(&self, lead: &str, now: Instant, reduced: bool) -> f32 {
+ pub(super) fn chunk_disclosure(&self, lead: &str, now: Instant, reduced: bool) -> f32 {
self.unfolded
.get(lead)
.map_or(1., |at| motion::progress(*at, motion::REVEAL, now, reduced))
@@ -3456,7 +3460,7 @@ mod motion_tests {
}
#[gpui::test]
- fn a_turns_steps_stay_folded_until_its_line_is_clicked(cx: &mut TestAppContext) {
+ fn a_chunks_steps_stay_folded_until_its_header_is_clicked(cx: &mut TestAppContext) {
let _clock = Clock::start();
let (chat, cx) = pane(cx, 30);
// A finished turn after the history: two steps, then the reply.
@@ -3480,6 +3484,13 @@ mod motion_tests {
cx.simulate_click(line.center(), gpui::Modifiers::default());
redraw(&chat, cx);
+ assert!(
+ cx.debug_bounds("tool-card").is_none(),
+ "the turn line is informational"
+ );
+ let header = bounds(cx, "activity-chunk-call");
+ cx.simulate_click(header.center(), gpui::Modifiers::default());
+ redraw(&chat, cx);
let call = bounds(cx, "tool-card");
let thought = bounds(cx, "thinking-title");
assert_eq!(
@@ -3492,7 +3503,8 @@ mod motion_tests {
"the steps open under the line, in order: {line:?}, {call:?}, {thought:?}"
);
- cx.simulate_click(line.center(), gpui::Modifiers::default());
+ let header = bounds(cx, "activity-chunk-call");
+ cx.simulate_click(header.center(), gpui::Modifiers::default());
redraw(&chat, cx);
assert!(
cx.debug_bounds("tool-card").is_none(),
@@ -3521,7 +3533,7 @@ mod motion_tests {
}
#[gpui::test]
- fn the_line_keeps_its_place_when_the_turns_first_step_arrives(cx: &mut TestAppContext) {
+ fn the_line_hands_off_without_a_jump_as_the_first_chunk_enters(cx: &mut TestAppContext) {
let clock = Clock::start();
let (chat, cx) = pane(cx, 30);
// A run is going and nothing has come back yet: the line waits
@@ -3546,17 +3558,23 @@ mod motion_tests {
});
let tops =
tops_through_entrance(&chat, &clock, start, &["turn-line", "timeline-row-h29"], cx);
- assert!(
- tops[0].iter().all(|top| *top == waiting.origin.y),
- "the line stays where it waited ({:?}) once a row carries it: {:?}",
- waiting.origin.y,
- tops[0]
+ assert_eq!(tops[0][0], waiting.origin.y, "the line hands off in place");
+ assert_eq!(
+ tops[1][0], older.origin.y,
+ "older rows do not jump on handoff"
);
+ assert_glides(&tops[0], "the line above the arriving chunk header");
+ assert_glides(&tops[1], "the history above the arriving chunk header");
+ for (line, history) in tops[0].iter().zip(&tops[1]) {
+ assert_eq!(
+ *line - *history,
+ waiting.origin.y - older.origin.y,
+ "the header's entrance moves the line and history together"
+ );
+ }
assert!(
- tops[1].iter().all(|top| *top == older.origin.y),
- "older rows hold still: {:?} then {:?}",
- older.origin.y,
- tops[1]
+ bounds(cx, "activity-chunk-call").top() >= bounds(cx, "turn-line").bottom(),
+ "the inline disclosure settles below the informational line"
);
}
diff --git a/apps/maple-agent/app/src/ui/chat/turn.rs b/apps/maple-agent/app/src/ui/chat/turn.rs
index 4809851eb..e486e14ae 100644
--- a/apps/maple-agent/app/src/ui/chat/turn.rs
+++ b/apps/maple-agent/app/src/ui/chat/turn.rs
@@ -1,11 +1,9 @@
-//! The line a turn's steps fold under.
+//! A turn's status line and independently disclosed activity chunks.
//!
-//! A turn is what Maple does between two messages from the user. Its
-//! thinking rows and tool calls are its steps. The first step carries the
-//! turn's line: the Maple mark, what Maple is doing, and for how long. The
-//! steps stay folded under the line until it is clicked. Before a turn has
-//! a step, the same line waits in the slot under the transcript.
+//! A turn runs between user messages. Visible messages and notices split
+//! its steps into chunks, without splitting its clock or animated status.
+use std::collections::HashMap;
use std::time::{Duration, Instant};
use gpui::{Context, Div, SharedString, div, prelude::*, px};
@@ -19,7 +17,9 @@ use super::transcript::{
use crate::ui::i18n::{MessageCache, tr};
use crate::ui::morph_text::morph_text;
use crate::ui::motion;
+use crate::ui::motion::HoverBg as _;
use crate::ui::theme;
+use crate::ui::{icons::icon, widgets};
/// Gap between two repaints of a running turn's time where loops hold
/// still: the seconds stay true without the tenths.
@@ -30,25 +30,87 @@ const RUN_TICK: Duration = Duration::from_secs(1);
const MARK_CYCLE: Duration = Duration::from_millis(1600);
const SHINE_CYCLE: Duration = Duration::from_millis(1900);
-/// What a transcript row is to its turn's line.
+/// A transcript row's place in its turn and activity chunk.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum TurnRow {
- /// A message, a notice, an error: always shown.
Plain,
- /// The turn's first step. The line is drawn above it.
+ /// The first chunk also carries the turn's status line.
Lead,
- /// A later step, folded under the lead at this index.
+ Chunk,
Step(usize),
}
-/// Each loaded row's place in its turn, kept beside the timeline so no
-/// frame regroups it.
+impl TurnRow {
+ pub(super) fn lead(self, index: usize) -> Option {
+ match self {
+ Self::Plain => None,
+ Self::Lead | Self::Chunk => Some(index),
+ Self::Step(lead) => Some(lead),
+ }
+ }
+}
+
+/// Header data maintained on row changes, never derived during rendering.
+#[derive(Default)]
+pub(super) struct Chunk {
+ end: usize,
+ icons: Vec<(&'static str, usize)>,
+ states: [usize; 4],
+}
+
+impl Chunk {
+ fn add_icon(&mut self, icon: &'static str) {
+ if let Some((_, count)) = self.icons.iter_mut().find(|(name, _)| *name == icon) {
+ *count += 1;
+ } else {
+ self.icons.push((icon, 1));
+ }
+ }
+
+ fn add(&mut self, (icon, state): (&'static str, step::StepState)) {
+ self.add_icon(icon);
+ self.states[state as usize] += 1;
+ }
+
+ fn replace(
+ &mut self,
+ before: (&'static str, step::StepState),
+ after: (&'static str, step::StepState),
+ ) {
+ self.states[before.1 as usize] -= 1;
+ self.states[after.1 as usize] += 1;
+ if before.0 != after.0 {
+ for (name, count) in &mut self.icons {
+ if *name == before.0 {
+ *count -= 1;
+ }
+ }
+ self.icons.retain(|(_, count)| *count > 0);
+ self.add_icon(after.0);
+ }
+ }
+
+ pub(super) fn count(&self) -> usize {
+ self.states.iter().sum()
+ }
+
+ pub(super) fn state(&self, live: bool) -> Option {
+ use step::StepState;
+ [StepState::Failed, StepState::Running, StepState::Stopped]
+ .into_iter()
+ .find(|state| {
+ self.states[*state as usize] > 0 && (*state != StepState::Running || live)
+ })
+ }
+}
+
#[derive(Default)]
pub(super) struct Turns {
rows: Vec,
- /// The lead of the turn at the end of the loaded rows, once that turn
- /// has a step.
+ chunks: HashMap,
+ /// First step of the latest user turn, kept stable for its clock.
tail: Option,
+ chunk: Option,
}
fn starts_turn(item: &AgentTimelineItem) -> bool {
@@ -69,16 +131,44 @@ fn is_step(item: &AgentTimelineItem) -> bool {
matches!(item.item_type.as_str(), "thinking" | "reasoning")
}
-/// What decides a row's place in its turn: whether it starts one, and
-/// whether it is a step.
-pub(super) fn part(item: &AgentTimelineItem) -> (bool, bool) {
- (starts_turn(item), is_step(item))
+/// Classification changes can move both turn and chunk boundaries.
+pub(super) fn part(item: &AgentTimelineItem) -> (bool, bool, bool) {
+ let step = is_step(item);
+ (
+ starts_turn(item),
+ step,
+ !step && !is_tool(item) && super::navigation::timeline_item_is_navigable(item),
+ )
+}
+
+pub(super) fn step_info(item: &AgentTimelineItem) -> (&'static str, step::StepState) {
+ if is_tool(item) {
+ if has_tool_input(item, "todos") {
+ return ("check", step::StepState::Done);
+ }
+ return (
+ step::tool_icon(item),
+ step::StepState::of(item.status.as_deref()),
+ );
+ }
+ let state = if item
+ .text
+ .as_deref()
+ .is_none_or(|text| text.trim().is_empty())
+ {
+ step::StepState::Running
+ } else {
+ step::StepState::Done
+ };
+ ("brain", state)
}
impl Turns {
/// Group a whole timeline: a snapshot, a history page, a trimmed window.
pub(super) fn rebuild(&mut self, timeline: &[AgentTimelineItem]) {
self.rows.clear();
+ self.chunks.clear();
+ self.chunk = None;
self.tail = None;
for item in timeline {
self.push(item);
@@ -87,17 +177,35 @@ impl Turns {
/// One row arrived at the end.
pub(super) fn push(&mut self, item: &AgentTimelineItem) {
- let row = if starts_turn(item) {
+ let index = self.rows.len();
+ let (starts_turn, is_step, breaks_chunk) = part(item);
+ let row = if starts_turn {
self.tail = None;
+ self.chunk = None;
TurnRow::Plain
- } else if !is_step(item) {
+ } else if !is_step {
+ // Hidden plans and empty streamed messages do not separate
+ // the activities around them.
+ if breaks_chunk {
+ self.chunk = None;
+ }
TurnRow::Plain
- } else if let Some(lead) = self.tail {
+ } else if let Some(lead) = self.chunk {
TurnRow::Step(lead)
} else {
- self.tail = Some(self.rows.len());
- TurnRow::Lead
+ self.chunk = Some(index);
+ if self.tail.is_none() {
+ self.tail = Some(index);
+ TurnRow::Lead
+ } else {
+ TurnRow::Chunk
+ }
};
+ if let Some(lead) = row.lead(index) {
+ let chunk = self.chunks.entry(lead).or_default();
+ chunk.end = index + 1;
+ chunk.add(step_info(item));
+ }
self.rows.push(row);
}
@@ -109,17 +217,26 @@ impl Turns {
self.tail
}
- /// One past the last step of the turn led by the row at `lead`.
+ pub(super) fn chunk(&self, lead: usize) -> Option<&Chunk> {
+ self.chunks.get(&lead)
+ }
+
pub(super) fn end(&self, lead: usize) -> usize {
- let mut end = lead + 1;
- for (index, row) in self.rows.iter().enumerate().skip(end) {
- match row {
- TurnRow::Step(of) if *of == lead => end = index + 1,
- TurnRow::Lead => break,
- _ => {}
- }
+ self.chunk(lead).map_or(lead + 1, |chunk| chunk.end)
+ }
+
+ pub(super) fn update_step(
+ &mut self,
+ index: usize,
+ before: (&'static str, step::StepState),
+ after: (&'static str, step::StepState),
+ ) -> Option {
+ if before == after {
+ return None;
}
- end
+ let lead = self.row(index).lead(index)?;
+ self.chunks.get_mut(&lead)?.replace(before, after);
+ Some(lead)
}
}
@@ -315,17 +432,9 @@ fn maple_mark(mark: Mark, phase: f32) -> Div {
grid
}
-/// The line, as tall as the slot under the transcript it first shows in,
-/// so taking its place in the list moves nothing. `fold` names the turn's
-/// lead and says whether its steps show; the slot's line has no steps to
-/// open and passes `None`.
-pub(super) fn render_line(
- line: Line,
- fold: Option<(&str, bool)>,
- chat: &gpui::WeakEntity,
- messages: &MessageCache,
-) -> Div {
- let key = fold.map_or("slot", |(lead, _)| lead);
+/// The summary keeps the same height and identity when it takes over the
+/// waiting slot. Chunk disclosures do not replace or restart its motion.
+pub(super) fn render_line(line: Line, key: &str, messages: &MessageCache) -> Div {
let id = |part: &str| SharedString::from(format!("turn-{part}-{key}"));
let (label, mark, time) = match line {
Line::Live {
@@ -398,31 +507,100 @@ pub(super) fn render_line(
.text_color(gpui::rgb(theme::text_muted()))
.child(gpui::text!(time))
}));
- let row = div().h(WAITING_ROW_HEIGHT).flex().items_center();
- let Some((lead, open)) = fold else {
- return row.child(button.role(gpui::Role::Status));
- };
- let lead = lead.to_owned();
- let chat = chat.clone();
- row.child(
- button
- .role(gpui::Role::DisclosureTriangle)
- .aria_expanded(open)
- .hover(|style| {
- style
- .cursor_pointer()
- .text_color(gpui::rgb(theme::text_primary()))
- })
- .child(motion::chevron(
- id("chevron"),
- open,
- px(14.),
- theme::text_muted(),
- ))
- .on_click(move |_event, _window, cx: &mut gpui::App| {
- chat.update(cx, |chat, cx| chat.toggle_turn(&lead, cx)).ok();
- }),
- )
+ div()
+ .h(WAITING_ROW_HEIGHT)
+ .flex()
+ .items_center()
+ .child(button.role(gpui::Role::Status))
+}
+
+pub(super) fn render_chunk(
+ lead: &str,
+ chunk: &Chunk,
+ open: bool,
+ live: bool,
+ chat: &gpui::WeakEntity,
+ messages: &MessageCache,
+) -> Div {
+ let label = messages.get("chat-activity-steps", [("count", chunk.count().into())]);
+ let status = chunk.state(live).map(|state| {
+ let (key, ink) = match state {
+ step::StepState::Failed => ("chat-status-failed", theme::status_error()),
+ step::StepState::Stopped => ("chat-status-stopped", theme::text_muted()),
+ _ => ("chat-status-running", theme::text_muted()),
+ };
+ let id = SharedString::from(format!("activity-status-{lead}"));
+ div()
+ .id(id.clone())
+ .debug_selector(move || id.to_string())
+ .role(gpui::Role::Status)
+ .aria_label(tr(key))
+ .text_xs()
+ .text_color(gpui::rgb(ink))
+ .child(gpui::text!(tr(key)))
+ });
+ let debug = format!("activity-chunk-{lead}");
+ let target = chat.clone();
+ let key = lead.to_owned();
+ div()
+ .flex()
+ .when(!open, |row| row.pb_2())
+ .items_start()
+ .child(
+ div()
+ .id(SharedString::from(format!("activity-toggle-{lead}")))
+ .debug_selector(move || debug.clone())
+ .role(gpui::Role::DisclosureTriangle)
+ .aria_label(label.clone())
+ .aria_expanded(open)
+ .tab_index(0)
+ .on_key_down(ChatScreen::sidebar_button_key_down)
+ .focus_visible(widgets::focus_ring)
+ .min_h(px(32.))
+ .max_w_full()
+ .px_2()
+ .ml(px(-8.))
+ .rounded(theme::RADIUS_SM)
+ .flex()
+ .flex_wrap()
+ .items_center()
+ .gap_2p5()
+ .text_sm()
+ .text_color(gpui::rgb(theme::text_secondary()))
+ .hover_bg(theme::overlay_hover())
+ .hover(|style| {
+ style
+ .cursor_pointer()
+ .text_color(gpui::rgb(theme::text_primary()))
+ })
+ .child(
+ div()
+ .w(step::NODE)
+ .flex()
+ .justify_center()
+ .child(motion::chevron(
+ SharedString::from(format!("activity-chevron-{lead}")),
+ open,
+ px(14.),
+ theme::text_muted(),
+ )),
+ )
+ .child(gpui::text!(label))
+ .child(
+ div().flex().gap_1p5().children(
+ chunk
+ .icons
+ .iter()
+ .map(|(name, _)| icon(name, px(12.), theme::text_muted())),
+ ),
+ )
+ .children(status)
+ .on_click(move |_, _, cx| {
+ target
+ .update(cx, |chat, cx| chat.toggle_chunk(&key, cx))
+ .ok();
+ }),
+ )
}
impl ChatScreen {
@@ -437,8 +615,8 @@ impl ChatScreen {
/// earlier one, and the line waits in the slot instead. A window that
/// is paged back in history, or still lacks the run's newest rows,
/// does not hold the turn the run works on at all.
- fn turn_runs(&self, lead: usize) -> bool {
- self.turns.tail() == Some(lead)
+ pub(super) fn turn_runs(&self, lead: usize) -> bool {
+ self.turns.tail().is_some_and(|turn| lead >= turn)
&& self.is_run_active()
&& !self.awaiting_first_token
&& !self.pages.after
@@ -483,25 +661,24 @@ impl ChatScreen {
}
}
- /// Whether the steps of the turn led by the row at `lead` show. "Show
- /// tool call details" opens every turn; a click on the line inverts
- /// that for its turn.
- pub(super) fn turn_open(&self, lead: usize) -> bool {
+ /// The existing details preference is the default; a click changes
+ /// only this chunk, including while more steps arrive in it.
+ pub(super) fn chunk_open(&self, lead: usize) -> bool {
self.timeline
.get(lead)
- .is_some_and(|item| self.tool_details != self.toggled_turns.contains(&item.id))
+ .is_some_and(|item| self.tool_details != self.toggled_chunks.contains(&item.id))
}
- /// Show or fold a turn's steps and re-measure their rows.
- pub(super) fn toggle_turn(&mut self, lead_id: &str, cx: &mut Context) {
+ /// Show or fold one chunk and re-measure only its rows.
+ pub(super) fn toggle_chunk(&mut self, lead_id: &str, cx: &mut Context) {
let Some(&(lead, _)) = self.timeline_index.get(lead_id) else {
return;
};
- if !self.toggled_turns.remove(lead_id) {
- self.toggled_turns.insert(lead_id.to_owned());
+ if !self.toggled_chunks.remove(lead_id) {
+ self.toggled_chunks.insert(lead_id.to_owned());
}
- let open = self.turn_open(lead);
- self.row_motion.disclose_turn(lead_id, open, motion::now());
+ let open = self.chunk_open(lead);
+ self.row_motion.disclose_chunk(lead_id, open, motion::now());
if !open {
self.keep_application_selection_shown(lead);
} else if self.list_state.is_following_tail()
@@ -614,8 +791,8 @@ impl ChatScreen {
/// A live row took its persisted id; what was kept under the old one
/// follows it.
pub(super) fn rekey_turn(&mut self, old: &str, new: &str) {
- if self.toggled_turns.remove(old) {
- self.toggled_turns.insert(new.to_owned());
+ if self.toggled_chunks.remove(old) {
+ self.toggled_chunks.insert(new.to_owned());
}
if let Some(worked) = self.turn_worked.remove(old) {
self.turn_worked.insert(new.to_owned(), worked);
@@ -678,11 +855,14 @@ mod tests {
}
#[test]
- fn a_turn_folds_its_later_steps_under_its_first() {
+ fn messages_split_chunks_without_splitting_the_turn() {
let timeline = [
item("message", Some("user")),
item("thinking", None),
- item("message", Some("assistant")),
+ AgentTimelineItem {
+ text: Some("Checking the remaining files.".into()),
+ ..item("message", Some("assistant"))
+ },
item("tool", None),
item("error", None),
item("message", Some("user")),
@@ -698,15 +878,15 @@ mod tests {
TurnRow::Plain,
TurnRow::Lead,
TurnRow::Plain,
- TurnRow::Step(1),
+ TurnRow::Chunk,
TurnRow::Plain,
TurnRow::Plain,
TurnRow::Plain,
TurnRow::Lead,
]
);
- // The first turn ends at its last step, not at the error after it.
- assert_eq!(turns.end(1), 4);
+ assert_eq!(turns.end(1), 2);
+ assert_eq!(turns.end(3), 4);
assert_eq!(turns.end(7), 8);
assert_eq!(turns.tail(), Some(7));
}
@@ -735,6 +915,103 @@ mod tests {
assert_eq!(live.tail(), None);
}
+ #[test]
+ fn hidden_plans_do_not_split_activity_and_status_updates_stay_in_their_chunk() {
+ let done = AgentTimelineItem {
+ status: Some("completed".into()),
+ ..item("tool", None)
+ };
+ let plan = AgentTimelineItem {
+ input: Some(serde_json::json!({"todos": [{"text": "Read", "status": "pending"}]})),
+ ..item("tool", None)
+ };
+ let mut turns = Turns::default();
+ turns.rebuild(&[done.clone(), plan, done.clone()]);
+ assert_eq!(turns.row(2), TurnRow::Step(0));
+ let chunk = turns.chunk(0).unwrap();
+ assert_eq!(chunk.count(), 2);
+ assert_eq!(chunk.state(true), None);
+ let failed = AgentTimelineItem {
+ status: Some("failed".into()),
+ ..done.clone()
+ };
+ assert_eq!(
+ turns.update_step(2, step_info(&done), step_info(&failed)),
+ Some(0)
+ );
+ assert_eq!(
+ turns.chunk(0).unwrap().state(false),
+ Some(step::StepState::Failed)
+ );
+ turns.update_step(2, step_info(&failed), step_info(&done));
+ assert_eq!(turns.chunk(0).unwrap().state(false), None);
+ assert_eq!(turns.chunk(0).unwrap().count(), 2);
+ turns.push(&AgentTimelineItem {
+ input: Some(serde_json::json!({"todos": [{"text": "Read", "status": "completed"}]})),
+ ..item("tool", None)
+ });
+ assert_eq!(turns.chunk(0).unwrap().count(), 3);
+ assert!(
+ turns
+ .chunk(0)
+ .unwrap()
+ .icons
+ .iter()
+ .any(|(icon, _)| *icon == "check")
+ );
+ }
+
+ #[test]
+ fn empty_messages_and_internal_rows_do_not_split_activity_chunks() {
+ let mut timeline = [
+ item("tool", None),
+ AgentTimelineItem {
+ text: Some("\n\n".into()),
+ ..item("message", Some("assistant"))
+ },
+ item("internal", None),
+ item("tool", None),
+ ];
+ let mut turns = Turns::default();
+ turns.rebuild(&timeline);
+ assert_eq!(turns.row(3), TurnRow::Step(0));
+ assert_eq!(turns.chunk(0).unwrap().count(), 2);
+ let before = part(&timeline[1]);
+ timeline[1].text = Some("Now checking the result.".into());
+ assert_ne!(before, part(&timeline[1]));
+ turns.rebuild(&timeline);
+ assert_eq!(turns.row(3), TurnRow::Chunk);
+ assert_eq!(turns.chunk(0).unwrap().count(), 1);
+ assert_eq!(turns.tail(), Some(0));
+ }
+
+ #[test]
+ fn finished_thinking_clears_its_chunk_status_during_a_live_turn() {
+ let thinking = item("thinking", None);
+ let mut turns = Turns::default();
+ turns.push(&thinking);
+ assert_eq!(
+ turns.chunk(0).unwrap().state(true),
+ Some(step::StepState::Running)
+ );
+ let done = AgentTimelineItem {
+ text: Some("The next action is clear.".into()),
+ ..thinking.clone()
+ };
+ turns.update_step(0, step_info(&thinking), step_info(&done));
+ assert_eq!(turns.chunk(0).unwrap().state(true), None);
+ turns.push(&AgentTimelineItem {
+ text: Some("Applying the change.".into()),
+ ..item("message", Some("assistant"))
+ });
+ turns.push(&item("tool", None));
+ assert_eq!(turns.chunk(0).unwrap().state(true), None);
+ assert_eq!(
+ turns.chunk(2).unwrap().state(true),
+ Some(step::StepState::Running)
+ );
+ }
+
#[test]
fn the_clock_stops_while_a_question_waits() {
let began = Instant::now();
diff --git a/apps/maple-agent/app/translation-revisions/de.txt b/apps/maple-agent/app/translation-revisions/de.txt
index 0cd01e19a..e6f400f0e 100644
--- a/apps/maple-agent/app/translation-revisions/de.txt
+++ b/apps/maple-agent/app/translation-revisions/de.txt
@@ -2,6 +2,7 @@
chat-absolute-path a2ba378ac24704c4
chat-active 196d1c9462f99ad3
chat-activity-outside dc914a2d8037659c
+chat-activity-steps a12bb21490dd0f51
chat-agent-task-cancelled e26bb0917a4c240b
chat-agents-running 15f7861d7b1f2dc3
chat-all-settings f521b783e34e05d0
diff --git a/apps/maple-agent/app/translation-revisions/es.txt b/apps/maple-agent/app/translation-revisions/es.txt
index 0cd01e19a..e6f400f0e 100644
--- a/apps/maple-agent/app/translation-revisions/es.txt
+++ b/apps/maple-agent/app/translation-revisions/es.txt
@@ -2,6 +2,7 @@
chat-absolute-path a2ba378ac24704c4
chat-active 196d1c9462f99ad3
chat-activity-outside dc914a2d8037659c
+chat-activity-steps a12bb21490dd0f51
chat-agent-task-cancelled e26bb0917a4c240b
chat-agents-running 15f7861d7b1f2dc3
chat-all-settings f521b783e34e05d0
diff --git a/apps/maple-agent/docs/motion.md b/apps/maple-agent/docs/motion.md
index c134332ab..db91ebdfc 100644
--- a/apps/maple-agent/docs/motion.md
+++ b/apps/maple-agent/docs/motion.md
@@ -91,7 +91,7 @@ the shared 15 fps `ticker` clock and pause in background windows.
| Disclosed details (tool output, thinking) | fade in, `REVEAL` | immediate |
| Streaming text | grows in place, no animation | — |
| A turn's line ("Maple is thinking", "Worked for 11s") | fades in under the transcript, `REVEAL`, and keeps its place when the turn's first step takes it into the list; a sheen crosses the mark and the words while Maple works, and the words morph when they change | immediate |
-| A turn's steps, shown from its line | fade in, `REVEAL`; the chevron turns, `TOGGLE` | immediate |
+| Activity chunks between visible messages, shown from their inline headers | fade in independently, `REVEAL`; each chevron turns, `TOGGLE` | immediate |
| Notices, queued messages, cards above the composer | fade and rise, `ENTER` | immediate |
| Files attached to the draft | fade and 6 px rise, `ENTER` | immediate |
| Composer and multi-line fields | height eases to the new line count, `resize(distance)` | same |
@@ -103,6 +103,12 @@ the shared 15 fps `ticker` clock and pause in background windows.
| Sidebar collapse | width eases, `PANEL` | same, reversed |
| Task status in the sidebar, project folders | indicators and folder icons cross-fade, `TOGGLE` | same |
+The turn's line stays informational and keeps one clock for the whole turn.
+Each activity chunk has its own disclosure; folding one leaves the other
+chunks and the assistant's explanations alone. Tool details keep their own
+disclosure state. Chunk headers use the same hover and chevron motion as
+other controls; they do not add another looping indicator.
+
Loading spinners for work that usually finishes quickly (opening a task)
appear only after 300 ms, so fast loads never flash a spinner.
From a765d44b1eceb043d04cd0b70e3c47ce9403f42a Mon Sep 17 00:00:00 2001
From: Matthew Ball <13823657+matthewrball@users.noreply.github.com>
Date: Tue, 17 Nov 2026 14:45:16 -0800
Subject: [PATCH 4/5] Agent: record the Korean step-count string
---
apps/maple-agent/app/translation-revisions/ko.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/maple-agent/app/translation-revisions/ko.txt b/apps/maple-agent/app/translation-revisions/ko.txt
index e0b1ef44a..00ab2b999 100644
--- a/apps/maple-agent/app/translation-revisions/ko.txt
+++ b/apps/maple-agent/app/translation-revisions/ko.txt
@@ -2,6 +2,7 @@
chat-absolute-path a2ba378ac24704c4
chat-active 196d1c9462f99ad3
chat-activity-outside dc914a2d8037659c
+chat-activity-steps a12bb21490dd0f51
chat-agent-task-cancelled e26bb0917a4c240b
chat-agents-running 15f7861d7b1f2dc3
chat-all-settings f521b783e34e05d0
@@ -354,7 +355,6 @@ chat-staging-unsafe-directory 13ed7aa88e08c0a8
chat-starting f00ec83fc396c4b0
chat-starting-agent 0e61b8da983ef787
chat-status-allowed 11310a7438dc9e0c
-chat-status-completed f7f8f9dd4adb3a0c
chat-status-denied deee947bb13482c4
chat-status-done 54904e435ce0c52e
chat-status-failed 3aa7979f86ebefa0
From db676ee7291bf29e6e2e76d57a7d61598fcd123a Mon Sep 17 00:00:00 2001
From: Matthew Ball <13823657+matthewrball@users.noreply.github.com>
Date: Tue, 17 Nov 2026 15:20:01 -0800
Subject: [PATCH 5/5] Agent: count steps in Korean the way the catalog counts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
"3단계" reads as stage 3. Use the catalog's counted form.
---
apps/maple-agent/app/locales/ko/app.ftl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/maple-agent/app/locales/ko/app.ftl b/apps/maple-agent/app/locales/ko/app.ftl
index 4b473f824..531cc000e 100644
--- a/apps/maple-agent/app/locales/ko/app.ftl
+++ b/apps/maple-agent/app/locales/ko/app.ftl
@@ -1554,7 +1554,7 @@ chat-turn-worked-seconds = { $seconds }초 동안 작업했어요
# $minutes is a whole number of minutes; $seconds is the rest, under 60.
chat-turn-worked-minutes = { $minutes }분 { $seconds }초 동안 작업했어요
# $count is the number of tool and thinking steps in one activity chunk.
-chat-activity-steps = { $count }단계
+chat-activity-steps = 단계 { $count }개
chat-settings = 설정
chat-usage = 사용량
chat-usage-unavailable = 사용량을 확인할 수 없음