From a50d3cba4fca0042c8e88ab4c7194bac1dc82ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Thu, 19 Nov 2026 22:58:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AC=AC=E5=9B=9B=E8=BC=AA=E5=AF=A9?= =?UTF-8?q?=E6=9F=A5=E7=9A=84=E5=85=A9=E5=80=8B=20P2=E2=80=94=E2=80=94?= =?UTF-8?q?=E6=8F=90=E9=86=92=E6=9C=9F=E9=99=90=E5=9C=A8=E6=91=98=E8=A6=81?= =?UTF-8?q?=E4=B9=8B=E5=BE=8C=E6=89=8D=E8=B5=B7=E7=AE=97=E3=80=81=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E6=89=93=E7=9A=84=20/=E6=8C=87=E4=BB=A4=E9=80=81?= =?UTF-8?q?=E4=B8=8D=E5=87=BA=E6=99=82=E7=85=A7=E6=A8=A3=E6=94=BE=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 「說了就做」的提醒事件改在安靜步驟真正開始前送(在可能的摘要之後),摘要時間不再吃掉第一次回應的 120 秒 - 螢幕電腦:送不出的訊息是否放回輸入框改看來源(自己打的 typed/按鈕送的 mirror_command),不再看是不是 / 開頭;自己打的「/goal …」「/技能」加附件照樣放回 已驗證: cargo test 740 通過;verify-anybot chat.md「說了就做」重跑結果相同,ctl down 無殘留;第四輪乾淨脈絡審查(bca9203)沒有 P0/P1 未驗證: 本 commit 本身沒有再做獨立審查;螢幕電腦斷線路徑要帳號伺服器與第二台電腦 Co-Authored-By: Claude Opus 5.5 --- src/agent.rs | 8 +++++--- src/app.rs | 2 +- src/app/goal_ui.rs | 2 +- src/app/mirror_ui.rs | 22 +++++++++++++++++----- src/app/plan_ui.rs | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/agent.rs b/src/agent.rs index 0c98eb9..c0c881a 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -2142,7 +2142,11 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc< m.text.push_str(&format!("\n\n{note}")); } } - if !reuse_slot && !hush { + // A quiet step after a nudge has no bubble yet: its line and its first-response + // deadline start here, after any summary written above (not before it). + if hush { + send(StreamEvent::Nudged(followthrough::NUDGE_LINE.into())); + } else if !reuse_slot { send(StreamEvent::NextStep(via.clone())); } } @@ -2298,7 +2302,6 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc< if let Some(short) = again.filter(|_| !steered && nudged_in_a_row < followthrough::MAX_IN_A_ROW && nudged_total < followthrough::MAX_PER_TURN) { nudged_in_a_row += 1; nudged_total += 1; - send(StreamEvent::Nudged(followthrough::NUDGE_LINE.into())); history.push(msg); history.push(Message { wake: true, ..Message::user(&followthrough::nudge(short)) }); hush = true; @@ -2347,7 +2350,6 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc< nudged_in_a_row += 1; nudged_total += 1; log::info!("AnyBot:Bot 說了要做卻沒呼叫工具({short:?}),提醒它接著做(這一輪第 {nudged_total} 次)"); - send(StreamEvent::Nudged(followthrough::NUDGE_LINE.into())); history.push(Message { wake: true, ..Message::user(&followthrough::nudge(short)) }); hush = true; continue; diff --git a/src/app.rs b/src/app.rs index 24c75a7..98d4d89 100644 --- a/src/app.rs +++ b/src/app.rs @@ -2791,7 +2791,7 @@ impl App { Some(Mode::Goal) => self.goal_clear(ctx, bot.id), Some(Mode::Plan) => self.plan_clear(ctx, bot.id), Some(Mode::Always) if self.mir.on => { - self.mirror_send(bot.id, "/always-approve off".into(), vec![], None); + self.mirror_command(bot.id, "/always-approve off"); } Some(Mode::Always) => self.always_command(ctx, bot.id, crate::always::Command::Off), None => {} diff --git a/src/app/goal_ui.rs b/src/app/goal_ui.rs index b65877c..f2e7f4b 100644 --- a/src/app/goal_ui.rs +++ b/src/app/goal_ui.rs @@ -99,7 +99,7 @@ impl App { /// 清除目標 above the input: on a screen the brain clears it, as if typed there. pub(super) fn goal_clear(&mut self, ctx: &egui::Context, bot_id: u64) { if self.mir.on { - self.mirror_send(bot_id, "/goal clear".into(), vec![], None); + self.mirror_command(bot_id, "/goal clear"); return; } self.goal_command(ctx, bot_id, Command::Clear, "/goal clear", vec![], None); diff --git a/src/app/mirror_ui.rs b/src/app/mirror_ui.rs index 24450ab..565e23a 100644 --- a/src/app/mirror_ui.rs +++ b/src/app/mirror_ui.rs @@ -452,7 +452,9 @@ fn act_id(client: &str) -> String { enum Out { Edit { seq: u64, ops: Vec }, Act(Value), - Send { bot: u64, id: String, text: String, atts: Vec, memories: Option> }, + /// `typed`: the person's own words from the input (they go back there if they can't be + /// sent); a button's command (「/goal clear」) is not. + Send { bot: u64, id: String, text: String, atts: Vec, memories: Option>, typed: bool }, Move { ops: Vec, n: usize, skills: Vec }, /// 技能 on a screen: done at the brain (see [`App::mirror_skill`]); the answer goes to `note`. Skill { body: Value, note: SkillNote, busy: Arc }, @@ -1542,7 +1544,7 @@ impl App { *err.lock().unwrap() = format!("大腦沒有改連接器的名稱:{e}"); } } - Out::Send { bot, id, text, atts, memories } => { + Out::Send { bot, id, text, atts, memories, typed } => { // The files first (each asked again while the line is down); one that can't // go keeps the whole message here — words without their file would be a // different message. @@ -1568,13 +1570,13 @@ impl App { } }; if let Err(e) = sent { - let back_in = if text.trim_start().starts_with('/') { "" } else { "(已放回輸入框)" }; + let back_in = if typed { "(已放回輸入框)" } else { "" }; *err.lock().unwrap() = format!("訊息沒有送到大腦{back_in}:{e}"); // Take back the message shown ahead of time; its words and files go back to the input. resync.store(true, Ordering::SeqCst); // (A command a button sent — 「/goal clear」 — isn't the person's words: it // doesn't go into the input, where it would join what they type next.) - if let Some(tx) = back.as_ref().filter(|_| !text.trim_start().starts_with('/')) { + if let Some(tx) = back.as_ref().filter(|_| typed) { let _ = tx.send(Incoming::Unsent { bot, text: text.clone(), atts: atts.clone() }); } } @@ -1670,6 +1672,16 @@ impl App { /// Send a message through the brain: files go up first, then the text. pub(super) fn mirror_send(&mut self, bot: u64, text: String, atts: Vec, memories: Option>) -> bool { + self.mirror_send_from(bot, text, atts, memories, true) + } + + /// A command a button sends on a screen (「/goal clear」): like a message, but never put + /// back into the input when it can't be sent. + pub(super) fn mirror_command(&mut self, bot: u64, text: &str) -> bool { + self.mirror_send_from(bot, text.to_string(), vec![], None, false) + } + + fn mirror_send_from(&mut self, bot: u64, text: String, atts: Vec, memories: Option>, typed: bool) -> bool { if !self.mirror_can_send() { *self.mir.error.lock().unwrap() = "連不到大腦,訊息沒有送出。".into(); return false; @@ -1686,7 +1698,7 @@ impl App { } let id = act_id(&self.mir.client); self.mir.sending.fetch_add(1, Ordering::AcqRel); - self.mirror_out(Out::Send { bot, id, text, atts, memories }); + self.mirror_out(Out::Send { bot, id, text, atts, memories, typed }); true } diff --git a/src/app/plan_ui.rs b/src/app/plan_ui.rs index 4a89003..ae8f470 100644 --- a/src/app/plan_ui.rs +++ b/src/app/plan_ui.rs @@ -121,7 +121,7 @@ impl App { /// 取消計畫 (the plan's icon above the input): on a screen the brain cancels it, as if typed there. pub(super) fn plan_clear(&mut self, ctx: &egui::Context, bot_id: u64) { if self.mir.on { - self.mirror_send(bot_id, "/plan clear".into(), vec![], None); + self.mirror_command(bot_id, "/plan clear"); return; } self.plan_command(ctx, bot_id, Command::Clear, "/plan clear", vec![], None);