Skip to content

Craft Anything: understand how any software works, and craft your own.

Rust

Mark open plan steps as stopped when a run ends (#876)

LIN ZHANG9fc397e51574
diff --git a/crates/ai/src/rebuild/feed.rs b/crates/ai/src/rebuild/feed.rs
index d7057d4e..7e88a5aa 100644
--- a/crates/ai/src/rebuild/feed.rs
+++ b/crates/ai/src/rebuild/feed.rs
@@ -76,6 +76,15 @@ pub fn apply(feed: &mut Vec<FeedItem>, e: &RunEvent) {
RunEvent::Preview(_) => {}
RunEvent::Finished { ok, message, paused } => {
end_stream(feed);
+ // #504: a run that ends with steps still open marks them stopped on the plan card,
+ // instead of leaving them "Doing"; a later run's checklist updates the list again.
+ if let Some(FeedItem::Plan(steps)) = feed.iter_mut().rev().find(|i| matches!(i, FeedItem::Plan(_))) {
+ for step in steps {
+ if step.status == PlanStatus::Doing {
+ step.status = PlanStatus::Stopped;
+ }
+ }
+ }
// An agent error already explains itself; don't say it twice.
let explained = matches!(feed.last(), Some(FeedItem::Error { .. }));
if *paused {
@@ -229,6 +238,39 @@ mod tests {
assert!(matches!(feed.last(), Some(FeedItem::Plan(p)) if p[0].status == PlanStatus::Doing));
}
+ /// #504: a run that ends with steps still open marks them stopped on the plan card instead of
+ /// leaving them "Doing"; a paused run stops them too, and the next run's checklist takes over.
+ #[test]
+ fn a_run_that_ends_marks_open_steps_stopped() {
+ let todo = |status: &str| {
+ json!({"todos": [
+ {"content": "Lay out the arena", "activeForm": "Laying out the arena", "status": "completed"},
+ {"content": "Add the snake", "activeForm": "Adding the snake", "status": status},
+ {"content": "Keep score", "activeForm": "Keeping score", "status": "pending"},
+ ]})
+ };
+ let call = |status: &str| RunEvent::Agent(AgentEvent::ToolStarted { call_id: "t".into(), tool: "TodoWrite".into(), input: todo(status) });
+ let steps = |f: &[FeedItem]| craft_anything_engine::feed::visible_plan(f).unwrap().to_vec();
+ let mut feed = vec![FeedItem::User(UserItem::Text("A snake game".into()))];
+ apply(&mut feed, &call("in_progress"));
+ apply(&mut feed, &RunEvent::Finished { ok: true, message: "Ready.".into(), paused: false });
+ let after = steps(&feed);
+ assert_eq!(after[0].status, PlanStatus::Done, "done steps stay done");
+ assert_eq!(after[1].status, PlanStatus::Stopped, "the step left open stops");
+ assert_eq!(after[2].status, PlanStatus::Todo, "never-started steps stay as they were");
+ // A paused run stops the open step too, and the next run's checklist takes the list over.
+ let mut paused = vec![FeedItem::User(UserItem::Text("A snake game".into()))];
+ apply(&mut paused, &call("in_progress"));
+ apply(&mut paused, &RunEvent::Finished { ok: true, message: "Paused.".into(), paused: true });
+ assert!(steps(&paused).iter().any(|s| s.status == PlanStatus::Stopped), "pausing stops the open step too");
+ apply(&mut paused, &call("in_progress"));
+ assert!(steps(&paused).iter().any(|s| s.status == PlanStatus::Doing), "the next run's checklist takes over");
+ // No checklist: nothing to mark, nothing to lose.
+ let mut bare = vec![FeedItem::User(UserItem::Text("A game".into()))];
+ apply(&mut bare, &RunEvent::Finished { ok: true, message: "Ready.".into(), paused: false });
+ assert!(matches!(bare.last(), Some(FeedItem::User(_))));
+ }
+
#[test]
fn a_run_keeps_the_feed_in_the_project() {
let d = tempfile::tempdir().unwrap();
diff --git a/crates/engine/src/feed.rs b/crates/engine/src/feed.rs
index 14841ca4..15e26744 100644
--- a/crates/engine/src/feed.rs
+++ b/crates/engine/src/feed.rs
@@ -13,10 +13,10 @@ use std::path::{Path, PathBuf};
/// Where the conversation is kept in the project folder.
pub const FEED_FILE: &str = "feed.json";
-/// The format written today (4 saves a dismissed plan card with it; 3 saved a prompt's pictures);
-/// files without a version are the earlier bare list. An older Craft Anything won't rewrite a file
-/// it can't read (`save` refuses a newer version).
-pub const FEED_VERSION: u32 = 4;
+/// The format written today (5 marks open plan steps stopped at a run's end; 4 saves a dismissed
+/// plan card with it; 3 saved a prompt's pictures); files without a version are the earlier bare
+/// list. An older Craft Anything won't rewrite a file it can't read (`save` refuses a newer version).
+pub const FEED_VERSION: u32 = 5;
/// What the person sent: as the feed shows it, and the pictures attached to it (their copies in
/// the project's `attachments/`).
@@ -71,6 +71,8 @@ pub enum PlanStatus {
Todo,
Doing,
Done,
+ /// A run ended with the step still open: stopped, not done (#504).
+ Stopped,
}
/// One entry in a project's activity feed.
@@ -295,6 +297,22 @@ mod tests {
assert!(visible_plan(&load(&ws)).is_some(), "a version 3 plan still shows");
}
+ /// #504: a step marked stopped when a run ended stays in the saved conversation (it's part of
+ /// the plan card's data, not a display flourish).
+ #[test]
+ fn a_stopped_step_is_kept_across_saves() {
+ let d = tempfile::tempdir().unwrap();
+ let ws = Workspace::create(d.path(), "x", "A game", TargetRef::None).unwrap();
+ let steps = vec![
+ PlanStep { text: "Lay out the arena".into(), doing: "Laying out the arena".into(), status: PlanStatus::Done },
+ PlanStep { text: "Add the snake".into(), doing: "Adding the snake".into(), status: PlanStatus::Stopped },
+ PlanStep { text: "Keep score".into(), doing: "Keeping score".into(), status: PlanStatus::Todo },
+ ];
+ save(&ws.root, &[FeedItem::User(UserItem::Text("A game".into())), FeedItem::Plan(steps)]).unwrap();
+ let loaded = load(&ws);
+ assert!(matches!(visible_plan(&loaded), Some(p) if p.iter().any(|s| s.status == PlanStatus::Stopped)));
+ }
+
#[test]
fn older_files_load_answers_are_kept_and_newer_files_are_left_alone() {
let d = tempfile::tempdir().unwrap();
diff --git a/crates/ui-egui/src/project.rs b/crates/ui-egui/src/project.rs
index fd901f86..a3c46f11 100644
--- a/crates/ui-egui/src/project.rs
+++ b/crates/ui-egui/src/project.rs
@@ -700,14 +700,27 @@ fn checklist(ui: &mut Ui, steps: &[PlanStep], t: &Tokens, began: Option<std::tim
PlanStatus::Todo => {
ui.painter().circle_stroke(r.center(), 6.5, egui::Stroke::new(1.0, t.field_border));
}
+ // #504: a run ended with this step open.
+ PlanStatus::Stopped => {
+ ui.painter().circle_stroke(r.center(), 6.5, egui::Stroke::new(1.5, t.warning));
+ ui.painter().circle_filled(r.center(), 3.0, t.warning);
+ }
}
let text = RichText::new(&s.text).size(theme::BODY);
let text = match s.status {
PlanStatus::Done => text.color(t.text_faint).strikethrough(),
PlanStatus::Doing => text.color(t.text).strong(),
PlanStatus::Todo => text.color(t.text_dim),
+ PlanStatus::Stopped => text.color(t.text_dim),
};
- ui.add(egui::Label::new(text).wrap());
+ let resp = ui.add(egui::Label::new(text).wrap());
+ if s.status == PlanStatus::Stopped {
+ // Sighted users get the warning marker above; screen readers
+ // get the status through the accessible label and the text.
+ let name = format!("{}: {}", s.text, tr("Stopped here"));
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, &name));
+ ui.label(RichText::new(tr("Stopped here")).size(theme::SMALL).color(t.warning));
+ }
});
}
});
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md
index bc3011b1..b4df2fe3 100644
--- a/docs/ROADMAP.md
+++ b/docs/ROADMAP.md
@@ -708,8 +708,9 @@ Gaps found while using the app for real projects.
(between builds: a fold during a build can be overwritten by its next save). The steps stay
in the conversation (`FEED_VERSION` 4, `FeedItem::PlanDismissed`), and a later run's
checklist shows again — claimed: claude, branch bugfix/r2.9-plan-card-dismiss
-- [ ] A run that ends with steps still open marks them as stopped on its card, instead of
+- [x] A run that ends with steps still open marks them as stopped on its card, instead of
showing "Doing" until someone folds it (#504: Claude's runs left the plan unticked)
+ — claimed: rust-craft, branch feature/R2.9-stop-open-steps; PR #876
- [x] #666: a long line in a feed's tool-work row (a Deep-mode decompile, a status note) ran off
the window and pushed the feed left; the header title can't wrap in egui, so it's the note's
first line now, cut at 90 characters, and the full note wraps in the body — claimed: claude,
diff --git a/docs/STATUS.md b/docs/STATUS.md
index c5707f88..82784e1a 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -93,6 +93,8 @@ workspace clippy, layers, fmt and the secret scan of all history were clean. Chi
| Parser review follow-ups | Java reference scans retain partial coverage; DEX signed LEB128 enforces 32-bit values; legacy AAPT strings stay inside their pool with a shared recovery probe limit; missing classic ext indirect metadata is not recovered as zeros. | Shared-budget revision `29c48e03` passed [full Linux CI](https://github.com/storytold/craft-anything/actions/runs/41762780268). The merge with main `41d2175e` awaits a new CI run. Extent-tree metadata handling is unchanged. |
| Stand-in retained body budgets | Check per-body limits after redaction and charge the capture budget only for distinct retained samples. Budget-rejected cached 304 responses remain unavailable. | All four original capture regressions and six deduplication regressions passed in [full Linux CI](https://github.com/storytold/craft-anything/actions/runs/41788735130) at revision `d601bc4e`. Workspace tests, strict Clippy, formatting, layers, locks, secrets, wasm-plugin checks, shared WASM compilation and the lockfile check passed. |
+| Plan steps stopped at a run's end | A run that finishes (ready, failed or paused) marks still-open steps `Stopped` on the plan card instead of leaving them "Doing" until the card is folded (#504). The stopped steps stay in the saved conversation (`FEED_VERSION` 5); a later run's checklist updates the list again, and a plan left partly unticked still shows with its stopped steps | Regression tests in `ai::rebuild::feed` (ready, paused and no-checklist finishes, a later run taking the list over) and an engine save/load round trip of a stopped step; the checklist draws a warning circle for stopped steps. Not checked: a live desktop run |
+
### Builder retry policy
Builder failures carry a typed reason through `Conversation::last_failure`. Typed authentication,
diff --git a/docs/file-formats.md b/docs/file-formats.md
index f1db3815..86312073 100644
--- a/docs/file-formats.md
+++ b/docs/file-formats.md
@@ -18,7 +18,7 @@ version up to the current one, then turn the document into Rust types. The step
| `<project>/questions.json` | `engine::questions` (`AskedQuestion`, written by `rebuild_question_ask`) | `QUESTIONS_VERSION` = 1 (`{version, items}`) | read as before | read as far as its fields are known |
| `<project>/pinned/<n>/pin.json` | `engine::pins` (`Pin`) | `PIN_VERSION` = 2 (`version`; missing = 1; 2 records the selected program for a copied direct launch) | brought forward | read as far as its fields are known |
| `<folder>/standin.json` | `engine::tools::standin_tools` (`analysis::standin::StandIn`; written only by `web_standin_build`) | `STANDIN_VERSION` = 1 (`version`, required) | brought forward | refused, with "update Craft Anything", and never written over |
-| `<project>/feed.json` | `ai::rebuild::feed` (written by the run) | `FEED_VERSION` = 4 (`{version, items}`; a bare list = 0; 4 adds `PlanDismissed`, a folded plan card) | read as before, saved as current | never written over; the conversation is rebuilt from the project for display |
+| `<project>/feed.json` | `ai::rebuild::feed` (written by the run) | `FEED_VERSION` = 5 (`{version, items}`; a bare list = 0; 4 adds `PlanDismissed`, a folded plan card; 5 marks open steps stopped at a run's end) | read as before, saved as current | never written over; the conversation is rebuilt from the project for display |
A saved `User` message with pictures is `{text, pictures: [paths]}`, where the pictures are the
copies in the project's `attachments/`; one without pictures stays the plain string earlier