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
failed-step-offers: offers don't count as Blocked; a failed step keeps the Approve chip (13a follow-up) (#639)
Oleksandr Ivanchenko49cddcacaf3b
diff --git a/frontend/src/approvalAsk.ts b/frontend/src/approvalAsk.tsindex 7afb5336..99479f69 100644--- a/frontend/src/approvalAsk.ts+++ b/frontend/src/approvalAsk.ts@@ -30,6 +30,18 @@ export function lastSentences(text: string, n = 2): string {return parts.slice(-n).join(' ');}+/**+ * True when a reply's meta rules out the Approve / Change… row: a question or a card of its own (`question_id`, `kind`),+ * or a Blocked reply (`blocked`), which shows as Blocked instead. Except a failed step's Blocked (`from: "failed_step"`,+ * 13a): it ends asking in the bot's own words ("If you approve it, I'll run it"), so the one-tap OK stays (Ada, Nov 14).+ */+export function metaHidesApprove(meta: Record<string, unknown> | null | undefined): boolean {+ if (!meta) return false;+ if (meta.question_id || meta.kind) return true;+ const blocked = meta.blocked as { from?: unknown } | null | undefined;+ return !!blocked && blocked.from !== 'failed_step';+}+/** True when the reply's last two sentences ask the person for an OK and nothing there says it's settled. */export function asksApproval(text: string | null | undefined): boolean {if (!text) return false;diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsxindex 6398bc32..cf2ae0f2 100644--- a/frontend/src/components/ChatView.tsx+++ b/frontend/src/components/ChatView.tsx@@ -80,7 +80,7 @@ import { ConnectionSuggestionMeta, parseConnectionMeta } from '../connectionSuggimport { routeReasonText, routeWhyText } from '../routeReason';import { useInbox } from '../inboxStore';import { doneItemsOf, doneOf } from '../replyDone';-import { APPROVE_TEXT, asksApproval, changePlaceholder } from '../approvalAsk';+import { APPROVE_TEXT, asksApproval, changePlaceholder, metaHidesApprove } from '../approvalAsk';import { DoneCheckLine } from './DoneMarker';import { ApproveRow } from './ApproveRow';import { CopyGhost } from './CopyGhost';@@ -1089,7 +1089,7 @@ export const ChatView: React.FC<ChatViewProps> = ({const last = messages[messages.length - 1];if (!last || last.sender_role !== 'kwant' || last.id.startsWith('temp-') || isStreaming || awaitingAnswer || pendingApprovals.length > 0) return null;const meta = parseMetaObject(last.meta);- if (meta && (meta.blocked || meta.question_id || meta.kind)) return null;+ if (metaHidesApprove(meta)) return null;return asksApproval(last.text) ? last.id : null;}, [messages, isStreaming, awaitingAnswer, pendingApprovals.length]);const approve = async (msg: ChatMessage) => {diff --git a/frontend/tests/replyChrome.test.mjs b/frontend/tests/replyChrome.test.mjsindex 8ac4ca3a..9e905d6e 100644--- a/frontend/tests/replyChrome.test.mjs+++ b/frontend/tests/replyChrome.test.mjs@@ -141,6 +141,23 @@ test('asksApproval looks only at the last two sentences', () => {assert.equal(m.asksApproval('Once you approve, I send it.\n\n```\nonce you approve\n```\nIt is live now. Nothing else to do.'), false);});+test('metaHidesApprove: a failed step\'s Blocked keeps the Approve row; any other Blocked, a question or a card hides it', () => {+ // Task 9's real ending after a refused step (13a): saved with meta.blocked from "failed_step"+ const t9 = "The command I tried was `python3 -m unittest`. If you approve it, I'll run it and report the result.";+ assert.equal(m.asksApproval(t9), true);+ assert.equal(m.metaHidesApprove({ blocked: { text: t9, from: 'failed_step' } }), false, 'failed_step keeps the chip');+ assert.equal(m.metaHidesApprove({ blocked: { text: 'no key for the Stripe API' } }), true, 'a plain Blocked: line still hides it');+ assert.equal(m.metaHidesApprove({ blocked: { text: 'x', from: 'keep_going' } }), true);+ assert.equal(m.metaHidesApprove({ blocked: { text: t9, from: 'failed_step' }, question_id: 'q1' }), true, 'a question has its own controls');+ assert.equal(m.metaHidesApprove({ kind: 'card' }), true);+ assert.equal(m.metaHidesApprove({}), false);+ assert.equal(m.metaHidesApprove(null), false);+ // ChatView's approveId reads it, instead of its own blocked/question/kind check+ const src = readFileSync(new URL('../src/components/ChatView.tsx', import.meta.url), 'utf8');+ assert.match(src, /if \(metaHidesApprove\(meta\)\) return null;/);+ assert.doesNotMatch(src, /meta\.blocked \|\| meta\.question_id/);+});+test('ApproveRow: a labelled group, Approve first, Change… second; both call back and lock while busy', async () => {const calls = [];const { host, unmount } = mount(ui.ApproveRow, { name: 'Ben', onApprove: () => calls.push('approve'), onChange: () => calls.push('change') });diff --git a/src/server/delivery_check.rs b/src/server/delivery_check.rsindex 99b95976..cdd44f11 100644--- a/src/server/delivery_check.rs+++ b/src/server/delivery_check.rs@@ -300,11 +300,12 @@ pub fn promise_line(reply: &str) -> Option<String> {/// "tell me to run it". Matched as whole words, and not in a sentence that opens with the bot's own/// plan ("I'll share…").const ASKS_PERSON: &[&str] = &["send me", "paste", "share", "upload", "allow", "approve", "sign in", "log in", "connect", "tell me"];-/// Offers, not waits: a reply that only offers ("Let me know if…", "If you'd like, I can…") goes on-/// without the person, so these words are taken out before looking for a wait.+/// Offers, not waits: a reply that only offers ("Let me know if…", "If you'd like, I can…", "Tell me if+/// you want…", "Whenever you're ready, tell me…") goes on without the person, so a sentence with one of+/// these is left out before looking for a wait (see [`asks_in`]).const OFFERS: &[&str] = &["let me know", "i'll be here", "if you want", "if you'd like", "if you would like", "if you like", "if you prefer",- "if you need anything",+ "if you need anything", "tell me if", "tell me whether", "whenever you're ready", "when you're ready",];/// How much of the ending [`waits_on_person`] keeps.const WAIT_CHARS: usize = 300;@@ -320,21 +321,25 @@ pub fn waits_on_person(reply: &str) -> Option<String> {}let para = reply.split("\n\n").map(str::trim).filter(|p| !p.is_empty()).last()?;let bare = para.lines().map(strip_markdown).filter(|l| !l.is_empty()).collect::<Vec<_>>().join(" ").replace(['’', '‘'], "'");- let mut lower = bare.to_ascii_lowercase();+ let lower = bare.to_ascii_lowercase();if lower.trim_end_matches(['*', '_', '`', ')', ' ']).ends_with('?') {return None;}- for offer in OFFERS {- lower = lower.replace(offer, "");- }- let waits = sentence_spans(&lower).into_iter().any(|(at, end)| {- let s = lower[at..end].trim_start();+ let waits = sentence_spans(&lower).into_iter().flat_map(|(at, end)| asks_in(&lower[at..end])).any(|s| {let planned = PROMISE_OPENERS.iter().any(|o| strip_leads(s).starts_with(o));NOT_A_PROMISE.iter().any(|w| s.contains(w)) || (!planned && ASKS_PERSON.iter().any(|w| has_words(s, w)))});waits.then(|| cut_at_word(&bare, WAIT_CHARS))}+/// The parts of one lowercased `sentence` that may wait on the person: its ", or " alternatives,+/// without the ones that hold an offer ([`OFFERS`]). The whole part goes, not just the offer's words,+/// so "Let me know once you've merged it" doesn't leave "once you…" behind. An alternative after ", or"+/// is its own ask: "Tell me if you want me to run it, or paste the output" still asks for the output.+fn asks_in(sentence: &str) -> impl Iterator<Item = &str> {+ sentence.split(", or ").map(str::trim_start).filter(|part| !OFFERS.iter().any(|o| has_words(part, o)))+}+/// What went wrong before a turn's own tool steps (13a), for [`failed_step_blocked`].#[derive(Debug, Clone, Copy, Default, PartialEq)]pub struct FailedBefore {@@ -1179,9 +1184,15 @@ mod tests {// Task 9 endings of the PR build after a declined card (decided replies, diag runs 2 and 3)"The real result is still unconfirmed. If you want it, run `cd work && python3 -m unittest`, or tell me to run it and I'll do so.","If you approve the command, I'll run it and confirm. You can also run `python3 -m unittest` in that folder and paste me the output.",+ // An offer next to a real ask: the ask after ", or" still waits (T9_PR_HELD's ending)+ "Tell me if you want me to run it, or paste the output and I'll check it against the table.",+ // Waits and asks that keep counting next to the offers below+ "I will try again once you approve the next card.",+ "Tell me to run it and I'll report the counts.",] {assert!(waits_on_person(ask).is_some(), "{ask}");}+ assert!(waits_on_person(T9_PR_HELD).is_some());// A promise ("I'll share…" is the bot's own plan), a Done: or Blocked: line, a question,// an offer, or a word that only contains an ask ("connection", "shared", "allowed")for not in [@@ -1192,6 +1203,14 @@ mod tests {"I can't reach the site. Should I try the mirror instead?","Here's the summary.\n\nLet me know if you want changes.","If you'd like, I can also add a chart.",+ // Offers with another opener (Rigel's S1/S2): the whole sentence goes, not just "let me know"+ "The draft is in the folder.\n\nLet me know when you've had a chance to review it.",+ "The draft is in the folder.\n\nLet me know once you've had a chance to review it.",+ "The notes are drafted.\n\nLet me know once you've merged it and I'll update the notes.",+ "The build is ready.\n\nWhenever you're ready, tell me and I'll deploy.",+ "The download failed.\n\nTell me if you want me to try a different mirror.",+ "The download failed.\n\nTell me whether you want me to try a different mirror.",+ "When you're ready, tell me and I'll ship it.","The connection failed, so I used the cached copy. The report is shared in the folder and the tests are allowed to run.","",] {