AnyBot/src/icons.rs

520 lines
24 KiB
Rust
Raw Normal View History

// Icons: one free set, Lucide (ISC licence, icons/lucide/LICENSE), drawn from its SVG files so
// every icon in the app has the same 2 px rounded line on a 24 px grid — no emoji anywhere.
// Each SVG is rendered once per size (white), kept as a texture and tinted when painted.
use eframe::egui::{self, vec2, Color32, Painter, Rect};
use std::collections::HashMap;
use std::sync::{Mutex, OnceLock};
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum Icon {
SidebarCollapse,
SidebarExpand,
Plus,
Search,
Gear,
More,
ArrowUp,
Stop,
Monitor,
Mic,
Sparkle,
Chat,
Shield,
Vault,
Key,
CreditCard,
Person,
Eye,
CloudDownload,
Clock,
Calendar,
Wave,
Close,
Download,
Smile,
Reply,
Apps,
Paperclip,
Record,
Pin,
Folder,
Bell,
Pencil,
Copy,
EyeOff,
Trash,
ArrowDown,
Refresh,
Star,
Share,
Upload,
NewChat,
History,
Eraser,
Bot,
Users,
Template,
Check,
FileSheet,
FileText,
FileCode,
FileImage,
FileVideo,
FileAudio,
File,
Lock,
Update,
Zap,
Alert,
Summary,
Plane,
MapPin,
CloudSun,
ShoppingBag,
Message,
Alarm,
CircleCheck,
CircleX,
Minus,
Loader,
Play,
Pause,
FileJson,
FileWord,
ChevronRight,
記憶: a page to see it, a few lines picked while typing, a local model The memory had grown into a list carried whole, a top-14 recalled by a trigram index and pasted into the system prompt with the clock, and a page that broke its own layout. Nobody could see what went to the model, the prompt cache missed every message, and 「記住」 kept saying the same thing twice. Rebuilt per the spec (docs/memory.md): - Three kinds in memory.db: 記得的事 (fact), 做過的事 (event, a line per finished turn), 整理過的 (rollup). Each keeps pinned, uses, last_used, deleted, superseded_by, span. state.json keeps the facts as the copy that syncs; the page reads SQLite. - Search: jieba words ∪ CJK bigrams in an FTS5 unicode61 table (Traditional text goes through Simplified first), weighted share of query terms hit; plus local vectors, vec = clamp((cos−0.35)/0.35). score = max + 0.15×min, events ×0.9. ≥0.15 suggested, ≥0.5 ticked, ≥0.55 carried when nobody chose (3 at most). - What the model gets: the system prompt has the time zone and the pinned memories only, the same every turn. Each person message gets 〔送出時間〕 and 〔相關記憶〕 from Message.memories, built in group_history into a transient Message.context, so the beginning of a chat reads the same next turn (cache hits) and the event log, skills and audit see only what was typed. A memory already carried in view isn't carried again; each carry counts a use. - Picks travel with the message: Cmd::Send / POST send / sync act "memories" (empty = none; absent = the brain chooses, once, saved). - remember finds the like one (cos ≥ 0.85 or the same words) and asks for `replaces`; the old one is superseded, never carried. A fact forgotten and remembered again comes back. New search_memory (query, kind), with dates; read-only. - Nightly on the brain, no model: events past 30 days fold into a line per week (「11/3–11/9 做過的事(14 件):整理照片 ×3…」, ≤400 chars, like with like by words or vectors), weeks past 180 days into months; the folded go to 最近刪除 for 30 days. Facts are never removed. The page offers duplicates, facts unused for half a year, and what can fold now. - Local model: minishlab/potion-multilingual-128M through m2v.rs (same token ids as model2vec-rs on 13/13 sentences, cos ≥ 0.9999, without tokenizers' 1.1 GB). Converted while downloading: vocab.bin, table.i8 (int8 + row scales), dims.json, 137 MB kept of 530 MB; ANYBOT_HF_BASE picks a mirror (now passed into the server's brain container too). Loaded when first needed (34 ms), let go after 10 idle minutes. The brain loads it; a screen only with a document folder set; hands and phones never. 設定 › 一般 › 語意搜尋: 本機模型/Ollama/關閉; a new engine clears every vector. - Three files, three connections: memory.db (backed up nightly, 7 kept), docs.db (a cache), oplog/audit.db (30 days). An old audit.db hands its memories and documents over once and shrinks (a real one: 172 MB → 16 KB). docs_search scans every chunk now, vectors cached in RAM (it stopped at 8000); FTS optimize + VACUUM daily (260 MB of tombstones over 31 MB of text). - API: POST /api/memory (owner) and /api/sync/memory (mirror). Reads answer on the HTTP thread; writes go through phone_act("memory"). - Screens: a memory dialog (Bot menu 記憶…, Bot settings 打開記憶) with counts, live search, filters, suggestions, per-item kind/date/uses and pin/edit/forget/restore; chips above the composer 300 ms after typing stops, with a token estimate; 「帶了 N 條記憶」 under person messages. The phone has the same as a 記憶 tab, chips and tag. Checked: make test passes (app 297, relay 16), with new tests for the scores and thresholds, Traditional Chinese segmentation, remember's dedupe and replaces, two turns sending the same beginning, no double carry, weekly/monthly folding and the trash, and the audit.db move. Brain idle 37 MB as before, ~230 MB with the model loaded; search on the brain 0.2–0.5 ms, 7–44 ms from the phone page. A deadlock found on the way (stats re-taking the lock) is fixed and tested. Docs: docs/memory.md has the whole design; FEATURES.md, protocol, architecture (zh/en), multi-device and install say what changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3SYw9JJ9dXwaNvYh4
2026-11-10 23:46:50 +00:00
Bookmark,
Brain,
Target,
工作流:照 OpenBot 工作流畫布的排版(它公開的程式沒有畫布,照截圖做),風格是 AnyBot 自己的。可以畫、加註解、執行,也可以在聊天裡用一般的話請 Bot 做和改——畫布開在那個 Bot 的聊天旁邊,看著它改。 - 畫布(側邊欄最上面一排的流程圖示):名稱選單(每個工作流和步驟數、新建、版本歷史、重新命名、建立副本、刪除)、右上「聊天/執行紀錄/▷ 執行工作流」、拖曳縮放、工具列(選取、拖曳|畫筆、便利貼、形狀、文字|搜尋|+ 新增節點)、縮放列、小地圖。窄視窗時縮放列移到工具列上面,等你確認那條橫跨上方。 - 卡片:觸發器(手動/排程、下次執行、立即執行)、Bot 步驟、等你確認、檢查、交付、通知你;從卡片底下的點拉線,不能連回觸發器、不能繞圈。 - 執行(workflow_run.rs):照線走;Bot 步驟是那個 Bot 聊天裡的一則問題,最後的回答交給下一步;檢查回「通過」才繼續;等你確認發通知;一次只跑一個;排程到了自動跑;執行紀錄 20 次、版本歷史 30 版。 - 聊出來:新工具 `workflow`(appctl;list/show/create/edit/run/stop/delete,刪除先問),屬於「例行任務與工作流」能力。Bot 做的排成一欄(tidy),插在中間時後面的往下移,使用者自己排過的不重排;改到的卡片和便利貼亮 2.6 秒,跑出畫面就縮到看得到全部。聊天抽成 chat_column,放在畫布旁邊(視窗 ≥ 900),跟著側邊欄選的 Bot 換。 - 修掉的:拖曳的起點用按下的位置(之前從點拉線會搬走卡片);搜尋打開時游標進搜尋框;一個步驟問的是正忙的 Bot(就是叫它開始的那一輪)時,那一輪結束不算這一步的回答(之前整個執行馬上失敗「做完了但沒有寫結果」);「要繼续嗎」簡體字。 - 側邊欄多了工作流按鈕,所有檔案往左一格:library.md 的座標 120,30 → 76,30。 - ctl desktop-shot:手機直接連線只聽 127.0.0.1(ANYBOT_SHOT_REAL=1 的視窗以前會聽區網和 Tailscale,有密碼、截完就關)。 已驗證: cargo test 855 過(新:workflow:: 3 個——聊天裡建立排整齊、一步步改(插中間、分支、刪掉接起來、錯一個整次不留)、run/stop;app::workflow_run 的 a_bots_workflow_call_shows_beside_its_chat,拿掉修正時會失敗;layout_audit 工作流四景;theme 設計檢查——浮在畫布上的改用 kit::floating,便利貼的字用淺色主題的字色);clippy 沒有新的(bin 8)。全新 scratch 照 workflow.md 六步逐字跑過:手機聊天裡建立、修改、執行(第 1 步在 Bot 聊天裡問、檢查「通過」、停在等你確認),桌面截圖:畫布+旁邊的聊天、在旁邊的聊天打字畫布跟著亮起來並縮到看得到全部、自己貼便利貼打字、拉線、搜尋。版本數、state 的步驟和位置另外看過。 未驗證: 真的模型聽一般的話做出工作流(scratch 只能用假模型);「等你確認」的通知真的跳出來(要 AnyBot.app/手機帳號);按「繼續」之後交付、通知你那兩步在真資料上(截圖模式按了會在這台 Mac 跳通知,沒按;單元測試有走)。動到 appctl 的 needs_approval(刪工作流先問,跟刪例行任務一樣):照規定要你看過再發佈。手機還沒有畫布。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 10:37:31 +00:00
// 工作流 (the canvas and its tools).
Workflow,
工作流多了 OpenBot 那些節點和觸發器:觸發器可以是手動、定時、Webhook、GitHub(和例行任務的事件觸發同一套);新增節點可以搜尋、分三組——輸入:提示詞、素材;步驟:LLM、助手、圖片、影片;流程:條件(是/否兩條路)、審批、輸出。重複的併掉:檢查就是條件,交付和通知你併成一個輸出。 - 觸發器:event(triggers::Trigger)跟排程二選一。Webhook 給呼叫網址(/hooks/<1000000+工作流 id>)和密碼、可複製、換一組;GitHub 給存放庫、事件(PR 合併、CI 失敗…)、Token;其他事件(Slack、新信、行事曆…)用 workflow 工具的 trigger 設,格式跟 create_routine 一樣。監看共用 channels_ui 的 triggers_poll(Watch 的 bot 0、id 1000000+工作流 id);發生了什麼放進那次執行的 input,交給第一步。 - 節點:提示詞(一段話當成上一步的結果)、素材(檔案,下一個 Bot 步驟收到附件;從聊天裡的檔案挑,大腦這台也可以選檔案)、LLM(直接呼叫模型,不用 Bot、不用工具,可選「供應商:模型」和系統提示詞,在背景執行緒跑,回來時下一次 tick 接著走)、助手(原本的 Bot 步驟)、圖片/影片(請 Bot 用自己的工具做出檔案、send_file 交出來)、條件(原本的檢查:是/否兩個點各拉線,邊帶 port;不成立而「否」沒接就停下說原因;沒走的那條路標成「沒走這條路」)、審批(原本的等你確認)、輸出(放進哪個聊天、要不要通知;舊的交付和通知你照樣跑、在右邊改時變成輸出)。 - 選到的卡片上面有「複製」「刪除」;助手、LLM、圖片、影片、條件有「試跑這一步」(只跑這一步,用前一步上次的結果,螢幕電腦也是交給大腦跑)。 - workflow 工具:kind 多了 prompt、material、llm、image、video、condition、output(deliver、notify、check、step 照舊收),trigger、files、model、system、notify、port(after 一個條件時走是或否)、connect 可以帶第三個值 yes/no;show 寫出「是:#5;否:#6」。 - 示範資料多一個工作流(ANYBOT_SHOT_TAB=2);功能地圖 workflow 補新的節點、觸發器和一步驗證,FEATURES 同步。 已驗證: cargo test 865 過(新:a_bot_builds_branches_and_the_new_kinds——工具建出提示詞、LLM、條件、圖片、輸出、Webhook 觸發,是/否 的邊和跳過的步驟,錯的觸發整次不留,舊名字變輸出;a_run_goes_through_the_new_kinds——事件的內容進第一步、提示詞交出去、素材變成附件、條件成立時跳過「否」那條、連不到的模型讓 LLM 那步失敗並說原因);clippy 沒有新的。截圖:新工作流的卡片(GitHub 觸發、提示詞、LLM、條件的是/否、圖片、審批、輸出)、可搜尋分三組的新增節點、觸發器右邊的 GitHub 設定、條件右邊的設定和卡片上的複製/刪除。 未驗證: 真的 GitHub/Webhook 觸發一次(要 token 和真的事件)、真的模型回答 LLM 步驟、Bot 真的做出圖片或影片(scratch 只有假模型);workflow.md 前五步這次沒重跑(指令沒變,只改了看到的名稱)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 12:31:38 +00:00
Split,
工作流:照 OpenBot 工作流畫布的排版(它公開的程式沒有畫布,照截圖做),風格是 AnyBot 自己的。可以畫、加註解、執行,也可以在聊天裡用一般的話請 Bot 做和改——畫布開在那個 Bot 的聊天旁邊,看著它改。 - 畫布(側邊欄最上面一排的流程圖示):名稱選單(每個工作流和步驟數、新建、版本歷史、重新命名、建立副本、刪除)、右上「聊天/執行紀錄/▷ 執行工作流」、拖曳縮放、工具列(選取、拖曳|畫筆、便利貼、形狀、文字|搜尋|+ 新增節點)、縮放列、小地圖。窄視窗時縮放列移到工具列上面,等你確認那條橫跨上方。 - 卡片:觸發器(手動/排程、下次執行、立即執行)、Bot 步驟、等你確認、檢查、交付、通知你;從卡片底下的點拉線,不能連回觸發器、不能繞圈。 - 執行(workflow_run.rs):照線走;Bot 步驟是那個 Bot 聊天裡的一則問題,最後的回答交給下一步;檢查回「通過」才繼續;等你確認發通知;一次只跑一個;排程到了自動跑;執行紀錄 20 次、版本歷史 30 版。 - 聊出來:新工具 `workflow`(appctl;list/show/create/edit/run/stop/delete,刪除先問),屬於「例行任務與工作流」能力。Bot 做的排成一欄(tidy),插在中間時後面的往下移,使用者自己排過的不重排;改到的卡片和便利貼亮 2.6 秒,跑出畫面就縮到看得到全部。聊天抽成 chat_column,放在畫布旁邊(視窗 ≥ 900),跟著側邊欄選的 Bot 換。 - 修掉的:拖曳的起點用按下的位置(之前從點拉線會搬走卡片);搜尋打開時游標進搜尋框;一個步驟問的是正忙的 Bot(就是叫它開始的那一輪)時,那一輪結束不算這一步的回答(之前整個執行馬上失敗「做完了但沒有寫結果」);「要繼续嗎」簡體字。 - 側邊欄多了工作流按鈕,所有檔案往左一格:library.md 的座標 120,30 → 76,30。 - ctl desktop-shot:手機直接連線只聽 127.0.0.1(ANYBOT_SHOT_REAL=1 的視窗以前會聽區網和 Tailscale,有密碼、截完就關)。 已驗證: cargo test 855 過(新:workflow:: 3 個——聊天裡建立排整齊、一步步改(插中間、分支、刪掉接起來、錯一個整次不留)、run/stop;app::workflow_run 的 a_bots_workflow_call_shows_beside_its_chat,拿掉修正時會失敗;layout_audit 工作流四景;theme 設計檢查——浮在畫布上的改用 kit::floating,便利貼的字用淺色主題的字色);clippy 沒有新的(bin 8)。全新 scratch 照 workflow.md 六步逐字跑過:手機聊天裡建立、修改、執行(第 1 步在 Bot 聊天裡問、檢查「通過」、停在等你確認),桌面截圖:畫布+旁邊的聊天、在旁邊的聊天打字畫布跟著亮起來並縮到看得到全部、自己貼便利貼打字、拉線、搜尋。版本數、state 的步驟和位置另外看過。 未驗證: 真的模型聽一般的話做出工作流(scratch 只能用假模型);「等你確認」的通知真的跳出來(要 AnyBot.app/手機帳號);按「繼續」之後交付、通知你那兩步在真資料上(截圖模式按了會在這台 Mac 跳通知,沒按;單元測試有走)。動到 appctl 的 needs_approval(刪工作流先問,跟刪例行任務一樣):照規定要你看過再發佈。手機還沒有畫布。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 10:37:31 +00:00
Hand,
Pointer,
StickyNote,
Square,
Type,
Map,
Scan,
Send,
修手機接管電腦後回不去;新增「風格」(8 套:紙、夜、墨、苔、海、糖、夕陽、終端機,一套顏色加聊天背景花紋,電腦和手機一起換,也能請 Bot 換);設定每一列都有圖示(電腦和手機)。 - 接管回不去(mobile/index.html newBoxFrame):以前每次打開/關掉都改同一個 iframe 的網址,iframe 換頁會加進上一頁紀錄;第二次之後按 ✕ 或返回,退的是框裡那一頁,接管畫面卡著。現在每次換一個新的框,關掉就拿掉。舊版重現:第 2、3 次關不掉;新版連續 3 次都回到首頁。 - 風格(src/theme.rs TEMPLATES、palette_for、backdrop):每套有淺色和深色的墨、紙、強調色(同一個產生器長出整個殼),加聊天背景 dots/grid/waves。State 新欄位 shell_template(空=自訂)。電腦:設定 › 一般 › 外觀最上面一排小圖(kit::style_gallery,每張是那個風格的縮小畫面),聊天區後面畫花紋(chat_backdrop);點強調色、動底色或重設回到自訂。手機:palettes 帶 backdrop,聊天背景用 CSS 畫;設定 › 一般最上面同一排小圖(api/settings 的 styles、style)。Bot:update_settings 多 `style`(appctl;不在 tools::specs 的鎖檔裡,鎖檔沒變)。截圖:ANYBOT_SHOT_STYLE=ocean。 - 設定圖示:icons::setting_icon 照名字的字配圖示(主題月亮、風格和顏色調色盤、通知鈴鐺、時區地球、權限盾牌、電腦螢幕…,沒對到是滑桿),card_row 和 setting_title 都畫;新 Lucide 圖示 palette、moon、globe、sliders-horizontal、volume-2、hard-drive。手機設定頁、Bot 設定、電腦頁的列用 sitem(同一套規則,SET_ICON)。 - 測試:theme::template_tests::every_template_reads_in_light_and_dark(每套淺深色都讀得清楚、紙就是原本的預設);appctl 的 update_settings 測試加 style。 - 功能地圖 appearance.md 加 appearance-style 和一步驗證、settings.md(Bot 能改四樣)、box.md 陷阱;FEATURES.md。 已驗證: cargo test 881 個全過;clippy 沒有新警告;scratch 手機:接管開關 3 次都回首頁(舊版第 2 次就卡住);設定 › 一般點「海」→ state shell_template=ocean、聊天背景波浪;聊天請 Bot `update_settings {"style":"terminal"}` → 手機強調色 #2d8a3e、格線;Bot 設定 36 列都有圖示。桌面截圖:外觀的 8 張小圖、海、終端機(深色)、糖的聊天,電腦設定一般/電腦頁每列有圖示。 未驗證: 在真的 iPhone 上滑返回手勢(接管開著時本來就停用,靠 ✕);花紋在很大的螢幕上的耗電(電腦版每幀畫點點/線,沒量)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-22 01:38:00 +00:00
// 設定's rows (setting_icon).
Palette,
Moon,
Globe,
Sliders,
Volume,
Drive,
}
impl Icon {
pub fn from_name(n: &str) -> Option<Icon> {
Some(match n {
"◧" => Icon::SidebarCollapse,
"◨" => Icon::SidebarExpand,
"+" => Icon::Plus,
"🔍" => Icon::Search,
"⚙" => Icon::Gear,
"⋯" => Icon::More,
"↑" => Icon::ArrowUp,
"■" => Icon::Stop,
"monitor" => Icon::Monitor,
"mic" => Icon::Mic,
_ => return None,
})
}
/// The Lucide file.
fn svg(self) -> &'static str {
match self {
Icon::ChevronRight => include_str!("../icons/lucide/chevron-right.svg"),
記憶: a page to see it, a few lines picked while typing, a local model The memory had grown into a list carried whole, a top-14 recalled by a trigram index and pasted into the system prompt with the clock, and a page that broke its own layout. Nobody could see what went to the model, the prompt cache missed every message, and 「記住」 kept saying the same thing twice. Rebuilt per the spec (docs/memory.md): - Three kinds in memory.db: 記得的事 (fact), 做過的事 (event, a line per finished turn), 整理過的 (rollup). Each keeps pinned, uses, last_used, deleted, superseded_by, span. state.json keeps the facts as the copy that syncs; the page reads SQLite. - Search: jieba words ∪ CJK bigrams in an FTS5 unicode61 table (Traditional text goes through Simplified first), weighted share of query terms hit; plus local vectors, vec = clamp((cos−0.35)/0.35). score = max + 0.15×min, events ×0.9. ≥0.15 suggested, ≥0.5 ticked, ≥0.55 carried when nobody chose (3 at most). - What the model gets: the system prompt has the time zone and the pinned memories only, the same every turn. Each person message gets 〔送出時間〕 and 〔相關記憶〕 from Message.memories, built in group_history into a transient Message.context, so the beginning of a chat reads the same next turn (cache hits) and the event log, skills and audit see only what was typed. A memory already carried in view isn't carried again; each carry counts a use. - Picks travel with the message: Cmd::Send / POST send / sync act "memories" (empty = none; absent = the brain chooses, once, saved). - remember finds the like one (cos ≥ 0.85 or the same words) and asks for `replaces`; the old one is superseded, never carried. A fact forgotten and remembered again comes back. New search_memory (query, kind), with dates; read-only. - Nightly on the brain, no model: events past 30 days fold into a line per week (「11/3–11/9 做過的事(14 件):整理照片 ×3…」, ≤400 chars, like with like by words or vectors), weeks past 180 days into months; the folded go to 最近刪除 for 30 days. Facts are never removed. The page offers duplicates, facts unused for half a year, and what can fold now. - Local model: minishlab/potion-multilingual-128M through m2v.rs (same token ids as model2vec-rs on 13/13 sentences, cos ≥ 0.9999, without tokenizers' 1.1 GB). Converted while downloading: vocab.bin, table.i8 (int8 + row scales), dims.json, 137 MB kept of 530 MB; ANYBOT_HF_BASE picks a mirror (now passed into the server's brain container too). Loaded when first needed (34 ms), let go after 10 idle minutes. The brain loads it; a screen only with a document folder set; hands and phones never. 設定 › 一般 › 語意搜尋: 本機模型/Ollama/關閉; a new engine clears every vector. - Three files, three connections: memory.db (backed up nightly, 7 kept), docs.db (a cache), oplog/audit.db (30 days). An old audit.db hands its memories and documents over once and shrinks (a real one: 172 MB → 16 KB). docs_search scans every chunk now, vectors cached in RAM (it stopped at 8000); FTS optimize + VACUUM daily (260 MB of tombstones over 31 MB of text). - API: POST /api/memory (owner) and /api/sync/memory (mirror). Reads answer on the HTTP thread; writes go through phone_act("memory"). - Screens: a memory dialog (Bot menu 記憶…, Bot settings 打開記憶) with counts, live search, filters, suggestions, per-item kind/date/uses and pin/edit/forget/restore; chips above the composer 300 ms after typing stops, with a token estimate; 「帶了 N 條記憶」 under person messages. The phone has the same as a 記憶 tab, chips and tag. Checked: make test passes (app 297, relay 16), with new tests for the scores and thresholds, Traditional Chinese segmentation, remember's dedupe and replaces, two turns sending the same beginning, no double carry, weekly/monthly folding and the trash, and the audit.db move. Brain idle 37 MB as before, ~230 MB with the model loaded; search on the brain 0.2–0.5 ms, 7–44 ms from the phone page. A deadlock found on the way (stats re-taking the lock) is fixed and tested. Docs: docs/memory.md has the whole design; FEATURES.md, protocol, architecture (zh/en), multi-device and install say what changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3SYw9JJ9dXwaNvYh4
2026-11-10 23:46:50 +00:00
Icon::Bookmark => include_str!("../icons/lucide/bookmark.svg"),
Icon::Brain => include_str!("../icons/lucide/brain.svg"),
Icon::SidebarCollapse => include_str!("../icons/lucide/panel-left-close.svg"),
Icon::SidebarExpand => include_str!("../icons/lucide/panel-left-open.svg"),
Icon::Plus => include_str!("../icons/lucide/plus.svg"),
Icon::Search => include_str!("../icons/lucide/search.svg"),
Icon::Gear => include_str!("../icons/lucide/settings.svg"),
Icon::More => include_str!("../icons/lucide/ellipsis.svg"),
Icon::ArrowUp => include_str!("../icons/lucide/arrow-up.svg"),
Icon::Stop => include_str!("../icons/lucide/square.svg"),
Icon::Monitor => include_str!("../icons/lucide/monitor.svg"),
Icon::Mic => include_str!("../icons/lucide/mic.svg"),
Icon::Sparkle => include_str!("../icons/lucide/sparkles.svg"),
Icon::Chat => include_str!("../icons/lucide/messages-square.svg"),
Icon::Shield => include_str!("../icons/lucide/shield-check.svg"),
Icon::Vault => include_str!("../icons/lucide/vault.svg"),
Icon::Key => include_str!("../icons/lucide/key-round.svg"),
Icon::CreditCard => include_str!("../icons/lucide/credit-card.svg"),
Icon::Person => include_str!("../icons/lucide/user-round.svg"),
Icon::Eye => include_str!("../icons/lucide/eye.svg"),
Icon::CloudDownload => include_str!("../icons/lucide/cloud-download.svg"),
Icon::Clock => include_str!("../icons/lucide/clock.svg"),
Icon::Calendar => include_str!("../icons/lucide/calendar.svg"),
Icon::Wave => include_str!("../icons/lucide/audio-lines.svg"),
Icon::Close => include_str!("../icons/lucide/x.svg"),
Icon::Download => include_str!("../icons/lucide/download.svg"),
Icon::Smile => include_str!("../icons/lucide/smile-plus.svg"),
Icon::Reply => include_str!("../icons/lucide/reply.svg"),
Icon::Apps => include_str!("../icons/lucide/layout-grid.svg"),
Icon::Paperclip => include_str!("../icons/lucide/paperclip.svg"),
Icon::Record => include_str!("../icons/lucide/circle-dot.svg"),
Icon::Pin => include_str!("../icons/lucide/pin.svg"),
Icon::Folder => include_str!("../icons/lucide/folder.svg"),
Icon::Bell => include_str!("../icons/lucide/bell-dot.svg"),
Icon::Pencil => include_str!("../icons/lucide/pencil.svg"),
Icon::Copy => include_str!("../icons/lucide/copy.svg"),
Icon::EyeOff => include_str!("../icons/lucide/eye-off.svg"),
Icon::Trash => include_str!("../icons/lucide/trash-2.svg"),
Icon::ArrowDown => include_str!("../icons/lucide/arrow-down.svg"),
Icon::Refresh => include_str!("../icons/lucide/refresh-cw.svg"),
Icon::Star => include_str!("../icons/lucide/star.svg"),
Icon::Share => include_str!("../icons/lucide/share.svg"),
Icon::Upload => include_str!("../icons/lucide/upload.svg"),
Icon::NewChat => include_str!("../icons/lucide/square-pen.svg"),
Icon::History => include_str!("../icons/lucide/history.svg"),
Icon::Eraser => include_str!("../icons/lucide/eraser.svg"),
Icon::Bot => include_str!("../icons/lucide/bot.svg"),
Icon::Users => include_str!("../icons/lucide/users.svg"),
Icon::Template => include_str!("../icons/lucide/layout-template.svg"),
Icon::Check => include_str!("../icons/lucide/check.svg"),
Icon::FileSheet => include_str!("../icons/lucide/file-spreadsheet.svg"),
Icon::FileText => include_str!("../icons/lucide/file-text.svg"),
Icon::FileCode => include_str!("../icons/lucide/file-code.svg"),
Icon::FileImage => include_str!("../icons/lucide/image.svg"),
Icon::FileVideo => include_str!("../icons/lucide/file-video.svg"),
Icon::FileAudio => include_str!("../icons/lucide/file-music.svg"),
Icon::File => include_str!("../icons/lucide/file.svg"),
Icon::Lock => include_str!("../icons/lucide/lock.svg"),
Icon::Update => include_str!("../icons/lucide/circle-arrow-up.svg"),
Icon::Zap => include_str!("../icons/lucide/zap.svg"),
Icon::Alert => include_str!("../icons/lucide/circle-alert.svg"),
Icon::Summary => include_str!("../icons/lucide/notebook-pen.svg"),
Icon::Plane => include_str!("../icons/lucide/plane.svg"),
Icon::MapPin => include_str!("../icons/lucide/map-pin.svg"),
Icon::CloudSun => include_str!("../icons/lucide/cloud-sun.svg"),
Icon::ShoppingBag => include_str!("../icons/lucide/shopping-bag.svg"),
Icon::Message => include_str!("../icons/lucide/message-circle.svg"),
Icon::Alarm => include_str!("../icons/lucide/alarm-clock.svg"),
Icon::Target => include_str!("../icons/lucide/target.svg"),
工作流:照 OpenBot 工作流畫布的排版(它公開的程式沒有畫布,照截圖做),風格是 AnyBot 自己的。可以畫、加註解、執行,也可以在聊天裡用一般的話請 Bot 做和改——畫布開在那個 Bot 的聊天旁邊,看著它改。 - 畫布(側邊欄最上面一排的流程圖示):名稱選單(每個工作流和步驟數、新建、版本歷史、重新命名、建立副本、刪除)、右上「聊天/執行紀錄/▷ 執行工作流」、拖曳縮放、工具列(選取、拖曳|畫筆、便利貼、形狀、文字|搜尋|+ 新增節點)、縮放列、小地圖。窄視窗時縮放列移到工具列上面,等你確認那條橫跨上方。 - 卡片:觸發器(手動/排程、下次執行、立即執行)、Bot 步驟、等你確認、檢查、交付、通知你;從卡片底下的點拉線,不能連回觸發器、不能繞圈。 - 執行(workflow_run.rs):照線走;Bot 步驟是那個 Bot 聊天裡的一則問題,最後的回答交給下一步;檢查回「通過」才繼續;等你確認發通知;一次只跑一個;排程到了自動跑;執行紀錄 20 次、版本歷史 30 版。 - 聊出來:新工具 `workflow`(appctl;list/show/create/edit/run/stop/delete,刪除先問),屬於「例行任務與工作流」能力。Bot 做的排成一欄(tidy),插在中間時後面的往下移,使用者自己排過的不重排;改到的卡片和便利貼亮 2.6 秒,跑出畫面就縮到看得到全部。聊天抽成 chat_column,放在畫布旁邊(視窗 ≥ 900),跟著側邊欄選的 Bot 換。 - 修掉的:拖曳的起點用按下的位置(之前從點拉線會搬走卡片);搜尋打開時游標進搜尋框;一個步驟問的是正忙的 Bot(就是叫它開始的那一輪)時,那一輪結束不算這一步的回答(之前整個執行馬上失敗「做完了但沒有寫結果」);「要繼续嗎」簡體字。 - 側邊欄多了工作流按鈕,所有檔案往左一格:library.md 的座標 120,30 → 76,30。 - ctl desktop-shot:手機直接連線只聽 127.0.0.1(ANYBOT_SHOT_REAL=1 的視窗以前會聽區網和 Tailscale,有密碼、截完就關)。 已驗證: cargo test 855 過(新:workflow:: 3 個——聊天裡建立排整齊、一步步改(插中間、分支、刪掉接起來、錯一個整次不留)、run/stop;app::workflow_run 的 a_bots_workflow_call_shows_beside_its_chat,拿掉修正時會失敗;layout_audit 工作流四景;theme 設計檢查——浮在畫布上的改用 kit::floating,便利貼的字用淺色主題的字色);clippy 沒有新的(bin 8)。全新 scratch 照 workflow.md 六步逐字跑過:手機聊天裡建立、修改、執行(第 1 步在 Bot 聊天裡問、檢查「通過」、停在等你確認),桌面截圖:畫布+旁邊的聊天、在旁邊的聊天打字畫布跟著亮起來並縮到看得到全部、自己貼便利貼打字、拉線、搜尋。版本數、state 的步驟和位置另外看過。 未驗證: 真的模型聽一般的話做出工作流(scratch 只能用假模型);「等你確認」的通知真的跳出來(要 AnyBot.app/手機帳號);按「繼續」之後交付、通知你那兩步在真資料上(截圖模式按了會在這台 Mac 跳通知,沒按;單元測試有走)。動到 appctl 的 needs_approval(刪工作流先問,跟刪例行任務一樣):照規定要你看過再發佈。手機還沒有畫布。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 10:37:31 +00:00
Icon::Workflow => include_str!("../icons/lucide/workflow.svg"),
工作流多了 OpenBot 那些節點和觸發器:觸發器可以是手動、定時、Webhook、GitHub(和例行任務的事件觸發同一套);新增節點可以搜尋、分三組——輸入:提示詞、素材;步驟:LLM、助手、圖片、影片;流程:條件(是/否兩條路)、審批、輸出。重複的併掉:檢查就是條件,交付和通知你併成一個輸出。 - 觸發器:event(triggers::Trigger)跟排程二選一。Webhook 給呼叫網址(/hooks/<1000000+工作流 id>)和密碼、可複製、換一組;GitHub 給存放庫、事件(PR 合併、CI 失敗…)、Token;其他事件(Slack、新信、行事曆…)用 workflow 工具的 trigger 設,格式跟 create_routine 一樣。監看共用 channels_ui 的 triggers_poll(Watch 的 bot 0、id 1000000+工作流 id);發生了什麼放進那次執行的 input,交給第一步。 - 節點:提示詞(一段話當成上一步的結果)、素材(檔案,下一個 Bot 步驟收到附件;從聊天裡的檔案挑,大腦這台也可以選檔案)、LLM(直接呼叫模型,不用 Bot、不用工具,可選「供應商:模型」和系統提示詞,在背景執行緒跑,回來時下一次 tick 接著走)、助手(原本的 Bot 步驟)、圖片/影片(請 Bot 用自己的工具做出檔案、send_file 交出來)、條件(原本的檢查:是/否兩個點各拉線,邊帶 port;不成立而「否」沒接就停下說原因;沒走的那條路標成「沒走這條路」)、審批(原本的等你確認)、輸出(放進哪個聊天、要不要通知;舊的交付和通知你照樣跑、在右邊改時變成輸出)。 - 選到的卡片上面有「複製」「刪除」;助手、LLM、圖片、影片、條件有「試跑這一步」(只跑這一步,用前一步上次的結果,螢幕電腦也是交給大腦跑)。 - workflow 工具:kind 多了 prompt、material、llm、image、video、condition、output(deliver、notify、check、step 照舊收),trigger、files、model、system、notify、port(after 一個條件時走是或否)、connect 可以帶第三個值 yes/no;show 寫出「是:#5;否:#6」。 - 示範資料多一個工作流(ANYBOT_SHOT_TAB=2);功能地圖 workflow 補新的節點、觸發器和一步驗證,FEATURES 同步。 已驗證: cargo test 865 過(新:a_bot_builds_branches_and_the_new_kinds——工具建出提示詞、LLM、條件、圖片、輸出、Webhook 觸發,是/否 的邊和跳過的步驟,錯的觸發整次不留,舊名字變輸出;a_run_goes_through_the_new_kinds——事件的內容進第一步、提示詞交出去、素材變成附件、條件成立時跳過「否」那條、連不到的模型讓 LLM 那步失敗並說原因);clippy 沒有新的。截圖:新工作流的卡片(GitHub 觸發、提示詞、LLM、條件的是/否、圖片、審批、輸出)、可搜尋分三組的新增節點、觸發器右邊的 GitHub 設定、條件右邊的設定和卡片上的複製/刪除。 未驗證: 真的 GitHub/Webhook 觸發一次(要 token 和真的事件)、真的模型回答 LLM 步驟、Bot 真的做出圖片或影片(scratch 只有假模型);workflow.md 前五步這次沒重跑(指令沒變,只改了看到的名稱)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 12:31:38 +00:00
Icon::Split => include_str!("../icons/lucide/split.svg"),
工作流:照 OpenBot 工作流畫布的排版(它公開的程式沒有畫布,照截圖做),風格是 AnyBot 自己的。可以畫、加註解、執行,也可以在聊天裡用一般的話請 Bot 做和改——畫布開在那個 Bot 的聊天旁邊,看著它改。 - 畫布(側邊欄最上面一排的流程圖示):名稱選單(每個工作流和步驟數、新建、版本歷史、重新命名、建立副本、刪除)、右上「聊天/執行紀錄/▷ 執行工作流」、拖曳縮放、工具列(選取、拖曳|畫筆、便利貼、形狀、文字|搜尋|+ 新增節點)、縮放列、小地圖。窄視窗時縮放列移到工具列上面,等你確認那條橫跨上方。 - 卡片:觸發器(手動/排程、下次執行、立即執行)、Bot 步驟、等你確認、檢查、交付、通知你;從卡片底下的點拉線,不能連回觸發器、不能繞圈。 - 執行(workflow_run.rs):照線走;Bot 步驟是那個 Bot 聊天裡的一則問題,最後的回答交給下一步;檢查回「通過」才繼續;等你確認發通知;一次只跑一個;排程到了自動跑;執行紀錄 20 次、版本歷史 30 版。 - 聊出來:新工具 `workflow`(appctl;list/show/create/edit/run/stop/delete,刪除先問),屬於「例行任務與工作流」能力。Bot 做的排成一欄(tidy),插在中間時後面的往下移,使用者自己排過的不重排;改到的卡片和便利貼亮 2.6 秒,跑出畫面就縮到看得到全部。聊天抽成 chat_column,放在畫布旁邊(視窗 ≥ 900),跟著側邊欄選的 Bot 換。 - 修掉的:拖曳的起點用按下的位置(之前從點拉線會搬走卡片);搜尋打開時游標進搜尋框;一個步驟問的是正忙的 Bot(就是叫它開始的那一輪)時,那一輪結束不算這一步的回答(之前整個執行馬上失敗「做完了但沒有寫結果」);「要繼续嗎」簡體字。 - 側邊欄多了工作流按鈕,所有檔案往左一格:library.md 的座標 120,30 → 76,30。 - ctl desktop-shot:手機直接連線只聽 127.0.0.1(ANYBOT_SHOT_REAL=1 的視窗以前會聽區網和 Tailscale,有密碼、截完就關)。 已驗證: cargo test 855 過(新:workflow:: 3 個——聊天裡建立排整齊、一步步改(插中間、分支、刪掉接起來、錯一個整次不留)、run/stop;app::workflow_run 的 a_bots_workflow_call_shows_beside_its_chat,拿掉修正時會失敗;layout_audit 工作流四景;theme 設計檢查——浮在畫布上的改用 kit::floating,便利貼的字用淺色主題的字色);clippy 沒有新的(bin 8)。全新 scratch 照 workflow.md 六步逐字跑過:手機聊天裡建立、修改、執行(第 1 步在 Bot 聊天裡問、檢查「通過」、停在等你確認),桌面截圖:畫布+旁邊的聊天、在旁邊的聊天打字畫布跟著亮起來並縮到看得到全部、自己貼便利貼打字、拉線、搜尋。版本數、state 的步驟和位置另外看過。 未驗證: 真的模型聽一般的話做出工作流(scratch 只能用假模型);「等你確認」的通知真的跳出來(要 AnyBot.app/手機帳號);按「繼續」之後交付、通知你那兩步在真資料上(截圖模式按了會在這台 Mac 跳通知,沒按;單元測試有走)。動到 appctl 的 needs_approval(刪工作流先問,跟刪例行任務一樣):照規定要你看過再發佈。手機還沒有畫布。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-21 10:37:31 +00:00
Icon::Hand => include_str!("../icons/lucide/hand.svg"),
Icon::Pointer => include_str!("../icons/lucide/mouse-pointer-2.svg"),
Icon::StickyNote => include_str!("../icons/lucide/sticky-note.svg"),
Icon::Square => include_str!("../icons/lucide/square.svg"),
Icon::Type => include_str!("../icons/lucide/type.svg"),
Icon::Map => include_str!("../icons/lucide/map.svg"),
Icon::Scan => include_str!("../icons/lucide/scan.svg"),
Icon::Send => include_str!("../icons/lucide/send.svg"),
修手機接管電腦後回不去;新增「風格」(8 套:紙、夜、墨、苔、海、糖、夕陽、終端機,一套顏色加聊天背景花紋,電腦和手機一起換,也能請 Bot 換);設定每一列都有圖示(電腦和手機)。 - 接管回不去(mobile/index.html newBoxFrame):以前每次打開/關掉都改同一個 iframe 的網址,iframe 換頁會加進上一頁紀錄;第二次之後按 ✕ 或返回,退的是框裡那一頁,接管畫面卡著。現在每次換一個新的框,關掉就拿掉。舊版重現:第 2、3 次關不掉;新版連續 3 次都回到首頁。 - 風格(src/theme.rs TEMPLATES、palette_for、backdrop):每套有淺色和深色的墨、紙、強調色(同一個產生器長出整個殼),加聊天背景 dots/grid/waves。State 新欄位 shell_template(空=自訂)。電腦:設定 › 一般 › 外觀最上面一排小圖(kit::style_gallery,每張是那個風格的縮小畫面),聊天區後面畫花紋(chat_backdrop);點強調色、動底色或重設回到自訂。手機:palettes 帶 backdrop,聊天背景用 CSS 畫;設定 › 一般最上面同一排小圖(api/settings 的 styles、style)。Bot:update_settings 多 `style`(appctl;不在 tools::specs 的鎖檔裡,鎖檔沒變)。截圖:ANYBOT_SHOT_STYLE=ocean。 - 設定圖示:icons::setting_icon 照名字的字配圖示(主題月亮、風格和顏色調色盤、通知鈴鐺、時區地球、權限盾牌、電腦螢幕…,沒對到是滑桿),card_row 和 setting_title 都畫;新 Lucide 圖示 palette、moon、globe、sliders-horizontal、volume-2、hard-drive。手機設定頁、Bot 設定、電腦頁的列用 sitem(同一套規則,SET_ICON)。 - 測試:theme::template_tests::every_template_reads_in_light_and_dark(每套淺深色都讀得清楚、紙就是原本的預設);appctl 的 update_settings 測試加 style。 - 功能地圖 appearance.md 加 appearance-style 和一步驗證、settings.md(Bot 能改四樣)、box.md 陷阱;FEATURES.md。 已驗證: cargo test 881 個全過;clippy 沒有新警告;scratch 手機:接管開關 3 次都回首頁(舊版第 2 次就卡住);設定 › 一般點「海」→ state shell_template=ocean、聊天背景波浪;聊天請 Bot `update_settings {"style":"terminal"}` → 手機強調色 #2d8a3e、格線;Bot 設定 36 列都有圖示。桌面截圖:外觀的 8 張小圖、海、終端機(深色)、糖的聊天,電腦設定一般/電腦頁每列有圖示。 未驗證: 在真的 iPhone 上滑返回手勢(接管開著時本來就停用,靠 ✕);花紋在很大的螢幕上的耗電(電腦版每幀畫點點/線,沒量)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-22 01:38:00 +00:00
Icon::Palette => include_str!("../icons/lucide/palette.svg"),
Icon::Moon => include_str!("../icons/lucide/moon.svg"),
Icon::Globe => include_str!("../icons/lucide/globe.svg"),
Icon::Sliders => include_str!("../icons/lucide/sliders-horizontal.svg"),
Icon::Volume => include_str!("../icons/lucide/volume-2.svg"),
Icon::Drive => include_str!("../icons/lucide/hard-drive.svg"),
Icon::CircleCheck => include_str!("../icons/lucide/circle-check.svg"),
Icon::CircleX => include_str!("../icons/lucide/circle-x.svg"),
Icon::Minus => include_str!("../icons/lucide/minus.svg"),
Icon::Loader => include_str!("../icons/lucide/loader.svg"),
Icon::Play => include_str!("../icons/lucide/play.svg"),
Icon::Pause => include_str!("../icons/lucide/pause.svg"),
Icon::FileJson => include_str!("../icons/lucide/file-json.svg"),
Icon::FileWord => include_str!("../icons/lucide/file-type.svg"),
}
}
/// Filled shapes (stop is a solid square, like a media stop button).
fn filled(self) -> bool {
matches!(self, Icon::Stop | Icon::Play | Icon::Pause)
}
}
/// The icon for a file name (cards, previews, the phone page).
pub fn for_file(name: &str) -> Icon {
match crate::preview::kind_of(name) {
"sheet" => Icon::FileSheet,
"image" => Icon::FileImage,
"video" => Icon::FileVideo,
"audio" => Icon::FileAudio,
"text" | "html" => Icon::FileCode,
"json" => Icon::FileJson,
"docx" | "doc" => Icon::FileWord,
"markdown" | "pdf" => Icon::FileText,
_ => Icon::File,
}
}
type Cache = Mutex<HashMap<(Icon, u32), egui::TextureHandle>>;
fn cache() -> &'static Cache {
static C: OnceLock<Cache> = OnceLock::new();
C.get_or_init(|| Mutex::new(HashMap::new()))
}
/// Render the SVG white at `px` × `px`.
fn rasterize(icon: Icon, px: u32) -> Option<egui::ColorImage> {
// (A little heavier than Lucide draws them: 2.25 sits better next to the text.)
let mut svg = icon.svg().replace("currentColor", "#ffffff").replace("stroke-width=\"2\"", "stroke-width=\"2.25\"");
if icon.filled() {
svg = svg.replace("fill=\"none\"", "fill=\"#ffffff\"");
}
let tree = resvg::usvg::Tree::from_str(&svg, &resvg::usvg::Options::default()).ok()?;
let mut pixmap = resvg::tiny_skia::Pixmap::new(px, px)?;
let size = tree.size();
let scale = px as f32 / size.width().max(size.height());
resvg::render(&tree, resvg::tiny_skia::Transform::from_scale(scale, scale), &mut pixmap.as_mut());
// tiny-skia keeps premultiplied RGBA, which is what egui wants.
let data: Vec<Color32> = pixmap.pixels().iter().map(|p| Color32::from_rgba_premultiplied(p.red(), p.green(), p.blue(), p.alpha())).collect();
Some(egui::ColorImage { size: [px as usize, px as usize], pixels: data, source_size: vec2(px as f32, px as f32) })
}
/// Draw `icon` filling `rect` (square), in `col`.
pub fn paint(p: &Painter, rect: Rect, icon: Icon, col: Color32) {
let ppp = p.ctx().pixels_per_point();
let side = rect.width().min(rect.height());
// Quantised size (2 px steps, capped): a resized window used to create a new texture for
// every pixel width, so the cache grew without limit while the window was dragged.
let px = ((side * ppp).round().max(8.0) as u32 / 2 * 2).clamp(8, 512);
let tex = {
let mut c = cache().lock().unwrap();
match c.get(&(icon, px)) {
Some(t) => t.clone(),
None => {
let Some(img) = rasterize(icon, px) else { return };
// Roomy hard cap: past it, start the cache fresh (textures reload on demand).
if c.len() >= 1500 {
c.clear();
}
let t = p.ctx().load_texture(format!("icon-{icon:?}-{px}"), img, egui::TextureOptions::LINEAR);
c.insert((icon, px), t.clone());
t
}
}
};
let r = Rect::from_center_size(rect.center(), vec2(side, side));
p.image(tex.id(), r, Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), col);
}
/// An icon followed by words, on one line.
pub fn label(ui: &mut egui::Ui, icon: Icon, text: &str, size: f32, col: Color32) -> egui::Response {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 6.0;
let (r, _) = ui.allocate_exact_size(vec2(size + 1.0, size + 2.0), egui::Sense::hover());
paint(ui.painter(), Rect::from_center_size(r.center(), vec2(size, size)), icon, col);
ui.label(egui::RichText::new(text).size(size).color(col));
})
.response
}
/// A rounded button with an icon and words (pills like 「需要你允許」).
pub fn pill(ui: &mut egui::Ui, icon: Icon, text: &str, fill: Color32, fg: Color32, height: f32) -> egui::Response {
let font = egui::FontId::proportional(13.0);
let galley = ui.painter().layout_no_wrap(text.to_string(), font, fg);
let icon_s = 14.0;
let w = 12.0 + icon_s + 6.0 + galley.size().x + 14.0;
let (rect, r) = ui.allocate_exact_size(vec2(w, height), egui::Sense::click());
let f = if r.hovered() { fill.gamma_multiply(0.88) } else { fill };
ui.painter().rect_filled(rect, height / 2.0, f);
paint(ui.painter(), Rect::from_center_size(egui::pos2(rect.left() + 12.0 + icon_s / 2.0, rect.center().y), vec2(icon_s, icon_s)), icon, fg);
ui.painter().galley(egui::pos2(rect.left() + 12.0 + icon_s + 6.0, rect.center().y - galley.size().y / 2.0), galley, fg);
r.on_hover_cursor(egui::CursorIcon::PointingHand)
}
/// A pill exactly `width` wide (a whole row), icon and words in the middle. The words are the
/// first of `texts` that fits, or else the last cut short with "…" — never wider than the row.
pub fn wide_pill(ui: &mut egui::Ui, icon: Icon, texts: &[String], fill: Color32, fg: Color32, height: f32, width: f32) -> egui::Response {
let font = egui::FontId::proportional(13.0);
let icon_s = 14.0;
let room = (width - 12.0 * 2.0 - icon_s - 6.0).max(0.0);
let measure = |t: &str| ui.painter().layout_no_wrap(t.to_string(), font.clone(), fg).size().x;
let text = texts.iter().find(|t| measure(t) <= room).cloned().unwrap_or_else(|| {
let mut chars: Vec<char> = texts.last().map(|t| t.chars().collect()).unwrap_or_default();
while !chars.is_empty() && measure(&format!("{}…", chars.iter().collect::<String>())) > room {
chars.pop();
}
format!("{}…", chars.into_iter().collect::<String>())
});
let galley = ui.painter().layout_no_wrap(text, font, fg);
let (rect, r) = ui.allocate_exact_size(vec2(width, height), egui::Sense::click());
let f = if r.hovered() { fill.gamma_multiply(0.88) } else { fill };
ui.painter().rect_filled(rect, height / 2.0, f);
let left = rect.center().x - (icon_s + 6.0 + galley.size().x) / 2.0;
paint(ui.painter(), Rect::from_center_size(egui::pos2(left + icon_s / 2.0, rect.center().y), vec2(icon_s, icon_s)), icon, fg);
ui.painter().galley(egui::pos2(left + icon_s + 6.0, rect.center().y - galley.size().y / 2.0), galley, fg);
r.on_hover_cursor(egui::CursorIcon::PointingHand)
}
/// A borderless icon button (hover shows a soft rounded square).
pub fn button(ui: &mut egui::Ui, icon: Icon, size: f32, col: Color32, hover_fill: Color32) -> egui::Response {
let (rect, r) = ui.allocate_exact_size(vec2(size, size), egui::Sense::click());
if r.hovered() {
ui.painter().rect_filled(rect, 7.0, hover_fill);
}
let inner = Rect::from_center_size(rect.center(), vec2(16.0, 16.0));
paint(ui.painter(), inner, icon, col);
r.on_hover_cursor(egui::CursorIcon::PointingHand)
}
修手機接管電腦後回不去;新增「風格」(8 套:紙、夜、墨、苔、海、糖、夕陽、終端機,一套顏色加聊天背景花紋,電腦和手機一起換,也能請 Bot 換);設定每一列都有圖示(電腦和手機)。 - 接管回不去(mobile/index.html newBoxFrame):以前每次打開/關掉都改同一個 iframe 的網址,iframe 換頁會加進上一頁紀錄;第二次之後按 ✕ 或返回,退的是框裡那一頁,接管畫面卡著。現在每次換一個新的框,關掉就拿掉。舊版重現:第 2、3 次關不掉;新版連續 3 次都回到首頁。 - 風格(src/theme.rs TEMPLATES、palette_for、backdrop):每套有淺色和深色的墨、紙、強調色(同一個產生器長出整個殼),加聊天背景 dots/grid/waves。State 新欄位 shell_template(空=自訂)。電腦:設定 › 一般 › 外觀最上面一排小圖(kit::style_gallery,每張是那個風格的縮小畫面),聊天區後面畫花紋(chat_backdrop);點強調色、動底色或重設回到自訂。手機:palettes 帶 backdrop,聊天背景用 CSS 畫;設定 › 一般最上面同一排小圖(api/settings 的 styles、style)。Bot:update_settings 多 `style`(appctl;不在 tools::specs 的鎖檔裡,鎖檔沒變)。截圖:ANYBOT_SHOT_STYLE=ocean。 - 設定圖示:icons::setting_icon 照名字的字配圖示(主題月亮、風格和顏色調色盤、通知鈴鐺、時區地球、權限盾牌、電腦螢幕…,沒對到是滑桿),card_row 和 setting_title 都畫;新 Lucide 圖示 palette、moon、globe、sliders-horizontal、volume-2、hard-drive。手機設定頁、Bot 設定、電腦頁的列用 sitem(同一套規則,SET_ICON)。 - 測試:theme::template_tests::every_template_reads_in_light_and_dark(每套淺深色都讀得清楚、紙就是原本的預設);appctl 的 update_settings 測試加 style。 - 功能地圖 appearance.md 加 appearance-style 和一步驗證、settings.md(Bot 能改四樣)、box.md 陷阱;FEATURES.md。 已驗證: cargo test 881 個全過;clippy 沒有新警告;scratch 手機:接管開關 3 次都回首頁(舊版第 2 次就卡住);設定 › 一般點「海」→ state shell_template=ocean、聊天背景波浪;聊天請 Bot `update_settings {"style":"terminal"}` → 手機強調色 #2d8a3e、格線;Bot 設定 36 列都有圖示。桌面截圖:外觀的 8 張小圖、海、終端機(深色)、糖的聊天,電腦設定一般/電腦頁每列有圖示。 未驗證: 在真的 iPhone 上滑返回手勢(接管開著時本來就停用,靠 ✕);花紋在很大的螢幕上的耗電(電腦版每幀畫點點/線,沒量)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-22 01:38:00 +00:00
/// The picture before a setting's name (設定: every row has one — the eye finds 通知 by its bell
/// before it reads the word). By the words in its name, first match wins; a name that matches
/// none gets the plain sliders.
pub fn setting_icon(label: &str) -> Icon {
const RULES: &[(&[&str], Icon)] = &[
(&["上網"], Icon::Globe),
(&["頁面"], Icon::FileText),
(&["合作", "同事"], Icon::Users),
(&["電話", "簡訊"], Icon::Message),
(&["主題"], Icon::Moon),
(&["風格", "強調色", "顏色", "底色", "對比", "外觀", "外殼"], Icon::Palette),
(&["密度"], Icon::Apps),
(&["慶祝"], Icon::Star),
(&["頭像"], Icon::Smile),
(&["語言"], Icon::Globe),
(&["時區", "時間"], Icon::Clock),
(&["通知", "響一聲", "提醒"], Icon::Bell),
(&["記憶", "意思找"], Icon::Brain),
(&["資料夾", "文件", "檔案"], Icon::Folder),
(&["金鑰", "Token", "token", "密鑰"], Icon::Key),
(&["密碼", "保險庫", "兩步"], Icon::Lock),
(&["瀏覽器", "網址", "網頁"], Icon::Globe),
(&["發布前", "檢查"], Icon::CircleCheck),
(&["更新", "版本", "重新啟動"], Icon::Update),
(&["備份", "快照", "還原"], Icon::History),
(&["磁碟", "用量", "容量"], Icon::Drive),
(&["團隊", "成員", "分享"], Icon::Users),
(&["帳號", "帳戶", "登入", "登出", "個人"], Icon::Person),
(&["手機", "裝置"], Icon::Monitor),
(&["語音", "聽", "說", "朗讀", "聲音"], Icon::Volume),
(&["麥克風", "錄音"], Icon::Mic),
(&["審核", "規則", "權限", "直接操作", "一律", "允許", "詢問", "隔離", "智慧"], Icon::Shield),
(&["連接器", "MCP", "整合"], Icon::Apps),
(&["管道", "Telegram", "Slack", "Discord", "訊息"], Icon::Message),
(&["技能"], Icon::Sparkle),
(&["模型", "AI"], Icon::Sparkle),
(&["電腦", "螢幕", "SSH", "Docker", "主機", "容器", "終端機", "執行"], Icon::Monitor),
(&["例行", "排程", "日程"], Icon::Alarm),
(&["工作流"], Icon::Workflow),
(&["Bot"], Icon::Bot),
(&["園丁", "改進", "診斷"], Icon::Target),
(&["資料", "放在哪"], Icon::Drive),
];
RULES.iter().find(|(words, _)| words.iter().any(|w| label.contains(w))).map(|(_, i)| *i).unwrap_or(Icon::Sliders)
}
字體改成 Apple 的(SF Pro+蘋方,粗體用半粗),回答不再用宋體;設定左邊每頁加圖示;「模型」改成供應商圖塊(不再是設定旁邊再一排清單);「個人資料與用量」改成數字列+大數字+長條+彩色比例條,不再一整片字。 - 字體(src/main.rs):Mac 上介面和讀的文字都用系統的 SF Pro(可變字體,400/600)加蘋方 PingFang TC(Regular/Semibold),跟 macOS 自己一樣;沒有蘋方的電腦用包在 App 裡的思源黑體。蘋方 78MB 只讀一次共用。思源宋體拿掉(App 小 16MB)。手機的 --font-read 改成跟介面同一種,標題 600。 - 設定左邊分頁:原本就配好的圖示畫出來(齒輪、人、星光、格子、螢幕、盾牌、保險庫、麥克風、雲);拿掉分頁和內容之間的線(底色已經分開)。 - 模型(新 src/app/models_ui.rs):每家一塊圖塊——服務的圖案(src/icons.rs provider_mark,自己畫的簡單圖形,不是任何人的商標圖檔)、名字、「● 可以用/還沒設定」、雲端/本機;點進去才是金鑰和網址,上面「‹ 模型」回來。從聊天、搜尋設定跳來直接進那一家。 - 個人資料與用量(src/app/me_ui.rs):五張有框的卡(兩三欄)→ 一條淡底沒有框的數字列(細節在滑過);最活躍的一天放到熱度格子旁邊一行;用量:大數字 token(新讀、寫、快取在滑過)、呼叫和花費一行、每天的長條、「依模型/依 Bot」切換(依模型一條彩色比例條,每列有服務圖案;依 Bot 每列有頭像)。示範截圖有一年的假資料(ANYBOT_SHOT_TAB=me)。 - 數字:過千萬不帶小數(3,699萬,不是 3699.0萬),整數不寫「.0」。 - 修:任務頁兩個任務同一毫秒開頭時 id 一樣,兩張卡搶同一個按鍵(版面檢查在變慢後抓到);卡片 id 加上它在清單裡的位置。 已驗證: cargo test 876 個全過(含 layout_audit::、featuremap::、stats::);clippy 沒有新警告;desktop-shot 看過聊天(中英混排基準線對齊)、設定一般、模型圖塊、個人資料上半和用量(捲下去)。 未驗證: 手機頁面的字體只改了 CSS,沒有在真的 iPhone 上看;Windows/Linux 的思源黑體備案沒有實機跑;版面檢查變慢(約 40 秒 → 100 秒,每個畫面都載入蘋方)。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha2uBHmbnuWBhNzjbJm
2026-11-22 00:35:28 +00:00
/// A model service's mark: a small rounded tile in the service's own colour with a simple shape
/// drawn here (no one's artwork copied — just enough to tell them apart at a glance, the way an
/// app icon is found before its name is read). The same tile in light and dark.
pub fn provider_mark(p: &Painter, rect: Rect, kind: crate::providers::ProviderKind, radius: u8) {
use crate::providers::ProviderKind as K;
use egui::{pos2, Shape, Stroke};
let rgb = |r, g, b| Color32::from_rgb(r, g, b);
let (tile, ink) = match kind {
K::Xai => (rgb(0x14, 0x14, 0x14), Color32::WHITE),
K::OpenAi => (rgb(0x14, 0x14, 0x14), Color32::WHITE),
K::ChatGpt => (rgb(0x10, 0xa3, 0x7f), Color32::WHITE),
K::Anthropic => (rgb(0xd9, 0x77, 0x57), Color32::WHITE),
K::Gemini => (rgb(0xee, 0xf2, 0xfd), rgb(0x3f, 0x7b, 0xf0)),
K::OpenRouter => (rgb(0x64, 0x67, 0xf2), Color32::WHITE),
K::OpenCodeGo => (rgb(0x23, 0x20, 0x1e), Color32::WHITE),
K::Ollama => (rgb(0xf4, 0xf4, 0xf2), rgb(0x1a, 0x1a, 0x1a)),
K::Custom => (rgb(0x6b, 0x72, 0x80), Color32::WHITE),
};
p.rect_filled(rect, radius, tile);
let c = rect.center();
let r = rect.width().min(rect.height()) * 0.28;
let line = |w: f32| Stroke::new((rect.width() * w).max(1.2), ink);
match kind {
// A plain X, one stroke longer.
K::Xai => {
p.line_segment([pos2(c.x - r, c.y - r), pos2(c.x + r, c.y + r)], line(0.075));
p.line_segment([pos2(c.x + r * 1.1, c.y - r * 1.25), pos2(c.x - r, c.y + r)], line(0.075));
}
// Six rings around a centre: a flower.
K::OpenAi | K::ChatGpt => {
for i in 0..6 {
let a = i as f32 * std::f32::consts::TAU / 6.0;
p.circle_stroke(c + vec2(a.cos(), a.sin()) * r * 0.45, r * 0.55, line(0.045));
}
}
// A burst of rays.
K::Anthropic => {
for i in 0..10 {
let a = i as f32 * std::f32::consts::TAU / 10.0;
let len = if i % 2 == 0 { r * 1.15 } else { r * 0.8 };
p.line_segment([c + vec2(a.cos(), a.sin()) * r * 0.18, c + vec2(a.cos(), a.sin()) * len], line(0.07));
}
}
// A four-pointed sparkle (four thin triangles from a small centre).
K::Gemini => {
let k = r * 0.2;
for (tip, a, b) in [
(pos2(c.x, c.y - r * 1.3), pos2(c.x - k, c.y), pos2(c.x + k, c.y)),
(pos2(c.x, c.y + r * 1.3), pos2(c.x - k, c.y), pos2(c.x + k, c.y)),
(pos2(c.x - r * 1.3, c.y), pos2(c.x, c.y - k), pos2(c.x, c.y + k)),
(pos2(c.x + r * 1.3, c.y), pos2(c.x, c.y - k), pos2(c.x, c.y + k)),
] {
p.add(Shape::convex_polygon(vec![tip, a, b], ink, Stroke::NONE));
}
}
// Two arrows passing each other: a router.
K::OpenRouter => {
let s = line(0.06);
let (y1, y2) = (c.y - r * 0.45, c.y + r * 0.45);
p.line_segment([pos2(c.x - r, y1), pos2(c.x + r, y1)], s);
p.line_segment([pos2(c.x + r, y1), pos2(c.x + r * 0.55, y1 - r * 0.4)], s);
p.line_segment([pos2(c.x + r, y2), pos2(c.x - r, y2)], s);
p.line_segment([pos2(c.x - r, y2), pos2(c.x - r * 0.55, y2 + r * 0.4)], s);
}
// Angle brackets: code.
K::OpenCodeGo => {
let s = line(0.06);
p.line_segment([pos2(c.x - r * 0.3, c.y - r * 0.8), pos2(c.x - r, c.y)], s);
p.line_segment([pos2(c.x - r, c.y), pos2(c.x - r * 0.3, c.y + r * 0.8)], s);
p.line_segment([pos2(c.x + r * 0.3, c.y - r * 0.8), pos2(c.x + r, c.y)], s);
p.line_segment([pos2(c.x + r, c.y), pos2(c.x + r * 0.3, c.y + r * 0.8)], s);
}
// A round face with two ears.
K::Ollama => {
let s = line(0.055);
p.circle_stroke(pos2(c.x, c.y + r * 0.25), r * 0.75, s);
p.line_segment([pos2(c.x - r * 0.4, c.y - r * 0.35), pos2(c.x - r * 0.5, c.y - r * 1.1)], s);
p.line_segment([pos2(c.x + r * 0.4, c.y - r * 0.35), pos2(c.x + r * 0.5, c.y - r * 1.1)], s);
p.circle_filled(pos2(c.x - r * 0.28, c.y + r * 0.15), r * 0.09, ink);
p.circle_filled(pos2(c.x + r * 0.28, c.y + r * 0.15), r * 0.09, ink);
}
K::Custom => paint(p, Rect::from_center_size(c, vec2(r * 2.2, r * 2.2)), Icon::Gear, ink),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn every_icon_renders() {
for icon in [Icon::Plus, Icon::Gear, Icon::Stop, Icon::FileSheet, Icon::Trash, Icon::Wave, Icon::Summary, Icon::Lock, Icon::Update, Icon::Play, Icon::Pause, Icon::FileJson, Icon::FileWord] {
let img = rasterize(icon, 32).expect("renders");
assert_eq!(img.size, [32, 32]);
assert!(img.pixels.iter().any(|p| p.a() > 0), "{icon:?} is empty");
}
assert_eq!(for_file("a.xlsx"), Icon::FileSheet);
assert_eq!(for_file("a.png"), Icon::FileImage);
}
/// A wide pill is exactly as wide as asked, however long its words (the sidebar's
/// 重新啟動以更新 ran past the sidebar's edge).
#[test]
fn a_wide_pill_never_outgrows_its_row() {
let ctx = egui::Context::default();
for width in [60.0, 160.0, 400.0] {
let mut got = 0.0;
let mut out = ctx.run_ui(egui::RawInput::default(), |root| {
let texts = ["重新啟動以更新(2026-11-11 17:23)".to_string(), "重新啟動以更新".to_string()];
got = wide_pill(root, Icon::Update, &texts, Color32::BLUE, Color32::WHITE, 30.0, width).rect.width();
});
out.textures_delta.clear(); // (no renderer here to hand the font atlas to)
assert_eq!(got, width);
}
}
}