Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
0.8.0 P9: a visible change shows before and after; a visible complaint is a change (#477)
Oleksandr Ivanchenko75a6059aff29
diff --git a/src/drivers/api.rs b/src/drivers/api.rsindex d8fa09c2..3bb26283 100644--- a/src/drivers/api.rs+++ b/src/drivers/api.rs@@ -1989,6 +1989,73 @@ mod tests {}}+ /// P1 on the API engine itself (Rigel's QA of #470, open item 2): with approvals off, the+ /// requests the driver really sends, on both request formats, tell the bot to do the work+ /// instead of offering it, once, and never to wait for a card; the turn's "[What to deliver]"+ /// line for a visible fix asks for the before and after pictures.+ #[tokio::test]+ async fn an_approvals_off_turn_tells_the_api_model_to_do_the_work() {+ use crate::drivers::DO_DONT_OFFER;+ let complaint = "the button is not aligned with booktun.ing styling!!!!";+ for path in ["/v1/messages", "/v1/chat/completions"] {+ let seen: Seen = Arc::default();+ let reply = if path == "/v1/messages" {+ json!({"content": [{"type": "text", "text": "ok"}], "usage": {"input_tokens": 1, "output_tokens": 1}})+ } else {+ json!({"choices": [{"message": {"role": "assistant", "content": "ok"}}], "usage": {"prompt_tokens": 1, "completion_tokens": 1}})+ };+ let app = Router::new()+ .route(+ path,+ post(|State((seen, reply)): State<(Seen, Value)>, headers: HeaderMap, Json(body): Json<Value>| async move {+ seen.lock().unwrap().push((headers, body));+ Json(reply)+ }),+ )+ .with_state((seen.clone(), reply));+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();+ let url = format!("http://{}{path}", listener.local_addr().unwrap());+ tokio::spawn(async move { axum::serve(listener, app).await.unwrap() });+ let driver = ApiDriver::new(Some("sk-ant-test-key".into()), Some(url));+ let (tx, mut rx) = mpsc::channel(64);+ tokio::spawn(async move { while rx.recv().await.is_some() {} });++ let tmp = tempfile::tempdir().unwrap();+ let mut input = turn(complaint, vec![]);+ input.mcp = Some(crate::mcp::McpTurnContext {+ servers: vec![],+ approver: Arc::new(crate::mcp::FixedApprover(true)),+ config_dir: tmp.path().to_path_buf(),+ permission_url: None,+ gateway: None,+ max_tool_iterations: 4,+ approvals: crate::mcp::Approvals::Off,+ records: Default::default(),+ });+ input.delivery = Some(crate::router::delivery::keyword_plan(complaint, &[]));+ driver.stream_turn(input, tx).await.unwrap();++ let body = seen.lock().unwrap()[0].1.to_string();+ let sent: String = serde_json::from_str::<Value>(&body)+ .unwrap()+ .as_object()+ .unwrap()+ .iter()+ .filter(|(k, _)| *k == "system" || *k == "messages")+ .map(|(_, v)| v.to_string())+ .collect();+ // JSON escapes the quotes and newlines in the prompt text; compare escaped text+ let escaped = |t: &str| serde_json::to_string(t).unwrap().trim_matches('"').to_string();+ assert!(sent.contains("[Approvals: off]"), "{path}: {sent}");+ assert_eq!(sent.matches(&escaped(DO_DONT_OFFER)).count(), 1, "{path}: {sent}");+ for never in ["approval card first", "wait for their answer", "Ask for what you need"] {+ assert!(!sent.contains(never), "{path}: {never}");+ }+ assert_eq!(sent.matches("[What to deliver] A change to something the person looks at").count(), 1, "{path}");+ assert!(sent.contains("a before and after screenshot is shared in the chat"), "{path}");+ }+ }+/// A store holding `n` messages in conversation "t1", oldest first, ids "m1".."mN".async fn conversation(n: usize) -> (tempfile::TempDir, crate::db::Database, Vec<crate::db::models::Message>) {let tmp = tempfile::tempdir().unwrap();diff --git a/src/drivers/mod.rs b/src/drivers/mod.rsindex 3fcf0fed..74be2282 100644--- a/src/drivers/mod.rs+++ b/src/drivers/mod.rs@@ -1172,6 +1172,7 @@ pub(crate) mod tests {("Hey team! What some cool feature we can add?", Deliverable::Ideas),("show me mockup image", Deliverable::Visual),("Fix differences!", Deliverable::Change),+ ("the button is not aligned with booktun.ing styling!!!!", Deliverable::Change),("mobile sticky booking CTA -> what is this??", Deliverable::Explain),];for (msg, kind) in messages {diff --git a/src/router/delivery.rs b/src/router/delivery.rsindex 05b041da..ef4a6f2d 100644--- a/src/router/delivery.rs+++ b/src/router/delivery.rs@@ -17,7 +17,8 @@ pub enum Deliverable {Ideas,/// "Show me", "a mockup", "a screenshot": an image shared in the chat.Visual,- /// "Fix …", "add …": the change made on a branch, checked, with a PR.+ /// "Fix …", "add …", "the button is not aligned!!": the change made on a branch, checked, with+ /// a PR; with a before and after picture when it's something the person looks at.Change,/// A question: a direct answer grounded in the project.Explain,@@ -103,6 +104,19 @@ impl DeliveryPlan {Self { kind, show, who: Vec::new(), done_when, source, firm: true }}+ /// The plan for a change to something the person looks at (a button, the styling, a page):+ /// the PR link and a before and after picture.+ pub fn visible_change(source: PlanSource) -> Self {+ Self {+ kind: Deliverable::Change,+ show: vec![Show::Link, Show::Image],+ who: Vec::new(),+ done_when: vec!["the PR link is in the reply".into(), BEFORE_AFTER_DONE.into()],+ source,+ firm: true,+ }+ }+/// Whether the person should get an image in the chat.pub fn wants_picture(&self) -> bool {self.show.contains(&Show::Image)@@ -116,6 +130,10 @@ impl DeliveryPlan {would change and a rough effort, and a mockup of each rendered in the browser with the project's real CSS, \screenshotted and shared in the chat. End with one recommendation and one choice card for which to build.",Deliverable::Visual => "Something to see: render it and share the image in the chat, every time; describing it isn't enough.",+ // A change to something they look at, whichever planner said so+ Deliverable::Change if self.wants_picture() => "A change to something the person looks at: screenshot it before \+ you change it, make the change on a branch, run the checks, open the PR and screenshot it after. Share both \+ pictures in the chat, put the PR link in the reply, and say what you did and what you checked.",Deliverable::Change => "A change: make it on a branch, run the checks, open the PR and share a screenshot if the UI \changed, then report what you did and what you checked.",Deliverable::Explain => "An answer: answer directly, grounded in the project's files or site.",@@ -133,6 +151,9 @@ impl DeliveryPlan {}}+/// The check a visible change adds.+pub const BEFORE_AFTER_DONE: &str = "a before and after screenshot is shared in the chat";+/// Words that ask for ideas on their own.const IDEA_WORDS: &[&str] = &["idea", "ideas", "suggest", "suggestion", "suggestions", "improve", "improvement", "improvements", "brainstorm",@@ -206,6 +227,55 @@ const PRAISE: &[&str] = &["good", "great", "fine", "nice", "perfect", "amazing", "awesome", "cool", "beautiful", "excellent", "ok", "okay","right", "wonderful", "brilliant", "fantastic", "gorgeous", "neat", "sweet", "lovely",];+/// Words that name something the person looks at: a change to it carries a before and after+/// picture ("fix the button", "the styling is off"), unlike an export feature or a login bug.+const VISIBLE_WORDS: &[&str] = &[+ "button", "buttons", "align", "aligned", "aligns", "alignment", "misaligned", "unaligned", "style", "styles",+ "styling", "styled", "stylesheet", "css", "colour", "colours", "color", "colors", "font", "fonts", "typography",+ "design", "designs", "layout", "layouts", "spacing", "margin", "margins", "padding", "header", "headers",+ "footer", "footers", "page", "pages", "mobile", "screen", "screens", "look", "looks", "ui", "logo", "icon",+ "icons", "theme", "navbar", "banner", "card", "cards",+];+/// "style" in these is code style, not looks: "fix the code style", "the lint style".+const CODE_STYLE_WORDS: &[&str] = &["code", "lint", "linter", "clippy", "rustfmt", "prettier", "eslint", "format", "formatting"];+const STYLE_WORDS: &[&str] = &["style", "styles", "styling", "styled"];+/// "look" before these isn't about looks: "look at the logs", "it looks like the export fails".+const NOT_LOOKS_AFTER: &[&str] = &["at", "into", "for", "like", "up", "through", "over"];+/// Words that say something is wrong with it: with a [`VISIBLE_WORDS`] word, a statement is a+/// request to fix it ("the button is not aligned with booktun.ing styling!!!!").+const DEFECT_WORDS: &[&str] = &[+ "wrong", "broken", "misaligned", "unaligned", "off", "ugly", "overlap", "overlaps", "overlapping",+ "inconsistent", "mismatch", "mismatched", "differences", "different", "weird", "messy", "cropped", "crooked",+ "blurry", "bad", "missing", "cut", "bug", "buggy", "glitch", "glitchy",+];+/// Negations that say something is wrong only when they negate how it looks ([`LOOKS_STATES`]):+/// "is not aligned", "doesn't look right"; not "No, the design is fine" or "don't touch the design".+const LOOKS_NEGATIONS: &[&str] =+ &["not", "isn't", "isnt", "aren't", "arent", "doesn't", "doesnt", "don't", "dont", "no"];+/// Words skipped between a negation and the state it negates: "isn't really aligned".+const NEGATION_SKIP: &[&str] =+ &["be", "is", "are", "quite", "really", "very", "properly", "fully", "correctly"];+/// How something should look, so that negated it is a defect.+const LOOKS_STATES: &[&str] = &[+ "aligned", "align", "centered", "centred", "match", "matching", "matches", "consistent", "visible", "showing",+ "show", "shown", "load", "loading", "loads", "work", "working", "works", "fit", "fits", "responsive", "readable",+ "right", "correct", "same", "look", "looks", "displayed", "display", "displaying", "render", "rendering",+];+/// "right" before these is a time or place, not how it looks: "not right now", "not right away".+const NOT_LOOKS_RIGHT_AFTER: &[&str] = &["now", "away", "here", "there"];+/// Words that negate a change verb right after them ("please don't change the footer"); "no need+/// to" is matched as a pair, and a "to" before the verb is skipped ("not to change").+const VERB_NEGATIONS: &[&str] = &["don't", "dont", "not", "never"];+/// Defect words that ask for a fix on their own, in a statement ("differences again!!"), as+/// "Fix differences!" does with its verb.+const DEFECT_ASKS: &[&str] = &["differences", "misaligned", "unaligned"];+/// What a bare change ("fix it", "Fix differences!") is made of besides its verb: nothing names+/// what it is about, so the person's earlier message does.+const BARE_OBJECTS: &[&str] = &[+ "it", "this", "that", "these", "those", "them", "differences", "difference", "issue", "issues", "problem",+ "problems", "everything", "all", "both", "same", "again", "asap", "up", "one", "ones", "thing", "things", "there",+ "here", "right", "away", "already", "too",+];/// A "no" makes a clause more than thanks: "this is not good".const NEGATIONS: &[&str] =&["not", "no", "nope", "don't", "dont", "isn't", "doesn't", "never", "can't", "won't", "wrong", "broken"];@@ -269,30 +339,172 @@ fn without_acknowledgements(text: &str) -> Option<String> {/// oldest first: a short follow-up with nothing of its own to go on ("more", "and the other one")/// expects what the last of them did. A greeting, a thank-you or an acknowledgement ("lgtm",/// "love it") is [`Deliverable::Other`] and inherits nothing; so is a statement nothing matched-/// ("the button is not aligned!!"): only a question gets [`Deliverable::Explain`].+/// ("the login is slow"). A complaint about something visible ("the button is not aligned!!") is+/// a [`Deliverable::Change`]; only a question gets [`Deliverable::Explain`].pub fn expected_kind(prompt: &str, recent: &[&str]) -> Deliverable {+ plan_kind(prompt, recent).0+}++/// The fast plan for every turn, from the message's words alone (no model call): its kind, what+/// to show and the plain checks for it. A change to something the person looks at shows a before+/// and after picture ([`DeliveryPlan::visible_change`]). `who` stays empty; Juno's analyzer fills+/// it for team chats. It is firm or lean ([`DeliveryPlan::firm`], see [`asks_firmly`]): a+/// complaint with no change verb ("the button is not aligned!!") is a lean visible Change, while+/// "fix it" / "Fix differences!" after it is firm.+pub fn keyword_plan(prompt: &str, recent: &[&str]) -> DeliveryPlan {+ let (kind, visible) = plan_kind(prompt, recent);+ let firm = text_that_gave(kind, prompt, recent).is_some_and(|t| asks_firmly(&t, kind));+ let base = if kind == Deliverable::Change && visible {+ DeliveryPlan::visible_change(PlanSource::Keywords)+ } else {+ DeliveryPlan::for_kind(kind, PlanSource::Keywords)+ };+ DeliveryPlan { firm, ..base }+}++/// The kind `prompt` expects, and for a change whether it's to something the person looks at:+/// its own words say so, or for a bare "fix it" / "Fix differences!" or a follow-up ("again"),+/// the person's last earlier message that asked for something.+fn plan_kind(prompt: &str, recent: &[&str]) -> (Deliverable, bool) {if super::team::is_small_talk(prompt) {- return Deliverable::Other;+ return (Deliverable::Other, false);+ }+ let Some(own) = without_acknowledgements(prompt) else { return (Deliverable::Other, false) };+ // "never mind", "no, stop": the person calls the last ask off, so nothing inherits it+ if super::team::is_small_talk(&own) || calls_it_off(&own) {+ return (Deliverable::Other, false);}- let Some(own) = without_acknowledgements(prompt) else { return Deliverable::Other };- if super::team::is_small_talk(&own) {- return Deliverable::Other;+ // The last earlier ask, and its words+ let earlier = || recent.iter().rev().find_map(|m| without_acknowledgements(m).and_then(|t| classify(&t).map(|k| (k, t))));+ match classify(&own) {+ Some(Deliverable::Change) => {+ let visible = names_something_visible(&own)+ || (is_bare_change(&own) && earlier().is_some_and(|(_, t)| names_something_visible(&t)));+ (Deliverable::Change, visible)+ }+ Some(kind) => (kind, false),+ None if super::team::reads_as_follow_up(&own) => match earlier() {+ Some((kind, t)) => (kind, kind == Deliverable::Change && names_something_visible(&t)),+ None => (Deliverable::Other, false),+ },+ None => (Deliverable::Other, false),}- classify(&own).unwrap_or_else(|| {- let inherited = super::team::reads_as_follow_up(&own)- .then(|| recent.iter().rev().find_map(|m| without_acknowledgements(m).and_then(|t| classify(&t))))- .flatten();- inherited.unwrap_or(Deliverable::Other)+}++/// Words that call the work off ("stop", "never mind", "forget it", "leave it as is").+const STOP_ASKS: &[&str] = &[+ "stop", "cancel", "abort", "nevermind", "nvm", "mind", "forget", "leave", "wait", "hold", "skip", "pause", "halt",+ "don't", "dont",+];+/// Words that may stand around a [`STOP_ASKS`] word in a message that only calls the work off.+const STOP_FILLER: &[&str] = &[+ "no", "never", "it", "that", "this", "on", "for", "the", "moment", "actually", "oh", "sorry", "thanks", "all",+ "everything", "as", "is", "anymore", "there",+];++/// Whether a short message only calls the work off: "stop", "never mind", "no, stop", "ok forget it",+/// "hold on", "cancel that". Short replies otherwise read as follow-ups and inherit the last ask, so+/// without this "never mind" after "fix the header" would plan a firm Change that commits and pushes.+fn calls_it_off(text: &str) -> bool {+ let words = tokens(text);+ words.len() <= 6+ && words.iter().any(|w| STOP_ASKS.contains(&w.as_str()))+ && words.iter().all(|w| {+ let w = w.as_str();+ STOP_ASKS.contains(&w) || STOP_FILLER.contains(&w) || LEAD_IN.contains(&w)+ })+}++/// Whether `text` names something the person looks at (see [`VISIBLE_WORDS`]).+fn names_something_visible(text: &str) -> bool {+ let words = tokens(text);+ let code_style = any_in(&words, CODE_STYLE_WORDS);+ words.iter().enumerate().any(|(i, w)| {+ let w = w.as_str();+ if !VISIBLE_WORDS.contains(&w) || (code_style && STYLE_WORDS.contains(&w)) {+ return false;+ }+ // "look at the logs", "it looks like the export fails"+ let next = words.get(i + 1).map(String::as_str);+ !(matches!(w, "look" | "looks") && next.is_some_and(|n| NOT_LOOKS_AFTER.contains(&n)))})}-/// The fast plan for every turn, from the message's words alone (no model call): its kind, what-/// to show and the plain checks for it. `who` stays empty; Juno's analyzer fills it for team chats.-/// It is firm or lean ([`DeliveryPlan::firm`], see [`asks_firmly`]).-pub fn keyword_plan(prompt: &str, recent: &[&str]) -> DeliveryPlan {- let kind = expected_kind(prompt, recent);- let firm = text_that_gave(kind, prompt, recent).is_some_and(|t| asks_firmly(&t, kind));- DeliveryPlan { firm, ..DeliveryPlan::for_kind(kind, PlanSource::Keywords) }+/// Whether a change ask names nothing but its verb and a pointer back ("fix it", "Fix differences!").+fn is_bare_change(text: &str) -> bool {+ tokens(text).iter().all(|w| {+ let w = w.as_str();+ LEAD_IN.contains(&w) || CHANGE_VERBS.contains(&w) || ARTICLES.contains(&w) || BARE_OBJECTS.contains(&w)+ })+}++/// Whether `text` is a statement that something visible is wrong ("the button is not aligned+/// with booktun.ing styling!!!!", "the colours are off on mobile"), not a question about it.+fn complains_about_something_visible(text: &str) -> bool {+ has_defect(text) && names_something_visible(text)+}++/// Whether `text` says something is wrong in any clause: an explicit defect word ("broken", "off"), a negated+/// looks state ("is not aligned", "doesn't match"), or "too" before a word that isn't praise+/// ("too small"; not "looks good too").+fn has_defect(text: &str) -> bool {+ text.split([',', '.', ';', '!', '?', '\n', '\r']).any(|clause| clause_has_defect(&tokens(clause)))+}++/// [`has_defect`] for one clause. A negation that opens the clause is an instruction, not a+/// complaint ("don't look at the footer yet", "please do not work on the mobile page"), and "right"+/// before "now", "away", "here" or "there" is a time or place, not how it looks ("not right now").+fn clause_has_defect(words: &[String]) -> bool {+ let opening = opening_negation(words);+ words.iter().enumerate().any(|(i, w)| {+ let w = w.as_str();+ if DEFECT_WORDS.contains(&w) {+ return true;+ }+ if w == "too" {+ return words.get(i + 1).is_some_and(|n| !PRAISE.contains(&n.as_str()));+ }+ if !LOOKS_NEGATIONS.contains(&w) || opening == Some(i) {+ return false;+ }+ let Some(j) = (i + 1..words.len()).find(|&j| !NEGATION_SKIP.contains(&words[j].as_str())) else {+ return false;+ };+ let state = words[j].as_str();+ LOOKS_STATES.contains(&state)+ && !(state == "right" && words.get(j + 1).is_some_and(|n| NOT_LOOKS_RIGHT_AFTER.contains(&n.as_str())))+ })+}++/// The index of the negation that opens a clause after its [`LEAD_IN`] words: don't, dont, never,+/// or the "not" of "do not". "the buttons don't work on mobile" has none: "the buttons" comes first.+fn opening_negation(words: &[String]) -> Option<usize> {+ let i = words.iter().position(|w| !LEAD_IN.contains(&w.as_str()))?;+ match words[i].as_str() {+ "don't" | "dont" | "never" => Some(i),+ "do" if words.get(i + 1).is_some_and(|n| n == "not") => Some(i + 1),+ _ => None,+ }+}++/// Whether the word at `i` (a change verb) is negated: "don't change", "do not change", "never+/// change", "not to change", "no need to change". "don't forget to fix" is not: "forget" stands+/// between them.+fn is_negated(words: &[String], i: usize) -> bool {+ let at = |j: usize| words.get(j).map(String::as_str);+ let Some(mut j) = i.checked_sub(1) else { return false };+ if at(j) == Some("to") {+ let Some(k) = j.checked_sub(1) else { return false };+ j = k;+ }+ at(j).is_some_and(|w| VERB_NEGATIONS.contains(&w))+ || (at(j) == Some("need") && j.checked_sub(1).is_some_and(|k| at(k) == Some("no")))+}++/// Whether `words` asks for a change with a verb that isn't negated ("please don't change the+/// footer" asks for nothing).+fn has_change_verb(words: &[String]) -> bool {+ words.iter().enumerate().any(|(i, w)| CHANGE_VERBS.contains(&w.as_str()) && !is_negated(words, i))}/// The words [`expected_kind`] read `kind` from: the message without its thanks, or for a@@ -408,13 +620,16 @@ fn classify(text: &str) -> Option<Deliverable> {return None;}let joined = words.join(" ");- let mut after_lead_in = words.iter().skip_while(|w| LEAD_IN.contains(&w.as_str()));+ let lead_in = words.iter().take_while(|w| LEAD_IN.contains(&w.as_str())).count();+ let mut after_lead_in = words.iter().skip(lead_in);let first = after_lead_in.next();let is_question_word = |w: &String| QUESTION_WORDS.contains(&w.as_str());let opens_with_question = words.first().is_some_and(is_question_word) || first.is_some_and(is_question_word);// A leading change verb wins over idea and picture words after it: "Please add the export// feature", "Fix the broken image on the home page", "can you add a footer?" ask for the work.- if let Some(verb) = first.filter(|w| !opens_with_question && CHANGE_VERBS.contains(&w.as_str())) {+ if let Some(verb) = first+ .filter(|w| !opens_with_question && CHANGE_VERBS.contains(&w.as_str()) && !is_negated(&words, lead_in))+ {// ...unless what it makes is the picture itself: "make a mockup", "create me a screenshot"let object = after_lead_in.find(|w| !ARTICLES.contains(&w.as_str()));if MAKE_VERBS.contains(&verb.as_str()) && object.is_some_and(|w| PICTURE_WORDS.contains(&w.as_str())) {@@ -426,6 +641,17 @@ fn classify(text: &str) -> Option<Deliverable> {if any_in(&words, IDEA_WORDS) || feature_ask || IDEA_PHRASES.iter().any(|p| joined.contains(p)) {return Some(Deliverable::Ideas);}+ // A complaint about something visible asks for the fix ("the button is not aligned with+ // booktun.ing styling!!!!"); a question about it ("why it not aligned…???") asks why, and+ // "show me the broken footer" asks to see it.+ let question = text.contains('?') || opens_with_question;+ let asks_to_see = joined.contains("show me")+ || joined.contains("show us")+ || first.is_some_and(|w| SEE_WORDS.contains(&w.as_str()))+ || any_in(&words, PICTURE_WORDS);+ if !question && !asks_to_see && complains_about_something_visible(text) {+ return Some(Deliverable::Change);+ }if any_in(&words, SEE_WORDS) || joined.contains("how it looks") || joined.contains("what it looks like") {return Some(Deliverable::Visual);}@@ -433,10 +659,10 @@ fn classify(text: &str) -> Option<Deliverable> {return Some(Deliverable::Visual);}// "no, just explain it"- if text.contains('?') || opens_with_question || any_in(&words, &["explain", "clarify"]) {+ if question || any_in(&words, &["explain", "clarify"]) {return Some(Deliverable::Explain);}- if any_in(&words, CHANGE_VERBS) {+ if has_change_verb(&words) || any_in(&words, DEFECT_ASKS) {return Some(Deliverable::Change);}None@@ -449,30 +675,220 @@ mod tests {#[test]fn his_messages_map_to_what_they_ask_for() {- // Oleks's messages from the 2026-11-09 chat, verbatim (release-080/proactive/conversation-2026-11-09.md)- let cases = [- ("Hey team! What some cool feature we can add?", Ideas),- ("mobile sticky booking CTA -> what is this??", Explain),- ("Wtf we need it for booktun.ing???", Explain),- ("show me how it lloks on page", Visual),- (- "i want to see this ---> The phone \"Find your book\" bar stays parked in Growth's backlog until analytics is connected.",- Visual,- ),- ("show me mockup image", Visual),- ("Screenshot give me!", Visual),- ("Show mw screenshot in chat!!", Visual),- ("why it not aligned with booktun.ing styling???", Explain),- // A statement nothing matched: no hint rather than "answer directly"- ("the button is not aligned with booktun.ing styling!!!!", Other),- ("Fix differences!", Change),+ use Show::{Image, Link, Text};+ let phone_bar = "i want to see this ---> The phone \"Find your book\" bar stays parked in Growth's backlog until analytics is connected.";+ // Oleks's messages from the 2026-11-09 chat, verbatim and in order, each planned with the+ // ones before it as `recent` (release-080/proactive/conversation-2026-11-09.md). He sent+ // the phone bar message twice.+ let sends: [(&str, Deliverable, &[Show]); 12] = [+ ("Hey team! What some cool feature we can add?", Ideas, &[Image, Text]),+ ("mobile sticky booking CTA -> what is this??", Explain, &[Text]),+ ("Wtf we need it for booktun.ing???", Explain, &[Text]),+ ("show me how it lloks on page", Visual, &[Image]),+ (phone_bar, Visual, &[Image]),+ (phone_bar, Visual, &[Image]),+ ("show me mockup image", Visual, &[Image]),+ ("Screenshot give me!", Visual, &[Image]),+ ("Show mw screenshot in chat!!", Visual, &[Image]),+ ("why it not aligned with booktun.ing styling???", Explain, &[Text]),+ // A complaint about something visible: fix it, with a before and after picture+ ("the button is not aligned with booktun.ing styling!!!!", Change, &[Link, Image]),+ // Bare: what it fixes is the button in his message before+ ("Fix differences!", Change, &[Link, Image]),];- for (msg, want) in cases {- let plan = keyword_plan(msg, &[]);- assert_eq!(plan.kind, want, "{msg}");+ let msgs: Vec<&str> = sends.iter().map(|s| s.0).collect();+ for (i, (msg, kind, show)) in sends.iter().enumerate() {+ let plan = keyword_plan(msg, &msgs[..i]);+ assert_eq!(plan.kind, *kind, "{msg}");+ assert_eq!(plan.show, show.to_vec(), "{msg}");assert_eq!(plan.source, PlanSource::Keywords);assert!(plan.who.is_empty());+ let before_after = plan.done_when.iter().any(|d| d == BEFORE_AFTER_DONE);+ assert_eq!(before_after, *kind == Change, "{msg}: {:?}", plan.done_when);+ if *kind == Change {+ assert!(plan.wants_picture(), "{msg}");+ assert!(plan.hint().contains("screenshot it before you change it"), "{msg}: {}", plan.hint());+ }+ }+ }++ #[test]+ fn a_change_to_something_visible_shows_before_and_after() {+ // Rigel's QA of #470 open item 1: "fix the misaligned button" pushed with no picture+ // A change verb leads: firm. A complaint with no verb leading it: lean (Ada's #469 decision).+ for (msg, firm) in [+ ("fix the misaligned button", true),+ ("Fix the design of the footer", true),+ ("make the header font bigger", true),+ ("change the CSS so the cards have more padding", true),+ ("update the colours on the pricing page", true),+ ("fix the layout on mobile", true),+ ("the button is too small, make it bigger", false),+ ("the spacing in the footer is off", false),+ ("the colours are wrong on mobile", false),+ ("the login page is broken", false),+ ("it looks bad on my screen", false),+ ("the margins are inconsistent", false),+ ("the logo is cropped", false),+ ] {+ let plan = keyword_plan(msg, &[]);+ assert_eq!(plan.kind, Change, "{msg}");+ assert_eq!(plan.show, vec![Show::Link, Show::Image], "{msg}");+ assert_eq!(plan.done_when, vec!["the PR link is in the reply".to_string(), BEFORE_AFTER_DONE.to_string()], "{msg}");+ assert_eq!(plan, DeliveryPlan { firm, ..DeliveryPlan::visible_change(PlanSource::Keywords) }, "{msg}");+ let hint = plan.hint();+ assert!(hint.contains("screenshot it before you change it"), "{msg}: {hint}");+ assert!(hint.contains("screenshot it after. Share both pictures in the chat, put the PR link in the reply"), "{hint}");+ assert!(hint.contains("Show in the chat: a link (the PR or page), an image."), "{hint}");+ assert!(hint.contains("Done when: the PR link is in the reply; a before and after screenshot is shared in the chat."), "{hint}");+ }+ // Nothing to look at: the PR link, no picture expected+ for msg in [+ "Please add the export feature",+ "fix the login bug",+ "please update the README",+ "Add a screenshot to the README",+ "delete the old dark image",+ "fix the code style",+ "Please fix the login bug, see the log below",+ "fix the crash, look at the logs",+ "fix it, it looks like the export fails",+ "refactor the router",+ "Fix it",+ "Fix differences!",+ "differences again!!",+ ] {+ let plan = keyword_plan(msg, &[]);+ assert_eq!(plan.kind, Change, "{msg}");+ assert_eq!(plan, DeliveryPlan { firm: plan.firm, ..DeliveryPlan::for_kind(Change, PlanSource::Keywords) }, "{msg}");+ assert!(!plan.wants_picture(), "{msg}");+ assert!(!plan.hint().contains("before you change it"), "{msg}");+ }+ }++ #[test]+ fn a_bare_fix_looks_at_what_was_asked_before() {+ let visible = DeliveryPlan::visible_change(PlanSource::Keywords);+ let link = DeliveryPlan::for_kind(Change, PlanSource::Keywords);+ // The earlier ask names something visible: the bare fix is about it+ assert_eq!(keyword_plan("Fix differences!", &["why it not aligned with booktun.ing styling???"]), visible);+ assert_eq!(keyword_plan("fix it", &["the header is cut off on mobile", "thanks!"]), visible);+ assert_eq!(keyword_plan("Fix it please", &["show me the footer"]), visible);+ // A follow-up keeps the earlier change and what it was about, and leans like it+ let lean_visible = DeliveryPlan { firm: false, ..visible.clone() };+ assert_eq!(keyword_plan("again", &["the button is not aligned with booktun.ing styling!!!!"]), lean_visible);+ // ...and the earlier ask names nothing visible: no picture+ assert_eq!(keyword_plan("fix it", &["why does the export fail?"]), link);+ assert_eq!(keyword_plan("again", &["please update the README"]), link);+ // A fix that names its own object doesn't borrow the earlier one's+ assert_eq!(keyword_plan("fix the login bug", &["the button is not aligned!!"]), link);+ // Only the last ask counts, not one further back+ assert_eq!(keyword_plan("fix it", &["the header is off", "why does the export fail?"]), link);+ }++ #[test]+ fn complaints_questions_and_thanks() {+ // A complaint about something visible is a request to fix it, with Rigel's QA wordings+ for msg in [+ "the button is not aligned with booktun.ing styling!!!!",+ "the button is not aligned!!",+ "The header isn't aligned with the logo",+ "the footer doesn't match the site styling",+ "the cards are misaligned",+ "differences in the button styling!!",+ "the dark theme looks wrong",+ ] {+ let lean_visible = DeliveryPlan { firm: false, ..DeliveryPlan::visible_change(PlanSource::Keywords) };+ assert_eq!(keyword_plan(msg, &[]), lean_visible, "{msg}");+ }+ // A question about it asks why+ for msg in [+ "why it not aligned with booktun.ing styling???",+ "why is the button not aligned?",+ "is the header wrong on mobile?",+ ] {+ assert_eq!(expected_kind(msg, &[]), Explain, "{msg}");+ }+ // Asking to see it is still something to see+ assert_eq!(expected_kind("show me the broken footer", &[]), Visual);+ assert_eq!(expected_kind("screenshot of the misaligned button please", &[]), Visual);+ // Praise and statements with nothing wrong in them ask for nothing+ for msg in ["Thanks, looks great!", "the button looks good", "the header is fine now, thanks", "the login is slow"] {+ assert_ne!(expected_kind(msg, &[]), Change, "{msg}");+ }+ assert_eq!(expected_kind("Thanks, looks great!", &[]), Other);+ assert_eq!(expected_kind("the login is slow", &[]), Other);+ }++ #[test]+ fn leave_it_alone_is_not_a_change() {+ // Ada's review of #477, M1: a "no", "not", "don't" or "too" that doesn't say how something+ // looks is not a complaint. M2: a negated change verb doesn't ask for the change.+ for msg in [+ "No, the design is fine",+ "don't touch the design",+ "the button looks good, no changes needed",+ "the new page looks good too",+ "the mobile page can wait, not now",+ "no need to change the header, I'm on it",+ "please don't change the footer",+ "do not change the footer",+ "never change the logo",+ "it's fine, not to change the header",+ // M3: "right now" is a time, and a clause that opens with a negation is an instruction+ "the mobile page can wait, not right now",+ "not right now, the header is fine",+ "the header can wait, not right away",+ "don't look at the footer yet",+ "don't work on the mobile page yet",+ "ok, do not look at the header yet",+ ] {+ let plan = keyword_plan(msg, &[]);+ assert_ne!(plan.kind, Change, "{msg}");+ assert!(!plan.done_when.iter().any(|d| d == BEFORE_AFTER_DONE), "{msg}");+ assert!(!plan.hint().contains("before you change it"), "{msg}");+ }+ // "looks" leans visual, as on main: something to see, never a change+ assert_eq!(expected_kind("the new page looks good too", &[]), Visual);+ assert_eq!(expected_kind("the mobile page can wait, not now", &[]), Other);+ assert_eq!(expected_kind("please don't change the footer", &[]), Other);+ // Not even after an earlier visible ask+ let recent = ["the button is not aligned with booktun.ing styling!!!!"];+ for msg in ["no need to change the header, I'm on it", "please don't change the footer"] {+ assert_ne!(expected_kind(msg, &recent), Change, "{msg}");}+ // Negations of how it looks, and "too" before a non-praise word, still complain+ for msg in [+ "the button is too small, make it bigger",+ "the header is too big",+ "The header isn't aligned with the logo",+ "the logo is not really centered",+ "the footer doesn't look right on mobile",+ "the cards are not properly aligned",+ "the font doesn't fit on the screen",+ "the header is not right",+ "the buttons don't work on mobile",+ "the page is not loading",+ "the colours don't match the brand",+ "too many buttons on the page",+ "the header is fine. the footer doesn't look right on mobile",+ ] {+ let lean_visible = DeliveryPlan { firm: false, ..DeliveryPlan::visible_change(PlanSource::Keywords) };+ assert_eq!(keyword_plan(msg, &[]), lean_visible, "{msg}");+ }+ // A change verb with something else between it and the negation is still asked for (lean:+ // no verb leads it, #469's rule)+ let plan = keyword_plan("don't forget to fix the header", &[]);+ assert_eq!(plan, DeliveryPlan { firm: false, ..DeliveryPlan::visible_change(PlanSource::Keywords) });+ assert_eq!(expected_kind("don't forget to update the README", &[]), Change);+ // Accepted in review: an opening "don't" reads as an instruction, so hiding is not a Change+ assert_ne!(expected_kind("please don't show the banner on mobile", &[]), Change);+ assert_eq!(opening_negation(&tokens("please do not look at it")), Some(2));+ assert_eq!(opening_negation(&tokens("the buttons don't work")), None);+ assert!(is_negated(&tokens("no need to change it"), 3));+ assert!(is_negated(&tokens("do not change it"), 2));+ assert!(!is_negated(&tokens("change it"), 0));+ assert!(!is_negated(&tokens("to change it"), 1));}#[test]@@ -491,7 +907,9 @@ mod tests {("why does the build fail?", Explain),("How do I fix this?", Explain),("can you explain the router?", Explain),- ("the login page is broken", Other),+ // A complaint about a page: fix it (with a before and after picture)+ ("the login page is broken", Change),+ ("the login is slow", Other),("send the newsletter", Other),("thanks!", Other),("ok, go ahead", Other),@@ -699,6 +1117,12 @@ mod tests {assert!(ideas.hint().contains("Done when: one mockup image per idea is shared in the chat."));assert!(DeliveryPlan::for_kind(Visual, PlanSource::Keywords).wants_picture());assert!(!DeliveryPlan::for_kind(Change, PlanSource::Keywords).wants_picture());+ let visible = DeliveryPlan::visible_change(PlanSource::Keywords);+ assert!(visible.wants_picture());+ assert!(visible.hint().starts_with("\n\n[What to deliver] A change to something the person looks at:"));+ assert!(!visible.hint().trim().contains('\n'));+ let plain = DeliveryPlan::for_kind(Change, PlanSource::Keywords).hint();+ assert!(plain.contains("share a screenshot if the UI changed") && !plain.contains("before you change it"), "{plain}");// Another planner's plan renders the same way, with its own show and checkslet analyzer = DeliveryPlan {kind: Change,@@ -710,6 +1134,8 @@ mod tests {};let hint = analyzer.hint();assert!(hint.contains("Show in the chat: a link (the PR or page), an image. Done when: the branch is pushed."), "{hint}");+ // An analyzer's Change with an image gets the before and after wording too+ assert!(hint.contains("screenshot it before you change it"), "{hint}");// It round-trips as JSON, for the analyzer's output and the turn's recordlet json = serde_json::to_string(&analyzer).unwrap();assert!(json.contains("\"kind\":\"change\"") && json.contains("\"source\":\"analyzer\""), "{json}");@@ -779,4 +1205,59 @@ mod tests {assert!(!carried(lean.clone()));assert!(carried(DeliveryPlan::for_kind(Visual, PlanSource::Analyzer)));}++ /// #477 on #469 (Ada's decision): a complaint with no change verb is a lean visible Change, so+ /// it never continues on its own; "Fix differences!" after it is a firm one.+ #[test]+ fn a_complaint_leans_and_a_fix_after_it_is_firm() {+ let complaint = "the button is not aligned with booktun.ing styling!!!!";+ let visible = DeliveryPlan::visible_change(PlanSource::Keywords);+ assert_eq!(keyword_plan(complaint, &[]), DeliveryPlan { firm: false, ..visible.clone() });+ assert_eq!(keyword_plan("Fix differences!", &[complaint]), visible);+ assert!(keyword_plan("Fix differences!", &[complaint]).firm);+ // expected_kind agrees with the plan's kind+ assert_eq!(expected_kind(complaint, &[]), Change);+ assert_eq!(expected_kind("Fix differences!", &[complaint]), Change);+ }++ /// A short "stop" or "never mind" after a firm Change (say one the person stopped) calls it+ /// off: it reads as a follow-up by length, but must not inherit the Change and its push.+ #[test]+ fn calling_it_off_inherits_nothing() {+ let other = DeliveryPlan { firm: false, ..DeliveryPlan::for_kind(Other, PlanSource::Keywords) };+ for recent in [&["fix the header button"][..], &["Fix differences!"][..], &["please add the export feature"][..]] {+ assert_eq!(keyword_plan(recent[0], &[]).kind, Change, "{recent:?}");+ for msg in [+ "never mind",+ "nevermind",+ "stop",+ "Stop!",+ "no, stop",+ "ok forget it",+ "cancel that",+ "hold on",+ "wait",+ "leave it as is",+ "nvm",+ "sorry, never mind",+ ] {+ assert!(calls_it_off(msg), "{msg}");+ assert_eq!(keyword_plan(msg, recent), other, "{msg} after {recent:?}");+ assert_eq!(expected_kind(msg, recent), Other, "{msg} after {recent:?}");+ let p = plan_for_turn(TurnPlanInput {+ person_message: Some(msg),+ recent,+ git_repo: true,+ ..Default::default()+ });+ assert!(p.as_ref().is_none_or(|p| p.kind != Change && !p.firm), "{msg} after {recent:?}: {p:?}");+ }+ }+ // Not a stop: a real follow-up, or a new ask that starts with one+ assert!(!calls_it_off("again"));+ assert!(!calls_it_off("hold on, fix the footer too"));+ assert!(!calls_it_off("stop the header animation"));+ assert_eq!(keyword_plan("again", &["fix the header button"]).kind, Change);+ assert_eq!(keyword_plan("wait, fix the footer instead", &["fix the header button"]).kind, Change);+ }}diff --git a/src/server/routes.rs b/src/server/routes.rsindex 3d38dfb7..83fa69b6 100644--- a/src/server/routes.rs+++ b/src/server/routes.rs@@ -6148,19 +6148,31 @@ mod tests {(prompt, last.filter(|_| history.is_empty()).unwrap())};// A statement the note would turn into "something to see": nothing to deliver, no expectation- let (prompt, current) = current_of("the login button colour is off");+ let (prompt, current) = current_of("the login is slow");assert!(keyword_plan(&prompt, &[]).wants_picture(), "the note's \"image/png\" reads as a picture ask");let plan = plan_of(&person_turn(), ¤t, true).expect("the person's words have a plan");assert_eq!(plan.kind, Deliverable::Other, "{plan:?}");assert_eq!(Expect::from_plan(&plan), None);- // "Fix the login button colour" + an attached image: the expectation is the person's words',- // a link to the change; the attachment adds no picture of its own- let (prompt, current) = current_of("Fix the login button colour");+ // A complaint about something visible is a lean visible Change from the person's words (#477)+ let (_, current) = current_of("the login button colour is off");+ let plan = plan_of(&person_turn(), ¤t, true).expect("the person's words have a plan");+ assert_eq!(plan, keyword_plan("the login button colour is off", &[]));+ assert!(plan.kind == Deliverable::Change && plan.wants_picture() && !plan.firm, "{plan:?}");+ // "Fix the login bug" + an attached image: the expectation is the person's words', a link to+ // the change; the attachment adds no picture of its own+ let (prompt, current) = current_of("Fix the login bug");let plan = plan_of(&person_turn(), ¤t, true).expect("a change in a git project");- assert_eq!(plan, keyword_plan("Fix the login button colour", &[]));+ assert_eq!(plan, keyword_plan("Fix the login bug", &[]));assert_eq!(plan.kind, keyword_plan(&prompt, &[]).kind, "a leading \"Fix\" wins either way");let expect = Expect::from_plan(&plan).unwrap();assert!(expect.link && !expect.image, "{expect:?}");+ // "Fix the login button colour" names something visible: its own words ask for before and+ // after pictures (#477), the same with or without the attachment note+ let (_, current) = current_of("Fix the login button colour");+ let plan = plan_of(&person_turn(), ¤t, true).expect("a change in a git project");+ assert_eq!(plan, keyword_plan("Fix the login button colour", &[]));+ let expect = Expect::from_plan(&plan).unwrap();+ assert!(expect.link && expect.image && expect.firm, "{expect:?}");// A message a bot sent through the chat API, a connected agent's, a bot's reply, or a turn// the person didn't start: no expectation