A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
pa-tui: expand the activity dock into per-group rows on focus (#3638)
Sebastian Müller57cf075279a9
diff --git a/crates/pa-tui/src/bash_view.rs b/crates/pa-tui/src/bash_view.rsindex 144fd15540..265a27f815 100644--- a/crates/pa-tui/src/bash_view.rs+++ b/crates/pa-tui/src/bash_view.rs@@ -15,7 +15,6 @@ use crate::{Line, Span};mod render;-#[cfg(test)]use render::format_duration;use render::{action_row, clean_line, error_line, hint_line, marker_line, metadata_row, pane_header_lines,@@ -99,6 +98,28 @@ pub fn parse_bash_activities(data: &Value) -> Vec<BashActivity> {activities}+/// The command's cell budget inside one activity-dock shell item.+const DOCK_COMMAND_CELLS: usize = 32;++/// The activity dock's shells row: the running shells only, one item each.+pub(crate) fn dock_shell_items(activities: &[BashActivity]) -> Vec<String> {+ activities+ .iter()+ .filter(|activity| activity.running())+ .map(dock_shell_item)+ .collect()+}++/// One running shell in the activity dock: `<command, truncated> · <elapsed>`.+fn dock_shell_item(activity: &BashActivity) -> String {+ let command = crate::heartbeats_picker::single_line(&activity.command);+ format!(+ "{} · {}",+ crate::width::truncate_to_width(&command, DOCK_COMMAND_CELLS, "\u{2026}"),+ format_duration(activity.duration_ms)+ )+}+/// The pane's interactive mode: the columned list, or a row's detail/// drill-in.#[derive(Debug, Clone, PartialEq, Eq)]diff --git a/crates/pa-tui/src/bash_view/tests.rs b/crates/pa-tui/src/bash_view/tests.rsindex 3d5b4fc05a..9dc6166e8b 100644--- a/crates/pa-tui/src/bash_view/tests.rs+++ b/crates/pa-tui/src/bash_view/tests.rs@@ -1109,3 +1109,21 @@ fn durations_format_compactly() {assert_eq!(format_duration(Some(3_412)), "3.4s");assert_eq!(format_duration(Some(125_000)), "2m 05s");}++/// The dock's shells row lists only the running shells, each `<command, truncated> · <elapsed>`;+/// done and failed runs stay rows inside the bash view.+#[test]+fn the_dock_shell_items_list_running_shells_only() {+ let mut rows = activities();+ rows.extend(failed_activities());+ rows.extend(parse_bash_activities(&json!({"activities": [+ {"id":"long","command":"python -m pytest tests/integration --maxfail=1 -x","status":"running","durationMs":125_000},+ ]})));+ assert_eq!(+ dock_shell_items(&rows),+ vec![+ "cargo build --release · 3.4s",+ "python -m pytest tests/integrat… · 2m 05s",+ ]+ );+}diff --git a/crates/pa-tui/src/chrome.rs b/crates/pa-tui/src/chrome.rsindex bfeb0232c1..125786c215 100644--- a/crates/pa-tui/src/chrome.rs+++ b/crates/pa-tui/src/chrome.rs@@ -107,7 +107,7 @@ pub enum ActivityGroup {Goal,}-/// Which way an arrow key steps along the dock's rendered groups.+/// Which way an Up/Down press steps along the dock's rendered groups.#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum ActivityDirection {/// The previous group, wrapping past the first.@@ -118,7 +118,9 @@ pub enum ActivityDirection {/// The bottom activity dock: it renders in every session, all-zero/// included (TS `SubagentSummaryLine` renders nothing at zero — a-/// sanctioned divergence).+/// sanctioned divergence). Unfocused it is one line of group counts;+/// focused it expands into one row per group with each group's details+/// (the operator's 2026-10-16 spec).#[derive(Debug, Clone, Default, PartialEq, Eq)]pub struct ActivityDock {/// The directly-running children right now (one addend of the dock's@@ -127,20 +129,28 @@ pub struct ActivityDock {/// The further running descendants below them: the total's other/// addend. Idle and dead rows never count.pub subagents_running_nested: usize,+ /// The idle descendants (the expanded subagents row's breakdown).+ pub subagents_idle: usize,+ /// The inactive descendants (the expanded subagents row's breakdown).+ pub subagents_inactive: usize,/// The current session's heartbeats (nested sessions' jobs never/// surface here).pub heartbeats: usize,+ /// The current session's active heartbeats, soonest next fire first,+ /// each `<countdown> <label>` (the expanded row).+ pub heartbeats_active: Vec<String>,/// How many of the scoped heartbeats are paused.pub heartbeats_paused: usize,- /// Bash processes actively running right now (the current session's- /// kernel registry only): finished runs stay rows inside the bash view.- pub bash_running: usize,- /// Factory runs actively live right now (a live state — running,- /// stopping, or paused — or a terminal run whose children are still- /// in flight, the residents teardown; the current session's kernel- /// registry only): fully terminal runs never inflate the indicator,- /// exactly like the bash group's running-only count.- pub factory_runs: usize,+ /// The bash processes actively running right now, one item each (the+ /// current session's kernel registry only): finished runs stay rows+ /// inside the bash view.+ pub shells: Vec<String>,+ /// The live factory runs, paused first, each `<name> <state>` (a live+ /// state — running, stopping, or paused — or a terminal run whose+ /// children are still in flight; the current session's kernel registry+ /// only): fully terminal runs never inflate the group, exactly like+ /// the shells group's running-only scoping.+ pub factory_runs: Vec<String>,/// Whether the factory group renders at all: the daemon's/// `factory_activity` advertisement (the factory's opt-in gate —/// `factory.enabled`, off by default). A daemon without the lane@@ -158,12 +168,13 @@ pub struct ActivityDock {}impl ActivityDock {- /// The groups this dock renders, left to right — the arrow- /// traversal order. The subagents, heartbeats, and shells groups- /// always render (an empty one reads its zero count and stays- /// traversable); the factory group renders exactly while the daemon- /// advertises the `factory_activity` lane (the opt-in gate), and the- /// goal group exactly while a live goal keeps its row mounted.+ /// The groups this dock renders — left to right collapsed, top to+ /// bottom expanded — and the Up/Down traversal order. The subagents,+ /// heartbeats, and shells groups always render (an empty one reads its+ /// zero count or its dimmed row and stays traversable); the factory+ /// group renders exactly while the daemon advertises the+ /// `factory_activity` lane (the opt-in gate), and the goal group+ /// exactly while a live goal keeps its row mounted.#[must_use]pub fn groups(&self) -> Vec<ActivityGroup> {let mut groups = vec![@@ -180,8 +191,8 @@ impl ActivityDock {groups}- /// One arrow step: the neighbor in `direction`, wrapping at the row's- /// ends; a `current` that no longer renders steps from the row's start.+ /// One step: the neighbor in `direction`, wrapping at the ends; a+ /// `current` that no longer renders steps from the first group.#[must_use]pub fn step(&self, current: ActivityGroup, direction: ActivityDirection) -> ActivityGroup {let groups = self.groups();@@ -675,14 +686,15 @@ fn land_marker(out: &mut Vec<crate::Span>, width: usize) {}}-/// The framed activity dock: a muted separator rule above one row of-/// the actionable groups — the row renders in every session, all-zero+/// The framed activity dock: a muted separator rule above the+/// actionable groups — one line of counts while unfocused, one row per+/// group while focused. The dock renders in every session, all-zero/// included. The TS summary line wraps its content in an/// accent-colored box (`╭─ subagents ─╮`); the inline design language/// keeps the separation with the same muted `─` rule that frames the/// pickers' search fields, not an accent box.///-/// The row color-codes live activity (the operator's 2026-09-24+/// The collapsed line color-codes live activity (the operator's 2026-09-24/// directive): every count-holding segment goes green while its count/// is above zero (subagents, heartbeats, shells, factory, the active/// goal) and stays neutral at zero. The subagents segment is one@@ -693,24 +705,42 @@ pub fn render_activity_dock(dock: &ActivityDock, theme: &Theme, width: usize) ->render_activity_dock_segments(dock, theme, width).0}-/// One rendered group segment's column span: a plain click on the-/// group's own cells opens that group's view (the dock's Enter route).+/// One rendered group's click surface: a plain click on the group's own+/// cells opens that group's view (the dock's Enter route).#[derive(Debug, Clone, PartialEq, Eq)]pub struct ActivityDockSegment {pub group: ActivityGroup,+ /// The index of the group's line in the rendered frame (the rule is+ /// line 0).+ pub row: usize,/// The row columns the group's spans occupy.pub cols: std::ops::Range<usize>,}-/// The framed activity dock plus its groups' column segments (see-/// [`render_activity_dock`]): the segments cover exactly the cells each-/// group renders, clamped to the row the truncation kept.+/// The framed activity dock plus its groups' click segments (see+/// [`render_activity_dock`]): collapsed, the segments cover exactly the+/// cells each group renders, clamped to the row the truncation kept;+/// expanded, each group's whole row.#[must_use]pub fn render_activity_dock_segments(dock: &ActivityDock,theme: &Theme,width: usize,) -> (Vec<Line>, Vec<ActivityDockSegment>) {+ let rule = vec![theme.fg_span(ThemeColor::BorderMuted, "─".repeat(width))];+ if dock.focused {+ let mut lines = vec![rule];+ let mut segments = Vec::new();+ for group in dock.groups() {+ segments.push(ActivityDockSegment {+ group,+ row: lines.len(),+ cols: 0..width,+ });+ lines.push(render_expanded_dock_row(dock, group, theme, width));+ }+ return (lines, segments);+ }// The status-dot vocabulary (`● running / ◐ idle / ○ inactive`): the half// circle marks waiting work; only the heartbeat pause keeps a dot.let cluster = |text: &str, color: ThemeColor| {@@ -721,93 +751,56 @@ pub fn render_activity_dock_segments(};// The live-only number: actively-running subagents right now, direct// children and nested descendants together — ONE number.- let running_color = |count: usize| {- if count > 0 {- ThemeColor::Success- } else {- ThemeColor::Muted- }- };let running = dock.subagents_running_direct + dock.subagents_running_nested;- // The row and the arrows share one group order (`groups()`): the- // focused selection never binds to a hidden segment.- let groups = dock.groups();+ let shells = dock.shells.len();+ let factory_runs = dock.factory_runs.len();let mut line = vec![Span::raw(" ")];let mut segments: Vec<ActivityDockSegment> = Vec::new();- for (index, group) in groups.iter().copied().enumerate() {+ for (index, group) in dock.groups().into_iter().enumerate() {if index > 0 {line.push(theme.fg_span(ThemeColor::Dim, " · "));}// The segment's column span is what the terminal paints (the// truncation below clamps its end).let start = line.iter().map(|s| str_width(&s.content)).sum();- let spans = match group {+ match group {ActivityGroup::Subagents => {- vec![theme.fg_span(running_color(running), format!("◆ {running} subagents"))]+ line.push(theme.fg_span(activity_color(running), format!("◆ {running} subagents")));}ActivityGroup::Heartbeats => {- let mut heartbeats = vec![theme.fg_span(- running_color(dock.heartbeats),+ line.push(theme.fg_span(+ activity_color(dock.heartbeats),format!("◷ {} heartbeat{}",dock.heartbeats,if dock.heartbeats == 1 { "" } else { "s" }),- )];+ ));if dock.heartbeats_paused > 0 {- heartbeats.extend(cluster(+ line.extend(cluster(&format!("◐ {} paused", dock.heartbeats_paused),ThemeColor::Warning,));}- heartbeats}// The label reads "shell(s)": the tool name stays bash() everywhere else.- ActivityGroup::Bash => vec![theme.fg_span(- running_color(dock.bash_running),- format!(- "▸ {} shell{}",- dock.bash_running,- if dock.bash_running == 1 { "" } else { "s" }- ),- )],+ ActivityGroup::Bash => line.push(theme.fg_span(+ activity_color(shells),+ format!("▸ {} shell{}", shells, if shells == 1 { "" } else { "s" }),+ )),// The factory page's indicator counts live runs only// (running, stopping, paused): done and failed runs stay as// panels inside the factory page, never in the indicator.- ActivityGroup::Factory => vec![theme.fg_span(- running_color(dock.factory_runs),- format!("⚙ {} factory", dock.factory_runs),- )],- // The goal row carries the dock's activity convention: an- // actively pursued goal reads green, and the paused and- // budget-limited states read amber (the paused heartbeat- // cluster's own warning color) — the dock is the goal's one- // chrome surface, so every live state stays visible.- ActivityGroup::Goal => {- let goal = dock.goal_label.as_deref().unwrap_or_default();- let goal_color = if goal.starts_with("Pursuing goal") {- ThemeColor::Success- } else {- ThemeColor::Warning- };- vec![theme.fg_span(goal_color, goal.to_string())]- }- };- if dock.focused && dock.selected == group {- // The focused group reads as one unit behind the ONE shared- // selection band; each span keeps its own status color.- let band = theme.selection_row_style();- for span in spans {- line.push(Span::styled(span.content.clone(), span.style.patch(band)));- }- } else {- for span in spans {- line.push(span);- }+ ActivityGroup::Factory => line.push(theme.fg_span(+ activity_color(factory_runs),+ format!("⚙ {factory_runs} factory"),+ )),+ ActivityGroup::Goal => line.push(goal_span(dock, theme)),}let end = line.iter().map(|s| str_width(&s.content)).sum();segments.push(ActivityDockSegment {group,+ row: 1,cols: start..end,});}@@ -827,13 +820,169 @@ pub fn render_activity_dock_segments(segment}).collect();- (- vec![- vec![theme.fg_span(ThemeColor::BorderMuted, "─".repeat(width))],- row,- ],- segments,- )+ (vec![rule, row], segments)+}++/// A count-holding segment's color: green while its count is above+/// zero, neutral at zero.+fn activity_color(count: usize) -> ThemeColor {+ if count > 0 {+ ThemeColor::Success+ } else {+ ThemeColor::Muted+ }+}++/// The goal group's label: an actively pursued goal reads green, and the+/// paused and budget-limited states read amber (the paused heartbeat+/// cluster's own warning color) — the dock is the goal's one chrome+/// surface, so every live state stays visible.+fn goal_span(dock: &ActivityDock, theme: &Theme) -> Span {+ let goal = dock.goal_label.as_deref().unwrap_or_default();+ let color = if goal.starts_with("Pursuing goal") {+ ThemeColor::Success+ } else {+ ThemeColor::Warning+ };+ theme.fg_span(color, goal.to_string())+}++/// The widest group name in the expanded dock (`heartbeats`): every+/// row's details start in the same column.+const EXPANDED_NAME_CELLS: usize = 10;++/// The separator between two items of one expanded row.+const EXPANDED_ITEM_SEPARATOR: &str = " · ";++/// One expanded dock row; the selected row carries the shared selection+/// band across the full width.+fn render_expanded_dock_row(+ dock: &ActivityDock,+ group: ActivityGroup,+ theme: &Theme,+ width: usize,+) -> Line {+ let row = match group {+ ActivityGroup::Subagents => {+ let running = dock.subagents_running_direct + dock.subagents_running_nested;+ let breakdown =+ (running + dock.subagents_idle + dock.subagents_inactive > 0).then(|| {+ format!(+ "{running} running · {} idle · {} inactive",+ dock.subagents_idle, dock.subagents_inactive+ )+ });+ expanded_group_row(+ theme,+ width,+ ("◆", "subagents"),+ running,+ breakdown.as_slice(),+ )+ }+ ActivityGroup::Heartbeats => expanded_group_row(+ theme,+ width,+ ("◷", "heartbeats"),+ dock.heartbeats_active.len(),+ &dock.heartbeats_active,+ ),+ ActivityGroup::Bash => expanded_group_row(+ theme,+ width,+ ("▸", "shells"),+ dock.shells.len(),+ &dock.shells,+ ),+ ActivityGroup::Factory => expanded_group_row(+ theme,+ width,+ ("⚙", "factory"),+ dock.factory_runs.len(),+ &dock.factory_runs,+ ),+ ActivityGroup::Goal => vec![Span::raw(" "), goal_span(dock, theme)],+ };+ let mut row = truncate_spans_to_width(&row, width);+ if dock.selected == group {+ let filled: usize = row.iter().map(|s| str_width(&s.content)).sum();+ row.push(Span::raw(" ".repeat(width.saturating_sub(filled))));+ let band = theme.selection_row_style();+ for span in &mut row {+ span.style = span.style.patch(band);+ }+ }+ row+}++/// A group row: the glyph and name, then the details (as many items as+/// fit, `+N` for the rest). An empty group renders its glyph and name+/// dimmed with no details.+fn expanded_group_row(+ theme: &Theme,+ width: usize,+ (glyph, name): (&str, &str),+ count: usize,+ items: &[String],+) -> Line {+ let title = format!("{glyph} {name}");+ if items.is_empty() {+ return vec![Span::raw(" "), theme.fg_span(ThemeColor::Dim, title)];+ }+ let mut row = vec![+ Span::raw(" "),+ theme.fg_span(activity_color(count), title),+ Span::raw(" ".repeat(EXPANDED_NAME_CELLS - str_width(name) + 2)),+ ];+ let used: usize = row.iter().map(|s| str_width(&s.content)).sum();+ let available = width.saturating_sub(used);+ let shown = fitting_items(items, available);+ let overflow = (shown < items.len()).then(|| format!(" +{}", items.len() - shown));+ let marker = overflow.as_deref().map_or(0, str_width);+ for (index, item) in items[..shown].iter().enumerate() {+ if index > 0 {+ row.push(theme.fg_span(ThemeColor::Dim, EXPANDED_ITEM_SEPARATOR));+ }+ // Only an oversized first item gets clipped here, to leave the `+N` marker its room.+ let item = if index == 0 {+ crate::width::truncate_to_width(item, available.saturating_sub(marker), "\u{2026}")+ } else {+ item.clone()+ };+ row.push(theme.fg_span(ThemeColor::Muted, item));+ }+ if let Some(overflow) = overflow {+ row.push(theme.fg_span(ThemeColor::Dim, overflow));+ }+ row+}++/// How many leading items fit `available` columns together with the+/// `+N` overflow marker for the rest; the first item always shows (the+/// caller clips an oversized one beside the marker).+fn fitting_items(items: &[String], available: usize) -> usize {+ let separator = str_width(EXPANDED_ITEM_SEPARATOR);+ let mut listed = 0;+ let mut fitting = 1;+ for (index, item) in items.iter().enumerate() {+ if index > 0 {+ listed += separator;+ }+ listed += str_width(item);+ if listed > available {+ break;+ }+ let shown = index + 1;+ let overflow = if shown < items.len() {+ str_width(&format!(" +{}", items.len() - shown))+ } else {+ 0+ };+ if listed + overflow <= available {+ fitting = shown;+ }+ }+ fitting}/// The footer's tok/sec row: one dim line — the dock's last row —diff --git a/crates/pa-tui/src/chrome/tests.rs b/crates/pa-tui/src/chrome/tests.rsindex a9c61c3457..c86e0e1592 100644--- a/crates/pa-tui/src/chrome/tests.rs+++ b/crates/pa-tui/src/chrome/tests.rs@@ -6,7 +6,7 @@ fn the_dock_segments_cover_each_groups_own_cells() {subagents_running_direct: 2,heartbeats: 3,heartbeats_paused: 1,- bash_running: 1,+ shells: items(1),factory_group: true,..ActivityDock::default()};@@ -123,7 +123,7 @@ fn activity_dock_frames_one_row_with_running_paused_and_goal_counts() {subagents_running_nested: 1,heartbeats: 3,heartbeats_paused: 1,- bash_running: 1,+ shells: items(1),factory_group: true,goal_label: Some("Pursuing goal (0s)".to_string()),..ActivityDock::default()@@ -223,7 +223,7 @@ fn activity_dock_frames_one_row_with_running_paused_and_goal_counts() {subagents_running_nested: 2,heartbeats: 4,heartbeats_paused: 2,- bash_running: 2,+ shells: items(2),goal_label: Some("Pursuing goal (12m 05s)".to_string()),..ActivityDock::default()};@@ -319,67 +319,156 @@ fn prompt_bar_subagent_segment_is_the_running_count_only() {);}-/// The hover band's own light color — the same ONE color every activity surface paints,-/// never the accent; each span keeps its own status color.+/// The plain text of each rendered line.+fn line_texts(frame: &[Line]) -> Vec<String> {+ frame+ .iter()+ .map(|line| line.iter().map(|span| span.content.as_str()).collect())+ .collect()+}++/// Focus expands the dock into one row per group in `groups()` order, each with its details;+/// the unfocused dock is the single collapsed line.#[test]-fn activity_dock_selection_is_the_hover_colored_band() {+fn the_focused_dock_expands_into_one_row_per_group() {let theme = Theme::builtin("prime", ColorMode::TrueColor);let dock = ActivityDock {- subagents_running_direct: 1,+ subagents_running_direct: 2,subagents_running_nested: 1,- heartbeats: 3,+ subagents_idle: 1,+ subagents_inactive: 2,+ heartbeats: 2,+ heartbeats_active: vec!["5m lane canary".to_string()],heartbeats_paused: 1,- bash_running: 1,- factory_runs: 1,+ shells: vec!["cargo test · 12.0s".to_string()],+ factory_runs: vec!["nightly paused".to_string()],factory_group: true,goal_label: Some("Pursuing goal (0s)".to_string()),+ selected: ActivityGroup::Subagents,+ focused: true,+ };+ let (frame, segments) = render_activity_dock_segments(&dock, &theme, 80);+ let texts = line_texts(&frame);+ assert_eq!(texts[0], "─".repeat(80), "the rule stays on top");+ let rows: Vec<&str> = texts[1..].iter().map(|row| row.trim_end()).collect();+ assert_eq!(+ rows,+ vec![+ " ◆ subagents 3 running · 1 idle · 2 inactive",+ " ◷ heartbeats 5m lane canary",+ " ▸ shells cargo test · 12.0s",+ " ⚙ factory nightly paused",+ " Pursuing goal (0s)",+ ]+ );+ assert_eq!(+ segments+ .iter()+ .map(|segment| (segment.group, segment.row))+ .collect::<Vec<_>>(),+ dock.groups().into_iter().zip(1..).collect::<Vec<_>>(),+ "every row is its group's click surface"+ );+ let collapsed = ActivityDock {+ focused: false,+ ..dock+ };+ let texts = line_texts(&render_activity_dock(&collapsed, &theme, 120));+ assert_eq!(+ texts[1..],+ [" ◆ 3 subagents · ◷ 2 heartbeats · ◐ 1 paused · ▸ 1 shell · ⚙ 1 factory · Pursuing goal (0s)"]+ );+}++/// The selected row carries the ONE shared selection band across the full width (the hover's+/// own color, never the accent) while its spans keep their own colors; no other row is banded,+/// and the collapsed line never is.+#[test]+fn the_expanded_dock_bands_exactly_the_selected_row() {+ let theme = Theme::builtin("prime", ColorMode::TrueColor);+ let dock = ActivityDock {+ heartbeats_active: items(2),+ shells: items(1),selected: ActivityGroup::Heartbeats,focused: true,+ ..ActivityDock::default()};- let frame = render_activity_dock(&dock, &theme, 120);- let row = &frame[1];- // The band is the theme's hover color (`Theme::hover_row_style`) with no extra- // modifiers — the ONE style every activity surface's selected row paints, never the accent.+ let frame = render_activity_dock(&dock, &theme, 60);let band = theme.selection_row_style();assert_eq!(band.bg, theme.hover_row_style().bg);assert_ne!(band.bg, theme.fg_style(ThemeColor::Accent).fg);- assert!(band.add_modifier.is_empty());- let span = |text: &str| {- row.iter()- .find(|span| span.content == text)- .unwrap_or_else(|| panic!("missing span {text:?}"))- };- // The selected group keeps its own status colors under the band.- let success = theme.fg_style(ThemeColor::Success).fg;- let warning = theme.fg_style(ThemeColor::Warning).fg;- let dim = theme.fg_style(ThemeColor::Dim).fg;- assert_eq!(span("\u{25f7} 3 heartbeats").style.bg, band.bg);- assert_eq!(span("\u{25f7} 3 heartbeats").style.fg, success);- assert_eq!(span(" \u{b7} ").style.bg, band.bg);- assert_eq!(span(" \u{b7} ").style.fg, dim);- assert_eq!(span("\u{25d0} 1 paused").style.bg, band.bg);- assert_eq!(span("\u{25d0} 1 paused").style.fg, warning);- let selected = ["\u{25f7} 3 heartbeats", " \u{b7} ", "\u{25d0} 1 paused"];- for span in row {- assert_eq!(- span.style.bg == band.bg,- selected.contains(&span.content.as_str()),- "the band rides exactly the selected group: {:?}",- span.content- );+ let heartbeats = &frame[2];+ assert_eq!(+ crate::width::spans_width(heartbeats),+ 60,+ "the band spans the row"+ );+ assert!(heartbeats.iter().all(|span| span.style.bg == band.bg));+ let title = heartbeats+ .iter()+ .find(|span| span.content == "◷ heartbeats")+ .expect("the heartbeats title renders");+ assert_eq!(title.style.fg, theme.fg_style(ThemeColor::Success).fg);+ for row in [&frame[1], &frame[3]] {+ assert!(row.iter().all(|span| span.style.bg != band.bg));}- let accent = theme.fg_style(ThemeColor::Accent).fg;- assert!(row.iter().all(|span| span.style.bg != accent));- // The band is a focus-owned signal: the same dock without focus- // renders no band at all.- let unfocused = ActivityDock {+ let collapsed = ActivityDock {focused: false,..dock};- let frame = render_activity_dock(&unfocused, &theme, 120);+ let frame = render_activity_dock(&collapsed, &theme, 60);assert!(frame[1].iter().all(|span| span.style.bg.is_none()));}+/// A row lists as many items as fit and counts the rest as `+N`.+#[test]+fn an_overflowing_expanded_row_counts_the_rest() {+ let theme = Theme::builtin("prime", ColorMode::TrueColor);+ let dock = ActivityDock {+ shells: items(9),+ selected: ActivityGroup::Subagents,+ focused: true,+ ..ActivityDock::default()+ };+ let texts = line_texts(&render_activity_dock(&dock, &theme, 50));+ assert_eq!(texts[3], " ▸ shells item 1 · item 2 · item 3 +6");+}++/// A large activity list fits by terminal cells, including a multi-digit omitted count.+#[test]+fn a_large_expanded_row_fits_wide_items_and_counts_the_omitted_items() {+ let theme = Theme::builtin("prime", ColorMode::TrueColor);+ let dock = ActivityDock {+ heartbeats_active: vec!["界界".to_string(); 4096],+ focused: true,+ ..ActivityDock::default()+ };+ let texts = line_texts(&render_activity_dock(&dock, &theme, 60));+ assert_eq!(+ texts[2],+ " ◷ heartbeats 界界 · 界界 · 界界 · 界界 +4092"+ );+ assert_eq!(fitting_items(&dock.heartbeats_active, 4096 * 9 - 5), 4096);+}++/// A first item too long to sit beside the `+N` marker is ellipsized, so the omitted count still+/// renders.+#[test]+fn an_oversized_first_item_keeps_the_overflow_marker() {+ let theme = Theme::builtin("prime", ColorMode::TrueColor);+ let dock = ActivityDock {+ heartbeats_active: vec![+ format!("5m {}", "check the deploy queue ".repeat(4)),+ "9m lane canary".to_string(),+ ],+ selected: ActivityGroup::Subagents,+ focused: true,+ ..ActivityDock::default()+ };+ let texts = line_texts(&render_activity_dock(&dock, &theme, 40));+ assert_eq!(texts[2], " ◷ heartbeats 5m check the deploy … +1");+}+/// One press steps to the neighboring rendered group and wraps; N groups take exactly N presses.#[test]fn dock_arrows_visit_every_group_even_when_empty() {@@ -416,7 +505,7 @@ fn dock_arrows_visit_every_group_even_when_empty() {ActivityGroup::Subagents,"the cycle wraps past the last group");- // Left: the same groups in reverse, wrapping past the first.+ // Up: the same groups in reverse, wrapping past the first.assert_eq!(dock.step(ActivityGroup::Subagents, ActivityDirection::Prev),ActivityGroup::Factory,@@ -459,7 +548,7 @@ fn dock_arrows_visit_the_same_groups_with_items() {subagents_running_nested: 2,heartbeats: 2,heartbeats_paused: 1,- bash_running: 1,+ shells: items(1),factory_group: true,goal_label: Some("Pursuing goal (0s)".to_string()),..ActivityDock::default()@@ -572,40 +661,38 @@ fn an_unadvertised_factory_lane_mounts_no_factory_group() {);}-/// Entering an empty group still renders it: the focused selection's-/// band — the ONE shared selection style — rides the group's-/// zero-count segment on the row — the dock-level empty state is-/// the zero readout itself (the view the group opens carries the-/// pane's own empty-state row).+/// An empty group keeps its expanded row: its glyph and name render dimmed with no details,+/// and the row stays selectable.#[test]-fn dock_renders_the_focused_empty_group() {+fn an_empty_group_renders_a_dimmed_row_and_stays_selectable() {let theme = Theme::builtin("prime", ColorMode::TrueColor);let dock = ActivityDock {+ heartbeats_paused: 2,selected: ActivityGroup::Heartbeats,focused: true,factory_group: true,..ActivityDock::default()};- let frame = render_activity_dock(&dock, &theme, 100);- let text = frame[1]- .iter()- .map(|span| span.content.as_str())- .collect::<String>();- assert_eq!(- text,- " ◆ 0 subagents · ◷ 0 heartbeats · ▸ 0 shells · ⚙ 0 factory"- );- // The selection's band rides exactly the entered empty group's- // zero readout, which keeps its own muted color (the selection- // never repaints the text).+ let frame = render_activity_dock(&dock, &theme, 60);+ let dim = theme.fg_style(ThemeColor::Dim).fg;let band = theme.selection_row_style();- let muted = theme.fg_style(ThemeColor::Muted).fg;- let heartbeat = frame[1]- .iter()- .find(|span| span.content == "◷ 0 heartbeats")- .unwrap_or_else(|| panic!("the empty heartbeats readout renders: {text}"));- assert_eq!(heartbeat.style.bg, band.bg);- assert_eq!(heartbeat.style.fg, muted);+ for (row, title) in+ frame[1..]+ .iter()+ .zip(["◆ subagents", "◷ heartbeats", "▸ shells", "⚙ factory"])+ {+ let text: String = row.iter().map(|span| span.content.as_str()).collect();+ assert_eq!(text.trim_end(), format!(" {title}"), "no details: {text:?}");+ let span = row+ .iter()+ .find(|span| span.content == title)+ .unwrap_or_else(|| panic!("the {title} row renders: {text:?}"));+ assert_eq!(span.style.fg, dim, "the empty {title} row reads dimmed");+ }+ assert!(+ frame[2].iter().all(|span| span.style.bg == band.bg),+ "the empty heartbeats row (paused heartbeats only) carries the selection"+ );}#[test]@@ -631,6 +718,11 @@ use super::*;use crate::theme::{ColorMode, Theme};use serde_json::json;+/// `count` placeholder detail items for one dock group.+fn items(count: usize) -> Vec<String> {+ (1..=count).map(|item| format!("item {item}")).collect()+}+fn theme() -> Theme {Theme::builtin("prime", ColorMode::TrueColor)}diff --git a/crates/pa-tui/src/factory_view.rs b/crates/pa-tui/src/factory_view.rsindex 6c30717e81..14d638f3b6 100644--- a/crates/pa-tui/src/factory_view.rs+++ b/crates/pa-tui/src/factory_view.rs@@ -134,6 +134,20 @@ impl FactoryRunSnapshot {}}+/// The activity dock's factory row: the live runs (the dock count's own+/// set), paused first, each `<name> <state>`.+#[must_use]+pub fn dock_factory_items(runs: &[FactoryRunSnapshot]) -> Vec<String> {+ let mut live: Vec<&FactoryRunSnapshot> = runs.iter().filter(|run| run.is_live()).collect();+ live.sort_by_key(|run| run.state.as_deref() != Some("paused"));+ live.iter()+ .map(|run| match &run.state {+ Some(state) => format!("{} {state}", run.display_name()),+ None => run.display_name(),+ })+ .collect()+}+/// One run-level action the page offers on a live run (the heartbeats/// picker's action-row grammar): the stop that tears the run and its/// children down, and the pause complement's resume.diff --git a/crates/pa-tui/src/factory_view/tests.rs b/crates/pa-tui/src/factory_view/tests.rsindex 411f21fc1e..b229b31b53 100644--- a/crates/pa-tui/src/factory_view/tests.rs+++ b/crates/pa-tui/src/factory_view/tests.rs@@ -1979,3 +1979,26 @@ fn rapid_churn_keeps_the_folded_page_coherent() {"every keypress resolved against the folded batch");}++/// The dock's factory row lists the live runs (the dock count's own set), paused runs first.+#[test]+fn the_dock_factory_items_list_live_runs_paused_first() {+ let mut response = three_run_response();+ response["runs"][0]["state"] = json!("done");+ response["runs"][0]["usage"]["running"] = json!(0);+ response["runs"][1]["state"] = json!("running");+ response["runs"][2]["state"] = json!("paused");+ let mut fourth = scripted_snapshot();+ fourth["runId"] = json!("run-jkl24680");+ fourth["name"] = json!("fourth-run");+ fourth["state"] = json!("paused");+ response["runs"].as_array_mut().unwrap().push(fourth);+ assert_eq!(+ dock_factory_items(&parse_factory_runs(&response)),+ vec![+ "fourth-run paused",+ "third-run paused",+ "second-run running"+ ]+ );+}diff --git a/crates/pa-tui/src/heartbeats_picker.rs b/crates/pa-tui/src/heartbeats_picker.rsindex 47b19d6257..314b3be5ba 100644--- a/crates/pa-tui/src/heartbeats_picker.rs+++ b/crates/pa-tui/src/heartbeats_picker.rs@@ -14,9 +14,9 @@ use crate::{Line, Span};mod data;pub use data::{- default_heartbeat_name, format_timestamp, next_run_label, parse_heartbeat_job,- parse_heartbeats, scope_heartbeats, session_label, single_line, sort_heartbeats, source_label,- HeartbeatEntry, HeartbeatJob,+ default_heartbeat_name, dock_heartbeat_items, format_timestamp, next_run_label,+ parse_heartbeat_job, parse_heartbeats, row_primary, scope_heartbeats, session_label,+ single_line, sort_heartbeats, source_label, HeartbeatEntry, HeartbeatJob,};mod schedule;diff --git a/crates/pa-tui/src/heartbeats_picker/data.rs b/crates/pa-tui/src/heartbeats_picker/data.rsindex 2c33614b13..55b7f7afcb 100644--- a/crates/pa-tui/src/heartbeats_picker/data.rs+++ b/crates/pa-tui/src/heartbeats_picker/data.rs@@ -198,6 +198,52 @@ pub fn default_heartbeat_name(entry: &HeartbeatEntry) -> &'static str {}}+/// A heartbeat's primary text (TS `primary`): the label, else the prompt, else+/// the default name.+#[must_use]+pub fn row_primary(entry: &HeartbeatEntry) -> String {+ entry+ .job+ .label+ .as_deref()+ .map(str::trim)+ .filter(|label| !label.is_empty())+ .map(str::to_string)+ .or_else(|| {+ let prompt = single_line(&entry.job.prompt);+ (!prompt.is_empty()).then_some(prompt)+ })+ .unwrap_or_else(|| default_heartbeat_name(entry).to_string())+}++/// The activity dock's heartbeats row: the active heartbeats only (paused+/// ones never list), soonest next fire first, each `<countdown> <label>`.+#[must_use]+pub fn dock_heartbeat_items(entries: &[HeartbeatEntry], now_ms: u64) -> Vec<String> {+ let mut active: Vec<&HeartbeatEntry> = entries+ .iter()+ .filter(|entry| entry.job.is_active())+ .collect();+ active.sort_by_key(|entry| {+ entry+ .job+ .next_run_at+ .as_deref()+ .and_then(crate::agents_view_state::iso_to_unix_ms)+ .unwrap_or(i64::MAX)+ });+ active+ .iter()+ .map(|entry| {+ format!(+ "{} {}",+ next_run_label(entry.job.next_run_at.as_deref(), now_ms),+ row_primary(entry)+ )+ })+ .collect()+}+/// Collapse all whitespace runs to single spaces.#[must_use]pub fn single_line(value: &str) -> String {@@ -218,11 +264,11 @@ pub fn format_timestamp(value: &str) -> String {}}-/// The next-run label in natural language ("in 45s", "in 5m", "in 10h"):+/// The next-run label as a bare countdown ("45s", "5m", "10h"):/// rounded seconds under a minute, then rounded minutes, hours, and days,-/// with a one-second floor. The `in ` prefix is the operator's wording-/// (2026-09-26 directive) — TS renders the bare countdown, superseded-/// here. A missing next run keeps the `—` placeholder; an unparseable+/// with a one-second floor. Bare countdown, no `in ` prefix (operator+/// directive 2026-10-17, reversing the 2026-09-26 wording; matches TS).+/// A missing next run keeps the `—` placeholder; an unparseable/// value renders raw.#[must_use]pub fn next_run_label(next_run_at: Option<&str>, now_ms: u64) -> String {@@ -235,16 +281,16 @@ pub fn next_run_label(next_run_at: Option<&str>, now_ms: u64) -> String {let delta = ((at - now_ms as i64).max(0) as f64) / 1000.0;let seconds = (delta.round() as i64).max(1);if seconds < 60 {- return format!("in {seconds}s");+ return format!("{seconds}s");}let minutes = ((seconds as f64) / 60.0).round() as i64;if minutes < 60 {- return format!("in {minutes}m");+ return format!("{minutes}m");}let hours = ((minutes as f64) / 60.0).round() as i64;if hours < 24 {- return format!("in {hours}h");+ return format!("{hours}h");}let days = ((hours as f64) / 24.0).round() as i64;- format!("in {days}d")+ format!("{days}d")}diff --git a/crates/pa-tui/src/heartbeats_picker/render.rs b/crates/pa-tui/src/heartbeats_picker/render.rsindex e68ccf9b49..a9015712fe 100644--- a/crates/pa-tui/src/heartbeats_picker/render.rs+++ b/crates/pa-tui/src/heartbeats_picker/render.rs@@ -2,9 +2,9 @@//! detail drill-in's pairs, and the action rows.use super::{- default_heartbeat_name, fill_row, hug_row, human_schedule, next_run_label, plain_cell,- session_label, single_line, source_label, status_dot, str_width, truncate_line, HeartbeatEntry,- Line, Span, Theme, ThemeColor,+ fill_row, hug_row, human_schedule, next_run_label, plain_cell, row_primary, session_label,+ single_line, source_label, status_dot, str_width, truncate_line, HeartbeatEntry, Line, Span,+ Theme, ThemeColor,};/// The table's column width caps: the schedule expression and the label@@ -14,7 +14,7 @@ const INTERVAL_CAP: usize = 18;const LABEL_CAP: usize = 32;/// The next-run column's fixed cell: wide enough for its header and every/// countdown the schedule can produce (the next run is bounded within a-/// year, so at most "in 365d").+/// year, so at most "365d").const NEXT_RUN_CELL: usize = 8;/// The delivery word (TS: `follow_up` renders `follow-up`).@@ -94,23 +94,6 @@ pub(super) fn detail_block_lines(.collect()}-/// The row's primary text (TS `primary`): the label, else the prompt, else-/// the default name.-fn row_primary(entry: &HeartbeatEntry) -> String {- entry- .job- .label- .as_deref()- .map(str::trim)- .filter(|label| !label.is_empty())- .map(str::to_string)- .or_else(|| {- let prompt = single_line(&entry.job.prompt);- (!prompt.is_empty()).then_some(prompt)- })- .unwrap_or_else(|| default_heartbeat_name(entry).to_string())-}-/// The table's column geometry: the interval, label, next-run, and status/// cells sized over the rows and their header labels, with the label/// column taking whatever width remains.diff --git a/crates/pa-tui/src/heartbeats_picker/tests.rs b/crates/pa-tui/src/heartbeats_picker/tests.rsindex 206cc2b844..d516b174dc 100644--- a/crates/pa-tui/src/heartbeats_picker/tests.rs+++ b/crates/pa-tui/src/heartbeats_picker/tests.rs@@ -118,13 +118,13 @@ fn the_list_renders_columned_rows_and_one_hint() {.expect("a column header row");assert!(header.contains("Label"));assert!(header.contains("Status"));- // The fixture's next run is long past, so the one-second floor renders ("in 1s").+ // The fixture's next run is long past, so the one-second floor renders ("1s").let row = text.iter().find(|row| row.contains("every 10m")).expect("a columned row");assert!(row.contains("tick user-1"));- assert!(row.contains("in 1s"));+ assert!(row.contains("1s"));assert!(row.contains("paused"));assert!(!text.iter().any(|row| row.starts_with(" created")));assert_eq!(@@ -265,16 +265,16 @@ fn the_next_run_label_is_natural_language() {let now = crate::agents_view_state::iso_to_unix_ms("2026-06-01T12:00:00.000Z").expect("the base parses") as u64;let label = |next_run_at: &str| next_run_label(Some(next_run_at), now);- assert_eq!(label("2026-06-01T12:00:45.000Z"), "in 45s");- assert_eq!(label("2026-06-01T12:05:00.000Z"), "in 5m");- assert_eq!(label("2026-06-01T22:00:00.000Z"), "in 10h");+ assert_eq!(label("2026-06-01T12:00:45.000Z"), "45s");+ assert_eq!(label("2026-06-01T12:05:00.000Z"), "5m");+ assert_eq!(label("2026-06-01T22:00:00.000Z"), "10h");// Unit boundaries round up into the next unit.- assert_eq!(label("2026-06-01T12:00:59.500Z"), "in 1m");- assert_eq!(label("2026-06-01T12:01:00.000Z"), "in 1m");- assert_eq!(label("2026-06-01T13:00:00.000Z"), "in 1h");- assert_eq!(label("2026-06-02T12:00:00.000Z"), "in 1d");- assert_eq!(label("2026-06-03T12:00:00.000Z"), "in 2d");- assert_eq!(label("2026-06-01T11:59:30.000Z"), "in 1s");+ assert_eq!(label("2026-06-01T12:00:59.500Z"), "1m");+ assert_eq!(label("2026-06-01T12:01:00.000Z"), "1m");+ assert_eq!(label("2026-06-01T13:00:00.000Z"), "1h");+ assert_eq!(label("2026-06-02T12:00:00.000Z"), "1d");+ assert_eq!(label("2026-06-03T12:00:00.000Z"), "2d");+ assert_eq!(label("2026-06-01T11:59:30.000Z"), "1s");assert_eq!(next_run_label(None, now), "\u{2014}");assert_eq!(label("soon-ish"), "soon-ish");}@@ -791,3 +791,27 @@ fn timestamps_cut_to_minutes_and_whitespace_collapses() {assert_eq!(format_timestamp("not a date"), "not a date");assert_eq!(single_line("a \n b\t c "), "a b c");}++/// The dock's heartbeats row: paused heartbeats never list, and the active ones read+/// `<countdown> <label>`, soonest next fire first.+#[test]+fn the_dock_heartbeat_items_list_active_heartbeats_by_next_fire() {+ let now = crate::agents_view_state::iso_to_unix_ms("2026-01-01T00:00:00.000Z").unwrap() as u64;+ let entry = |id: &str, status: &str, next_run_at: &str| {+ let mut value = job_value(id, "heartbeat", status);+ value["job"]["label"] = serde_json::json!(format!("{id} job"));+ value["job"]["nextRunAt"] = serde_json::json!(next_run_at);+ value+ };+ let catalog = parse_heartbeats(&serde_json::json!({+ "heartbeats": [+ entry("late", "active", "2026-01-01T02:00:00.000Z"),+ entry("paused", "paused", "2026-01-01T00:01:00.000Z"),+ entry("soon", "active", "2026-01-01T00:05:00.000Z"),+ ],+ }));+ assert_eq!(+ dock_heartbeat_items(&catalog, now),+ vec!["5m soon job", "2h late job"]+ );+}diff --git a/crates/pa-tui/src/interactive/run.rs b/crates/pa-tui/src/interactive/run.rsindex cf14a570d5..ede6f6a694 100644--- a/crates/pa-tui/src/interactive/run.rs+++ b/crates/pa-tui/src/interactive/run.rs@@ -1898,6 +1898,7 @@ async fn run_interactive_surface(} => {last_bash_refresh = Instant::now();session.spawn_bash_activity_refresh();+ session.refresh_expanded_dock(&mut view);}() = async {// The factory lane's 2s poll: the bash poll's cadencediff --git a/crates/pa-tui/src/session_ui.rs b/crates/pa-tui/src/session_ui.rsindex 67ea9ecea1..3cf220399e 100644--- a/crates/pa-tui/src/session_ui.rs+++ b/crates/pa-tui/src/session_ui.rs@@ -320,7 +320,7 @@ pub(crate) struct SessionUi {factory_updates: mpsc::UnboundedSender<FactoryUpdate>,/// The open view's selected run id: the refresh's watch target.factory_selected_run: Option<String>,- /// The subagent summary line holds keyboard focus.+ /// The activity dock holds keyboard focus (and renders expanded).subagents_focused: bool,activity_group: crate::chrome::ActivityGroup,subagent_counts: crate::subagents::SubagentCounts,@@ -484,7 +484,7 @@ impl SessionUi {std::mem::take(&mut self.trim_after_frame)}- /// Hand the keyboard focus to the compact dock on its selected group (operator ruling+ /// Hand the keyboard focus to the dock on its selected group (operator ruling/// 2026-09-26: leaving a panel lands on the panel's own dock item, never the prompt bar).fn focus_activity_dock(&mut self, view: &mut AgentView) {self.subagents_focused = true;diff --git a/crates/pa-tui/src/session_ui/keys.rs b/crates/pa-tui/src/session_ui/keys.rsindex de389240fd..afec33e006 100644--- a/crates/pa-tui/src/session_ui/keys.rs+++ b/crates/pa-tui/src/session_ui/keys.rs@@ -432,46 +432,46 @@ impl SessionUi {self.dirty = true;return Ok(());}- // The activity dock owns focus while focused; every other key falls- // through after releasing the focus.+ // The focused (expanded) dock owns these keys; every other key falls through after+ // releasing the focus. Configured bindings match first, so a rebound arrow keeps its+ // configured action; the literal Left/Right fallbacks apply only after none matched.if self.subagents_focused {let kb = view.editor.keybindings();- if kb.matches(&id, "tui.select.confirm") || kb.matches(&id, "app.subagents.focus") {+ let open =+ kb.matches(&id, "tui.select.confirm") || kb.matches(&id, "app.subagents.focus");+ let down = kb.matches(&id, "tui.select.down");+ let up = kb.matches(&id, "tui.select.up");+ let back = kb.matches(&id, "tui.select.cancel") || kb.matches(&id, "app.agents.back");+ let expand = kb.matches(&id, "app.tools.expand");+ if open {self.open_dock_group_view(view);return Ok(());}- if id == "left" && self.activity_group == crate::chrome::ActivityGroup::Subagents {- // Left from the subagents selection opens the agents view (the operator's- // 2026-09-28 muscle-memory ask; left reads as `agents back` everywhere else).- self.open_dock_group_view(view);- return Ok(());- }- if id == "left" || id == "right" {- // One press, one group: the step wraps at the row's ends, so an empty group is- // still visited (the operator's 2026-09-26 directive).- let direction = if id == "left" {- crate::chrome::ActivityDirection::Prev- } else {+ let dock = self.activity_dock_state();+ // Up from the top row leaves the dock; Down from the bottom row wraps to the top.+ if down || (up && dock.groups()[0] != self.activity_group) {+ let direction = if down {crate::chrome::ActivityDirection::Next+ } else {+ crate::chrome::ActivityDirection::Prev};- self.activity_group = self- .activity_dock_state()- .step(self.activity_group, direction);+ self.activity_group = dock.step(self.activity_group, direction);self.update_subagent_summary(view);self.dirty = true;return Ok(());}- if kb.matches(&id, "tui.select.up")- || kb.matches(&id, "tui.select.cancel")- || kb.matches(&id, "app.agents.back")- {+ if expand {+ self.cycle_detail(view);+ return Ok(());+ }+ if up || back || id == "left" {self.subagents_focused = false;self.update_subagent_summary(view);self.dirty = true;return Ok(());}- if kb.matches(&id, "app.tools.expand") {- self.cycle_detail(view);+ if id == "right" {+ self.open_dock_group_view(view);return Ok(());}self.subagents_focused = false;diff --git a/crates/pa-tui/src/session_ui/panels.rs b/crates/pa-tui/src/session_ui/panels.rsindex 54b42ff6bc..8160bc425d 100644--- a/crates/pa-tui/src/session_ui/panels.rs+++ b/crates/pa-tui/src/session_ui/panels.rs@@ -71,7 +71,7 @@ impl SessionUi {}}- /// Refresh the one-line activity dock and the title's cost (the only writer+ /// Refresh the activity dock and the title's cost (the only writer/// of `chrome.cost_usd`).pub(super) fn update_subagent_summary(&mut self, view: &mut AgentView) {let identity = crate::subagents::SessionIdentity::new(@@ -84,8 +84,8 @@ impl SessionUi {// session's row.view.chrome.cost_usd = crate::subagents::family_cost(&self.roster, &identity);let dock = self.activity_dock_state();- // A focused selection must stay on a rendered group: only the goal group can leave the row- // (its goal ended), and the selection steps back to the group that now ends the row.+ // A focused selection must stay on a rendered group: only the goal group can leave the dock+ // (its goal ended), and the selection steps back to the group that is now last.if self.subagents_focused && !dock.groups().contains(&self.activity_group) {self.activity_group =dock.step(self.activity_group, crate::chrome::ActivityDirection::Prev);@@ -102,41 +102,42 @@ impl SessionUi {}}- /// The dock's feed state: the live counts, the goal row's label, and the selection/focus the- /// caller owns. A group renders exactly when it stays traversable.+ /// The dock's feed state: the live counts and each group's details, the goal row's label, and+ /// the selection/focus the caller owns. A group renders exactly when it stays traversable.pub(super) fn activity_dock_state(&self) -> crate::chrome::ActivityDock {// The dock is the goal's one chrome surface (the operator's 2026-09-24 directive): every// live state renders its row — pursuing reads the elapsed time, the paused and// budget-limited states keep their label here.let goal_label = tray_goal_label(&self.goal_view.goal);- // The dock's bash indicator counts only runs actively running right now (operator scoping):+ // The dock's shells group lists only runs actively running right now (operator scoping):// finished runs stay in the bash view.- let bash_rows = crate::bash_view::parse_bash_activities(&self.bash_activities);- let bash_running = bash_rows- .iter()- .filter(|activity| activity.running())- .count();- // The dock's factory indicator counts live runs only — the- // view's one liveness rule (`FactoryRunSnapshot::is_live`: a- // live state, or children still in flight — a `done` run whose- // resident children still run keeps its count like its panel- // and its stop control). Fully terminal runs stay as panels- // inside the factory page, never in the indicator — the bash- // group's running-only scoping, one lane over.- let factory_runs = crate::factory_view::parse_factory_runs(&self.factory_graph)- .iter()- .filter(|run| run.is_live())- .count();+ let shells = crate::bash_view::dock_shell_items(&crate::bash_view::parse_bash_activities(+ &self.bash_activities,+ ));+ // The dock's factory group lists live runs only — the view's one liveness rule+ // (`FactoryRunSnapshot::is_live`: a live state, or children still in flight — a `done`+ // run whose resident children still run keeps its entry like its panel and its stop+ // control). Fully terminal runs stay as panels inside the factory page, never in the+ // dock — the shells group's running-only scoping, one lane over.+ let factory_runs = crate::factory_view::dock_factory_items(+ &crate::factory_view::parse_factory_runs(&self.factory_graph),+ );// The dock's subagent count is the live running count only:// idle and dead registry rows (passivated children the ledger- // still seeds) never bloat the indicator — they render in the- // scoped agents view.+ // still seeds) never bloat the collapsed indicator — the expanded+ // row breaks them out.crate::chrome::ActivityDock {subagents_running_direct: self.subagent_counts.running_direct,subagents_running_nested: self.subagent_counts.running_nested,+ subagents_idle: self.subagent_counts.idle,+ subagents_inactive: self.subagent_counts.inactive,heartbeats: self.heartbeat_catalog.len(),+ heartbeats_active: crate::heartbeats_picker::dock_heartbeat_items(+ &self.heartbeat_catalog,+ crate::agents_view_state::now_ms(),+ ),heartbeats_paused: paused_heartbeat_count(&self.heartbeat_catalog),- bash_running,+ shells,factory_runs,// The group renders exactly while the daemon advertises the// lane: the factory's opt-in gate (a daemon without the@@ -148,7 +149,7 @@ impl SessionUi {}}- /// The editor's Down and Alt+A hand focus to the compact dock.+ /// The editor's Down and Alt+A hand focus to the dock, which expands it.pub(super) fn focus_subagents_summary(&mut self,source: &DockFocusSource,@@ -166,8 +167,7 @@ impl SessionUi {// all-zero dock, or one with only shells running, must stay// reachable — TS `SubagentSummaryLine.isSelectable()` gated// this on existing subagents, a sanctioned divergence). The- // grab lands on the row's first group; Left/Right walk the- // rest.+ // grab lands on the top row; Up/Down walk the rest.self.activity_group = crate::chrome::ActivityGroup::Subagents;}DockFocusSource::Shortcut => {}@@ -354,6 +354,14 @@ impl SessionUi {Ok(())}+ /// The expanded dock's heartbeat countdowns ride the run loop's 2s bash-activity poll (the+ /// collapsed line carries no time label, so it skips the recount).+ pub(crate) fn refresh_expanded_dock(&mut self, view: &mut AgentView) {+ if self.subagents_focused {+ self.sync_activity_dock(view);+ }+ }+/// The activity dock follows the scoped heartbeat catalog (the tray no/// longer carries a heartbeat count beside the model name).pub(crate) fn sync_activity_dock(&mut self, view: &mut AgentView) {diff --git a/crates/pa-tui/src/view/click.rs b/crates/pa-tui/src/view/click.rsindex 6499134f17..dee0a4a958 100644--- a/crates/pa-tui/src/view/click.rs+++ b/crates/pa-tui/src/view/click.rs@@ -510,14 +510,16 @@ mod tests {assert_eq!(view.click_target_at(card_row, 2), None);}- /// The dock's own surfaces, with an empty group still clickable.- fn dock_frame(focused: crate::chrome::ActivityGroup) -> AgentView {+ /// The dock's own surfaces, with an empty group still clickable: collapsed, or expanded with+ /// the `focused` group selected.+ fn dock_frame(focused: Option<crate::chrome::ActivityGroup>) -> AgentView {let mut view = view();view.chrome.show_manage = true;view.chrome.activity = Some(crate::chrome::ActivityDock {heartbeats: 1,- selected: focused,- focused: true,+ heartbeats_active: vec!["5m canary".to_string()],+ selected: focused.unwrap_or_default(),+ focused: focused.is_some(),..Default::default()});view.editor.set_text("hello world");@@ -541,7 +543,7 @@ mod tests {#[test]fn the_dock_groups_and_the_manage_hint_resolve_click_targets() {- let view = dock_frame(crate::chrome::ActivityGroup::Heartbeats);+ let view = dock_frame(None);let (_, heartbeats) = region_span(&view,&ClickAction::OpenDockGroup(crate::chrome::ActivityGroup::Heartbeats),@@ -591,7 +593,7 @@ mod tests {#[test]fn the_hover_tracks_the_dock_surfaces_row_level() {- let mut view = dock_frame(crate::chrome::ActivityGroup::Heartbeats);+ let mut view = dock_frame(None);let (group_row, heartbeats) = region_span(&view,&ClickAction::OpenDockGroup(crate::chrome::ActivityGroup::Heartbeats),@@ -611,15 +613,43 @@ mod tests {assert_eq!(view.hover_pos, None);}- /// The dock's hover affordance (operator directive 2026-09-29): the hovered segment carries- /// the ONE light band over its own cells; the focused group's selection band stays.+ /// The expanded dock: every group's whole row is its click surface, one row per group.+ #[test]+ fn the_expanded_dock_rows_resolve_click_targets() {+ let view = dock_frame(Some(crate::chrome::ActivityGroup::Heartbeats));+ let groups = [+ crate::chrome::ActivityGroup::Subagents,+ crate::chrome::ActivityGroup::Heartbeats,+ crate::chrome::ActivityGroup::Bash,+ ];+ let (top, _) = region_span(&view, &ClickAction::OpenDockGroup(groups[0]));+ for (offset, group) in groups.into_iter().enumerate() {+ let (row, cols) = region_span(&view, &ClickAction::OpenDockGroup(group));+ assert_eq!(+ (row, cols),+ (top + offset, 0..80),+ "{group:?} owns its whole row"+ );+ assert_eq!(+ view.click_target_at(row, 79),+ Some(ClickAction::OpenDockGroup(group))+ );+ }+ }++ /// The dock's hover affordance (operator directive 2026-09-29): the hovered row carries the+ /// ONE light band; the selected row's band stays.#[test]fn the_dock_hover_paints_the_one_band_and_never_demotes_the_selection() {- let mut view = dock_frame(crate::chrome::ActivityGroup::Heartbeats);- let (group_row, subagents) = region_span(+ let mut view = dock_frame(Some(crate::chrome::ActivityGroup::Heartbeats));+ let (subagents_row, subagents) = region_span(&view,&ClickAction::OpenDockGroup(crate::chrome::ActivityGroup::Subagents),);+ let (heartbeats_row, heartbeats) = region_span(+ &view,+ &ClickAction::OpenDockGroup(crate::chrome::ActivityGroup::Heartbeats),+ );let (hint_row, hint) = region_span(&view, &ClickAction::OpenAgentsView);let light = view.theme.hover_row_style().bg;let gray = view.theme.selection_row_style().bg;@@ -627,40 +657,37 @@ mod tests {gray, light,"the selection paints the hover's own color — the one-color ruling");- // Hover the EMPTY subagents segment while the heartbeats group- // holds the focused selection.- assert!(view.note_hover(group_row, subagents.start));- let hovered = view.render_frame(80, 24);- let row_text = hovered[group_row]- .iter()- .map(|span| span.content.as_str())- .collect::<String>();- assert!(row_text.contains("subagents"), "the dock row renders");- let band = |cols: &std::ops::Range<usize>| {+ let band = |frame: &Vec<crate::Line>, row: usize, cols: &std::ops::Range<usize>| {let mut col = 0usize;let mut cells = Vec::new();- for span in &hovered[group_row] {+ for span in &frame[row] {let width = crate::width::str_width(&span.content);- let covered = col.max(cols.start) < (col + width).min(cols.end);- if covered {+ if col.max(cols.start) < (col + width).min(cols.end) {cells.push(span.style.bg);}col += width;}cells};+ // Hover the EMPTY subagents row while the heartbeats row holds the selection.+ assert!(view.note_hover(subagents_row, subagents.start));+ let hovered = view.render_frame(80, 24);+ let row_text = hovered[subagents_row]+ .iter()+ .map(|span| span.content.as_str())+ .collect::<String>();+ assert!(row_text.contains("subagents"), "the subagents row renders");assert!(- band(&subagents).iter().all(|bg| *bg == light),- "the hovered group's cells carry the light hover band"+ band(&hovered, subagents_row, &subagents)+ .iter()+ .all(|bg| *bg == light),+ "the hovered row carries the light hover band");- let heartbeats = region_span(- &view,- &ClickAction::OpenDockGroup(crate::chrome::ActivityGroup::Heartbeats),- )- .1;assert!(- band(&heartbeats).iter().all(|bg| *bg == gray),- "the focused group's cells keep the selection band under the hover"+ band(&hovered, heartbeats_row, &heartbeats)+ .iter()+ .all(|bg| *bg == gray),+ "the selected row keeps the selection band under the hover");assert!(view.note_hover(hint_row, hint.start));let hovered = view.render_frame(80, 24);@@ -672,28 +699,22 @@ mod tests {hint_cells.iter().any(|span| span.style.bg == light),"the hovered hint carries the light band: {hint_cells:?}");- // A hover onto the FOCUSED group keeps the selection band: the- // paint skips cells that already carry a background.- assert!(view.note_hover(group_row, heartbeats.start));+ // A hover onto the SELECTED row keeps its band.+ assert!(view.note_hover(heartbeats_row, heartbeats.start));let hovered = view.render_frame(80, 24);- let mut col = 0usize;- let mut kept = true;- for span in &hovered[group_row] {- let width = crate::width::str_width(&span.content);- let covered = col.max(heartbeats.start) < (col + width).min(heartbeats.end);- if covered && span.style.bg != gray {- kept = false;- }- col += width;- }- assert!(kept, "the hovered focused group keeps its band");+ assert!(+ band(&hovered, heartbeats_row, &heartbeats)+ .iter()+ .all(|bg| *bg == gray),+ "the hovered selected row keeps its band"+ );}- /// The dock's groups share one row: a hover moving onto another+ /// The collapsed dock's groups share one row: a hover moving onto another/// segment ON THE SAME ROW is a change (the band follows).#[test]fn the_hover_follows_the_mouse_across_the_dock_row() {- let mut view = dock_frame(crate::chrome::ActivityGroup::Heartbeats);+ let mut view = dock_frame(None);let (group_row, subagents) = region_span(&view,&ClickAction::OpenDockGroup(crate::chrome::ActivityGroup::Subagents),diff --git a/crates/pa-tui/src/view/panels.rs b/crates/pa-tui/src/view/panels.rsindex c1098a2545..d1624003a2 100644--- a/crates/pa-tui/src/view/panels.rs+++ b/crates/pa-tui/src/view/panels.rs@@ -45,14 +45,14 @@ impl AgentView {action: ClickAction::OpenAgentsView,});}- // The activity dock's group segments are click regions too:- // the groups sit on the frame's second row.+ // The activity dock's group segments are click regions too: the+ // dock frame starts right under the tray.if let Some(dock) = &self.chrome.activity {let (frame, segments) =crate::chrome::render_activity_dock_segments(dock, &self.theme, width);for segment in segments {self.click.record_dock_region(DockClickRegion {- dock_row: tray_row + 2,+ dock_row: tray_row + 1 + segment.row,cols: segment.cols,action: ClickAction::OpenDockGroup(segment.group),});diff --git a/crates/pa-tui/tests/dock_arrows_headless.rs b/crates/pa-tui/tests/dock_arrows_headless.rsindex 916456f484..c6705738f5 100644--- a/crates/pa-tui/tests/dock_arrows_headless.rs+++ b/crates/pa-tui/tests/dock_arrows_headless.rs@@ -1,7 +1,7 @@-//! Headless e2e for the activity dock's arrow traversal (operator-//! directive 2026-09-26): every rendered section is one press away in-//! both directions (empty sections visited, cycle wraps), and entering-//! opens its view; the TS dock has no section traversal (Rust divergence).+//! Headless e2e for the activity dock's keyboard contract: focus expands the+//! dock into one row per group, Up/Down walk the rows (Down wraps from the+//! bottom row to the top), Enter/Right open the row's page, and Left/Esc+//! collapse back to the prompt; the TS dock has no group rows (Rust divergence).//! The event-driven pins below hold the dock's update contract: every dock//! input repaints on its own daemon event, never on a per-wake recompute.#![cfg(unix)]@@ -47,6 +47,8 @@ struct MockSupervisor {/// Live frames to push right after the `roster_subscribe` response (the events the dock pins/// drive): each attach re-sends them.pushes: Vec<Value>,+ /// Advertise the factory lane (an empty run list), which mounts the dock's factory group.+ factory_lane: bool,}impl MockSupervisor {@@ -56,6 +58,7 @@ impl MockSupervisor {goal: Option<Value>,roster: Vec<Value>,pushes: Vec<Value>,+ factory_lane: bool,) -> Self {MockSupervisor {listener: UnixListener::bind(socket).expect("bind mock socket"),@@ -63,6 +66,7 @@ impl MockSupervisor {goal,roster,pushes,+ factory_lane,}}@@ -92,7 +96,7 @@ impl MockSupervisor {let hello = json!({"type": "daemon_hello","protocol": { "name": "prime-agent.daemon", "version": 7 },- "serverCapabilities": [],+ "serverCapabilities": if self.factory_lane { json!(["factory_activity"]) } else { json!([]) },"clientId": "mock",});write_json(&mut writer, &hello);@@ -151,6 +155,18 @@ impl MockSupervisor {}),);}+ "factory_activity" => {+ write_json(+ &mut writer,+ &json!({+ "type": "response",+ "id": id,+ "command": "factory_activity",+ "success": true,+ "data": { "runs": [] },+ }),+ );+ }"roster_subscribe" => {let snapshot = self.roster@@ -279,7 +295,10 @@ fn canary_heartbeats() -> Value {})}-fn options(socket: PathBuf) -> InteractiveOptions {+fn options(+ socket: PathBuf,+ keybindings: pa_tui::keybindings::KeybindingsManager,+) -> InteractiveOptions {InteractiveOptions {models: None,socket_path: socket,@@ -308,7 +327,7 @@ fn options(socket: PathBuf) -> InteractiveOptions {provider_auth: None,update_commands: None,telemetry: None,- keybindings: pa_tui::keybindings::KeybindingsManager::new(),+ keybindings,session_rlm_depth: None,prompt_stash: std::sync::Arc::default(),session_has_children: false,@@ -326,8 +345,12 @@ fn right() -> KeyEvent {KeyEvent::new(KeyCode::Right, KeyModifiers::NONE)}-fn left() -> KeyEvent {- KeyEvent::new(KeyCode::Left, KeyModifiers::NONE)+fn down() -> KeyEvent {+ KeyEvent::new(KeyCode::Down, KeyModifiers::NONE)+}++fn up() -> KeyEvent {+ KeyEvent::new(KeyCode::Up, KeyModifiers::NONE)}fn enter() -> KeyEvent {@@ -356,13 +379,34 @@ fn run_plan_with_roster(goal: Option<Value>,roster: Vec<Value>,pushes: Vec<Value>,+) -> pa_tui::interactive::InteractiveOutcome {+ run_scenario(+ steps,+ heartbeats,+ goal,+ roster,+ pushes,+ false,+ pa_tui::keybindings::KeybindingsManager::new(),+ )+}++/// The full mock surface: `run_plan_with_roster` plus the factory lane and the client keybindings.+fn run_scenario(+ steps: Vec<HeadlessStep>,+ heartbeats: Option<Value>,+ goal: Option<Value>,+ roster: Vec<Value>,+ pushes: Vec<Value>,+ factory_lane: bool,+ keybindings: pa_tui::keybindings::KeybindingsManager,) -> pa_tui::interactive::InteractiveOutcome {// The ambient TMUX variable adds a startup notice; scrub it so runs are the same inside tmux// and out.std::env::remove_var("TMUX");let dir = tempfile::TempDir::new().expect("temp dir");let socket = dir.path().join("tui.sock");- let supervisor = MockSupervisor::bind(&socket, heartbeats, goal, roster, pushes);+ let supervisor = MockSupervisor::bind(&socket, heartbeats, goal, roster, pushes, factory_lane);let handle = std::thread::spawn(move || supervisor.serve());let runtime = tokio::runtime::Builder::new_multi_thread()@@ -375,184 +419,213 @@ fn run_plan_with_roster(height: 40,};let outcome = runtime- .block_on(run_interactive(options(socket), UiMode::Headless(plan)))+ .block_on(run_interactive(+ options(socket, keybindings),+ UiMode::Headless(plan),+ )).expect("interactive run");handle.join().expect("mock supervisor finished");outcome}-/// The arrows still visit each empty section in order, each opening its own view (panel-exit-/// ruling 2026-09-26); Left from the subagents section opens the scoped agents view (2026-09-28).+/// The line index of the first frame line containing `needle`.+fn line_of(frame: &str, needle: &str) -> Option<usize> {+ frame.lines().position(|line| line.contains(needle))+}++/// Focusing the dock expands it into one row per group in the groups' order (an empty group keeps+/// its row); unfocusing collapses it back to the single line.#[test]-fn dock_arrows_visit_each_empty_section_in_order_both_directions() {+fn focus_expands_the_dock_into_one_row_per_group_and_unfocus_collapses_it() {+ let collapsed =+ " \u{25c6} 0 subagents \u{b7} \u{25f7} 1 heartbeat \u{b7} \u{25b8} 0 shells \u{b7} Pursuing goal (0s)";let steps = vec![HeadlessStep::WaitRender {- needle: "Pursuing goal (0s)".to_string(),+ needle: collapsed.to_string(),timeout_ms: 5_000,},- // The selection starts on the subagents section.HeadlessStep::Key(alt_a()),- HeadlessStep::WaitMs(100),- // One right press lands on the EMPTY heartbeats section.- HeadlessStep::Key(right()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(enter()),- HeadlessStep::WaitRender {- needle: "No running or paused heartbeats".to_string(),- timeout_ms: 5_000,- },- HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(right()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(enter()),HeadlessStep::WaitRender {- needle: "No background commands".to_string(),+ needle: "\u{25c6} subagents".to_string(),timeout_ms: 5_000,},HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(right()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(enter()),- HeadlessStep::WaitRender {- needle: "status active".to_string(),- timeout_ms: 5_000,- },- HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(left()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(left()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(enter()),- HeadlessStep::WaitRender {- needle: "No running or paused heartbeats".to_string(),+ HeadlessStep::WaitGone {+ needle: "\u{25c6} subagents".to_string(),timeout_ms: 5_000,},- HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(left()),- HeadlessStep::WaitMs(100),- // Left from the subagents selection opens the scoped agents view (the operator's 2026-09-28- // ask); the plan ends on the agents surface.- HeadlessStep::Key(left()),- HeadlessStep::WaitMs(300),];- let outcome = run_plan(steps, None, Some(live_goal()));+ let outcome = run_plan(steps, Some(canary_heartbeats()), Some(live_goal()));let all = outcome.frames.join("\n");-- assert!(- all.contains(- " \u{25c6} 0 subagents \u{b7} \u{25f7} 0 heartbeats \u{b7} \u{25b8} 0 shells \u{b7} Pursuing goal (0s)"- ),- "the dock renders every section with its zero count:\n{all}"+ let expanded = outcome+ .frames+ .iter()+ .find(|frame| frame.contains("\u{25c6} subagents"))+ .unwrap_or_else(|| panic!("the focused dock never expanded:\n{all}"));+ let rows: Vec<Option<usize>> = [+ "\u{25c6} subagents",+ "\u{25f7} heartbeats",+ "\u{25b8} shells",+ "Pursuing goal (0s)",+ ]+ .iter()+ .map(|needle| line_of(expanded, needle))+ .collect();+ let first = rows[0].unwrap_or_else(|| panic!("no subagents row:\n{expanded}"));+ assert_eq!(+ rows,+ (first..first + 4).map(Some).collect::<Vec<_>>(),+ "one row per group, stacked in the groups' order:\n{expanded}");-assert!(- all.contains("No running or paused heartbeats"),- "the empty heartbeats section opens its view's empty state:\n{all}"+ expanded+ .lines()+ .nth(first + 1)+ .is_some_and(|row| row.contains("lane canary")),+ "the heartbeats row lists the active heartbeat:\n{expanded}");assert!(- all.contains("No background commands"),- "the empty shells section opens its view's empty state:\n{all}"+ !expanded.contains("\u{25c6} 0 subagents"),+ "the expanded dock replaces the collapsed line:\n{expanded}");-+ let last = outcome.frames.last().cloned().unwrap_or_default();assert!(- outcome.return_to_agents_view,- "left from the subagents selection hands the pane to the agents view"+ last.contains(collapsed) && !last.contains("\u{25c6} subagents"),+ "Esc collapsed the dock back to its single line:\n{all}");}-/// Filling a section never moves another (panel-exit ruling 2026-09-26 keeps the dock focused).+/// Enter and Right each open the selected row's page on every row (the factory row included while+/// the lane is advertised); Down steps the rows and wraps from the bottom (goal) row to the top.#[test]-fn dock_arrows_visit_the_same_sections_when_one_has_rows() {+fn enter_and_right_open_every_rows_page_and_down_wraps_to_the_top() {+ for open in [enter(), right()] {+ let steps = vec![+ HeadlessStep::WaitRender {+ needle: "\u{2699} 0 factory \u{b7} Pursuing goal (0s)".to_string(),+ timeout_ms: 5_000,+ },+ HeadlessStep::Key(alt_a()),+ HeadlessStep::WaitMs(100),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(open),+ HeadlessStep::WaitRender {+ needle: "No running or paused heartbeats".to_string(),+ timeout_ms: 5_000,+ },+ // A page's exit lands back on its own dock row.+ HeadlessStep::Key(escape()),+ HeadlessStep::WaitMs(100),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(open),+ HeadlessStep::WaitRender {+ needle: "No background commands".to_string(),+ timeout_ms: 5_000,+ },+ HeadlessStep::Key(escape()),+ HeadlessStep::WaitMs(100),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(open),+ HeadlessStep::WaitRender {+ needle: "No live factory runs.".to_string(),+ timeout_ms: 5_000,+ },+ HeadlessStep::Key(escape()),+ HeadlessStep::WaitMs(100),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(open),+ HeadlessStep::WaitRender {+ needle: "status active".to_string(),+ timeout_ms: 5_000,+ },+ HeadlessStep::Key(escape()),+ HeadlessStep::WaitMs(100),+ // Down from the bottom (goal) row wraps to the subagents row.+ HeadlessStep::Key(down()),+ HeadlessStep::Key(open),+ HeadlessStep::WaitMs(300),+ ];+ let outcome = run_scenario(+ steps,+ None,+ Some(live_goal()),+ Vec::new(),+ Vec::new(),+ true,+ pa_tui::keybindings::KeybindingsManager::new(),+ );+ let all = outcome.frames.join("\n");+ for page in [+ "No running or paused heartbeats",+ "No background commands",+ "No live factory runs.",+ "status active",+ ] {+ assert!(all.contains(page), "{open:?} did not open {page:?}:\n{all}");+ }+ assert!(+ outcome.return_to_agents_view,+ "Down wrapped to the subagents row and {open:?} opened the agents view:\n{all}"+ );+ }+}++/// Up from a lower row steps one row up instead of leaving the dock: Down then Up lands back on+/// the subagents row, whose Enter opens the agents view.+#[test]+fn up_from_a_lower_row_steps_to_the_row_above() {let steps = vec![HeadlessStep::WaitRender {- needle: "\u{25f7} 1 heartbeat".to_string(),+ needle: "Pursuing goal (0s)".to_string(),timeout_ms: 5_000,},HeadlessStep::Key(alt_a()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(right()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(enter()),- HeadlessStep::WaitRender {- needle: "lane canary".to_string(),- timeout_ms: 5_000,- },- HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(right()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(enter()),- HeadlessStep::WaitRender {- needle: "No background commands".to_string(),- timeout_ms: 5_000,- },- HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(right()),- HeadlessStep::WaitMs(100),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(up()),HeadlessStep::Key(enter()),- HeadlessStep::WaitRender {- needle: "status active".to_string(),- timeout_ms: 5_000,- },- HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(left()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(left()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(enter()),- HeadlessStep::WaitRender {- needle: "lane canary".to_string(),- timeout_ms: 5_000,- },- HeadlessStep::Key(escape()),- HeadlessStep::WaitMs(100),+ HeadlessStep::WaitMs(300),];- let outcome = run_plan(steps, Some(canary_heartbeats()), Some(live_goal()));- let all = outcome.frames.join("\n");- assert!(- all.contains(- " \u{25c6} 0 subagents \u{b7} \u{25f7} 1 heartbeat \u{b7} \u{25b8} 0 shells \u{b7} Pursuing goal (0s)"- ),- "the dock row reads the live counts:\n{all}"- );+ let outcome = run_plan(steps, None, Some(live_goal()));assert!(- all.contains("lane canary"),- "the filled heartbeats section lists its rows:\n{all}"+ outcome.return_to_agents_view,+ "Up returned to the subagents row and Enter opened the agents view:\n{}",+ outcome.frames.join("\n"));- assert!(!outcome.return_to_agents_view);}-/// Left from the subagents selection opens the agents view (the operator's 2026-09-28 ask): the TS-/// dock has no left/right handling at all, so this is the documented Rust divergence; the editor's-/// `agents back` is the same rule on the adjacent surface.+/// A rebound key keeps its configured action: with `tui.select.up` bound to Right, Right on the+/// heartbeats row steps up to the subagents row instead of opening the heartbeats page.#[test]-fn left_from_the_subagents_selection_opens_the_agents_view() {+fn a_rebound_right_keeps_its_configured_action() {+ let keybindings = pa_tui::keybindings::KeybindingsManager::with_user_bindings(+ [("tui.select.up".to_string(), vec!["right".to_string()])]+ .into_iter()+ .collect(),+ );let steps = vec![HeadlessStep::WaitRender {needle: "Pursuing goal (0s)".to_string(),timeout_ms: 5_000,},- // The selection starts on the subagents section.HeadlessStep::Key(alt_a()),- HeadlessStep::WaitMs(100),- HeadlessStep::Key(left()),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(right()),+ HeadlessStep::Key(enter()),HeadlessStep::WaitMs(300),];- let outcome = run_plan(steps, None, Some(live_goal()));- assert!(- outcome.return_to_agents_view,- "left from the subagents selection hands the pane to the agents view"+ let outcome = run_scenario(+ steps,+ None,+ Some(live_goal()),+ Vec::new(),+ Vec::new(),+ false,+ keybindings,);let all = outcome.frames.join("\n");assert!(- all.contains("\u{25c6} 0 subagents"),- "the dock row mounted before the handoff:\n{all}"+ outcome.return_to_agents_view && !all.contains("No running or paused heartbeats"),+ "the rebound Right stepped up to the subagents row, whose Enter opened the agents view:\n{all}");}diff --git a/crates/pa-tui/tests/dock_panel_exit_focus_headless.rs b/crates/pa-tui/tests/dock_panel_exit_focus_headless.rsindex 345d8158d2..9e81c73666 100644--- a/crates/pa-tui/tests/dock_panel_exit_focus_headless.rs+++ b/crates/pa-tui/tests/dock_panel_exit_focus_headless.rs@@ -324,20 +324,21 @@ fn wait_gone(needle: &str) -> HeadlessStep {/// next Enter re-opens the Heartbeats panel, and the run never hands off to the agents view.fn heartbeats_exit_plan(exit: KeyCode) -> Vec<HeadlessStep> {vec![- // The barrier pins the panel's content (its row label); the navigation itself steps the- // rendered groups, empty ones included, so it never depends on the feed's landing order.+ // The barriers pin the panel's own column header (the expanded dock row lists the+ // heartbeat's label too); the navigation steps the rendered rows, empty ones included,+ // so it never depends on the feed's landing order.wait_render("\u{25f7} 1 heartbeat"),alt_a(),HeadlessStep::WaitMs(150),// The dock's focus starts on the subagents section (the default selection).- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),key(KeyCode::Enter),- wait_render("Workspace tidy"),+ wait_render("Next run"),key(exit),- wait_gone("Workspace tidy"),+ wait_gone("Next run"),key(KeyCode::Enter),- wait_render("Workspace tidy"),+ wait_render("Next run"),]}@@ -347,16 +348,16 @@ fn shells_exit_plan(exit: KeyCode) -> Vec<HeadlessStep> {wait_render("\u{25b8} 1 shell"),alt_a(),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),key(KeyCode::Enter),- wait_render("render the frames"),+ wait_render("Duration"),key(exit),- wait_gone("render the frames"),+ wait_gone("Duration"),key(KeyCode::Enter),- wait_render("render the frames"),+ wait_render("Duration"),]}@@ -367,11 +368,11 @@ fn goal_exit_plan(exit: KeyCode) -> Vec<HeadlessStep> {wait_render("Pursuing goal (0s)"),alt_a(),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),key(KeyCode::Enter),wait_render("land the dock exit focus"),@@ -389,7 +390,7 @@ fn heartbeats_panel_esc_returns_to_the_dock_item() {let outcome = run_plan(heartbeats_exit_plan(KeyCode::Esc));let last = outcome.frames.last().expect("frames were captured");assert!(- last.contains("Workspace tidy"),+ last.contains("Next run"),"the reopened Heartbeats panel owns the final frame:\n{last}");assert!(@@ -408,22 +409,22 @@ fn heartbeats_command_path_esc_returns_to_the_dock_item() {wait_render("Pursuing goal (0s)"),alt_a(),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),- key(KeyCode::Right),+ key(KeyCode::Down),HeadlessStep::WaitMs(150),HeadlessStep::Submit("/heartbeats".to_string()),- wait_render("Workspace tidy"),+ wait_render("Next run"),key(KeyCode::Esc),- wait_gone("Workspace tidy"),+ wait_gone("Next run"),key(KeyCode::Enter),- wait_render("Workspace tidy"),+ wait_render("Next run"),]);let last = outcome.frames.last().expect("frames were captured");assert!(- last.contains("Workspace tidy"),+ last.contains("Next run"),"the reopened Heartbeats panel owns the final frame:\n{last}");assert!(@@ -441,7 +442,7 @@ fn heartbeats_panel_left_returns_to_the_dock_item() {let outcome = run_plan(heartbeats_exit_plan(KeyCode::Left));let last = outcome.frames.last().expect("frames were captured");assert!(- last.contains("Workspace tidy"),+ last.contains("Next run"),"the reopened Heartbeats panel owns the final frame:\n{last}");assert!(@@ -455,7 +456,7 @@ fn shells_panel_esc_returns_to_the_dock_item() {let outcome = run_plan(shells_exit_plan(KeyCode::Esc));let last = outcome.frames.last().expect("frames were captured");assert!(- last.contains("render the frames"),+ last.contains("Duration"),"the reopened Shells panel owns the final frame:\n{last}");assert!(@@ -469,7 +470,7 @@ fn shells_panel_left_returns_to_the_dock_item() {let outcome = run_plan(shells_exit_plan(KeyCode::Left));let last = outcome.frames.last().expect("frames were captured");assert!(- last.contains("render the frames"),+ last.contains("Duration"),"the reopened Shells panel owns the final frame:\n{last}");assert!(diff --git a/crates/pa-tui/tests/factory_command_headless.rs b/crates/pa-tui/tests/factory_command_headless.rsindex 8f8f4a1d38..0b189f7651 100644--- a/crates/pa-tui/tests/factory_command_headless.rs+++ b/crates/pa-tui/tests/factory_command_headless.rs@@ -815,12 +815,7 @@ fn alt_a() -> KeyEvent {KeyEvent::new(KeyCode::Char('a'), KeyModifiers::ALT)}-/// One right-arrow key event (the dock's next-section step).-fn dock_right() -> KeyEvent {- KeyEvent::new(KeyCode::Right, KeyModifiers::NONE)-}--/// One down-arrow key event (the page's `tui.select.down`).+/// One down-arrow key event (`tui.select.down`: the dock's next row, the page's next run).fn down() -> KeyEvent {KeyEvent::new(KeyCode::Down, KeyModifiers::NONE)}@@ -838,7 +833,7 @@ fn escape() -> KeyEvent {/// The page's picker keys repaint on the key itself, never waiting for/// the 2-second refresh poll (the input loop's render contract: every/// dispatched input paints — the same TS `handleInput` parity that-/// carries the dock's arrows and every other picker key). The pin closes+/// carries the dock's keys and every other picker key). The pin closes/// the page on the input right after the arrow, so no poll window can/// sit between the move and the paint: the moved selection marker must/// land in a captured frame on the arrow's own repaint — and the poll@@ -857,12 +852,12 @@ fn factory_page_picker_keys_paint_the_moved_selection_on_the_key() {]});let steps = vec![- // Focus the dock and step to the factory group (subagents ->- // heartbeats -> shells -> factory); Enter opens the page.+ // Focus the dock and step down to the factory row (subagents ->+ // heartbeats -> shells -> factory rows); Enter opens the page.HeadlessStep::Key(alt_a()),- HeadlessStep::Key(dock_right()),- HeadlessStep::Key(dock_right()),- HeadlessStep::Key(dock_right()),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(down()),HeadlessStep::Key(enter()),// The page opens on the feed's live head: the newest run.HeadlessStep::WaitRender {diff --git a/crates/pa-tui/tests/prompt_history_nav_headless.rs b/crates/pa-tui/tests/prompt_history_nav_headless.rsindex 09409eddac..c79954f41d 100644--- a/crates/pa-tui/tests/prompt_history_nav_headless.rs+++ b/crates/pa-tui/tests/prompt_history_nav_headless.rs@@ -323,11 +323,6 @@ fn escape() -> KeyEvent {KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE)}-/// Right: the dock's group-traversal arrow (the focused row's `left`/`right` arms).-fn right() -> KeyEvent {- KeyEvent::new(KeyCode::Right, KeyModifiers::NONE)-}-fn wait_render(needle: &str) -> HeadlessStep {HeadlessStep::WaitRender {needle: needle.to_string(),@@ -400,18 +395,17 @@ fn the_drafts_down_enters_the_dock_and_up_returns_before_the_recall() {);}-/// Coexistence: the right arrow walks to the heartbeats group (the 2026-09-26 dock-arrows-/// directive), and Escape closes the panel onto the dock's own item (the 2026-09-26 panel-exit-/// ruling): the history recall works right after the round trip.+/// Coexistence: Down walks the expanded dock to the heartbeats row, and Escape closes the panel+/// onto the dock's own item (the 2026-09-26 panel-exit ruling): the history recall works right+/// after the round trip.#[test]fn alt_a_arrows_and_enter_still_open_the_dock_group_view_and_recall_survives_it() {let mut steps = Vec::new();steps.push(wait_render("heartbeat"));steps.extend(submit("first prompt"));steps.push(HeadlessStep::Key(alt_a()));- // The dock's row starts the focus on the subagents group; one right arrow steps to heartbeats- // (the rendered-group cycle).- steps.push(HeadlessStep::Key(right()));+ // The dock's focus starts on the subagents row; one Down steps to heartbeats.+ steps.push(HeadlessStep::Key(down()));steps.push(HeadlessStep::Key(enter()));steps.push(wait_render("Heartbeats"));steps.push(HeadlessStep::Key(escape()));diff --git a/crates/pa-tui/tests/tray_prompt_down_headless.rs b/crates/pa-tui/tests/tray_prompt_down_headless.rsindex 9548c22f9b..8bd89c9178 100644--- a/crates/pa-tui/tests/tray_prompt_down_headless.rs+++ b/crates/pa-tui/tests/tray_prompt_down_headless.rs@@ -251,9 +251,9 @@ fn up() -> KeyEvent {KeyEvent::new(KeyCode::Up, KeyModifiers::NONE)}-/// One right-arrow key event (the dock's next-section step).-fn right() -> KeyEvent {- KeyEvent::new(KeyCode::Right, KeyModifiers::NONE)+/// One left-arrow key event (the focused dock's return to the prompt).+fn left() -> KeyEvent {+ KeyEvent::new(KeyCode::Left, KeyModifiers::NONE)}/// One plain Enter key event (the focused section's open).@@ -323,8 +323,8 @@ fn prompt_down_enters_the_all_zero_dock_and_enter_opens_subagents() {);}-/// Every empty group stays reachable from the prompt's Down: Right walks-/// to the empty heartbeats and shells groups, and Enter opens each view's+/// Every empty group stays reachable from the prompt's Down: Down walks+/// to the empty heartbeats and shells rows, and Enter opens each view's/// empty state.#[test]fn prompt_down_reaches_every_empty_group() {@@ -334,7 +334,7 @@ fn prompt_down_reaches_every_empty_group() {timeout_ms: 5_000,},HeadlessStep::Key(down()),- HeadlessStep::Key(right()),+ HeadlessStep::Key(down()),HeadlessStep::Key(enter()),HeadlessStep::WaitRender {needle: "No running or paused heartbeats".to_string(),@@ -342,7 +342,7 @@ fn prompt_down_reaches_every_empty_group() {},// The panel's exit lands back on its own dock item.HeadlessStep::Key(escape()),- HeadlessStep::Key(right()),+ HeadlessStep::Key(down()),HeadlessStep::Key(enter()),HeadlessStep::WaitRender {needle: "No background commands".to_string(),@@ -362,7 +362,7 @@ fn prompt_down_reaches_every_empty_group() {}/// Bug 2: with a shell running and zero subagents, the prompt's Down-/// enters the dock and two Right presses reach the shells group, whose+/// enters the dock and two more Down presses reach the shells row, whose/// Enter opens the bash view listing the running shell.#[test]fn prompt_down_reaches_the_shells_group_with_zero_subagents() {@@ -373,8 +373,8 @@ fn prompt_down_reaches_the_shells_group_with_zero_subagents() {timeout_ms: 5_000,},HeadlessStep::Key(down()),- HeadlessStep::Key(right()),- HeadlessStep::Key(right()),+ HeadlessStep::Key(down()),+ HeadlessStep::Key(down()),HeadlessStep::Key(enter()),HeadlessStep::WaitRender {needle: "render the frames".to_string(),@@ -390,20 +390,25 @@ fn prompt_down_reaches_the_shells_group_with_zero_subagents() {assert!(!outcome.return_to_agents_view);}-/// Up and Esc from the focused dock return to the prompt: the Enter that-/// follows reaches the empty prompt, never the dock's heartbeats group-/// (whose view would render its empty state), and the typed text after it-/// lands in the prompt — the barrier proves the Enter was handled.+/// Up from the top row, and Esc or Left from any row, return to the+/// prompt: the Enter that follows reaches the empty prompt, never a dock+/// page (the agents view or the heartbeats view's empty state), and the+/// typed text after it lands in the prompt — the barrier proves the Enter+/// was handled.#[test]-fn up_and_esc_return_from_the_dock_to_the_prompt() {- for back in [up(), escape()] {- let steps = vec![- HeadlessStep::WaitRender {- needle: ALL_ZERO_DOCK.to_string(),- timeout_ms: 5_000,- },- HeadlessStep::Key(down()),- HeadlessStep::Key(right()),+fn up_from_the_top_row_and_esc_or_left_return_from_the_dock_to_the_prompt() {+ let cases = [+ (vec![down()], up()),+ (vec![down(), down()], escape()),+ (vec![down(), down()], left()),+ ];+ for (grab, back) in cases {+ let mut steps = vec![HeadlessStep::WaitRender {+ needle: ALL_ZERO_DOCK.to_string(),+ timeout_ms: 5_000,+ }];+ steps.extend(grab.into_iter().map(HeadlessStep::Key));+ steps.extend([HeadlessStep::Key(back),HeadlessStep::Key(enter()),HeadlessStep::Type("back at the prompt".to_string()),@@ -411,12 +416,16 @@ fn up_and_esc_return_from_the_dock_to_the_prompt() {needle: "back at the prompt".to_string(),timeout_ms: 5_000,},- ];+ ]);let outcome = run_plan(steps, false);let all = outcome.frames.join("\n");+ let last = outcome.frames.last().cloned().unwrap_or_default();assert!(- all.contains("back at the prompt") && !all.contains("No running or paused heartbeats"),- "{back:?} returned the focus to the prompt before the Enter:\n{all}"+ last.contains("back at the prompt")+ && last.contains(ALL_ZERO_DOCK)+ && !all.contains("No running or paused heartbeats")+ && !outcome.return_to_agents_view,+ "{back:?} collapsed the dock and returned the focus to the prompt before the Enter:\n{all}");}}diff --git a/scripts/review_dock_events_parity.py b/scripts/review_dock_events_parity.pyindex 1ce29771a2..3e18dd9ad4 100644--- a/scripts/review_dock_events_parity.py+++ b/scripts/review_dock_events_parity.py@@ -4,8 +4,9 @@Both ordinary clients receive controlled protocol-7 roster/goal events afterobservable attach. No headless flags, provider or live sessions are used. Thereceipt records full-frame differences instead of normalizing TS's boxed dock-into Rust's one-line dock. Behavioral assertions cover event-driven refresh;-full-frame/style equality is reported separately and never claimed by them.+into Rust's one-line dock, which expands into per-group rows on focus.+Behavioral assertions cover event-driven refresh; full-frame/style equality is+reported separately and never claimed by them."""import argparseimport json@@ -106,8 +107,10 @@ class DockSupervisor(Supervisor):'timeUsedSeconds': 12, 'continuationsUsed': 0}}})-def running_visible(text, kind, count):- label = 'running' if kind == 'ts' else 'subagents'+def running_visible(text, kind, count, expanded=False):+ # Rust's collapsed dock reads "N subagents"; its focused (expanded) dock's+ # subagents row reads the "N running · …" breakdown, like TS's box.+ label = 'running' if kind == 'ts' or expanded else 'subagents'return re.search(r'(?<!\d)' + str(count) + r'\s+' + label + r'\b', text) is not None@@ -180,7 +183,7 @@ def run_case(binary, kind, root, observed):terminal.send('\x1b[B') # Same ordinary Down key from an empty editor.terminal.wait('dock focus changes rendered attributes',lambda: terminal.screen.dock_styles() != before_focus, server)- snap('dock_focused', lambda text: running_visible(text, kind, 2))+ snap('dock_focused', lambda text: running_visible(text, kind, 2, expanded=True))assert observed['frames']['dock_focused']['dock_styled_rows'] != before_focusterminal.send('\x1b')terminal.wait('Escape restores editor focus', lambda: terminal.screen.dock_styles() == before_focus, server)@@ -232,7 +235,7 @@ def main():args = parser.parse_args()receipt = {'verified': False, 'runs': {}, 'scope': __doc__,'frame_scope': '120x40 decoded text + dock SGR cells and complete raw ANSI, not pixels/font rendering.',- 'preexisting_ts_limitation': 'Pinned TS uses a boxed running/idle/inactive dock; Rust uses a one-line fixed-group dock. Layouts are not normalized into equality.',+ 'preexisting_ts_limitation': 'Pinned TS uses a boxed running/idle/inactive dock; Rust uses a one-line fixed-group dock that expands into per-group rows on focus. Layouts are not normalized into equality.','preexisting_cost_difference': 'TS binds initial family cost from get_context_tree and does not refresh it on roster-only events. Rust refreshes cost from the live roster. Exact phase costs asserted and retained without normalization or synthetic refresh events.','not_verified': ['frame/style equality', 'actual daemon roster production', 'new-session/no-session fallback', 'agents-view lazy query search']}try:diff --git a/scripts/test_review_dock_events_parity.py b/scripts/test_review_dock_events_parity.pyindex 3696329b45..1ba89ac300 100644--- a/scripts/test_review_dock_events_parity.py+++ b/scripts/test_review_dock_events_parity.py@@ -37,6 +37,10 @@ class CaptureTests(unittest.TestCase):self.assertTrue(running_visible('1 running', 'ts', 1))self.assertFalse(running_visible('1 running', 'ts', 2))self.assertTrue(running_visible('2 subagents', 'rust', 2))+ expanded = '◆ subagents 2 running · 0 idle · 0 inactive'+ self.assertTrue(running_visible(expanded, 'rust', 2, expanded=True))+ self.assertFalse(running_visible(expanded, 'rust', 2))+ self.assertFalse(running_visible('◆ 2 subagents', 'rust', 2, expanded=True))def test_count_has_integer_boundaries(self):for kind, label in [('ts', 'running'), ('rust', 'subagents')]: