From cc47b3d29dae5aa5611914a303af25b39220c238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Sat, 21 Nov 2026 11:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A6=E4=B8=8B=E8=A7=92=E7=9C=8B=E5=BE=97?= =?UTF-8?q?=E5=87=BA=20Bot=20=E5=9C=A8=E5=93=AA=E4=B8=80=E5=8F=B0=E3=80=81?= =?UTF-8?q?=E9=BB=9E=E4=B8=80=E4=B8=8B=E5=B0=B1=E6=8F=9B=EF=BC=88=E8=A8=88?= =?UTF-8?q?=E7=95=AB=20B1=20=E7=AC=AC=E4=B8=80=E6=AD=A5=EF=BC=89=EF=BC=9A?= =?UTF-8?q?=E5=90=8D=E5=AD=97=E4=B8=8B=E9=9D=A2=E5=A4=9A=E4=B8=80=E8=A1=8C?= =?UTF-8?q?=E2=80=94=E2=80=94=E3=80=8C=E9=80=99=E5=8F=B0=E9=9B=BB=E8=85=A6?= =?UTF-8?q?=E3=80=8D=E6=88=96=E3=80=8C=E5=A4=A7=E8=85=A6=E3=80=8C=E9=9B=B2?= =?UTF-8?q?=E7=AB=AF=E5=A4=A7=E8=85=A6=E3=80=8D=E3=80=8D=EF=BC=88=E7=B6=A0?= =?UTF-8?q?=E9=BB=9E=E9=80=A3=E5=BE=97=E5=88=B0=E3=80=81=E7=81=B0=E9=BB=9E?= =?UTF-8?q?=E9=80=A3=E4=B8=8D=E5=88=B0=EF=BC=89=EF=BC=8C=E4=B8=8D=E7=94=A8?= =?UTF-8?q?=E6=89=93=E9=96=8B=E8=A8=AD=E5=AE=9A=E5=B0=B1=E7=9F=A5=E9=81=93?= =?UTF-8?q?=E7=8F=BE=E5=9C=A8=E7=9C=8B=E7=9A=84=E6=98=AF=E5=93=AA=E4=B8=80?= =?UTF-8?q?=E5=8F=B0=E7=9A=84=20Bot=E3=80=82=E9=BB=9E=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E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9C=AC=E5=9C=A8?= =?UTF-8?q?=E6=9A=AB=E5=AD=98=E8=B3=87=E6=96=99=E5=A4=BE=EF=BC=89=E3=80=82?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=9C=B0=E5=9C=96=20settings.md=EF=BC=88sett?= =?UTF-8?q?ings-whose=E3=80=81=E9=A9=97=E8=AD=89=E6=AD=A5=E9=A9=9F?= =?UTF-8?q?=EF=BC=89=E3=80=81FEATURES.md=E3=80=81=E8=A8=88=E7=95=AB=20B1?= =?UTF-8?q?=20=E7=8B=80=E6=85=8B=E5=90=8C=E6=AD=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 已驗證: cargo test 全綠(824),新測試 the_bottom_left_says_whose_bots_these_are;featuremap、layout_audit 過;clippy 錯誤數跟之前一樣(12);桌面截圖(ABV_ALLOW_WINDOW,按左下角打開選單):沒登入「✓ 這台電腦(王性驊的Mac mini)/登入帳號,才能換到別台大腦…/設定…」,螢幕模式「daniel/● 大腦「雲端大腦」」、選單「這台電腦(…)/✓ 雲端大腦/jenny-Host(離線)灰/設定…」。 未驗證: 真的從選單換到另一台大腦再換回來——要帳號裡有兩台大腦的實機(切換本身是原本設定頁那段)。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm --- FEATURES.md | 5 +++ docs/feature-map/settings.md | 2 + docs/plan-2026-11-openbot.md | 2 +- src/app.rs | 39 ++++++++++++++++++ src/app/sidebar_ui.rs | 77 +++++++++++++++++++++++++++++++++--- 5 files changed, 119 insertions(+), 6 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index 7c7cbf6..190ffee 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -1564,6 +1564,11 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開) - 指令輸出、連接器的回答太長時,給模型的只留開頭和結尾各 6000 字,中間寫「…(中間省略 N 個字;完整內容用 read_result 讀:id=r…)…」;完整的存在資料夾的 `outputs/`(一份最多 20 MB、留 7 天,同樣的內容同一個 id)。較早的結果為了騰出空間被收起時也一樣寫 id。 - 每個 Bot 都有 `read_result`(id、從第幾個字、一次最多兩萬字),只是看,計畫模式也能用。以前叫 Bot「再做一次這一步」看完整的:會改東西的步驟重做很危險,答案也可能不一樣,長紀錄的中間就這樣不見了。 +### Bot 在哪一台(左下角) + +- 左下角你的名字下面多一行:Bot 在哪一台——「這台電腦」,或「大腦「雲端大腦」」(綠點連得到、灰點連不到)。不用打開設定就看得出現在看的是哪一台的 Bot。 +- 點一下開「Bot 在哪一台」選單(以前是直接打開設定):「這台電腦(這台的名字)」、帳號裡每台可以當大腦的電腦(手腳不列),現在用的那台打勾,離線的灰、不能點;點一下就換過去——跟 設定 › 手機與帳號 大腦那一欄的「改用它當大腦」「改回用這台自己的 Bot」是同一件事。沒登入帳號時多一行「登入帳號,才能換到別台大腦…」;最下面「設定…」(⌘, 照舊)。帳號裡的電腦清單每 15 秒更新一次。截圖用 `ANYBOT_SHOT_VIEW=whose`(示範資料:已登入、是「雲端大腦」的螢幕、另一台離線)。 + ### 模型在哪裡跑(本機/區網/雲端) - 每個模型服務依它的網址標在哪裡跑:「本機」(localhost、127.x、::1)、「區網」(10.x、172.16–31.x、192.168.x、169.254.x、100.64–127.x 的 tailnet、fc00::/7、fe80::、`.local`、`.lan`、`.home`、`.internal`、`.home.arpa`、`.ts.net`、沒有點的名字)、「雲端」(其他全部,ChatGPT 方案一律算雲端)。只看網址字串、不查 DNS(畫面每一格都會畫到);一個公開網域就算其實指回家裡,也說雲端——分不出來時寧可說「會送出去」。本機、區網是綠字,雲端是灰字。 diff --git a/docs/feature-map/settings.md b/docs/feature-map/settings.md index 3d38bfc..bc9695f 100644 --- a/docs/feature-map/settings.md +++ b/docs/feature-map/settings.md @@ -10,6 +10,7 @@ - 通知:Bot 做完或等你時通知、需要你時響一聲([account](account.md))。Mac 上的通知是 AnyBot.app 自己發的(貓的圖示),點一下打開那個 Bot;從建置資料夾直接跑(不是 .app)時改用系統的 display notification,圖示是「工序指令編寫程式」。 - Bot:時區,例行任務和提醒用([routines](routines.md))。 - 帳戶:「登入」或「管理帳戶」打開「手機與帳號」頁;資料放在哪。 +- `settings-whose` 左下角(你的名字):名字下面一行寫 Bot 在哪一台——「這台電腦」,或「大腦「名字」」(綠點連得到、灰點連不到)。點一下開「Bot 在哪一台」選單:「這台電腦(這台的名字)」、帳號裡每台可以當大腦的電腦(現在用的打勾,離線的灰、不能點),點一下就換——跟「手機與帳號」頁大腦那一欄的「改用它當大腦」「改回用這台自己的 Bot」一樣([account](account.md));沒登入帳號多一行「登入帳號,才能換到別台大腦…」;最下面「設定…」(⌘, 也可以)。 - `settings-account` 「手機與帳號」頁(從 一般 › 帳戶 進去,[account](account.md)):「AnyBot 帳號」(登入、備份、還原)、大腦和「加一台電腦」([computers](computers.md))、「同一個網路直接連」、「手機可以做什麼」、「直接連線的裝置」、「分享給團隊」([team](team.md))、「帳號裡的電腦」。 - `settings-models` 「模型」:每家 AI 供應商的 API 金鑰、服務網址、新 Bot 預設模型、「測試連線並取得模型清單」([models](models.md));本機或區網的供應商多「看不到圖時,請雲端模型看截圖和附件」(預設關,[chat](chat.md))。「ChatGPT 方案」沒有金鑰和網址欄,改成「ChatGPT 帳號」:登入狀態、「使用 ChatGPT 繼續」「登出」「換帳號」「打開登入頁」「管理用量」;連到別台大腦時多一格貼回登入網址和「完成登入」。 - `settings-integrations` 「整合」,三個小分頁: @@ -44,6 +45,7 @@ - 基本前提和「手機已登入」(README),開著 Bot 1 的聊天:`$CTL phone click '.row[data-bot="1"]'`。 +- **左下角:Bot 在哪一台**(covers `settings-whose`):前提:要開視窗。指令:`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot whose ANYBOT_SHOT_VIEW=whose ANYBOT_SHOT_SIZE=1000x620 'ANYBOT_SHOT_CLICK=90,595@6' ANYBOT_SHOT_FRAMES=14`(示範資料:已登入、是「雲端大腦」的螢幕、jenny-Host 離線),再不帶 `ANYBOT_SHOT_VIEW` 跑一次(沒登入)。看到:左下角「daniel/● 大腦「雲端大腦」」;選單「Bot 在哪一台」下「這台電腦(…)」「✓ 雲端大腦」「jenny-Host(離線)」(灰),分隔線下「設定…」;沒登入時是「✓ 這台電腦(…)」「登入帳號,才能換到別台大腦…」「設定…」。真的切換要帳號裡有另一台大腦:走不到,和「手機與帳號」頁的按鈕是同一段(`mir.want`、`mir.leave`)。 - **Bot 改三樣**(covers `settings-by-bot`、`settings-general`):請 Bot 換深色、只用黑色、時區紐約,再傳一句。指令:`$CTL phone send '改 [[call update_settings {"theme":"dark","accent":"black","timezone":"America/New_York"}]]' && $CTL phone wait-text '時區 → America/New_York' --in '#msgs' && $CTL phone send 幾點 && $CTL phone wait-text 'FAKE-MODEL 回答:幾點' --in '#msgs' && $CTL model 'select(.kind == "turn") | .user' && TZ=America/New_York date +%H:%M`。看到:不用卡片,「已更新:主題 → dark、聊天的顏色 → black、時區 → America/New_York」;Bot 收到的〔送出時間〕是紐約時間。 - **錯的時區**(covers `settings-by-bot`):指令:`$CTL phone send '錯 [[call update_settings {"timezone":"Mars/Base"}]]' && $CTL phone wait-text '不是有效的時區名稱' --in '#msgs' && $CTL state .timezone`。看到:「「Mars/Base」不是有效的時區名稱(例如 Asia/Taipei)」;還是 America/New_York。 - **手機的設定**(covers `settings-general`、`settings-account`、`settings-models`、`settings-integrations`、`settings-computers`、`settings-perms`、`settings-vault`、`settings-updates`):重新整理,帳戶選單 › 設定 › 一般。指令:`$CTL phone open --listed && $CTL phone click '#b-me' && $CTL phone click '#sheet-in .opt' --text 設定 && $CTL phone wait '[data-go="updates"]' && $CTL phone shot settings-tabs && $CTL phone click '[data-go="general"]' && $CTL phone wait-text America/New_York --in '#list' && $CTL phone wait-text 只用黑色 --in '#list' && $CTL phone shot settings-general`。看到:八列(沒有語音);一般裡主題「深色」、聊天的顏色「只用黑色」、時區、通知、這支手機的外觀。 diff --git a/docs/plan-2026-11-openbot.md b/docs/plan-2026-11-openbot.md index e06ea18..93ac91c 100644 --- a/docs/plan-2026-11-openbot.md +++ b/docs/plan-2026-11-openbot.md @@ -96,7 +96,7 @@ 通用、外觀、通知、語音、帳號、手機連接、應用行為、Computer Use、更新)和「伺服器設定」(模型、助手、記憶、 保險庫、例行任務、成員、稽核、儲存…)。手機連線用「誰幫你傳資料」來說明:通過 OpenBot(推薦)或專用網路(偵測到 Tailscale)。 -**B1. 「現在在哪一台」的切換器** +**B1. 「現在在哪一台」的切換器**——11/21 做了第一步:左下角名字下面寫 Bot 在哪一台,點開「Bot 在哪一台」選單切換(這台電腦、帳號裡每台大腦、設定…)。每列的「重新連線」「換網址」「移除」還沒放進來。 - 做什麼:側邊欄最下面的帳號頭像改成伺服器選單:「這台電腦」、帳號裡每個大腦(狀態點:在線/連線中/離線/版本不合), 目前那台打勾;每列:「設定」「重新連線」「換網址」「改用它」「移除」。取代藏在 設定 › 一般 › 帳戶 › 手機與帳號 › 大腦 的「改用它當大腦」和「改回用這台自己的 Bot」。 diff --git a/src/app.rs b/src/app.rs index b8608c0..ba4b1b1 100644 --- a/src/app.rs +++ b/src/app.rs @@ -715,6 +715,23 @@ impl App { // Optional view for checking the dialogs in a picture. match std::env::var("ANYBOT_SHOT_VIEW").as_deref() { Ok("chat") => app.state.selected = 1, + // 在哪一台 (bottom left): signed in, a screen of 雲端大腦, another brain off. (An + // account server that refuses at once; the screen's copy in a temp folder.) + Ok("whose") => { + app.state.selected = 1; + let r = &mut app.state.remote; + r.relay_url = "https://127.0.0.1:9/demo".into(); + r.relay_user = "daniel".into(); + r.host_token = "demo".into(); + r.host_id = "this-mac".into(); + r.host_name = "王性驊的Mac mini".into(); + r.brain_id = "brain-1".into(); + r.brain_name = "雲端大腦".into(); + app.mir.dir = std::env::temp_dir().join("anybot-shot-whose"); + app.mir.on = true; + app.mir.online = true; + *app.rm.peers.lock().unwrap() = vec![("brain-1".into(), "雲端大腦".into(), true), ("brain-2".into(), "jenny-Host".into(), false), ("this-mac".into(), "王性驊的Mac mini".into(), true)]; + } // A chat with nothing in it yet. Ok("empty") => { app.state.selected = 3; @@ -8225,6 +8242,28 @@ fn dialog_body(ui: &mut egui::Ui, id: impl std::hash::Hash + std::fmt::Debug, #[cfg(test)] mod tests { + /// The bottom left says whose bots these are: this computer's, or the brain's this one shows + /// (its dot green while the brain is in reach). + #[test] + fn the_bottom_left_says_whose_bots_these_are() { + use super::*; + let ctx = egui::Context::default(); + let mut app = App::new(&ctx, Some(std::env::temp_dir().join("anybot-whose-test.png"))); + let p = app.pal; + assert_eq!(app.whose_bots(), (t("這台電腦"), p.up)); + app.state.remote.brain_name = "雲端大腦".into(); + app.mir.on = true; + app.mir.online = true; + assert_eq!(app.whose_bots(), ("大腦「雲端大腦」".to_string(), p.up)); + app.mir.online = false; + assert_eq!(app.whose_bots().1, p.text3, "out of reach: grey"); + app.state.remote.brain_name.clear(); + assert_eq!(app.whose_bots().0, "大腦「大腦」"); + assert_eq!(app.brain_for_words().as_deref(), Some("大腦")); + app.mir.on = false; + assert_eq!(app.brain_for_words(), None); + } + /// On a window the processor draws, the animations go at 4 frames a second; with a graphics /// card they keep their own pace (a slower one stays as it is). #[test] diff --git a/src/app/sidebar_ui.rs b/src/app/sidebar_ui.rs index a396400..4faa03a 100644 --- a/src/app/sidebar_ui.rs +++ b/src/app/sidebar_ui.rs @@ -227,12 +227,16 @@ impl App { ui.painter().circle_filled(c, 16.0, p.active); ui.painter().circle_stroke(c, 15.5, Stroke::new(1.0, p.border)); ui.painter().text(c, egui::Align2::CENTER_CENTER, initials, egui::FontId::proportional(FONT_XS), p.text2); + // Under the name, whose bots these are: this computer's, or the brain's it shows + // (with the brain's line: green when in reach). A press opens 在哪一台. + let (here, dot) = self.whose_bots(); let label = shorten_width(ui, &name, w - 52.0, 14.0); - ui.painter().text(rect.left_center() + vec2(44.0, 0.0), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(FONT_BASE), p.text); - if r.on_hover_text(t("設定(⌘,)")).on_hover_cursor(egui::CursorIcon::PointingHand).clicked() { - self.show_settings = true; - self.settings_tab = SettingsTab::General; - } + ui.painter().text(rect.left_center() + vec2(44.0, -8.0), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(FONT_BASE), p.text); + ui.painter().circle_filled(rect.left_center() + vec2(47.0, 9.0), 3.0, dot); + let sub = shorten_width(ui, &here, w - 64.0, FONT_XS); + ui.painter().text(rect.left_center() + vec2(54.0, 9.0), egui::Align2::LEFT_CENTER, sub, egui::FontId::proportional(FONT_XS), p.text3); + let r = r.on_hover_text(t("Bot 在哪一台:這台電腦或帳號裡的大腦(點一下切換);設定(⌘,)")).on_hover_cursor(egui::CursorIcon::PointingHand); + egui::Popup::menu(&r).show(|ui| self.whose_menu(ui)); if pill_icon(ui, crate::icons::Icon::Upload, p).on_hover_text(t("傳送檔案或文字到其他裝置")).clicked() { self.open_drops(); } @@ -935,6 +939,69 @@ impl App { self.mark(); } + /// Whose bots the window shows, in a few words, and the colour of its dot: this computer's, + /// or the brain's this one is a screen of (green when in reach, grey when not). + pub(super) fn whose_bots(&self) -> (String, Color32) { + let p = self.pal; + if self.mir.on { + let name = self.state.remote.brain_name.trim(); + let name = if name.is_empty() { t("大腦") } else { name.to_string() }; + (format!("{}「{name}」", t("大腦")), if self.mir.online { p.up } else { p.text3 }) + } else { + (t("這台電腦"), p.up) + } + } + + /// 在哪一台 (the bottom-left menu): this computer and every brain of the account, the one in + /// use ticked, each with whether it is in reach; a press moves the window there — the same as + /// 改用它當大腦 / 改回用這台自己的 Bot in 設定 › 手機與帳號. Then 設定. + pub(super) fn whose_menu(&mut self, ui: &mut egui::Ui) { + let p = self.pal; + ui.set_min_width(menu_ui::MENU_W.max(250.0)); + ui.spacing_mut().item_spacing.y = 0.0; + menu_ui::caption(ui, p, "Bot 在哪一台"); + let host = self.state.remote.host_name.trim().to_string(); + let here = if host.is_empty() { t("這台電腦") } else { format!("{}({host})", t("這台電腦")) }; + let r = menu_ui::item_text(ui, p, Some(if self.mir.on { crate::icons::Icon::Monitor } else { crate::icons::Icon::Check }), &here).on_hover_text(t("用這台電腦自己的 Bot、聊天和設定")); + if r.clicked() { + if self.mir.on { + self.mir.leave = true; + } + ui.close(); + } + let signed_in = !self.state.remote.host_token.is_empty(); + let me = self.state.remote.host_id.clone(); + let current = self.state.remote.brain_id.clone(); + let brains: Vec<(String, String, bool)> = self.rm.peers.lock().unwrap().iter().filter(|(id, _, _)| !id.is_empty() && *id != me && !crate::remote::is_hands(id)).cloned().collect(); + for (id, name, online) in brains { + let on = self.mir.on && id == current; + let reach = if on { self.mir.online } else { online }; + let label = if reach { name.clone() } else { format!("{name}({})", t("離線")) }; + let r = ui.add_enabled_ui(on || online, |ui| menu_ui::item_text(ui, p, Some(if on { crate::icons::Icon::Check } else { crate::icons::Icon::Brain }), &label)).inner; + let r = r.on_hover_text(t(if on { "現在看的是這台大腦的 Bot" } else { "改用它當大腦:看它的 Bot、聊天和設定(這台當它的螢幕和手腳)" })); + if r.clicked() { + if !on { + self.mir.want = Some((id.clone(), name.clone())); + // The brain's bots may use this computer (each action still asks). + self.state.remote.device_link = true; + self.mark(); + } + ui.close(); + } + } + if !signed_in && menu_ui::item(ui, p, crate::icons::Icon::Person, "登入帳號,才能換到別台大腦…").clicked() { + self.show_settings = true; + self.settings_tab = SettingsTab::General; + ui.close(); + } + menu_ui::sep(ui, p); + if menu_ui::item(ui, p, crate::icons::Icon::Gear, "設定…").on_hover_text(t("⌘,")).clicked() { + self.show_settings = true; + self.settings_tab = SettingsTab::General; + ui.close(); + } + } + /// The name shown at the bottom left: the account, else the Mac's user. pub(super) fn person_name(&self) -> String { if !self.state.remote.relay_user.is_empty() {