fix: 第四輪審查的兩個 P2——提醒期限在摘要之後才起算、自己打的 /指令送不出時照樣放回

- 「說了就做」的提醒事件改在安靜步驟真正開始前送(在可能的摘要之後),摘要時間不再吃掉第一次回應的 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 <noreply@anthropic.com>
This commit is contained in:
王性驊 2026-11-19 22:58:44 +08:00
parent bca9203264
commit a50d3cba4f
5 changed files with 25 additions and 11 deletions

View File

@ -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;

View File

@ -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 => {}

View File

@ -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);

View File

@ -452,7 +452,9 @@ fn act_id(client: &str) -> String {
enum Out {
Edit { seq: u64, ops: Vec<Value> },
Act(Value),
Send { bot: u64, id: String, text: String, atts: Vec<crate::attach::Attachment>, memories: Option<Vec<String>> },
/// `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<crate::attach::Attachment>, memories: Option<Vec<String>>, typed: bool },
Move { ops: Vec<Value>, n: usize, skills: Vec<Skill> },
/// 技能 on a screen: done at the brain (see [`App::mirror_skill`]); the answer goes to `note`.
Skill { body: Value, note: SkillNote, busy: Arc<AtomicBool> },
@ -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<crate::attach::Attachment>, memories: Option<Vec<String>>) -> 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<crate::attach::Attachment>, memories: Option<Vec<String>>, 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
}

View File

@ -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);