diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a330df..7c9e679 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to CodeCraft. Versions follow [Semantic Versioning](https://semver.org/); until 1.0, minor versions may contain breaking changes. +## [Unreleased] + +### Fixed + +- The factory's planning chats (spec chat, "Plan a feature", "Cut a milestone") no longer run the review loop + of the agent mode (the "refine" rounds of build mode), which checked their answers as if they were code. + ## [v202611-00049] – 2026-11-16 ### Added diff --git a/server/src/factory.rs b/server/src/factory.rs index 6d7f18e..df1fc43 100644 --- a/server/src/factory.rs +++ b/server/src/factory.rs @@ -1529,6 +1529,16 @@ pub fn draft_of(app: &App, user: &User, session: &crate::types::Session) -> Opti (session.owner_id.as_deref() == Some(&user.id) && cwd.starts_with(&home) && cwd != home).then_some(cwd) } +/// Is this a planning chat of the factory (spec chat in `_drafts`, issue chat in `_issues`)? They produce +/// text, not code, so the review loop of the agent mode is switched off for them. +pub fn is_planning_chat(app: &App, session: &crate::types::Session) -> bool { + app.factory_dir().is_some_and(|dir| is_planning_path(&dir, std::path::Path::new(&session.cwd))) +} + +fn is_planning_path(factory: &std::path::Path, cwd: &std::path::Path) -> bool { + cwd.strip_prefix(factory).map(|rel| rel.components().any(|c| c.as_os_str() == "_drafts" || c.as_os_str() == "_issues")).unwrap_or(false) +} + /// Start a spec chat with the given model. pub fn start_spec_chat(app: &Arc, user: &User, model: &str) -> Result { let id = crate::types::new_id(); @@ -1804,6 +1814,16 @@ mod tests { assert!(parse_result(t).is_some_and(|v| v["decision"] == "issues")); } + #[test] + fn planning_chats_are_recognised_by_their_folder() { + let f = std::path::Path::new("/factory"); + assert!(is_planning_path(f, std::path::Path::new("/factory/zink/_drafts/abc"))); + assert!(is_planning_path(f, std::path::Path::new("/factory/zink/_issues/abc"))); + assert!(!is_planning_path(f, std::path::Path::new("/factory/zink/zink/dunkelfeld"))); + assert!(!is_planning_path(f, std::path::Path::new("/factory/zink/zink/_work/dunkelfeld-1"))); + assert!(!is_planning_path(f, std::path::Path::new("/workspace/_drafts/x"))); + } + #[test] fn encodes_labels() { assert_eq!(urlenc("factory:qa"), "factory%3Aqa"); diff --git a/server/src/runner.rs b/server/src/runner.rs index 0931902..a04a9fa 100644 --- a/server/src/runner.rs +++ b/server/src/runner.rs @@ -293,6 +293,10 @@ pub async fn run_session(app: Arc, session_id: &str, cancel: CancellationTo let roots = app.user_roots(session.owner_id.as_deref()); let root = app.root_for(session.owner_id.as_deref(), &cwd); let mut agent = prompts::find_agent_for(&app, &root, &cwd, &session.agent, session.owner_id.as_deref()); + // Chats that plan (spec chat, issue chat) write no code: the mode's review of the work does not apply. + if crate::factory::is_planning_chat(&app, &session) { + agent.refine = None; + } let clean_room = session.clean_room(app.config().craft.clean_room); // The craft prompt follows the session's clean room / deep switch. if agent.name == "craft" && agent.source == "builtin" {