From 85988b14d44e787c6acc680c3629393463c5a4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sat, 26 Sep 2026 08:31:32 -0400 Subject: [PATCH] T24b round 1 fix - AgentProgress splits its bar only for two steps or more; a task of one step draws a plain bar - test a_task_of_one_step_draws_before_and_after renders 0 of 1 and 1 of 1 --- TASKS.md | 1 + src/agent/progress.rs | 14 +++++++++----- src/agent/tests.rs | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/TASKS.md b/TASKS.md index eec4fc8..a37d01e 100644 --- a/TASKS.md +++ b/TASKS.md @@ -275,3 +275,4 @@ Per-component lines live in `tasks/`. Tags there: | T24a | 1 | FAIL | tall arguments pushed the approval dialog's title and buttons off screen; a long tool name in a narrow column pushed the time and chevron out of the card; the dark capture closed the card the light one opened | | T24a | 2 | FAIL | a dialog body's children shrank to the capped column instead of scrolling: a 2000px body drew at 860px and a scroll moved nothing | | T24a | 3 | PASS | | +| T24b | 1 | FAIL | a task of one step crashed at render: its bar asked for one segment, and a segmented bar needs two | diff --git a/src/agent/progress.rs b/src/agent/progress.rs index 76f727f..95b1d25 100644 --- a/src/agent/progress.rs +++ b/src/agent/progress.rs @@ -246,7 +246,7 @@ impl RenderOnce for AgentStatus { } } -/// How far an agent has come: the step at work, how many are done of how many, the time so far, and a bar split by step. +/// How far an agent has come: the step at work, how many are done of how many, the time so far, and a bar split by step when there are two or more. #[derive(IntoElement)] pub struct AgentProgress { id: ElementId, @@ -309,9 +309,13 @@ impl RenderOnce for AgentProgress { tabular(div().flex_none().text_color(colors.fg_subtle)).child(took(spent)) })), ) - .child( - ProgressBar::new((self.id, "bar"), self.done as f32 / self.total as f32) - .segments(self.total), - ) + .child({ + let bar = ProgressBar::new((self.id, "bar"), self.done as f32 / self.total as f32); + if self.total >= 2 { + bar.segments(self.total) + } else { + bar + } + }) } } diff --git a/src/agent/tests.rs b/src/agent/tests.rs index 3b0c7d3..dcf52ec 100644 --- a/src/agent/tests.rs +++ b/src/agent/tests.rs @@ -129,3 +129,28 @@ fn the_prompt_walks_deny_always_then_once(cx: &mut TestAppContext) { fn progress_past_its_total_fails_loud() { let _ = AgentProgress::new("progress", "Writing", 6, 5); } + +/// A progress bar for a task of one step, `done` or not. +struct Single { + done: usize, +} + +impl Render for Single { + fn render(&mut self, _: &mut Window, _: &mut Context) -> impl IntoElement { + div() + .w_full() + .child(AgentProgress::new("single", "The one step", self.done, 1)) + } +} + +#[gpui::test] +fn a_task_of_one_step_draws_before_and_after(cx: &mut TestAppContext) { + cx.update(Theme::init); + let (view, cx) = cx.add_window_view(|_, _| Single { done: 0 }); + settle(cx); + view.update(cx, |single, cx| { + single.done = 1; + cx.notify(); + }); + settle(cx); +}