Factory: no review loop in planning chats

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Sonnet 5.5 committed 2026-11-16 13:21:34 +01:00
1 parent a9a98a25e7
commit fa6173d224
3 files changed
+31

No files matched your search

+20
View File
@@ -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<App>, user: &User, model: &str) -> Result<crate::types::Session> {
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");