From 5efc2ac9ae217ead48015ff4bd0cc6b04dedd3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Tue, 17 Nov 2026 00:19:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=95=B6=E8=9E=A2=E5=B9=95=E7=9A=84?= =?UTF-8?q?=E9=9B=BB=E8=85=A6=E6=9B=B4=E6=96=B0=E9=87=8D=E9=96=8B=E5=BE=8C?= =?UTF-8?q?=EF=BC=8C=E5=BC=B7=E8=AA=BF=E8=89=B2=E4=B8=8D=E5=86=8D=E8=AE=8A?= =?UTF-8?q?=E5=9B=9E=E6=A9=98=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 這台 Mac 是雲端大腦的螢幕。螢幕上屬於這台自己的設定列在 LOCAL_KEYS,外觀(底色、強調色、對比、密度、慶祝動畫)是後來才加的,沒有列進去:在螢幕上改強調色只送去大腦、這台自己的 state.json 一直是 clay;更新重開時從大腦設定的副本開始,大腦若是不認得外觀的舊版,回來的就是預設的紙和 clay。 - 新增 LOOK_KEYS:外觀存在這台,連到大腦、大腦的設定傳來、存檔時都用這台的;改了照樣送給大腦(手機的顏色跟著大腦)。 - copy_own:原本四份手寫的「這台自己的欄位」清單(keep_local_fields、mirror_save、mirror_leave 只有主題和聊天的顏色)合成一份。 已驗證:cargo test --bin anybot 529 通過(新增 a_screen_keeps_its_own_look_and_settings:兩份清單上每個欄位設成非預設值都要被 copy_own 帶過去,清單加了欄位卻沒複製會失敗)。 未驗證:真的連雲端大腦更新重開一次(要先在新版選一次強調色,之後才會留住)。 --- FEATURES.md | 1 + docs/feature-map/settings.md | 2 +- src/app/mirror_ui.rs | 82 ++++++++++++++++++++++++++---------- 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index 56f6635..778039a 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -2536,6 +2536,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開) ## 多台電腦:大腦、手腳、螢幕(2026-11-04) - 帳號裡一台 AnyBot 當大腦(Bot、聊天、記憶、排程都在它上面),其他有視窗的電腦當螢幕(看到、改的都是大腦的 Bot),沒有螢幕的電腦當手腳;同一個帳號的電腦之間即時同步。 +- 螢幕上的主題、外觀(底色、強調色、對比、密度、慶祝動畫)、聊天的顏色、側欄寬度、「在這台電腦上執行」是那台自己的:存在那台,更新重開、大腦的設定傳來都用那台的(大腦是舊版、不認得外觀時也一樣)。外觀改了也送給大腦,手機的顏色跟著大腦。 - 每台 AnyBot 和帳號伺服器之間保持一條長連線(WebSocket),斷了自動接回;連不到時畫面說明是哪一段。 - 「加一台電腦」給一行 `anybot setup 網址 配對碼`,新電腦不用密碼就接成那個大腦的手腳。 - 看不到圖片的模型:你帳號裡看得到圖的模型會先描述圖片(看圖小幫手)。 diff --git a/docs/feature-map/settings.md b/docs/feature-map/settings.md index 384c4e4..0456b4b 100644 --- a/docs/feature-map/settings.md +++ b/docs/feature-map/settings.md @@ -57,6 +57,6 @@ Bot 設定(每個 Bot 一個視窗,[bots](bots.md)): - 大腦、「分享給團隊」、「帳號裡的電腦」登入帳號後才出現。 - 一般 Bot 的指示寫在個人檔案(Soul 與指示);「指示」卡片只有群組才有。 - Bot 設定要按「儲存」才算;關掉或按「取消」就不存。 -- 連到別台大腦的螢幕電腦上,模型金鑰、語音這些是大腦的設定,改了存在大腦;主題、強調色、「在這台電腦上執行」、手機與帳號還是這台自己的([computers](computers.md))。 +- 連到別台大腦的螢幕電腦上,模型金鑰、語音這些是大腦的設定,改了存在大腦;主題、外觀(底色、強調色、對比、密度、慶祝動畫)、聊天的顏色、「在這台電腦上執行」、手機與帳號還是這台自己的([computers](computers.md)):存在這台,更新重開、大腦的設定傳來都不會蓋掉(以前外觀不算這台的,更新後強調色總是變回橘色)。外觀改了也告訴大腦,手機跟著大腦的。 - 被管理員鎖住的開關是灰的,旁邊寫「由你的管理員設定,無法變更」([safety](safety.md))。 - 「Bot 做完或等你時通知」開著卻沒有橫幅:看 macOS 系統設定 › 通知 › AnyBot 是不是被關掉;`anybot --banner 標題 內文`(用 AnyBot.app 裡的那個程式)會送一則並說是怎麼送的。 diff --git a/src/app/mirror_ui.rs b/src/app/mirror_ui.rs index fcfcc1c..93d63a2 100644 --- a/src/app/mirror_ui.rs +++ b/src/app/mirror_ui.rs @@ -17,6 +17,32 @@ use std::sync::atomic::AtomicU64; /// Settings that belong to each computer, never to the brain. const LOCAL_KEYS: &[&str] = &["remote", "theme", "accent", "sidebar_collapsed", "sidebar_width", "selected", "machine_label", "local_execution", "local_never", "messages_send", "messages_no_ask"]; +/// 外觀 (底色、強調色、對比、密度、慶祝動畫): kept in this computer's own file and put back over the +/// brain's whenever the brain's settings come — an update restarted the screen on its copy of the +/// brain's, and a brain that doesn't know these (an older one) answered with 紙 and its clay every +/// time, so the 強調色 picked here was orange again. Still sent to the brain when changed here: the +/// phone wears the brain's. +const LOOK_KEYS: &[&str] = &["shell_tone", "shell_accent", "shell_contrast", "dense", "celebrate"]; + +/// This computer's own settings (LOCAL_KEYS but `selected`, which names a bot of one side, and +/// LOOK_KEYS) from `from` onto `to`. The one list of them: four hand-kept lists had drifted apart. +fn copy_own(to: &mut State, from: &State) { + to.remote = from.remote.clone(); + to.theme = from.theme; + to.accent = from.accent; + to.sidebar_collapsed = from.sidebar_collapsed; + to.sidebar_width = from.sidebar_width; + to.machine_label = from.machine_label.clone(); + to.local_execution = from.local_execution; + to.local_never = from.local_never; + to.messages_send = from.messages_send; + to.messages_no_ask = from.messages_no_ask; + to.shell_tone = from.shell_tone; + to.shell_accent = from.shell_accent.clone(); + to.shell_contrast = from.shell_contrast; + to.dense = from.dense; + to.celebrate = from.celebrate; +} /// Bot fields the brain alone changes (its chat, and what a turn leaves behind). const BOT_RUNTIME: &[&str] = &["id", "messages", "threads", "unread", "last_turn", "context_tokens", "goal", "regen_undo", "branches", "branch_of"]; /// Stands in for a key or token the brain doesn't hand out. @@ -912,9 +938,8 @@ impl App { remote.brain_name.clear(); remote.hands_for.clear(); remote.hands_for_name.clear(); + copy_own(&mut local, &self.state); local.remote = remote; - local.theme = self.state.theme; - local.accent = self.state.accent; if local.bot(local.selected).is_none() { local.selected = local.primary_bot; } @@ -937,17 +962,8 @@ impl App { } fn keep_local_fields(&mut self, from: &State) { + copy_own(&mut self.state, from); let st = &mut self.state; - st.remote = from.remote.clone(); - st.theme = from.theme; - st.accent = from.accent; - st.sidebar_collapsed = from.sidebar_collapsed; - st.sidebar_width = from.sidebar_width; - st.machine_label = from.machine_label.clone(); - st.local_execution = from.local_execution; - st.local_never = from.local_never; - st.messages_send = from.messages_send; - st.messages_no_ask = from.messages_no_ask; if st.bot(from.selected).is_some() { st.selected = from.selected; } else if st.bot(st.selected).is_none() { @@ -1225,16 +1241,7 @@ impl App { /// Saving on a screen: edits go to the brain; this computer's own file keeps its own bots. pub(super) fn mirror_save(&mut self) { if let Some(local) = self.mir.local.as_mut() { - local.remote = self.state.remote.clone(); - local.theme = self.state.theme; - local.accent = self.state.accent; - local.sidebar_collapsed = self.state.sidebar_collapsed; - local.sidebar_width = self.state.sidebar_width; - local.machine_label = self.state.machine_label.clone(); - local.local_execution = self.state.local_execution; - local.local_never = self.state.local_never; - local.messages_send = self.state.messages_send; - local.messages_no_ask = self.state.messages_no_ask; + copy_own(local, &self.state); local.save(); } if !self.mir.online || !self.mir.base.is_object() { @@ -1473,6 +1480,37 @@ impl App { mod tests { use super::*; + /// 每次更新強調色都變回橘色:外觀是這台自己的,連到大腦時、大腦的設定來時、存檔時都用這台的。 + /// Every key on the two lists is set off its default here and must come across — a key added + /// to a list but not to copy_own (or not here) fails. + #[test] + fn a_screen_keeps_its_own_look_and_settings() { + let mut from = State::first_run(); + from.remote.host_name = "這台".into(); + from.theme = crate::model::Theme::Dark; + from.accent = crate::model::Accent::BotColor; + from.sidebar_collapsed = !from.sidebar_collapsed; + from.sidebar_width += 40.0; + from.machine_label = "工作機".into(); + from.local_execution = !from.local_execution; + from.local_never = !from.local_never; + from.messages_send = !from.messages_send; + from.messages_no_ask = !from.messages_no_ask; + from.shell_tone = 0.25; + from.shell_accent = "indigo".into(); + from.shell_contrast = 0.75; + from.dense = !from.dense; + from.celebrate = !from.celebrate; + let (base, want) = (serde_json::to_value(State::first_run()).unwrap(), serde_json::to_value(&from).unwrap()); + let mut to = State::first_run(); + copy_own(&mut to, &from); + let got = serde_json::to_value(&to).unwrap(); + for k in LOCAL_KEYS.iter().chain(LOOK_KEYS).filter(|k| **k != "selected") { + assert_ne!(want[k], base[k], "{k}: set it off its default in this test"); + assert_eq!(got[k], want[k], "{k} is this computer's own, but copy_own doesn't copy it"); + } + } + #[test] fn a_screen_reads_only_turns_it_saw_end() { let turn = |at: i64, outcome| TurnSettlement { turn_id: format!("t{at}"), outcome, settled_at_ms: at };