AnyBot/src/app/computers_ui.rs

1375 lines
72 KiB
Rust
Raw Normal View History

// The computers part of the window: 「Bot 的電腦」 (status, live screen, take control, rebuilds,
// snapshots, secrets, where it runs), 「你的電腦」 (macOS permissions, the per-app grants) and
// the floating bar shown while a bot drives this Mac.
//
// Wording follows the reference assistant's strings where it has them (docs/specs/).
use super::*;
use crate::cloudbox::{self, Rebuild, Run};
/// The floating bar stays this long after the bot's last mouse/keyboard action on this Mac.
const LOCAL_BAR_SECS: u64 = 8;
fix: Linux 操作恢復順暢——保險箱空的不給填入工具、同一個錯誤不再鬼打牆;Wayland 可一律允許、長網頁有編號、Enter 只看游標那格;做完就關掉瀏覽器 一台 Linux(Ubuntu 26.04、X11)上一輪 Threads 海巡 40 分鐘只送出 1 則:小模型一直誤叫保險箱填入(171 次),而 4b53ad4 之後回的是「沒有開著的分頁,請先 browser_open」,Bot 照做又再誤叫。 - 保險箱:只給有東西可填的種類(空的就沒有 vault 工具、browser 也沒有 fill);填入先查 id 在不在,錯誤講對、指向 type;規劃與填入都在這個任務自己的分頁上(本機、box、遠端手腳) - 同一個工具連續 3 次回一樣的錯誤(換參數也一樣):這一回合不再執行 - Wayland(GNOME/KDE,wlroots 的座標點擊)認不出 App 時,改給「操作這台電腦的螢幕」一律允許(一律允許清單裡可移除) - 元素樹走訪上限 4000 → 20000:長網頁捲下去,看得到的部分也有編號 - 敏感動作關卡:Enter/送出只看游標所在(或正在打字)的欄位;座標點擊只看點到的最內層控制項;英文整字比對(PayPal 不是 pay);步驟在別台電腦時不查大腦本機的編號 - 打字先點欄位再檢查最前面是不是 AnyBot;批次從 AnyBot 切到要操作的 App 不再中斷,切到第三個 App 或回到 AnyBot 才停 - 估算對話長度只算真的會送出的最新 3 張截圖 - 做完就關掉瀏覽器(設定 › 電腦 › AnyBot 瀏覽器設定檔,預設開):一輪結束關掉用過的 Firefox/Chrome,別的 Bot 還在用就只關自己的分頁;box 的 Chromium 不變 Mac 444、Linux 448 個測試通過;Firefox 收尾實機測試(Mac、Linux Snap 版)通過;已在那台 Linux 上部署驗證。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:21:32 +00:00
/// The row for 「一律允許」 on the whole screen (a desktop that can't name apps).
const SCREEN_ROW: &str = "整個螢幕(看不出是哪個 App 時)";
/// Another AnyBot of the account: (id, name, online).
pub type Peer = (String, String, bool);
#[derive(Default)]
pub struct ComputerUi {
/// 其他電腦 is expanded.
pub others_open: bool,
/// The account's other AnyBots (id, name, online), fetched from the relay now and then.
pub peers: Arc<Mutex<Option<Vec<Peer>>>>,
pub peers_at: Option<Instant>,
/// 你的電腦's name being edited.
pub renaming_machine: Option<String>,
/// 更新: the first click arms it for 3 s (「再點選一次以確認」).
pub arm_update: Option<Instant>,
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
/// 要移除「…」嗎? for another computer (its name).
pub confirm_remove: Option<String>,
/// 要重設 AnyBot 的電腦嗎?
pub confirm_reset: bool,
/// 一律允許的應用程式 is expanded.
pub apps_open: bool,
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
/// 接管 during a hand-off: this app told the bots' computer to let the person have it.
pub control: bool,
pub confirm: Option<Rebuild>,
pub note: Arc<Mutex<String>>,
pub(super) disk: Arc<Mutex<Option<String>>>,
new_secret: (String, String),
replace_secret: Option<String>,
secret_error: String,
docker_host: Option<String>,
/// 容器隔離 row: "runc" (standard) or "runsc" (gVisor).
box_runtime: String,
/// Checked in the background: the Docker host has gVisor, and the runtime the box runs on.
runtime_facts: Arc<Mutex<Option<RuntimeFacts>>>,
show_log: bool,
teach_name: String,
teach_for: Option<u64>,
teach_error: String,
schedule_edit: String,
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
/// The time is being typed: the field shows what was typed, not what is saved (it showed
/// the saved time again every frame, so with 自動更新 on the time could not be changed).
schedule_typing: bool,
pub update_ready: bool,
update_checked: Option<Instant>,
update_flag: Arc<AtomicBool>,
/// The 電腦 card's small live picture of the box's screen.
thumb: Option<egui::TextureHandle>,
thumb_img: Arc<Mutex<Option<egui::ColorImage>>>,
thumb_busy: Arc<AtomicBool>,
thumb_at: Option<Instant>,
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
/// Whose screen the picture is (每個 Bot 一個螢幕: the selected bot's own, else the shared one).
thumb_bot: u64,
/// 每個 Bot 一個螢幕: 全部螢幕, the member picked in a group chat, the small pictures.
pub(super) screens: super::screens_ui::ScreensUi,
}
/// (the Docker host has gVisor, the runtime the box runs on now)
type RuntimeFacts = (bool, Option<String>);
fn status_color(r: &Run, p: Palette) -> Color32 {
match r {
2026-11-16 14:07:07 +00:00
Run::Running => p.up,
Run::Starting(_) | Run::Rebuilding(..) => p.attention,
Run::Failed(_) => p.danger,
_ => p.text3,
}
}
/// A rounded status pill: coloured dot + label.
fn status_pill(ui: &mut egui::Ui, r: &Run, p: Palette) {
let label = r.label();
let font = egui::FontId::proportional(FONT_XS);
let galley = ui.painter().layout_no_wrap(label, font, p.text2);
let size = vec2(galley.size().x + 26.0, 22.0);
let (rect, _) = ui.allocate_exact_size(size, egui::Sense::hover());
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.painter().rect_filled(rect, R_M, p.hover);
let c = rect.left_center() + vec2(11.0, 0.0);
let col = status_color(r, p);
if matches!(r, Run::Starting(_) | Run::Rebuilding(..)) {
let t = ui.input(|i| i.time) as f32;
ui.painter().circle_filled(c, 4.0 + (t * 4.0).sin().abs() * 2.0, col.gamma_multiply(0.35));
沒有顯示卡的電腦上,Bot 工作時視窗一直閃、一直卡:Jenny 的大腦(jenny-Host,2 核虛擬機,畫面由 CPU 畫、從 noVNC 看)升級後「對話一直閃」。實測兩個原因:一、Bot 工作時每 5 秒存一次檔,在畫面的執行緒上把整份聊天重寫——她的 Bot 留了 3.5 萬則舊對話(60 MB),每次存 77–90 MB,在我的 Mac 上一次 90–290 毫秒,那台慢好幾倍,等於每 5 秒停住快一秒,一小時寫幾十 GB;二、轉圈、流光字、側欄頭像、串流每秒把整個視窗重畫 20–30 次,每張都靠 CPU 畫(那台捲動 5 秒,畫圖就用掉 2.4 秒 CPU),旁邊還有 Bot 自己開的 Firefox。 現在:過去的對話(討論串)另存在 chats/threads/bot-<編號>.json,只有收起、切換、刪掉對話時才寫;工作中的存檔只寫目前這段(同樣大小的假聊天:每次 7–10 毫秒、0.75 MB)。讀檔直接讀進型別,不先轉成 JSON 樹(3.5 萬則 67 毫秒)。舊格式(對話在聊天檔裡)照讀、第一次存檔搬出去;中間跑過舊版 AnyBot(看不到另存的對話、新放下的寫在聊天檔裡)兩邊合併、舊版放下的排前面、不重複;壞掉的檔改名留著;刪掉 Bot 兩個檔一起刪。另存的檔放在子資料夾:舊版會刪掉 chats/ 裡它不認得的 bot-*.json。開視窗時從 wgpu 的介面卡認出「CPU 畫圖」(llvmpipe/lavapipe),那時這些動畫每 250 毫秒一張(每秒 4 張,還是看得出在動);有顯示卡照舊。功能地圖 chat.md、FEATURES.md 同步。 另外在 Jenny 那台把系統的螢幕閱讀器(orca,11/21 00:00:47 被打開,跟升級同一刻)關掉:同樣捲動 5 秒,AnyBot 主執行緒從 1.31–1.38 秒降到 0.83–0.86 秒(那是那台的設定,不在這個 commit 裡)。 已驗證: cargo test 全綠(819);新測試 earlier_conversations_are_not_written_again_while_a_bot_works(工作中舊對話檔不重寫、讀回、舊格式搬出、舊版跑過的合併不重複、壞檔留著、刪 Bot 一起刪)、animations_slow_down_when_the_processor_draws_the_window;featuremap 全過;clippy 錯誤數跟改之前一樣(12 個,都在沒動的檔);verify-anybot:scratch AnyBot 上傳訊息→開始新對話→舊的在 chats/threads/bot-1.json、聊天檔只剩現在這段→再回一則只有聊天檔更新、舊對話檔時間不變→重開兩段都在→切回過去的對話兩個檔互換。 未驗證: 「CPU 畫圖」那條在這台 Mac 走不到(有顯示卡),要在 jenny-Host 裝上新版後實測 Bot 工作時的 CPU 和畫面;Windows 沒試。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 02:42:51 +00:00
ui.ctx().request_repaint_after(super::anim_after(60));
}
ui.painter().circle_filled(c, 3.5, col);
ui.painter().galley(rect.left_center() + vec2(20.0, -galley.size().y / 2.0), galley, p.text2);
}
/// A little monitor drawn with lines (no emoji font needed).
impl App {
/// Called once at start.
pub(super) fn computers_start(&mut self) {
if !self.demo {
// A computer that will show another brain (mirror_boot, a moment later) says so now:
// the box's first look would otherwise start the Lima VM it is about to put to sleep.
let r = &self.state.remote;
cloudbox::set_brain(r.brain_id.is_empty() || r.host_token.is_empty());
cloudbox::start_background();
}
}
// ---------- settings page ----------
pub(super) fn computers_page(&mut self, ui: &mut egui::Ui) {
let p = self.pal;
let run = cloudbox::run_state();
// Check now and then whether this AnyBot carries a newer computer.
if !self.demo && self.cu.update_checked.is_none_or(|t| t.elapsed().as_secs() > 30) {
self.cu.update_checked = Some(Instant::now());
let flag = self.cu.update_flag.clone();
let facts = self.cu.runtime_facts.clone();
std::thread::spawn(move || {
flag.store(cloudbox::update_available(), Ordering::SeqCst);
*facts.lock().unwrap() = Some((cloudbox::host_has_gvisor(), cloudbox::running_runtime()));
});
}
self.cu.update_ready = self.cu.update_flag.load(Ordering::SeqCst);
ui.spacing_mut().item_spacing.y = 0.0;
// ── 你的電腦 ── (title: this computer's name, with a pencil to rename it)
let label = if self.state.machine_label.trim().is_empty() { crate::remote::default_host_name() } else { self.state.machine_label.clone() };
let renaming = self.cu.renaming_machine.clone();
let mut rename_to: Option<Option<String>> = None;
let mut keep_buf: Option<String> = None;
let mut start_rename = false;
sec_title(ui, "你的電腦", p, |ui| match renaming {
Some(mut buf) => {
let r = ui.add(egui::TextEdit::singleline(&mut buf).desired_width(180.0).char_limit(100));
if !r.has_focus() && !r.lost_focus() {
r.request_focus();
}
if r.lost_focus() {
let cancel = ui.input(|i| i.key_pressed(Key::Escape));
let v = buf.trim().to_string();
rename_to = Some(if !cancel && !v.is_empty() { Some(v) } else { None });
} else {
keep_buf = Some(buf);
}
}
None => {
if crate::icons::button(ui, crate::icons::Icon::Pencil, 14.0, p.text3, p.hover).on_hover_text(format!("{},{label}", t("重新命名這台電腦"))).clicked() {
start_rename = true;
}
ui.label(RichText::new(&label).size(FONT_SM).color(p.text2));
}
});
if let Some(buf) = keep_buf {
self.cu.renaming_machine = Some(buf);
}
match rename_to {
Some(Some(v)) => {
self.state.machine_label = v;
self.cu.renaming_machine = None;
self.mark();
}
Some(None) => self.cu.renaming_machine = None,
None => {}
}
if start_rename {
self.cu.renaming_machine = Some(label.clone());
}
sec_card(ui, p, |ui| {
// 在這台電腦上執行: 一律允許 / 每次詢問 / 永不允許 (default 每次詢問).
let locked = !self.managed.local.allows();
let current = if self.state.local_never || locked { "never" } else if self.state.local_execution { "always" } else { "ask" };
let name = |v: &str| {
t(match v {
"always" => "一律允許",
"never" => "永不允許",
_ => "每次詢問",
})
};
let mut pick: Option<&str> = None;
sec_row(ui, p, "在這台電腦上執行", "讓 Bot 在你的電腦上開啟檔案並執行任務。自動審核仍會先檢查所有操作。", |ui| {
ui.add_enabled_ui(!locked, |ui| {
egui::ComboBox::from_id_salt("local-permission").selected_text(name(current)).width(110.0).show_ui(ui, |ui| {
for v in ["always", "ask", "never"] {
if ui.selectable_label(current == v, name(v)).clicked() {
pick = Some(v);
}
}
});
});
});
if let Some(v) = pick {
self.state.local_execution = v == "always";
self.state.local_never = v == "never";
self.mark();
}
if locked {
sec_note(ui, p, "由你的管理員設定,無法變更");
}
// 經這台電腦轉送流量 (the box's new connections leave through this computer).
let allowed = self.managed.egress.allows() && cloudbox::docker_host().is_empty();
let mut via = cloudbox::egress_via_mac() && allowed;
let help = "將 Bot 的電腦的網路流量改經這台電腦而非雲端轉送,例如要連公司內網或 VPN 才看得到的服務。僅對新連線生效。";
let desc = if !self.managed.egress.allows() {
"已由管理員停用".to_string()
} else if !cloudbox::docker_host().is_empty() {
"Bot 的電腦在別的主機上時不能用".to_string()
} else if via {
match (crate::egress::port(), &run) {
(_, Run::Asleep) => "電腦休眠中,喚醒後會重新連線".to_string(),
(Some(_), Run::Running) => format!("本次已轉送 {} 個連線", crate::egress::CONNECTIONS.load(Ordering::Relaxed)),
_ => "等待 Bot 的電腦連線".to_string(),
}
} else {
String::new()
};
let mut egress_err = None;
sec_row_s(ui, p, "經這台電腦轉送流量", &desc, help, |ui| {
if ui.add_enabled(allowed, toggle(&mut via)).changed() {
if let Err(e) = cloudbox::set_egress_via_mac(via) {
egress_err = Some(e);
}
}
});
if let Some(e) = egress_err {
*self.cu.note.lock().unwrap() = e;
}
// 其他電腦: every AnyBot signed in to this account (from the relay), then SSH computers.
let signed_in = !self.state.remote.relay_url.is_empty() && !self.state.remote.host_token.is_empty();
if signed_in && !self.demo && self.cu.peers_at.is_none_or(|t| t.elapsed().as_secs() > 20) {
self.cu.peers_at = Some(Instant::now());
let (slot, settings) = (self.cu.peers.clone(), self.state.remote.clone());
let ctx = ui.ctx().clone();
std::thread::spawn(move || {
let me = settings.host_id.clone();
let list: Vec<_> = crate::remote::devices_online(&settings).into_iter().filter(|(id, _, _)| *id != me).collect();
*slot.lock().unwrap() = Some(list);
ctx.request_repaint();
});
}
let peers: Vec<(String, String, bool)> = if self.demo { vec![("d1".into(), "辦公室的 Mac mini".into(), true), ("d2".into(), "家裡的筆電".into(), false)] } else { self.cu.peers.lock().unwrap().clone().unwrap_or_default() };
let ssh = self.state.remote_computers.clone();
let n = peers.len() + ssh.len();
let mut names: Vec<String> = peers.iter().map(|p| p.1.clone()).collect();
names.extend(ssh.iter().map(|c| c.name.clone()));
let others_help = if signed_in { "在其他電腦安裝 AnyBot 並登入同一個帳號,就會自動出現在這裡。也可以用 SSH 加入。" } else { "登入 AnyBot 帳號(設定 → 一般 → 手機與帳號)後,同一個帳號裡的電腦會自動出現在這裡。也可以用 SSH 加入。" };
let desc = if n == 0 {
String::new()
} else if n == 1 {
match (peers.first(), ssh.first()) {
(Some(p), _) => format!("{} · {}", p.1, t(if p.2 { "目前在線上" } else { "離線" })),
(_, Some(c)) => format!("{} · SSH", c.name),
_ => String::new(),
}
} else {
names.join("、")
};
let open = self.cu.others_open;
let mut flip = false;
sec_row_s(ui, p, "其他電腦", &desc, others_help, |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
let b = egui::Button::new(RichText::new(format!("{n} {}", if open { "⌄" } else { "›" })).size(FONT_SM)).corner_radius(R_M);
if ui.add(b).clicked() {
flip = true;
}
});
if flip {
self.cu.others_open = !open;
}
if open {
for (_, name, online) in &peers {
let status = t(if *online { "目前在線上" } else { "離線" });
sec_row_s(ui, p, name, &format!("{} · {status}", t("同一個帳號")), "", |ui| {
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
2026-11-16 14:07:07 +00:00
ui.painter().circle_filled(r.center(), 3.0, if *online { p.up } else { p.text3 });
});
}
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
for c in &ssh {
let mut remove = false;
sec_row_s(ui, p, &c.name, &format!("SSH · {}", c.ssh_target), "", |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(t("移除")).color(p.danger)).corner_radius(R_M)).on_hover_text(format!("{} {}", t("移除"), c.name)).clicked() {
remove = true;
}
});
if remove {
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
self.cu.confirm_remove = Some(c.name.clone());
}
}
let mut add = None;
let taken = self.state.computer_names();
Frame::new().inner_margin(Margin::symmetric(14, 8)).show(ui, |ui| {
ui.horizontal(|ui| {
let w = (ui.available_width() - 80.0) / 2.0;
ui.add(egui::TextEdit::singleline(&mut self.new_remote.0).hint_text(t("SSH 電腦名稱,例如 工作站")).desired_width(w - 8.0));
ui.add(egui::TextEdit::singleline(&mut self.new_remote.1).hint_text("me@studio.local").desired_width(w - 8.0));
let ok = !self.new_remote.0.trim().is_empty() && !self.new_remote.1.trim().is_empty() && !taken.contains(&self.new_remote.0.trim().to_string());
if ui.add_enabled(ok, secondary_button("新增")).clicked() {
add = Some(crate::model::RemoteComputer { name: self.new_remote.0.trim().into(), ssh_target: self.new_remote.1.trim().into(), dir: String::new() });
}
});
});
if let Some(c) = add {
self.state.remote_computers.push(c);
self.new_remote = Default::default();
self.mark();
}
}
// This computer for the account's other AnyBots (裝置連結).
if signed_in {
let mut link = self.state.remote.device_link;
sec_row(ui, p, "讓帳號裡的其他電腦使用這台", "同一個帳號的其他 AnyBot(例如放在伺服器上的)可以看這台的畫面、在這台上做事。每個動作還是會先問你。要讓 Bot 操作別台,就在那台打開這個。要移除一台電腦,在那台登出帳號即可。", |ui| {
ui.add(toggle(&mut link));
});
if link != self.state.remote.device_link {
self.state.remote.device_link = link;
self.mark();
}
}
});
// ── 訊息 (Mac) ──
if cfg!(target_os = "macos") {
sec_title(ui, "訊息", p, |_| {});
let mut send = self.state.messages_send;
let mut no_ask = self.state.messages_no_ask;
sec_card(ui, p, |ui| {
sec_row(ui, p, "傳送訊息", "允許 Bot 以你的身分從這台 Mac 上的「訊息」傳送訊息", |ui| {
ui.add(toggle(&mut send));
});
if send {
sec_row(ui, p, "無需詢問直接傳送", "每則訊息都跳過核准卡片", |ui| {
ui.add(toggle(&mut no_ask));
});
}
});
if send != self.state.messages_send || no_ask != self.state.messages_no_ask {
self.state.messages_send = send;
self.state.messages_no_ask = no_ask;
self.mark();
}
}
// ── AnyBot Computer Use: seeing and using this computer's screen ──
self.mac_permissions_card(ui);
// ── Bot 的電腦 ── (on a screen of a brain, it is the brain's)
if self.mir.on {
sec_title(ui, "Bot 的電腦", p, |_| {});
sec_card(ui, p, |ui| {
let name = self.state.remote.brain_name.clone();
let mut view = false;
sec_row(ui, p, "在大腦上", &format!("每個 Bot 自己的電腦(例如「Master 的電腦」)在大腦「{name}」上,要在那台管理;這裡可以看它的畫面。這台電腦是大腦的手腳:上面的權限決定 Bot 能不能看這台的畫面、操作這台。"), |ui| {
view = ui.add(primary_button("開啟電腦", p)).clicked();
});
if view {
self.open_viewer();
}
});
} else {
sec_title(ui, "Bot 的電腦", p, |ui| status_pill(ui, &run, p));
#[derive(PartialEq)]
enum Act {
None,
Recheck,
Download,
Docker,
Browser,
Wake,
View,
UpdateClick,
Reset,
Snapshot,
AskClean,
Disk,
}
let mut act = Act::None;
let armed = self.cu.arm_update.filter(|t| t.elapsed().as_secs_f32() < 3.0).is_some();
if armed {
ui.ctx().request_repaint_after(std::time::Duration::from_millis(300));
}
let busy_rebuild = matches!(run, Run::Rebuilding(..));
let update_ready = self.cu.update_ready;
let working: Vec<String> = self.streams.keys().filter_map(|id| self.state.bot(*id).map(|b| b.name.clone())).collect();
let mut on = cloudbox::auto_update_at().is_some();
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
let mut at = if self.cu.schedule_typing { self.cu.schedule_edit.clone() } else { cloudbox::auto_update_at().unwrap_or_else(|| self.cu.schedule_edit.clone()) };
let mut typed = false;
if at.is_empty() {
at = "03:00".into();
}
let mut schedule_changed = false;
let disk = self.cu.disk.lock().unwrap().clone();
let note = self.cu.note.lock().unwrap().clone();
sec_card(ui, p, |ui| {
match &run {
Run::NoDocker(why) => {
sec_row_s(ui, p, "Bot 的電腦", "還沒有 Docker", &format!("{why}\n在那之前,Bot 的電腦是一個封閉的資料夾(沒有桌面)。"), |ui| {
if ui.add(secondary_button("重新檢查")).clicked() {
act = Act::Recheck;
}
if cfg!(target_os = "macos") {
if ui.add(primary_button("下載 OrbStack", p)).clicked() {
act = Act::Download;
}
} else if ui.add(primary_button("安裝 Docker 的說明", p)).clicked() {
act = Act::Docker;
}
});
return;
}
Run::Rebuilding(phase, detail) => {
let steps: &[&str] = if matches!(phase.as_str(), "backing-up" | "moving") { &["backing-up", "creating", "moving"] } else { &["cleaning-up", "wiping", "creating", "restoring"] };
let at = steps.iter().position(|s| s == phase).unwrap_or(0);
Frame::new().inner_margin(Margin::symmetric(14, 10)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
for (i, s) in steps.iter().enumerate() {
let done = i < at;
let on = i == at;
let col = if done || on { p.accent } else { p.text3 };
let icon = if done { crate::icons::Icon::CircleCheck } else if on { crate::icons::Icon::Loader } else { crate::icons::Icon::Minus };
crate::icons::label(ui, icon, cloudbox::phase_label(s), FONT_XS, col);
if i + 1 < steps.len() {
ui.label(RichText::new("—").size(FONT_XS).color(p.text3));
}
}
});
ui.add_space(6.0);
ui.add(egui::ProgressBar::new((at as f32 + 0.5) / steps.len() as f32).desired_height(6.0).fill(p.accent));
ui.add_space(4.0);
hint(ui, format!("{detail}…(開始後就不能取消)"), p);
});
}
_ => {
// The screen: AnyBot has no per-bot overview, so it opens from here.
sec_row(ui, p, "Bot 的電腦", "一台 Linux 電腦,你所有的 Bot 共用,每個 Bot 有自己的資料夾(例如「Master 的電腦」)。一直開著,不會休眠。", |ui| {
if ui.add(primary_button("開啟電腦", p)).on_hover_text(t("看 Bot 的電腦的螢幕,也可以取得控制權自己操作")).clicked() {
act = Act::View;
}
match run {
Run::Running => {}
_ => {
if ui.add(secondary_button("喚醒電腦")).clicked() {
act = Act::Wake;
}
}
}
if ui.add(secondary_button("在瀏覽器開啟")).on_hover_text(t("用 noVNC 全螢幕觀看")).clicked() {
act = Act::Browser;
}
});
Bots do a planned sequence in one step; the box's screen settles by what it shows; no login is ever the only copy - computer_use_batch: up to 8 planned actions run in one docker exec (steps chained with && and a done-marker each), the first failure stops the rest, one picture comes back at the end. Typed text rides inside the script quoted (one stdin for the chain). The prompt tells the model when to use it (a form whose fields are all visible) and when not to (step 2 needs step 1's screen). - The box waits for the screen to stop changing, not the clock: two matching small probes (~60 ms each) mean settled — ~160 ms on a still screen where every step paid a fixed 500 ms, and a page mid-load is waited for (up to ~0.9 s) instead of captured mid-change. The picture is JPEG, and the a11y read runs in parallel with the capture (look ~307 ms; two steps with pictures 1102 ms). (SETTLE_SH is a group command: dash needs ';' after it — found by box_screen_is_exact.) - The home volume (every bot's logins) is never one command from loss: snapshots keep generations (last 7 days, then one per week; the old single snapshot migrates by file date), Reset and Restore save the running box first and refuse to wipe if saving fails, a box built on an empty volume re-fills itself from the newest snapshot, and a sleeping holder container keeps the volume attached so `docker volume prune` can't take it. make doctor shows volume and snapshot state; the 電腦 card shows the box's average step times and says resets save first. - box_batch_in_one_round_trip (ignored): three typed steps, ASCII and Chinese, land in one trip. On the real box after upgrading v3→v5: box_update_keeps_files (files survive, snapshot 2 代), box_numbers_are_exact, box_screen_is_exact, box_end_to_end, box_traffic_via_mac pass; 155 unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 01:47:37 +00:00
// What a step on this box really costs (from the app's own timings).
let (n, exec_ms, total_ms) = cloudbox::step_stats();
if n > 0 {
hint(ui, format!("最近 {n} 步畫面操作:在電腦上做平均 {exec_ms} ms,整步(含編號畫面)平均 {total_ms} ms"), p);
}
}
}
// 更新 Bot 的電腦: two clicks (the first arms it for 3 s).
sec_row(ui, p, "更新 Bot 的電腦", "更新你的 Bot 共用的電腦。你的檔案和登入資訊會保留,但已安裝的應用程式和套件會被移除。所有 Bot 會一起更新。", |ui| {
let b = if armed {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
egui::Button::new(RichText::new(t("再點選一次以確認")).color(p.danger)).fill(p.danger.gamma_multiply(0.14)).corner_radius(R_M).min_size(vec2(64.0, 30.0))
} else {
secondary_button("更新")
};
if ui.add_enabled(update_ready && !busy_rebuild, b).clicked() {
act = Act::UpdateClick;
}
});
// The status line under it.
let (icon, text, accent) = if !update_ready {
(crate::icons::Icon::CircleCheck, t("你的電腦已是最新版本"), true)
} else if !working.is_empty() {
let names = if working.len() > 3 { format!("{}、另外 {} 位", working[..3].join("、"), working.len() - 3) } else { working.join("、") };
(crate::icons::Icon::Clock, format!("更新會停止 {names}"), false)
} else {
(crate::icons::Icon::Update, t("有新版的 Bot 的電腦可以更新"), true)
};
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
// Up to date is a plain grey line; only something to do (a new version) or to know
// before pressing (who would be stopped) gets a block.
let up_to_date = !update_ready;
Frame::new().inner_margin(Margin { left: 14, right: 14, top: 0, bottom: 8 }).show(ui, |ui| {
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
if up_to_date {
crate::icons::label(ui, icon, &text, FONT_SM, p.text3);
return;
}
let fill = if accent { p.accent.gamma_multiply(0.09) } else { p.hover };
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
Frame::new().fill(fill).corner_radius(R_M).inner_margin(Margin { left: 12, right: 8, top: 8, bottom: 8 }).show(ui, |ui| {
ui.set_width(ui.available_width());
crate::icons::label(ui, icon, &text, FONT_SM, if accent { p.accent } else { p.text2 });
});
});
// 自動更新 (at a local time each day, an hour to catch up).
let desc = if on { format!("每天 {}", at.trim()) } else { String::new() };
sec_row_s(ui, p, "自動更新", &desc, "有新映像檔可用時,電腦會在你選的時間自動更新;錯過的話一小時內還會補做。開始後不能取消;有 Bot 在用電腦時會等它做完。", |ui| {
let changed = ui.add(toggle(&mut on)).changed();
feat: 電腦版不再破版、通知用 AnyBot 的貓、手機網頁像 App;從帳號看畫面不再斷線 電腦版:右側「進行中」的長重試訊息蓋過「停止」、衝出卡片,現在以「…」結尾(滑鼠移上去看 全文);Bot 設定的「團隊成員可以使用…」疊到儲存/取消、權限規則疊到「刪除」、「新增規則」 被切掉、電腦分頁的時間欄被切掉、窄視窗裡允許卡片的按鈕、「已排入…」和輸入框提示被切掉, 都修好。粉圓體比思源黑體寬,寫死寬度的地方用它就擠爆。新的 layout_audit 測試用三種字型、 最窄/一般/寬的視窗、示範和很長的資料,把每個設定分頁、Bot 設定、例行任務、右側面板畫一遍, 字被切掉或疊在一起就失敗(截圖模式也多了 ANYBOT_SHOT_PANEL/STATUS/TAB/SCROLL)。 通知:Mac 上原本用 osascript 的 display notification,橫幅是「工序指令編寫程式」的圖示、 點了還打開它。現在是 AnyBot.app 自己發的(NSUserNotificationCenter:新的 UNUserNotificationCenter 只給有 Apple 開發者簽章的 App 用,AnyBot 自簽),圖示是貓,點一 下打開那個 Bot;不在 .app 裡才退回 osascript。Linux 的 notify-send 帶上 AnyBot 的圖示。 anybot --banner 標題 內文 可以送一則試試。 手機(PWA):manifest 和 service worker 改成 mobile/ 裡一份,帳號伺服器和這台共用;加滿版的 maskable 圖示和 Android 狀態列用的單色貓(原本彩色圖變成白方塊)。每支手機滿版(左右安全 區域、狀態列跟著畫面顏色)、首頁提示裝成 App、換畫面左右滑、iPhone 主畫面 App 從左邊緣滑回 上一頁、按鈕長按不選字、搜尋框不放大。通知可以選要哪幾種(需要你/做完了/例行任務暫停/ 收到檔案)、送測試通知,App 圖示上的數字是正在等你的 Bot。 帳號伺服器:看 Bot 電腦畫面時,瀏覽器回的 Pong 沒算成還活著,靜止畫面一分鐘就被切;看畫面 的票證十分鐘一到就切斷、重連又拿同一張過期的票回不來。現在票證記得誰申請的(那支手機的 登入、帳號裡那台電腦),申請者還有效就一直連著,使用中的票證會續期。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:06:12 +00:00
// As wide as 「00:00」 in this font (a fixed 56 cut the last digit in some fonts).
let digits = ui.painter().layout_no_wrap("00:00".into(), egui::TextStyle::Monospace.resolve(ui.style()), p.text).size().x;
// (+ the field's own padding, 9 px each side, and room for the cursor.)
let r = ui.add(egui::TextEdit::singleline(&mut at).desired_width(digits + 26.0).char_limit(5).font(egui::TextStyle::Monospace));
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
typed |= r.changed();
if changed || r.lost_focus() {
schedule_changed = true;
}
});
// 重設 Bot 的電腦: from the last snapshot (red, asks first).
let snap = cloudbox::snapshot_time().map(|t| t.format("%m/%d %H:%M").to_string());
let desc = match &snap { Some(t) => format!("上次快照:{t}"), None => t("還沒有快照") };
Bots do a planned sequence in one step; the box's screen settles by what it shows; no login is ever the only copy - computer_use_batch: up to 8 planned actions run in one docker exec (steps chained with && and a done-marker each), the first failure stops the rest, one picture comes back at the end. Typed text rides inside the script quoted (one stdin for the chain). The prompt tells the model when to use it (a form whose fields are all visible) and when not to (step 2 needs step 1's screen). - The box waits for the screen to stop changing, not the clock: two matching small probes (~60 ms each) mean settled — ~160 ms on a still screen where every step paid a fixed 500 ms, and a page mid-load is waited for (up to ~0.9 s) instead of captured mid-change. The picture is JPEG, and the a11y read runs in parallel with the capture (look ~307 ms; two steps with pictures 1102 ms). (SETTLE_SH is a group command: dash needs ';' after it — found by box_screen_is_exact.) - The home volume (every bot's logins) is never one command from loss: snapshots keep generations (last 7 days, then one per week; the old single snapshot migrates by file date), Reset and Restore save the running box first and refuse to wipe if saving fails, a box built on an empty volume re-fills itself from the newest snapshot, and a sleeping holder container keeps the volume attached so `docker volume prune` can't take it. make doctor shows volume and snapshot state; the 電腦 card shows the box's average step times and says resets save first. - box_batch_in_one_round_trip (ignored): three typed steps, ASCII and Chinese, land in one trip. On the real box after upgrading v3→v5: box_update_keeps_files (files survive, snapshot 2 代), box_numbers_are_exact, box_screen_is_exact, box_end_to_end, box_traffic_via_mac pass; 155 unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 01:47:37 +00:00
sec_row_s(ui, p, "重設 Bot 的電腦", &desc, "電腦卡住時可重新開始。它會從你上次儲存的快照重建,最近的變更可能會遺失;沒有快照時會換一台全新的電腦。「儲存快照」把 Bot 的檔案備份到這台電腦,每天也會自動存一份。重設或還原之前,會先把現在的電腦存成一份快照(存不下就不會動手),之後還能從它找回;快照保留最近 7 天,之前每週各留一份。", |ui| {
if ui.add_enabled(!busy_rebuild, danger_button("重設", p)).clicked() {
act = Act::Reset;
}
if ui.add_enabled(run.is_running(), secondary_button("儲存快照")).on_hover_text(t("把 Bot 的檔案備份到這台電腦;每天也會自動存一份")).clicked() {
act = Act::Snapshot;
}
});
// 磁碟 (AnyBot).
sec_row(ui, p, "磁碟", "查看 Bot 的電腦用了多少空間,或請主要 Bot 提出清理方案(等你核准才刪)", |ui| {
if ui.add(secondary_button("請 Bot 提出清理方案")).clicked() {
act = Act::AskClean;
}
if ui.add(secondary_button("檢查用量")).clicked() {
act = Act::Disk;
}
});
if let Some(d) = &disk {
Frame::new().inner_margin(Margin::symmetric(14, 6)).show(ui, |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
Frame::new().fill(p.hover).corner_radius(R_M).inner_margin(Margin::symmetric(10, 8)).show(ui, |ui| {
ui.set_width(ui.available_width());
2026-11-16 14:07:07 +00:00
ui.label(RichText::new(d).monospace().size(FONT_SM).color(p.text2));
});
});
}
if !note.is_empty() {
sec_note(ui, p, &note);
}
});
Bug sweep: gates, relay 2FA, Windows input, snapshots, encodings Permissions and reach - a file leaving a computer passes the same questions as reading it; "looking" shell commands that do more than look ask first - a symlink out of the work/sealed folder counts as outside it (real paths, not just lexical ones); the search walk skips links - web_fetch and skill_install read the public web only: localhost, the LAN and cloud metadata are refused, at every redirect - preview shows a file without running it; browser_upload may ask - vault: logins no longer match across shared suffixes (pages.dev, com.tw, ...); registrable_domain knows public suffixes - axwrite: found elements are retained (use-after-free) Relay - replacing or turning off 2FA needs the current code (rate-limited); new recovery codes only count once enrollment is verified - a removed computer loses its socket and its `call` access - a site name taken by another account answers 409 - RELAY_TRUST_PROXY: the login lock counts the caller's address, not the proxy's (compose files and README) - httpd: half a body is not a request Desktop - sign-in, join and restore work with 2FA on (code field; --serve reads ANYBOT_ACCOUNT_CODE; the setup wizard points to a pairing code) - Windows: text was typed twice; modifiers are held through click, drag and scroll; horizontal scroll; screen control is no longer refused - a recording that hits the limit is transcribed, not thrown away - bot's computer: a new home volume restores the snapshot; a snapshot is read through before the home is wiped; a failed volume removal stops reset/restore - events of a stopped turn no longer land in the next one; each channel message gets a turn of its own - saving a bot's settings keeps what it got meanwhile (three-way merge); a save file that cannot be read is kept - pages in Big5/GBK/Shift_JIS are read in their own encoding (encoding_rs); osascript output past 64 KB no longer stalls - pick_tab keeps a job's own non-http tab; pictures larger than the texture limit are fitted; the auto-update time field takes typing - skills live in <data>/skills; memories are unnumbered in the prompt; the phone may skillify and skill_install CI - the test step fails when the tests fail (it piped into tail) Tests: anybot 268 passed, 27 ignored; relay 16 passed; clippy unchanged. Not run: Windows on a real machine (win.rs type-checked alone), the Docker paths of the bot's computer, the live accessibility writes. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-10 03:46:17 +00:00
self.cu.schedule_typing |= typed;
if schedule_changed {
// Done typing: a real time is saved; anything else gives way to the saved one.
if chrono::NaiveTime::parse_from_str(at.trim(), "%H:%M").is_ok() {
cloudbox::set_auto_update_at(on.then(|| at.trim().to_string()));
}
self.cu.schedule_typing = false;
}
self.cu.schedule_edit = at;
match act {
Act::None => {}
Act::Recheck => cloudbox::refresh(),
Act::Download => crate::preview::open_with_system("https://orbstack.dev/download"),
Act::Docker => crate::preview::open_with_system("https://docs.docker.com/engine/install/"),
Act::View => self.open_viewer(),
Act::Wake => self.box_task(|| cloudbox::ensure_running().map(|_| "Bot 的電腦已經開好了。".to_string())),
Act::Browser => self.box_task(|| {
let url = cloudbox::viewer_url(false)?;
crate::preview::open_with_system(&url);
Ok(String::new())
}),
Act::UpdateClick => {
if armed {
self.cu.arm_update = None;
let ids: Vec<u64> = self.streams.keys().copied().collect();
for id in ids {
self.stop(id);
}
*self.cu.note.lock().unwrap() = match cloudbox::rebuild(Rebuild::Update) {
Ok(()) => t("更新已開始。"),
Err(e) => e,
};
} else {
self.cu.arm_update = Some(Instant::now());
}
}
Act::Reset => self.cu.confirm_reset = true,
Act::Snapshot => self.box_task(|| cloudbox::save_snapshot().map(|n| format!("已儲存快照({})。", cloudbox::human(n)))),
Act::AskClean => self.ask_primary_bot("檢查「Bot 的電腦」的磁碟使用情況,並提出安全的清理方案供我核准。先列出用量最大的地方,不要直接刪除任何東西。"),
Act::Disk => {
let slot = self.cu.disk.clone();
*slot.lock().unwrap() = Some("檢查中…".into());
std::thread::spawn(move || {
let r = cloudbox::disk_report().unwrap_or_else(|e| e);
*slot.lock().unwrap() = Some(r);
});
}
}
// ── 終端機與環境密鑰 ──
if !matches!(run, Run::NoDocker(_)) {
sec_title(ui, "終端機與環境密鑰", p, |_| {});
sec_card(ui, p, |ui| {
Frame::new().inner_margin(Margin::symmetric(14, 8)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.spacing_mut().item_spacing.y = 4.0;
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 4.0;
ui.label(RichText::new(t("給指令用的帳密")).size(FONT_SM).color(p.text2));
help_mark(ui, "例如 CRM_API_TOKEN。Bot 執行指令時會變成環境變數;值只能寫入,不能讀出。", p);
});
let names = cloudbox::secret_names();
let mut remove = None;
for n in &names {
ui.horizontal(|ui| {
ui.label(RichText::new(n).monospace().size(FONT_SM));
ui.label(RichText::new("••••••••").size(FONT_SM).color(p.text3));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(t("刪除")).size(FONT_XS).color(p.danger)).frame(false)).clicked() {
remove = Some(n.clone());
}
2026-11-16 14:07:07 +00:00
if ui.add(egui::Button::new(RichText::new(t("取代")).size(FONT_SM).color(p.text2)).frame(false)).clicked() {
self.cu.new_secret = (n.clone(), String::new());
self.cu.replace_secret = Some(n.clone());
}
});
});
}
if let Some(n) = remove {
cloudbox::remove_secret(&n);
}
ui.horizontal(|ui| {
let w = (ui.available_width() - 80.0) / 2.0;
let replacing = self.cu.replace_secret.is_some();
ui.add_enabled(!replacing, egui::TextEdit::singleline(&mut self.cu.new_secret.0).hint_text(t("名稱,例如 CRM_API_TOKEN")).desired_width(w - 8.0).font(egui::TextStyle::Monospace));
ui.add(egui::TextEdit::singleline(&mut self.cu.new_secret.1).password(true).hint_text(t("值")).desired_width(w - 8.0));
let ok = !self.cu.new_secret.0.trim().is_empty() && !self.cu.new_secret.1.is_empty();
if ui.add_enabled(ok, primary_button(if replacing { "取代" } else { "新增" }, p)).clicked() {
match cloudbox::set_secret(&self.cu.new_secret.0, &self.cu.new_secret.1) {
Ok(()) => {
self.cu.new_secret = Default::default();
self.cu.replace_secret = None;
self.cu.secret_error.clear();
}
Err(e) => self.cu.secret_error = e,
}
}
});
let up = self.cu.new_secret.0.to_uppercase();
if up != self.cu.new_secret.0 {
self.cu.new_secret.0 = up;
}
if !self.cu.secret_error.is_empty() {
ui.label(RichText::new(&self.cu.secret_error).size(FONT_XS).color(p.danger));
}
});
});
// ── 在哪裡執行 ──
sec_title(ui, "在哪裡執行", p, |_| {});
let current = cloudbox::docker_host();
fix: 測試不再碰使用者的資料夾和真的 Docker 電腦;設定 › 電腦 的 Docker 主機不再被切掉 2026-11-17 一個 app 測試的 shell 步驟被「Bot 不能自己換電腦」移回 Bot 的電腦,啟動了使用者的 anybot-gvisor Lima VM 還卡住。查下去:cargo test 時 State::path() 是使用者真的 AnyBot 資料夾,所以測試讀到它的 Docker 主機設定(也可能寫進去)。 - cargo test 時資料夾是這次測試自己的(暫存資料夾 anybot-test-data-<pid>);ANYBOT_DATA_DIR 照舊優先。 - cargo test 時 docker 一律指向不存在的位址(NO_BOX_IN_TESTS),馬上失敗;不開、也不關 Lima 虛擬機。要對真的電腦跑的實機測試(標 ignored、手動跑)設 ANYBOT_TEST_REAL_BOX=1。 - 設定 › 電腦 ›「Docker 主機」:位址寫在名稱下面(太長以 … 結尾、滑過看全文),按「修改」才出現橫跨整張卡的輸入框(套用/取消)。以前 180px 的框裡 Lima 位址被切掉 299px:版面檢查長期失敗的那一條就是這個,跟這台 Mac 的設定有關才一直沒被當真。 - docs/plan-2026-11-engineering.md:參考 xai-org/grok-build 的工程基礎與機制補強計畫(E1–E11、R1–R7、M1–M7),E1 做完。 已驗證:cargo test 550 全過(包括 text_stays_inside_its_place_on_every_screen,第一次全綠);新測試 tests_never_reach_the_real_box_or_data(資料夾在暫存、docker 位址、不開 VM、docker 一叫就失敗);跑完整套測試前後 anybot-gvisor 的開機時間沒變。 未驗證:「修改」展開後的輸入框截圖(那一列在頁面下面,截圖沒捲到;版面檢查有涵蓋)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:02:13 +00:00
// (None: not being changed — the address shows whole under the name; 修改 opens a
// field across the card. A Lima address no longer sat cut off in a 180px field.)
let mut edit = self.cu.docker_host.take();
let (mut apply, mut open, mut cancel) = (false, false, false);
sec_card(ui, p, |ui| {
fix: 測試不再碰使用者的資料夾和真的 Docker 電腦;設定 › 電腦 的 Docker 主機不再被切掉 2026-11-17 一個 app 測試的 shell 步驟被「Bot 不能自己換電腦」移回 Bot 的電腦,啟動了使用者的 anybot-gvisor Lima VM 還卡住。查下去:cargo test 時 State::path() 是使用者真的 AnyBot 資料夾,所以測試讀到它的 Docker 主機設定(也可能寫進去)。 - cargo test 時資料夾是這次測試自己的(暫存資料夾 anybot-test-data-<pid>);ANYBOT_DATA_DIR 照舊優先。 - cargo test 時 docker 一律指向不存在的位址(NO_BOX_IN_TESTS),馬上失敗;不開、也不關 Lima 虛擬機。要對真的電腦跑的實機測試(標 ignored、手動跑)設 ANYBOT_TEST_REAL_BOX=1。 - 設定 › 電腦 ›「Docker 主機」:位址寫在名稱下面(太長以 … 結尾、滑過看全文),按「修改」才出現橫跨整張卡的輸入框(套用/取消)。以前 180px 的框裡 Lima 位址被切掉 299px:版面檢查長期失敗的那一條就是這個,跟這台 Mac 的設定有關才一直沒被當真。 - docs/plan-2026-11-engineering.md:參考 xai-org/grok-build 的工程基礎與機制補強計畫(E1–E11、R1–R7、M1–M7),E1 做完。 已驗證:cargo test 550 全過(包括 text_stays_inside_its_place_on_every_screen,第一次全綠);新測試 tests_never_reach_the_real_box_or_data(資料夾在暫存、docker 位址、不開 VM、docker 一叫就失敗);跑完整套測試前後 anybot-gvisor 的開機時間沒變。 未驗證:「修改」展開後的輸入框截圖(那一列在頁面下面,截圖沒捲到;版面檢查有涵蓋)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:02:13 +00:00
const DOCKER_HELP: &str = "預設在這台電腦的 Docker 裡。也可以放到雲端或公司伺服器,例如 ssh://me@server。換位置後會在新的地方重新建立,舊檔案可以用快照搬過去。";
match edit.as_mut() {
None => {
let shown = if current.is_empty() { t("這台電腦(預設)") } else { current.clone() };
sec_row_s(ui, p, "Docker 主機", &shown, DOCKER_HELP, |ui| {
if ui.add(egui::Button::new(RichText::new(t("修改")).size(FONT_SM))).clicked() {
open = true;
}
});
}
fix: 測試不再碰使用者的資料夾和真的 Docker 電腦;設定 › 電腦 的 Docker 主機不再被切掉 2026-11-17 一個 app 測試的 shell 步驟被「Bot 不能自己換電腦」移回 Bot 的電腦,啟動了使用者的 anybot-gvisor Lima VM 還卡住。查下去:cargo test 時 State::path() 是使用者真的 AnyBot 資料夾,所以測試讀到它的 Docker 主機設定(也可能寫進去)。 - cargo test 時資料夾是這次測試自己的(暫存資料夾 anybot-test-data-<pid>);ANYBOT_DATA_DIR 照舊優先。 - cargo test 時 docker 一律指向不存在的位址(NO_BOX_IN_TESTS),馬上失敗;不開、也不關 Lima 虛擬機。要對真的電腦跑的實機測試(標 ignored、手動跑)設 ANYBOT_TEST_REAL_BOX=1。 - 設定 › 電腦 ›「Docker 主機」:位址寫在名稱下面(太長以 … 結尾、滑過看全文),按「修改」才出現橫跨整張卡的輸入框(套用/取消)。以前 180px 的框裡 Lima 位址被切掉 299px:版面檢查長期失敗的那一條就是這個,跟這台 Mac 的設定有關才一直沒被當真。 - docs/plan-2026-11-engineering.md:參考 xai-org/grok-build 的工程基礎與機制補強計畫(E1–E11、R1–R7、M1–M7),E1 做完。 已驗證:cargo test 550 全過(包括 text_stays_inside_its_place_on_every_screen,第一次全綠);新測試 tests_never_reach_the_real_box_or_data(資料夾在暫存、docker 位址、不開 VM、docker 一叫就失敗);跑完整套測試前後 anybot-gvisor 的開機時間沒變。 未驗證:「修改」展開後的輸入框截圖(那一列在頁面下面,截圖沒捲到;版面檢查有涵蓋)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:02:13 +00:00
Some(e) => {
sec_row(ui, p, "Docker 主機", DOCKER_HELP, |ui| {
if ui.add_enabled(e.trim() != current, primary_button("套用", p)).clicked() {
apply = true;
}
if ui.add(egui::Button::new(RichText::new(t("取消")).size(FONT_XS).color(p.text3)).frame(false)).clicked() {
cancel = true;
}
});
ui.add(egui::TextEdit::singleline(e).hint_text(t("這台電腦(預設)")).desired_width(ui.available_width()).font(egui::TextStyle::Monospace));
ui.add_space(6.0);
}
}
let rt_now = cloudbox::box_runtime();
let facts = self.cu.runtime_facts.lock().unwrap().clone();
// What the box really runs on, and what pressing 更新 would change.
let status = match &facts {
Some((false, _)) if rt_now == "runsc" => "這台 Docker 主機沒有裝 gVisor:會用標準隔離開機".to_string(),
Some((_, Some(running))) if *running != rt_now => format!("目前是{};按電腦的「更新」重建後改成{}", if running == "runsc" { "強隔離" } else { "標準" }, if rt_now == "runsc" { "強隔離" } else { "標準" }),
Some((_, Some(running))) => format!("目前是{}", if running == "runsc" { "強隔離(gVisor)" } else { "標準" }),
_ => String::new(),
};
let gvisor_here = facts.as_ref().map(|f| f.0).unwrap_or(false);
sec_row_s(ui, p, "容器隔離", &status, "標準:容器和這台 Docker 主機共用 Linux 核心,Bot 開網頁時只有一層牆。Docker 主機裝了 gVisor 才能選強隔離:電腦得到自己的虛擬核心,Chromium 的沙盒也會打開,多一道牆。改完按電腦的「更新」重建後生效。", |ui| {
let rt = if self.cu.box_runtime.is_empty() { rt_now.clone() } else { self.cu.box_runtime.clone() };
let std_on = rt == "runc";
let gvis_on = rt == "runsc";
// (The row lays out right to left: 強隔離 first puts 標準 on its left.)
let g = ui.add_enabled_ui(gvisor_here || gvis_on, |ui| ui.selectable_label(gvis_on, t("強隔離(gVisor)"))).inner;
if g.clicked() {
self.cu.box_runtime = "runsc".into();
}
g.on_disabled_hover_text(t("這台 Docker 主機沒有裝 gVisor(runsc)"));
if ui.selectable_label(std_on, t("標準")).clicked() {
self.cu.box_runtime = "runc".into();
}
if !self.cu.box_runtime.is_empty() && self.cu.box_runtime != rt_now {
if ui.add(primary_button("套用", p)).clicked() {
cloudbox::set_box_runtime(&self.cu.box_runtime);
self.cu.box_runtime.clear();
self.cu.update_checked = None;
}
if ui.add(egui::Button::new(RichText::new(t("取消")).size(FONT_XS).color(p.text3)).frame(false)).clicked() {
self.cu.box_runtime.clear();
}
}
});
});
fix: 測試不再碰使用者的資料夾和真的 Docker 電腦;設定 › 電腦 的 Docker 主機不再被切掉 2026-11-17 一個 app 測試的 shell 步驟被「Bot 不能自己換電腦」移回 Bot 的電腦,啟動了使用者的 anybot-gvisor Lima VM 還卡住。查下去:cargo test 時 State::path() 是使用者真的 AnyBot 資料夾,所以測試讀到它的 Docker 主機設定(也可能寫進去)。 - cargo test 時資料夾是這次測試自己的(暫存資料夾 anybot-test-data-<pid>);ANYBOT_DATA_DIR 照舊優先。 - cargo test 時 docker 一律指向不存在的位址(NO_BOX_IN_TESTS),馬上失敗;不開、也不關 Lima 虛擬機。要對真的電腦跑的實機測試(標 ignored、手動跑)設 ANYBOT_TEST_REAL_BOX=1。 - 設定 › 電腦 ›「Docker 主機」:位址寫在名稱下面(太長以 … 結尾、滑過看全文),按「修改」才出現橫跨整張卡的輸入框(套用/取消)。以前 180px 的框裡 Lima 位址被切掉 299px:版面檢查長期失敗的那一條就是這個,跟這台 Mac 的設定有關才一直沒被當真。 - docs/plan-2026-11-engineering.md:參考 xai-org/grok-build 的工程基礎與機制補強計畫(E1–E11、R1–R7、M1–M7),E1 做完。 已驗證:cargo test 550 全過(包括 text_stays_inside_its_place_on_every_screen,第一次全綠);新測試 tests_never_reach_the_real_box_or_data(資料夾在暫存、docker 位址、不開 VM、docker 一叫就失敗);跑完整套測試前後 anybot-gvisor 的開機時間沒變。 未驗證:「修改」展開後的輸入框截圖(那一列在頁面下面,截圖沒捲到;版面檢查有涵蓋)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:02:13 +00:00
if open {
edit = Some(current.clone());
}
if cancel {
edit = None;
}
if apply {
fix: 測試不再碰使用者的資料夾和真的 Docker 電腦;設定 › 電腦 的 Docker 主機不再被切掉 2026-11-17 一個 app 測試的 shell 步驟被「Bot 不能自己換電腦」移回 Bot 的電腦,啟動了使用者的 anybot-gvisor Lima VM 還卡住。查下去:cargo test 時 State::path() 是使用者真的 AnyBot 資料夾,所以測試讀到它的 Docker 主機設定(也可能寫進去)。 - cargo test 時資料夾是這次測試自己的(暫存資料夾 anybot-test-data-<pid>);ANYBOT_DATA_DIR 照舊優先。 - cargo test 時 docker 一律指向不存在的位址(NO_BOX_IN_TESTS),馬上失敗;不開、也不關 Lima 虛擬機。要對真的電腦跑的實機測試(標 ignored、手動跑)設 ANYBOT_TEST_REAL_BOX=1。 - 設定 › 電腦 ›「Docker 主機」:位址寫在名稱下面(太長以 … 結尾、滑過看全文),按「修改」才出現橫跨整張卡的輸入框(套用/取消)。以前 180px 的框裡 Lima 位址被切掉 299px:版面檢查長期失敗的那一條就是這個,跟這台 Mac 的設定有關才一直沒被當真。 - docs/plan-2026-11-engineering.md:參考 xai-org/grok-build 的工程基礎與機制補強計畫(E1–E11、R1–R7、M1–M7),E1 做完。 已驗證:cargo test 550 全過(包括 text_stays_inside_its_place_on_every_screen,第一次全綠);新測試 tests_never_reach_the_real_box_or_data(資料夾在暫存、docker 位址、不開 VM、docker 一叫就失敗);跑完整套測試前後 anybot-gvisor 的開機時間沒變。 未驗證:「修改」展開後的輸入框截圖(那一列在頁面下面,截圖沒捲到;版面檢查有涵蓋)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:02:13 +00:00
if let Some(e) = edit.take() {
cloudbox::set_docker_host(e.trim());
}
}
fix: 測試不再碰使用者的資料夾和真的 Docker 電腦;設定 › 電腦 的 Docker 主機不再被切掉 2026-11-17 一個 app 測試的 shell 步驟被「Bot 不能自己換電腦」移回 Bot 的電腦,啟動了使用者的 anybot-gvisor Lima VM 還卡住。查下去:cargo test 時 State::path() 是使用者真的 AnyBot 資料夾,所以測試讀到它的 Docker 主機設定(也可能寫進去)。 - cargo test 時資料夾是這次測試自己的(暫存資料夾 anybot-test-data-<pid>);ANYBOT_DATA_DIR 照舊優先。 - cargo test 時 docker 一律指向不存在的位址(NO_BOX_IN_TESTS),馬上失敗;不開、也不關 Lima 虛擬機。要對真的電腦跑的實機測試(標 ignored、手動跑)設 ANYBOT_TEST_REAL_BOX=1。 - 設定 › 電腦 ›「Docker 主機」:位址寫在名稱下面(太長以 … 結尾、滑過看全文),按「修改」才出現橫跨整張卡的輸入框(套用/取消)。以前 180px 的框裡 Lima 位址被切掉 299px:版面檢查長期失敗的那一條就是這個,跟這台 Mac 的設定有關才一直沒被當真。 - docs/plan-2026-11-engineering.md:參考 xai-org/grok-build 的工程基礎與機制補強計畫(E1–E11、R1–R7、M1–M7),E1 做完。 已驗證:cargo test 550 全過(包括 text_stays_inside_its_place_on_every_screen,第一次全綠);新測試 tests_never_reach_the_real_box_or_data(資料夾在暫存、docker 位址、不開 VM、docker 一叫就失敗);跑完整套測試前後 anybot-gvisor 的開機時間沒變。 未驗證:「修改」展開後的輸入框截圖(那一列在頁面下面,截圖沒捲到;版面檢查有涵蓋)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 03:02:13 +00:00
self.cu.docker_host = edit;
if ui.add(egui::Button::new(RichText::new(t(if self.cu.show_log { "隱藏紀錄" } else { "顯示紀錄" })).size(FONT_XS).color(p.text3)).frame(false)).clicked() {
self.cu.show_log = !self.cu.show_log;
}
if self.cu.show_log {
let lines = cloudbox::log_lines();
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
Frame::new().fill(p.hover).corner_radius(R_M).inner_margin(Margin::symmetric(10, 8)).show(ui, |ui| {
ui.set_width(ui.available_width());
if lines.is_empty() {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(t("(沒有紀錄)")).size(FONT_XS).color(p.text3));
}
for l in lines.iter().rev().take(30) {
2026-11-16 14:07:07 +00:00
ui.label(RichText::new(l).monospace().size(FONT_SM).color(p.text2));
}
});
}
}
}
// ── 示範教學、瀏覽器 ──
ui.add_space(SEC_GAP * 0.5);
ui.spacing_mut().item_spacing.y = 6.0;
self.teach_card(ui);
setting_card(ui, p, |ui| self.browser_profiles_section(ui, p));
self.computers_dialogs(ui.ctx());
}
/// 要移除「…」嗎? and 要重設 AnyBot 的電腦嗎?
fn computers_dialogs(&mut self, ctx: &egui::Context) {
let p = self.pal;
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
if let Some(name) = self.cu.confirm_remove.clone() {
let mut keep = true;
let mut remove = false;
let close = dialog(ctx, "remove-computer", &format!("要移除「{name}」嗎?"), 420.0, true, p, |ui| {
dialog_body(ui, "remove-computer-body", 200.0, |ui| {
ui.label(t("Bot 將無法再在這台電腦上執行任務。之後可以再用 SSH 加回來。"));
});
dialog_footer(ui, p, |ui| {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if ui.add(danger_button("移除", p)).clicked() {
remove = true;
keep = false;
}
if ui.add(secondary_button("取消")).clicked() {
keep = false;
}
});
});
});
安全、修正: harden sandboxes, approval gates, vault, relay roles, and fix protocol/UI bugs - macOS 沙盒與工具 (tools.rs, policy.rs, docindex.rs): block AppleScript raw events and concatenation outside the sandbox; stop exposing ~/.ssh or localhost sockets in Sealed mode; deny writes to shell profiles, LaunchAgents and .git/hooks; expand secret-file ignores and enforce symlink/policy checks across SSH, device and document search. - 電腦操作與遮罩 (computer.rs, agent.rs, marks.rs, desktop.rs, cloudbox.rs, portal.rs): forbid clicking or typing into AnyBot's own windows; extend the sensitive-action hard gate to raw coordinates, Return/Delete submits and remote devices; stop batch steps if the front app changes; black out secrets on zoom, show, >600-node trees, adjacent OTP labels, box screenshots and control text lists; preserve non-text Wayland clipboards. - 保險庫與瀏覽器 (vault.rs, vault_store.rs, browser.rs, botbrowser.rs, web.rs, box/browser): verify tab host and HTTPS atomically at fill time; taint filled tabs against browser_eval and PDF export while masking card/CVC values and screenshots; remember sites only on always-allow; drop --remote-allow-origins=*; gate private URLs and block metadata/Docker ports, OrbStack 198.18/15 and IPv6 transition ranges. - 帳號伺服器、同步與傳送 (relay/, remote.rs, mirror_ui.rs, share.rs, drops.rs): isolate paired hands hosts from brain sync, tickets, pairing and backup overwrites; redact routine trigger secrets and clear REDACTED when endpoints change; isolate channel and team-member turns from owner memories, appctl and grants; scrub shared bot exports and reset grants/routines on import; validate drop IDs and serialize chunk writes. - 網路與協定穩定性 (httpd.rs, tunnel.rs, vnc.rs, Caddyfile*): fix chunked integer overflow and CRLF header injection; enforce Origin checks, connection/job caps, 200 MB backup reads, unique atomic temp files and ASCII hex guards; bound deflate unzip and VNC sniff buffers; move VNC stdin/text off the tunnel loop. - 介面、排程、語言與其他修正 (app.rs, i18n.rs, providers.rs, skills.rs, routines.rs, setup.rs, store.rs, preview.rs, attach.rs, speech.rs, teams.rs, mcp.rs, voice.rs): wire up the delete-routine confirmation dialog and mirror run-now; preserve unsaved mirror edits across brief disconnects; give Chinese skills distinct folders and approval gates; convert parsed tool JSON fields without corrupting code fences, URLs or paths; fix Hourly DST offsets and time out unattended routine approvals; lock --install-skill, cap docx/xlsx unzip sizes, isolate test env keys, and tighten local file permissions. Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-12 06:34:10 +00:00
if remove {
self.state.remote_computers.retain(|c| c.name != name);
self.mark();
}
if !keep || close {
self.cu.confirm_remove = None;
}
}
if self.cu.confirm_reset {
let working = self.streams.len();
let has_snap = cloudbox::snapshot_time().is_some();
let mut keep = true;
let mut go = false;
let close = dialog(ctx, "reset-computer", "要重設 AnyBot 的電腦嗎?", 460.0, true, p, |ui| {
dialog_body(ui, "reset-computer-body", 320.0, |ui| {
let w = if working == 0 { t("所有執行中的工作都將被中斷。") } else { format!("{working} 個 Bot 正在工作,將會被中斷。") };
Bots do a planned sequence in one step; the box's screen settles by what it shows; no login is ever the only copy - computer_use_batch: up to 8 planned actions run in one docker exec (steps chained with && and a done-marker each), the first failure stops the rest, one picture comes back at the end. Typed text rides inside the script quoted (one stdin for the chain). The prompt tells the model when to use it (a form whose fields are all visible) and when not to (step 2 needs step 1's screen). - The box waits for the screen to stop changing, not the clock: two matching small probes (~60 ms each) mean settled — ~160 ms on a still screen where every step paid a fixed 500 ms, and a page mid-load is waited for (up to ~0.9 s) instead of captured mid-change. The picture is JPEG, and the a11y read runs in parallel with the capture (look ~307 ms; two steps with pictures 1102 ms). (SETTLE_SH is a group command: dash needs ';' after it — found by box_screen_is_exact.) - The home volume (every bot's logins) is never one command from loss: snapshots keep generations (last 7 days, then one per week; the old single snapshot migrates by file date), Reset and Restore save the running box first and refuse to wipe if saving fails, a box built on an empty volume re-fills itself from the newest snapshot, and a sleeping holder container keeps the volume attached so `docker volume prune` can't take it. make doctor shows volume and snapshot state; the 電腦 card shows the box's average step times and says resets save first. - box_batch_in_one_round_trip (ignored): three typed steps, ASCII and Chinese, land in one trip. On the real box after upgrading v3→v5: box_update_keeps_files (files survive, snapshot 2 代), box_numbers_are_exact, box_screen_is_exact, box_end_to_end, box_traffic_via_mac pass; 155 unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 01:47:37 +00:00
ui.label(if has_snap { format!("從上次儲存的快照還原。這會關閉目前的電腦,並以最新版本啟動一台全新的電腦。目前電腦的內容會先存成快照,事後可以找回。{w}") } else { format!("還沒有快照:這會換一台全新的電腦,裡面的檔案和登入資訊都會清除。{w}") });
ui.add_space(8.0);
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
Frame::new().fill(p.danger.gamma_multiply(0.08)).corner_radius(R_M).inner_margin(Margin::same(10)).show(ui, |ui| {
ui.add(egui::Label::new(RichText::new(t("警告:尚未同步到快照的工作(包括最近的檔案)將會遺失。已安裝的應用程式和套件會被移除。")).size(FONT_SM).color(p.danger)).wrap());
});
});
dialog_footer(ui, p, |ui| {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
if ui.add(danger_button("重設 AnyBot 的電腦", p)).clicked() {
go = true;
keep = false;
}
if ui.add(secondary_button("取消")).clicked() {
keep = false;
}
});
});
});
if go {
let ids: Vec<u64> = self.streams.keys().copied().collect();
for id in ids {
self.stop(id);
}
let kind = if has_snap { Rebuild::Restore } else { Rebuild::Reset };
*self.cu.note.lock().unwrap() = match cloudbox::rebuild(kind) {
Ok(()) => t("重設已開始。"),
Err(e) => e,
};
}
if !keep || close {
self.cu.confirm_reset = false;
}
}
}
/// 「AnyBot Computer Use」: what seeing and using this computer's screen needs.
pub(super) fn mac_permissions_card(&mut self, ui: &mut egui::Ui) {
let p = self.pal;
if cfg!(target_os = "linux") {
#[cfg(target_os = "linux")]
{
let kind = crate::desk::kind();
let (state, sub) = match kind {
crate::desk::Kind::X11 => ("已授予", "X11 桌面:可以截圖、點擊、打字,也能錄製示範"),
crate::desk::Kind::Wlr => ("已授予", "Wayland 桌面:可以截圖、點擊、打字(錄製示範需要 Xorg 工作階段)"),
crate::desk::Kind::Portal => ("第一次使用時詢問", "Wayland 桌面:第一次使用時系統會跳出視窗,打開「允許遠端操作」再按「分享」(錄製示範需要 Xorg 工作階段)"),
crate::desk::Kind::None if crate::desk::wayland() => ("無法使用", "找不到 xdg-desktop-portal 的遠端桌面功能,請安裝 xdg-desktop-portal-gnome 或 -kde"),
crate::desk::Kind::None => ("無法使用", "這台電腦沒有顯示器"),
};
sec_title(ui, "AnyBot Computer Use", p, |_| {});
sec_card(ui, p, |ui| {
sec_row(ui, p, "看畫面和操作", sub, |ui| {
ui.label(RichText::new(t(state)).size(FONT_SM).color(p.text2));
});
});
}
self.allowed_apps_section(ui);
return;
}
if !cfg!(target_os = "macos") {
return;
}
let see = crate::computer::screen_capture_ok();
let control = crate::axread::trusted(false);
sec_title(ui, "AnyBot Computer Use", p, |_| {});
let mut open_pane = None;
sec_card(ui, p, |ui| {
let state = |ok: bool| t(if ok { "已授予" } else { "未授予" });
sec_row(ui, p, "螢幕錄製", "讓 Bot 看到你的螢幕", |ui| {
ui.label(RichText::new(state(see)).size(FONT_SM).color(if see { p.text2 } else { p.danger }));
});
sec_row(ui, p, "輔助使用", "讓 Bot 點擊和打字,也用來錄製示範", |ui| {
ui.label(RichText::new(state(control)).size(FONT_SM).color(if control { p.text2 } else { p.danger }));
});
if !see || !control {
sec_row(ui, p, "授予權限", "打開系統設定的面板。把 AnyBot(或「終端機」)加到清單裡並打開。", |ui| {
if ui.add(primary_button("開啟設定", p)).clicked() {
open_pane = Some(if !see { "Privacy_ScreenCapture" } else { "Privacy_Accessibility" });
}
});
}
});
if let Some(pane) = open_pane {
let _ = crate::computer::spawn_reaped(std::process::Command::new("open").arg(format!("x-apple.systempreferences:com.apple.preference.security?{pane}")));
}
self.allowed_apps_section(ui);
}
/// 一律允許的應用程式: apps bots may use without asking (per bot), with a remove button.
fn allowed_apps_section(&mut self, ui: &mut egui::Ui) {
let p = self.pal;
let apps: Vec<(u64, String, String)> = self
.state
.bots
.iter()
fix: Linux 操作恢復順暢——保險箱空的不給填入工具、同一個錯誤不再鬼打牆;Wayland 可一律允許、長網頁有編號、Enter 只看游標那格;做完就關掉瀏覽器 一台 Linux(Ubuntu 26.04、X11)上一輪 Threads 海巡 40 分鐘只送出 1 則:小模型一直誤叫保險箱填入(171 次),而 4b53ad4 之後回的是「沒有開著的分頁,請先 browser_open」,Bot 照做又再誤叫。 - 保險箱:只給有東西可填的種類(空的就沒有 vault 工具、browser 也沒有 fill);填入先查 id 在不在,錯誤講對、指向 type;規劃與填入都在這個任務自己的分頁上(本機、box、遠端手腳) - 同一個工具連續 3 次回一樣的錯誤(換參數也一樣):這一回合不再執行 - Wayland(GNOME/KDE,wlroots 的座標點擊)認不出 App 時,改給「操作這台電腦的螢幕」一律允許(一律允許清單裡可移除) - 元素樹走訪上限 4000 → 20000:長網頁捲下去,看得到的部分也有編號 - 敏感動作關卡:Enter/送出只看游標所在(或正在打字)的欄位;座標點擊只看點到的最內層控制項;英文整字比對(PayPal 不是 pay);步驟在別台電腦時不查大腦本機的編號 - 打字先點欄位再檢查最前面是不是 AnyBot;批次從 AnyBot 切到要操作的 App 不再中斷,切到第三個 App 或回到 AnyBot 才停 - 估算對話長度只算真的會送出的最新 3 張截圖 - 做完就關掉瀏覽器(設定 › 電腦 › AnyBot 瀏覽器設定檔,預設開):一輪結束關掉用過的 Firefox/Chrome,別的 Bot 還在用就只關自己的分頁;box 的 Chromium 不變 Mac 444、Linux 448 個測試通過;Firefox 收尾實機測試(Mac、Linux Snap 版)通過;已在那台 Linux 上部署驗證。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:21:32 +00:00
// (The whole screen, when the desktop couldn't name the app: listed and removable too.)
.flat_map(|b| b.allow_rules.iter().filter_map(|g| if g == "computer:control" { Some(SCREEN_ROW) } else { g.strip_prefix("app:") }).map(|a| (b.id, b.name.clone(), a.to_string())).collect::<Vec<_>>())
.collect();
if apps.is_empty() {
return;
}
let open = self.cu.apps_open;
let mut remove = None;
let mut flip = false;
sec_card(ui, p, |ui| {
sec_row(ui, p, "一律允許的應用程式", "Bot 無需事先詢問即可使用這些應用程式", |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
let b = egui::Button::new(RichText::new(format!("{} 個應用程式 {}", apps.len(), if open { "⌄" } else { "›" })).size(FONT_SM)).corner_radius(R_M);
if ui.add(b).clicked() {
flip = true;
}
});
if open {
for (id, bot, app) in &apps {
sec_row_s(ui, p, app, &format!("{bot} 可以使用"), "", |ui| {
if crate::icons::button(ui, crate::icons::Icon::Trash, 14.0, p.text3, p.hover).on_hover_text(format!("{} {app}", t("移除"))).clicked() {
fix: Linux 操作恢復順暢——保險箱空的不給填入工具、同一個錯誤不再鬼打牆;Wayland 可一律允許、長網頁有編號、Enter 只看游標那格;做完就關掉瀏覽器 一台 Linux(Ubuntu 26.04、X11)上一輪 Threads 海巡 40 分鐘只送出 1 則:小模型一直誤叫保險箱填入(171 次),而 4b53ad4 之後回的是「沒有開著的分頁,請先 browser_open」,Bot 照做又再誤叫。 - 保險箱:只給有東西可填的種類(空的就沒有 vault 工具、browser 也沒有 fill);填入先查 id 在不在,錯誤講對、指向 type;規劃與填入都在這個任務自己的分頁上(本機、box、遠端手腳) - 同一個工具連續 3 次回一樣的錯誤(換參數也一樣):這一回合不再執行 - Wayland(GNOME/KDE,wlroots 的座標點擊)認不出 App 時,改給「操作這台電腦的螢幕」一律允許(一律允許清單裡可移除) - 元素樹走訪上限 4000 → 20000:長網頁捲下去,看得到的部分也有編號 - 敏感動作關卡:Enter/送出只看游標所在(或正在打字)的欄位;座標點擊只看點到的最內層控制項;英文整字比對(PayPal 不是 pay);步驟在別台電腦時不查大腦本機的編號 - 打字先點欄位再檢查最前面是不是 AnyBot;批次從 AnyBot 切到要操作的 App 不再中斷,切到第三個 App 或回到 AnyBot 才停 - 估算對話長度只算真的會送出的最新 3 張截圖 - 做完就關掉瀏覽器(設定 › 電腦 › AnyBot 瀏覽器設定檔,預設開):一輪結束關掉用過的 Firefox/Chrome,別的 Bot 還在用就只關自己的分頁;box 的 Chromium 不變 Mac 444、Linux 448 個測試通過;Firefox 收尾實機測試(Mac、Linux Snap 版)通過;已在那台 Linux 上部署驗證。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 08:21:32 +00:00
remove = Some((*id, if app == SCREEN_ROW { "computer:control".to_string() } else { format!("app:{app}") }));
}
});
}
}
});
if flip {
self.cu.apps_open = !open;
}
if let Some((id, g)) = remove {
if let Some(b) = self.state.bot_mut(id) {
b.allow_rules.retain(|x| *x != g);
}
self.mark();
}
}
pub(super) fn box_task(&mut self, f: impl FnOnce() -> Result<String, String> + Send + 'static) {
let note = self.cu.note.clone();
*note.lock().unwrap() = "處理中…".into();
std::thread::spawn(move || {
let r = f();
*note.lock().unwrap() = match r {
Ok(s) => s,
Err(e) => e,
};
cloudbox::refresh();
});
}
fn ask_primary_bot(&mut self, text: &str) {
let id = self.state.primary_bot;
self.drafts.insert(id, text.to_string());
self.state.selected = id;
self.show_settings = false;
}
/// The confirm dialog for a rebuild (the original's wording).
pub(super) fn rebuild_dialog(&mut self, ctx: &egui::Context) {
let Some(kind) = self.cu.confirm else { return };
let p = self.pal;
let mut go = false;
let mut close = dialog(ctx, "box-rebuild", &format!("{}?", kind.title()), 420.0, true, p, |ui| {
dialog_body(ui, "box-rebuild-body", 300.0, |ui| {
ui.add(egui::Label::new(RichText::new(kind.warning()).size(FONT_BASE)).wrap());
if kind == Rebuild::Update && cloudbox::is_busy() {
ui.add_space(6.0);
ui.label(RichText::new(t("有 Bot 正在用這台電腦,等它做完再重建。")).size(FONT_XS).color(p.danger));
}
});
dialog_footer(ui, p, |ui| {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
let btn = if kind == Rebuild::Reset { danger_button(kind.title(), p) } else { primary_button(kind.title(), p) };
if ui.add(btn).clicked() {
go = true;
}
if ui.add(secondary_button("取消")).clicked() {
go = false;
self.cu.confirm = None;
}
});
});
});
if go {
if kind == Rebuild::Update {
// 更新會先停掉正在工作的 Bot,聊天會保留.
let ids: Vec<u64> = self.streams.keys().copied().collect();
for id in ids {
self.stop(id);
}
}
*self.cu.note.lock().unwrap() = match cloudbox::rebuild(kind) {
Ok(()) => format!("{}已開始。", kind.title()),
Err(e) => e,
};
close = true;
}
if close {
self.cu.confirm = None;
}
}
// ---------- the live screen ----------
/// The box's screen as a small picture, refreshed every few seconds while it is shown (taking
/// it never wakes the box; asleep it shows the last picture).
pub(super) fn box_thumbnail(&mut self, ctx: &egui::Context) -> Option<(egui::TextureId, egui::Vec2)> {
if let Some(img) = self.cu.thumb_img.lock().unwrap().take() {
match &mut self.cu.thumb {
Some(t) => t.set(img, egui::TextureOptions::LINEAR),
None => self.cu.thumb = Some(ctx.load_texture("box-thumb", img, egui::TextureOptions::LINEAR)),
}
}
// On a screen of a brain the bots' computer is the brain's: its picture comes from there.
let brain = self.mir.on.then(|| self.state.remote.clone());
let running = if brain.is_some() { self.mir.box_state["running"].as_bool().unwrap_or(false) } else { cloudbox::run_state().is_running() };
let every = if running { 3 } else { 30 };
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
// The selected bot's own screen (another bot picked: a new picture at once; in a group
// chat the member the person picked).
let bot = self.shown_bot(self.state.selected);
let fresh = self.cu.thumb_bot != bot;
if (fresh || !self.cu.thumb_at.map(|t| t.elapsed().as_secs() < every).unwrap_or(false)) && !self.cu.thumb_busy.swap(true, Ordering::SeqCst) {
self.cu.thumb_at = Some(Instant::now());
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
self.cu.thumb_bot = bot;
let key = self.screen_key_for(bot);
let (slot, busy, c) = (self.cu.thumb_img.clone(), self.cu.thumb_busy.clone(), ctx.clone());
std::thread::spawn(move || {
let img = match &brain {
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
Some(s) => crate::remote::sync_screen(s, true, bot).ok().and_then(|b| image::load_from_memory(&b).ok()).map(|i| i.to_rgba8()),
None => cloudbox::thumbnail_of(&key, 320).or_else(|| cloudbox::thumbnail(320)),
};
if let Some(img) = img {
let size = [img.width() as usize, img.height() as usize];
*slot.lock().unwrap() = Some(egui::ColorImage::from_rgba_unmultiplied(size, img.as_raw()));
c.request_repaint();
}
busy.store(false, Ordering::SeqCst);
});
}
ctx.request_repaint_after(std::time::Duration::from_secs(every));
self.cu.thumb.as_ref().map(|t| (t.id(), t.size_vec2()))
}
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
/// 看畫面: the bots' computer in the browser (noVNC), live, where the person can also take
/// over. On a screen of a brain it is the brain's computer, through the account server (a
/// link made for this once); here it is this computer's own box.
pub(super) fn open_viewer(&mut self) {
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
self.open_screen(false);
}
fn open_screen(&mut self, control: bool) {
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
// 每個 Bot 一個螢幕: the selected bot's own screen (the shared one when it has none open).
self.open_screen_of(self.shown_bot(self.state.selected), control);
}
/// `bot`'s own screen to watch (or take over), the shared one when it has none open.
pub(super) fn open_screen_of(&mut self, bot: u64, control: bool) {
self.show_settings = false;
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
let name = self.state.bot(bot).map(|b| format!("{} 的電腦", b.name)).unwrap_or_else(|| "Bot 的電腦".into());
if self.mir.on {
let s = self.state.remote.clone();
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
self.box_task(move || {
let ticket = crate::remote::screen_ticket(&s)?;
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
let url = format!("{}/screen#host={}&ticket={ticket}&name={}&bot={bot}{}", s.relay_url.trim_end_matches('/'), s.brain_id, crate::httpd::url_encode(&name), if control { "&control=1" } else { "" });
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
crate::preview::open_with_system(&url);
Ok(String::new())
});
return;
}
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
if self.demo {
return;
}
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
let key = self.screen_key_for(bot);
fix: 接管、打字、看畫面都只動自己那個螢幕;開著畫面的螢幕不會被收掉 每個 Bot 一個螢幕說好了「接管時只有它停手,別的 Bot 照做」,程式沒有照做: 任何人對任何螢幕動滑鼠打字,LAST_INPUT 是全域的一顆,所有 Bot 的電腦步驟都停 8 秒。現在記在每顆螢幕自己的按鍵時間上,person_active 只看自己那顆;電腦步驟 (computer_run)問的是自己正在用的那顆。 在 viewer 打的字(中文輸入、貼上的文字)以前永遠進共用螢幕(DISPLAY=:1),Bot 自己的螢幕收不到。現在 relay 在 vtext 上帶上這個 viewer 是替哪個 Bot 開的, tunnel/remote 換成螢幕 key,vnc::person_typed 在 on_screen 裡貼進那個螢幕。 新 relay+舊大腦會退回共用螢幕(=舊行為),新大腦+舊 relay 也是,不會斷話。 開著畫面看的那顆螢幕不再被 10 分鐘閒置收掉:連上時 touch 一次,viewer 活著每 60 秒 touch 一次(靜止畫面不送 frame,不能掛在讀取迴圈上)。 瀏覽器那條路的螢幕已滿提示:screen_cdp_port 把 anybot-screen 的 stderr 丟了, FULL= 進不了錯誤字串,screen_full 認不到——加 2>&1(computer 那條路早就有)。 瀏覽器清單和收工清分頁不再無端開螢幕:新增 browser_open_port 只讀 env 檔、 從不 up(老映像照 screen_sh 的規則退回共用埠),running_port 改用它;Bot 一輪 工作要用瀏覽器時照樣會開(ensure 走 browser_running)。 「開啟電腦」不再凍視窗:查「有哪些螢幕開著」的 docker 呼叫(5 秒)從 UI 執行 緒搬進背景工作。功能地圖:開著看畫面的不算閒置;viewer 打的字進正在看的螢幕。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 02:59:22 +00:00
// Asking the box which screens are open is a docker call: it goes in the background task,
// so a starting box can't freeze the window for its timeout.
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
self.box_task(move || {
fix: 接管、打字、看畫面都只動自己那個螢幕;開著畫面的螢幕不會被收掉 每個 Bot 一個螢幕說好了「接管時只有它停手,別的 Bot 照做」,程式沒有照做: 任何人對任何螢幕動滑鼠打字,LAST_INPUT 是全域的一顆,所有 Bot 的電腦步驟都停 8 秒。現在記在每顆螢幕自己的按鍵時間上,person_active 只看自己那顆;電腦步驟 (computer_run)問的是自己正在用的那顆。 在 viewer 打的字(中文輸入、貼上的文字)以前永遠進共用螢幕(DISPLAY=:1),Bot 自己的螢幕收不到。現在 relay 在 vtext 上帶上這個 viewer 是替哪個 Bot 開的, tunnel/remote 換成螢幕 key,vnc::person_typed 在 on_screen 裡貼進那個螢幕。 新 relay+舊大腦會退回共用螢幕(=舊行為),新大腦+舊 relay 也是,不會斷話。 開著畫面看的那顆螢幕不再被 10 分鐘閒置收掉:連上時 touch 一次,viewer 活著每 60 秒 touch 一次(靜止畫面不送 frame,不能掛在讀取迴圈上)。 瀏覽器那條路的螢幕已滿提示:screen_cdp_port 把 anybot-screen 的 stderr 丟了, FULL= 進不了錯誤字串,screen_full 認不到——加 2>&1(computer 那條路早就有)。 瀏覽器清單和收工清分頁不再無端開螢幕:新增 browser_open_port 只讀 env 檔、 從不 up(老映像照 screen_sh 的規則退回共用埠),running_port 改用它;Bot 一輪 工作要用瀏覽器時照樣會開(ensure 走 browser_running)。 「開啟電腦」不再凍視窗:查「有哪些螢幕開著」的 docker 呼叫(5 秒)從 UI 執行 緒搬進背景工作。功能地圖:開著看畫面的不算閒置;viewer 打的字進正在看的螢幕。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 02:59:22 +00:00
let key = if cloudbox::open_screens().iter().any(|(k, _)| *k == key) { key } else { String::new() };
// This viewer is noVNC straight to the box (AnyBot never sees it): marked used now,
// so a screen idle for almost 10 minutes isn't reaped before the page connects; from
// then on the box sees the connection itself (box/screen's reap: watched).
cloudbox::touch_screen(&key);
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
let url = cloudbox::viewer_url_of(&key, control)?;
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
crate::preview::open_with_system(&url);
Ok(String::new())
});
}
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
/// 接管: open the computer with control (the bot waits for the person meanwhile).
pub(super) fn take_over_computer(&mut self) {
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
self.open_screen(true);
if self.cu.control {
return;
}
self.cu.control = true;
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
self.hold_computer(true);
}
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
/// 我完成了 / 跳過: the bot gets its computer back.
pub(super) fn give_back_computer(&mut self) {
if !self.cu.control {
return;
}
self.cu.control = false;
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
self.hold_computer(false);
}
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
fn hold_computer(&mut self, on: bool) {
// (The selected bot's screen: the bots on their own screens go on meanwhile. Given back
// is the screen taken, whichever bot is selected by then.)
let (bot, key) = match (on, self.cu.screens.held.take()) {
(false, Some(h)) => h,
_ => {
let bot = self.shown_bot(self.state.selected);
(bot, self.screen_key_for(bot))
}
};
if on {
self.cu.screens.held = Some((bot, key.clone()));
}
People watch and help on the bots' computer through VNC (noVNC), carried by the account server The core: the bot works the computer; a person watches it like a colleague, and takes over when it needs them. VNC is made for that (only what changed, every mouse move and key, touch on phones), so the pictures sent one by one go, and with them their own input path. - vnc.rs: a VNC proxy to the box's x11vnc through one docker exec (a Python bridge that ends with either side). It signs in to the box with the box's own password (its VNC_PASSWORD) and offers the viewer no password, so the password never leaves the brain. The person's clicks and keys make the bot's steps wait until 8 s after they stop; text typed in the viewer's box (any language) is pasted in the box. - Account server: /screen (the viewer page) and /novnc.js (noVNC 1.6.0, MPL-2.0, bundled); /relay/vnc/<host> takes the browser's WebSocket (account session, or a 10-minute ticket the app asks for with POST /relay/screen-ticket; owners and admins) and carries it over that AnyBot's lasting connection (vopen / vdata / vtext / vclose). Both ends of that connection wait 2 ms instead of 40 ms to read while things move: a request and its answer took up to 160 ms more than needed. - Phone page: 看 Bot 的電腦 and 接管 open the viewer page (also on the local network: /api/vnc on the AnyBot's own phone server). This Mac's own screen moved to the ⋯ menu. - Mac app: 看畫面 opens the viewer in the browser (a screen of a brain: the brain's computer by ticket; else this computer's box, noVNC straight from it). The in-app picture viewer, the live JPEG stream, the person's click/move/scroll/key endpoints and the input shell are gone. - Opening a Mac app uses LaunchServices (`open -a`): agent-desktop's launch waited on the window through accessibility and failed without 輔助使用 now and then. Measured on this Mac (made-up account, local relay + headless brain + the real box): viewer signed in in 0.4–0.7 s, a request and its answer through relay + brain + box 25–58 ms median; headless Chrome shows the desktop live in /screen. remote_e2e 28/28 ×2, 149 unit tests, relay 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 15:05:44 +00:00
if self.mir.on {
let s = self.state.remote.clone();
std::thread::spawn(move || {
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
let _ = crate::remote::sync_post(&s, "screen", &serde_json::json!({"kind": "hold", "on": on, "bot": bot}));
});
} else {
feat: 每個 Bot 一個螢幕——Bot 的電腦上各有自己的螢幕和瀏覽器,支線另開暫時的螢幕,右側面板和「全部螢幕」看得到每一個 照 Grok Bot 的分法:一台電腦、每個 Bot 一個螢幕,大家同時做互不干擾。使用者自己的電腦只有一個實體螢幕,還是一次一個 Bot。 - box:anybot-screen(up/down/list/reap)開關每個 Bot 的螢幕,同時最多 6 個,閒置 10 分鐘關掉;browser 每個螢幕自己的設定檔(第一次從共用的複製登入;支線 <key>-t<n> 從主線那份複製,關掉時刪掉);start.sh 給每個螢幕 VNC token;Bot 電腦升到版本 10 - cloudbox:每個螢幕有自己的狀態(編號、尺寸、貼上檔、瀏覽器埠),指令開的視窗出現在它的 Bot 的螢幕上;branch_screen、close_screen、open_screens、thumbnail_of - agent:在 Bot 的電腦上,一輪用它自己的螢幕(支線用暫時的),佔用照螢幕算 - 支線結束時關掉它的暫時螢幕 - 畫面:右側「電腦」顯示目前 Bot 的螢幕;群組跟著正在回答的成員,「成員」卡片點小畫面就固定顯示那個成員;「全部螢幕(N)」一格一個螢幕;接管時只停那個 Bot;手機和中繼帶上要看哪個 Bot 的螢幕 - 群組和支線的系統指示:看不到彼此開著的網頁,交棒時寫網址或檔案路徑 - 功能地圖:screen、team、computers、browser Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha4mzWbjJAWAsDVuBun
2026-11-15 08:12:09 +00:00
cloudbox::hold(&key, on);
}
}
pub(super) fn local_control_bar(&mut self, ctx: &egui::Context) {
if self.demo {
return;
}
let held = crate::computer::HELD_BY_PERSON.load(Ordering::SeqCst);
let recent = crate::computer::LAST_ACTION.lock().unwrap().clone().filter(|(t, _)| t.elapsed().as_secs() < LOCAL_BAR_SECS);
if !held && recent.is_none() {
return;
}
let who = recent.map(|r| r.1).filter(|w| !w.is_empty()).unwrap_or_else(|| "Bot".into());
let p = self.pal;
let mut stop_bot: Option<String> = None;
let mut toggle = false;
let monitor_w = ctx.input(|i| i.viewport().monitor_size).map(|s| s.x).unwrap_or(1440.0);
ctx.show_viewport_immediate(
egui::ViewportId::from_hash_of("anybot-local-control"),
egui::ViewportBuilder::default()
.with_title("AnyBot 正在操作你的電腦")
.with_inner_size([440.0, 46.0])
.with_position([(monitor_w - 440.0) / 2.0, 34.0])
.with_decorations(false)
.with_always_on_top()
.with_resizable(false)
.with_transparent(true),
|ui, _| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
Frame::new().fill(p.elevated).stroke(Stroke::new(1.0, p.border)).corner_radius(R_FULL).inner_margin(Margin::symmetric(16, 8)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
2026-11-16 14:07:07 +00:00
ui.painter().circle_filled(r.center(), 4.5, if held { p.text3 } else { p.danger });
let text = if held { "你正在操作,Bot 已暫停".to_string() } else { format!("{who} 正在操作你的電腦") };
ui.label(RichText::new(text).size(FONT_SM).strong().family(crate::bold()));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if !held && ui.add(egui::Button::new(RichText::new(t("停止")).size(FONT_XS)).corner_radius(R_L)).clicked() {
stop_bot = Some(who.clone());
}
let label = if held { "交還給 Bot" } else { "取得控制權" };
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(label).size(FONT_XS).strong().family(crate::bold()).color(p.on_primary)).fill(p.primary).corner_radius(R_L)).clicked() {
toggle = true;
}
});
});
});
},
);
if toggle {
crate::computer::HELD_BY_PERSON.store(!held, Ordering::SeqCst);
if held {
*crate::computer::LAST_ACTION.lock().unwrap() = None;
}
}
if let Some(name) = stop_bot {
let ids: Vec<u64> = self.streams.keys().copied().filter(|id| self.state.bot(*id).map(|b| b.name == name).unwrap_or(false)).collect();
for id in ids {
self.stop(id);
}
*crate::computer::LAST_ACTION.lock().unwrap() = None;
}
ctx.request_repaint_after(std::time::Duration::from_millis(500));
}
}
// ---------- 示範教學 ----------
impl App {
/// 教它一項任務 from the + menu: start recording right away under a dated name.
pub(super) fn teach_quick(&mut self, bot_id: u64) {
let Some(bot) = self.state.bot(bot_id).cloned() else { return };
if crate::teach::recording().is_some() {
return;
}
self.cu.teach_name = format!("{} {}", t("示範"), chrono::Local::now().format("%m/%d %H:%M"));
match crate::teach::start(&bot.name) {
Ok(()) => {
self.cu.teach_for = Some(bot_id);
self.cu.teach_error.clear();
}
Err(e) => self.att.error = Some(e),
}
}
pub(super) fn teach_card(&mut self, ui: &mut egui::Ui) {
if !crate::computer::demo_supported() {
return;
}
let p = self.pal;
let bot_id = self.state.selected;
let Some(bot) = self.state.bot(bot_id).cloned() else { return };
setting_card(ui, p, |ui| {
setting_title(ui, "示範教學", &format!("錄下你在這台 Mac 上執行任務的過程。{} 會學習這些步驟,之後可以自行再次執行。", bot.name), p);
ui.horizontal(|ui| {
ui.add(egui::TextEdit::singleline(&mut self.cu.teach_name).hint_text(t("這個任務叫什麼,例如 匯出本月報表")).desired_width(ui.available_width() - 110.0));
let ok = !self.cu.teach_name.trim().is_empty() && crate::teach::recording().is_none();
if ui.add_enabled(ok, primary_button("開始錄製", p)).clicked() {
match crate::teach::start(&bot.name) {
Ok(()) => {
self.cu.teach_for = Some(bot_id);
self.cu.teach_error.clear();
self.show_settings = false;
}
Err(e) => self.cu.teach_error = e,
}
}
});
if !self.cu.teach_error.is_empty() {
2026-11-16 14:07:07 +00:00
ui.add(egui::Label::new(RichText::new(&self.cu.teach_error).size(FONT_SM).color(p.danger)).wrap());
}
hint(ui, "按下開始後照平常的方式操作;做完按畫面上方的「完成」。會記錄點擊、打字和捲動,並且每 0.5 秒拍一張螢幕畫面(需要「螢幕與系統錄音」權限),完成後合成錄影;每一步會留一張當時的畫面給 Bot 看。不會擋住或改變你的操作。", p);
let mut remove = None;
for (i, d) in bot.demos.iter().enumerate() {
ui.add_space(6.0);
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
Frame::new().fill(p.elevated).corner_radius(R_M).inner_margin(Margin::symmetric(12, 8)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
ui.label(RichText::new(&d.name).strong().family(crate::bold()).size(FONT_SM));
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.label(RichText::new(format!("{} · {} 個步驟", d.created, d.steps.len())).size(FONT_XS).color(p.text3));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(t("刪除")).size(FONT_XS).color(p.text3)).frame(false)).clicked() {
remove = Some(i);
}
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if !d.video.is_empty() && ui.add(egui::Button::new(RichText::new(t("播放錄影")).size(FONT_XS).color(p.accent)).frame(false)).clicked() {
crate::preview::open_with_system(&d.video.to_string());
}
});
});
2026-11-16 14:07:07 +00:00
egui::CollapsingHeader::new(RichText::new(t("步驟")).size(FONT_SM).color(p.text2)).id_salt(("demo", bot_id, i)).show(ui, |ui| {
for (n, s) in d.steps.iter().enumerate() {
ui.horizontal(|ui| {
2026-11-16 14:07:07 +00:00
ui.label(RichText::new(format!("{}. {s}", n + 1)).size(FONT_SM).color(p.text2));
if let Some(shot) = d.shots.get(n).filter(|x| !x.is_empty()) {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(t("畫面")).size(FONT_XS).color(p.accent)).frame(false)).on_hover_text(t("打開這一步當時的畫面")).clicked() {
crate::preview::open_with_system(&shot.to_string());
}
}
});
}
});
});
}
if let Some(i) = remove {
if let Some(b) = self.state.bot_mut(bot_id) {
b.demos.remove(i);
}
self.mark();
}
});
}
/// 「{Bot} 正在觀看並學習」 with 完成 / 取消, on top of every window while recording.
pub(super) fn teach_bar(&mut self, ctx: &egui::Context) {
let Some((who, since)) = crate::teach::recording() else { return };
let p = self.pal;
let mut finish = false;
let mut cancel = false;
let monitor_w = ctx.input(|i| i.viewport().monitor_size).map(|s| s.x).unwrap_or(1440.0);
ctx.show_viewport_immediate(
egui::ViewportId::from_hash_of("anybot-teach"),
egui::ViewportBuilder::default()
.with_title("AnyBot 示範教學")
.with_inner_size([420.0, 46.0])
.with_position([(monitor_w - 420.0) / 2.0, 34.0])
.with_decorations(false)
.with_always_on_top()
.with_resizable(false)
.with_transparent(true),
|ui, _| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
Frame::new().fill(p.elevated).stroke(Stroke::new(1.0, p.border)).corner_radius(R_FULL).inner_margin(Margin::symmetric(16, 8)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
let (r, _) = ui.allocate_exact_size(vec2(10.0, 10.0), egui::Sense::hover());
let t = ui.input(|i| i.time) as f32;
2026-11-16 14:07:07 +00:00
ui.painter().circle_filled(r.center(), 4.5, p.danger.gamma_multiply(0.6 + 0.4 * (t * 3.0).sin().abs()));
let secs = since.elapsed().as_secs();
ui.label(RichText::new(format!("{who} 正在觀看並學習 {:02}:{:02}", secs / 60, secs % 60)).size(FONT_SM).strong().family(crate::bold()));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(crate::i18n::t("取消")).size(FONT_XS)).corner_radius(R_L)).clicked() {
cancel = true;
}
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
if ui.add(egui::Button::new(RichText::new(crate::i18n::t("完成")).size(FONT_XS).strong().family(crate::bold()).color(p.on_primary)).fill(p.primary).corner_radius(R_L)).clicked() {
finish = true;
}
});
});
});
},
);
ctx.request_repaint_after(std::time::Duration::from_millis(250));
if cancel {
crate::teach::cancel();
}
if finish {
let demo = crate::teach::finish(&self.cu.teach_name);
let n = demo.steps.len();
if let Some(id) = self.cu.teach_for.take() {
if let Some(b) = self.state.bot_mut(id) {
b.demos.retain(|d| d.name != demo.name);
b.demos.push(demo);
}
self.notice = Some(format!("已記下「{}」({n} 個步驟)。之後跟 Bot 說「照示範做 {}」就可以。", self.cu.teach_name.trim(), self.cu.teach_name.trim()));
self.state.selected = id;
}
self.cu.teach_name.clear();
self.mark();
}
}
}
/// An on/off switch (the original's toggle, size md).
pub(super) fn toggle(on: &mut bool) -> impl egui::Widget + '_ {
move |ui: &mut egui::Ui| -> egui::Response {
let size = vec2(36.0, 20.0);
let (rect, mut r) = ui.allocate_exact_size(size, egui::Sense::click());
if r.clicked() {
*on = !*on;
r.mark_changed();
}
let t = ui.ctx().animate_bool_responsive(r.id, *on);
// On is ink with a white knob; off is the quiet grey.
let dark = ui.visuals().dark_mode;
let off_col = if dark { Color32::from_gray(0x4a) } else { Color32::from_gray(0xd4) };
let on_col = if dark { Color32::from_gray(0xf5) } else { Color32::from_gray(0x1c) };
let fill = if ui.is_enabled() { egui::lerp(egui::Rgba::from(off_col)..=egui::Rgba::from(on_col), t).into() } else { off_col.gamma_multiply(0.6) };
design: 一套設計規格(電腦和手機同值)+讀的文字改成 Claude/Notion 的文件樣式 依 Claude 的設計原則:定一套字級並守住、卡片樣式按角色用、重複的元素一致。 - 字型:只留思源黑體(介面)+新加思源宋體(回答、頁面內文和標題,SIL OFL); 拿掉粉圓體和「系統字型」選項、粉圓單一粗細的「粗體畫兩次」補丁;Mermaid 圖改用思源黑體; fonts/OFL.txt 補上思源黑體/宋體的版權 - 規格(theme.rs fs/sp/radius、手機 :root --fs-* --sp-* --r-*):字級 12/13/14/16/18/22/28、 閱讀行高 1.7、間距 4–32、圓角 6/10/14;桌面 253 個寫死字級、166 個寫死圓角換成規格名稱, 手機 167 個字級、79 個圓角、19 個色碼換成變數 - 看守測試:桌面和手機數字要一樣;畫面程式裡不准再寫死字級和圓角,寫死的顏色只准減少(88) - 讀的文字:聊天 16 px 宋體行高 27、頁面同;標題 # 22 / ## 18 / ### 16;表格只有橫細線、 表頭灰色粗體、數字欄靠右;提示框淡底無邊條只有小標上色;程式碼淡底無框;數字卡只留細框 - 頁面視窗:宋體大標題、一行小字資訊、現況當開頭段落、結論是安靜的提示框;目錄收成一行 「▸ 目錄 · N 節」(⌘F 展開);刪除移到左邊,不再貼著「完成」;閱讀欄 680 - 圓餅圖拿掉黑色外圈、字照規格 已驗證: cargo test 518 全過(含排版檢查、規格比對、看守測試;看守測試故意放一個寫死字級確認會擋)、 clippy 21=基線;桌面頁面、聊天、表格原解析度截圖目視;手機 390 px 深淺截圖、node 圖表 65/通知 9 未驗證: 使用者機器上的實際視窗;iOS/Android 實機的宋體備援(手機用系統宋體,沒有就退回 serif)
2026-11-16 13:51:30 +00:00
ui.painter().rect_filled(rect, R_M, fill);
let x = egui::lerp((rect.left() + 10.0)..=(rect.right() - 10.0), t);
let knob = if dark && *on { Color32::from_gray(0x1c) } else { Color32::WHITE };
ui.painter().circle_filled(egui::pos2(x, rect.center().y), 8.0, knob);
r.on_hover_cursor(egui::CursorIcon::PointingHand)
}
}
/// The original's settings layout: sections 28 px apart, a small grey title (and something on
/// its right), then a card of rows (12 px corners, a hairline, 8 px top and bottom).
const SEC_GAP: f32 = 28.0;
2026-11-16 14:07:07 +00:00
// 電腦頁的區段、群組、列、說明:共用元件(kit.rs)的別名,和其他設定頁長得一樣。
fn sec_title(ui: &mut egui::Ui, title: &str, p: Palette, accessory: impl FnOnce(&mut egui::Ui)) {
2026-11-16 14:07:07 +00:00
section_with(ui, title, p, accessory);
}
fn sec_card(ui: &mut egui::Ui, p: Palette, body: impl FnOnce(&mut egui::Ui)) {
2026-11-16 14:07:07 +00:00
rows_card(ui, p, body);
}
/// A row: the setting's name (「?」 explains on hover) on the left, its control on the right.
fn sec_row(ui: &mut egui::Ui, p: Palette, label: &str, help: &str, control: impl FnOnce(&mut egui::Ui)) {
2026-11-16 14:07:07 +00:00
card_row(ui, p, label, "", help, control);
}
/// A row with a short status line under the name (目前在線上、上次快照…).
fn sec_row_s(ui: &mut egui::Ui, p: Palette, label: &str, status: &str, help: &str, control: impl FnOnce(&mut egui::Ui)) {
2026-11-16 14:07:07 +00:00
card_row(ui, p, label, status, help, control);
}
fn sec_note(ui: &mut egui::Ui, p: Palette, text: &str) {
2026-11-16 14:07:07 +00:00
Frame::new().inner_margin(Margin { left: 4, right: 4, top: 4, bottom: 8 }).show(ui, |ui| {
hint(ui, text, p);
});
}