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); +}