字體改成 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
This commit is contained in:
王性驊 2026-11-22 08:35:28 +08:00
parent 550edc9c13
commit 5845986227
19 changed files with 474 additions and 197 deletions

View File

@ -639,8 +639,8 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。
### AI 供應商
- 左邊是供應商清單,寬 200 px(估計值)。「● 」表示已經可以用,「○ 」表示還沒設定。
- 右邊是選中的那家:
- 先是每家一塊圖塊(照 OpenBot 的設定排版,三塊一排,窄的時候兩塊):服務的圖案(AnyBot 自己畫的簡單圖形,不是任何人的商標圖檔)、名字、「● 可以用」或「還沒設定」(ChatGPT 方案:「還沒登入」)、右下雲端/本機。以前是設定分頁旁邊再一排供應商清單,三欄字擠在一起。
- 點一塊進那家的頁,上面「‹ 模型」回到圖塊;從別處跳來(聊天的「設定 API 金鑰」、搜尋設定)直接進那家的頁:
- 名稱。
- 取得金鑰的說明(第 11 節)。
- 「API 金鑰」:隱藏顯示。提示「貼上金鑰,或設定環境變數 (變數名)」。Ollama 沒有這一欄。
@ -1577,9 +1577,9 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
### 個人資料與用量(設定 › 個人資料)
- 設定多一頁「個人資料」(一般的下一頁;左下角選單也有「個人資料與用量…」)。最上面名字和「過去一年有 N 個活躍日」。
- 五張卡:**Token**(過去一年,不算快取命中:模型新讀的、寫進快取的和寫出來的)、**最活躍的一天**(token 最多那天和日期)、**訊息**(你和 Bot 寫的,不算步驟和 AnyBot 自己的提示行)、**目前連續天數**(今天還沒用不算斷,寫「自 11月22日 起」)、**最長連續天數**(起訖日期)。視窗夠寬三張一排,否則兩張。
- **活動**:一年的熱度格子(53 週,一週一欄、週日在上),依最忙那天分四級深淺,沒有用量只有訊息的那天照訊息算;滑過看「2026年11月20日:3,610 token、12 則訊息」。
- **用量**:7 天/30 天/90 天/一年。token(新讀、寫、快取讀到)、呼叫次數、花費——只算模型服務自己回報的(例如 OpenRouter),沒回報的寫「未定價」(部分有部分沒有:「US$0.97(另有 694 次呼叫未定價)」),不是 0 元;每天一條(滑過看數字)、依模型、依 Bot(前 8 名,發布前檢查、目標檢查各自一列,刪掉的 Bot 寫「Bot 9(已刪除)」)。
- 一條淡底、沒有框的數字列(大數字、底下一行小字,窄的時候兩個一排):**Token・一年**(不算快取命中:模型新讀的、寫進快取的和寫出來的)、**訊息・一年**(你和 Bot 寫的,不算步驟和 AnyBot 自己的提示行)、**連續使用**(今天還沒用不算斷;滑過看「自 11月22日 起」)、**最長連續**(滑過看起訖日期)。以前是五張有框的卡、兩三欄,一整片字。數字過千萬不帶小數(3,699萬),整數不寫「.0」。
- **活動**:一年的熱度格子(53 週,一週一欄、週日在上),依最忙那天分四級深淺,沒有用量只有訊息的那天照訊息算;滑過看「2026年11月20日:3,610 token、12 則訊息」。圖例旁邊一行「最活躍:11月20日・3,610 token」。
- **用量**:7 天/30 天/90 天/一年。一個大數字 token(滑過看新讀、寫、快取讀到),下面一行呼叫次數、花費——只算模型服務自己回報的(例如 OpenRouter),沒回報的寫「未定價」(部分有部分沒有:「US$0.97(另有 694 次呼叫未定價)」),不是 0 元;每天一條長條(滑過看數字,那條變深);再用「依模型/依 Bot」切換:依模型是一條彩色比例條,下面每個模型一列(服務的圖案、色點、名字、token・百分比),依 Bot 每列是頭像、名字、細長條、token・百分比(前 8 名,發布前檢查、目標檢查各自一列,刪掉的 Bot 寫「Bot 9(已刪除)」)。
- 都從已經有的紀錄算(`usage/YYYY-MM.jsonl` 和每則訊息的時間),不另外存;用大腦的時區切日子;打開時在背景算,一分鐘內再看不重算。螢幕電腦向大腦要(`api/sync/stats`),手機用 `api/stats`(擁有者才有)。
### 所有檔案(側邊欄的資料夾按鈕)
@ -1746,7 +1746,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
- **只管你自己的訊息**:例行任務、訊息管道和團隊成員的訊息照平常做,不受計畫模式限制。照計畫做的期間每一輪都帶著這份計畫(像 Claude Code 把核准的計畫交回給模型),所以聊別的事前先取消。清除聊天記錄、開始新對話會連計畫一起清掉;分享 Bot 的檔案不含計畫。重開 AnyBot 計畫還在;還沒核准時重開,傳一句話它就接著規劃。
- 手機一樣:計畫卡、問題卡都有;目標和計畫在輸入框上方是一排小圖示(計畫旁邊寫「2/5」),點一下展開那一行和「清除目標」/「取消計畫」。
- **外觀(Bot 是主角)**:介面本身安靜(黑、白、灰),顏色和動作都留給 Bot。
- **字型**:介面用思源黑體(Noto Sans TC),讀的文字——Bot 的回答、頁面內文和標題——用思源宋體(Noto Serif TC),像 Claude 的回答一樣是書的字;兩種都有 Regular 和 Bold,包在 App 裡,每台電腦看起來一樣。程式碼用系統的等寬字。沒有字型選項。
- **字型**:跟 Apple 的 App 一樣,介面和讀的文字(Bot 的回答、頁面)都用 macOS 自己的字:英文 SF Pro、中文蘋方(PingFang TC),粗體用半粗(Semibold,比 Bold 輕鬆)。沒有蘋方的電腦(Windows、Linux)用包在 App 裡的思源黑體。程式碼用系統的等寬字。沒有字型選項。(以前回答用思源宋體,讀起來正式、重。)
- **你的訊息是淡灰泡泡**(預設「安靜」;設定 › 一般 › 聊天的顏色可以改成「跟著 Bot」:你的訊息泡泡、送出鈕、側邊欄選中的那格用 Bot 的顏色,或「只用黑色」)。Bot 的回覆不用泡泡,像文件一樣排在頁面上,只有錯誤訊息有泡泡。
- **輸入框上方的臉**:Bot 的臉從輸入框後面探出來,旁邊一句話說它在做什麼(原本對話最後的轉圈那一行搬到這裡)。眼睛就是狀態:待命時往下看輸入框;在想時往上、慢慢左右飄;有步驟在跑時看著旁邊那句「正在…」;需要你時看著你,臉上多一個黃點,旁邊寫「等你決定」;做完笑兩秒;上一輪出錯時眼睛變兩條橫線。新對話時沒有這張小臉(臉是中間那張大的)。
- **每種情境一套動作和一個小道具**(都在臉自己的方框裡,不會碰到旁邊的字;從頭後經過的畫在臉後面,在前面的壓在臉上、描一圈底色,所以頭像不會擋住動畫;換情境時淡入淡出,步驟很快連續切換時至少停 0.6 秒,不會一直閃):
@ -2162,7 +2162,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
- 間距:4、8、12、16、24、32。
- 圓角三種:6(標籤、色塊、小控制項)、10(輸入框、程式碼、提示框)、14(卡片、對話框、面板);按鈕、分段選擇是膠囊(跟手機、macOS 26 一樣:形狀本身就說「可以按」,不用框)。
- 浮在上面的東西(聊天的輸入框、工作流畫布上的工具列和面板、選單)用一層柔和陰影浮起來(調色盤的 `shade`,手機的 `--shade`),不靠粗框線;平放的卡片用細框和底色分組。
- 中文和英文用同一套字型(介面思源黑體、閱讀思源宋體),基準線和大小對得齊;缺的字用系統字型(蘋方等)補。程式碼用 **SF Mono**,沒有就用 Menlo。
- 中文和英文用 Apple 的一對字(SF Pro+蘋方),基準線和大小對得齊;沒有蘋方時用思源黑體,缺的字用系統字型補。程式碼用 **SF Mono**,沒有就用 Menlo。
- 「·」分隔號前後不加空格。
### 共用元件(`src/app/kit.rs`)
@ -2548,7 +2548,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
### 字型
- 介面用 **思源黑體**(Noto Sans TC),讀的文字(回答、頁面)用 **思源宋體**(Noto Serif TC),都是 SIL OFL 1.1 授權,檔案和授權在 `fonts/`,直接包進 App。
- Mac 上用系統的 **SF Pro** 和 **蘋方**(不包進 App);其他電腦用 **思源黑體**(Noto Sans TC,SIL OFL 1.1 授權,檔案和授權在 `fonts/`,包進 App)。
- 它們沒有的字,改用系統字型(蘋方)補上。Mermaid 圖表裡的字也是思源黑體。
- 沒有字型選項(以前的粉圓體和「系統字型」已經拿掉)。Bot 的電腦的桌面也是思源黑體(第 14 版起)。
@ -2836,7 +2836,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
## 對話的 Markdown 與流程圖(2026-11-04)
- 以 pulldown-cmark 解析(表格、刪除線、待辦清單、數學區塊):思源宋體 16 px、標題 22/18/16 px、單一換行照樣換行、粗體(思源宋體的真粗體)、斜體、刪除線、行內程式碼、可點的連結、多層清單、待辦勾選框、引用線、表格(可橫向捲動)、分隔線。
- 以 pulldown-cmark 解析(表格、刪除線、待辦清單、數學區塊):16 px(跟介面同一種字)、標題 22/18/16 px、單一換行照樣換行、粗體(真的半粗字,不是描粗)、斜體、刪除線、行內程式碼、可點的連結、多層清單、待辦勾選框、引用線、表格(可橫向捲動)、分隔線。
- 程式碼區塊:圓角邊框、上色(註解、字串、數字、關鍵字)、可橫向捲動、滑過時右上角「複製程式碼」,複製後兩秒顯示勾。
- ```mermaid:用純 Rust 的 mermaid-rs-renderer 畫成圖(流程圖、時序圖、類別圖、狀態圖、ER、甘特圖、圓餅圖、心智圖、時間軸…),中文用思源黑體,跟著深淺色主題。回覆還在產生時先顯示原始碼,結束後才畫。點圖可放大檢視(縮放、拖曳、下載 PNG 到「下載項目」)。畫不出來時顯示「無法顯示此圖表」並保留原始碼。

View File

@ -8,7 +8,7 @@ AnyBot 長什麼樣子、用什麼語言,和怎麼聽、怎麼說:設定 ›
- `appearance-colors` 強調色(八個點:黏土、靛藍、苔綠、藍綠、玫紅、琥珀、石板、墨黑)、聊天的顏色(你的訊息泡泡:安靜=淡灰,預設;跟著 Bot;只用黑色——手機同一個設定;只有點,選中的有外圈)。
- `appearance-language` 語言:選單和 Bot 回答用的語言。
- `appearance-more` 外觀最後一列「更多外觀設定」按「展開」才出現:底色(冷→暖滑桿)、對比(柔和→鮮明滑桿)、密度(寬鬆/緊湊)、慶祝動畫(開/關,目標達成時撒彩帶)、頭像動態(自動/完整/減少:Bot 頭像做事時的呼吸和眼神,減少只換表情;自動在畫面用 CPU 畫的電腦上減少,那時下面寫「這台的畫面用 CPU 畫,自動減少」)、外殼顏色重設(回預設「紙」)。這幾項和上面的一樣,調了立刻整個殼跟著換,不用重開。
- `appearance-fonts` 字型:沒有字型選項:介面思源黑體、讀的文字(回答、頁面)思源宋體。設定列名稱旁的「?」平常不顯示,滑鼠移到那一列才出現;設定下面的說明只有一行,長的滑過看全文。
- `appearance-fonts` 字型:沒有字型選項:跟 Apple 一樣,介面和讀的文字(回答、頁面)都是 SF Pro 加蘋方(PingFang TC),粗體用半粗(Semibold);沒有蘋方的電腦用包在 App 裡的思源黑體。設定列名稱旁的「?」平常不顯示,滑鼠移到那一列才出現;設定下面的說明只有一行,長的滑過看全文。
- `appearance-voice` 語音:「語音服務」一張清單,「聽(語音轉文字)」把說的話變文字(語音輸入、語音聊天、會議錄音),「說(朗讀)」把回答唸出來;各自在右邊選服務,選了在那一列下面展開要填的欄位(快速填入、網址、金鑰、模型;「說」還有「聲音」選單),能用了列上寫「可以用」,並有「試試看(說一句話)」或「試聽」。沒設定時沒有語音輸入,請 AnyBot 唸會說「還沒設定語音」。
- `appearance-voices` 「聲音」選單:第一項「預設(eve)」,下面是服務列出的聲音,選了試唸一句;拿不到清單時寫原因,可以直接輸入名稱或「再試一次」。每個 Bot 的 對話詳細資訊 › 語音聊天 ›「聲音」是同一個選單(預設是這裡選的)。

View File

@ -9,8 +9,8 @@
- `pageview-steps` ```steps 進度:[x] 完成、[>] 進行中、[ ] 還沒到。
- `pageview-chart` ```chart 圖表(bar/line/pie,可以多系列):長條圖自動由大到小排序,月份/年份等自有順序的標籤不排;單系列把數字直接標在圖上不畫 y 軸;多條線在線尾標系列名;長條的 y 軸一定從 0 開始,折線離 0 很遠(最小值比資料的高低差還大,例如 1,649–1,796)時照資料範圍畫、不從 0 開始;圖下附數據表(名稱靠左、數字靠右、每欄只有內容那麼寬,太寬就左右捲動,不會把頁面撐寬;超過 6 列時收成「▸ 數據 · N 筆」,點了展開);第一行可以是「圖型 標題」、只寫圖型(bar/line/pie 或 長條/折線/圓餅)或只寫標題,`#` 開頭是註解,`|---|` 分隔列略過,少填的格子當 0;手機也畫原生圖,讀法和樣式相同:照手機寬度畫、字不縮小,折線和多系列長條有 y 軸數字,只有一項的圓餅是整圓,圖例再多項都畫得到。
- `pageview-callout` 提示框:`> [!NOTE]`/`[!TIP]`/`[!WARNING]`/`[!IMPORTANT]`。
- `pageview-desktop` 打開的頁面像一份文件(電腦和手機同一套):標題宋體粗體 28,下面一行小字作者、「更新於」、第幾版和「這一版更新了:…」;一行現況(summary)是開頭段落、不加框;結論(verdict)是淡底的「結論」提示框;kpis 是只有細框的數字卡(每張三行疊著:標籤、數字、變化;四張並排每張太窄時一排兩張;字太長以 … 結尾,滑過看全文)。頁面視窗不會被內容撐寬:太寬的表格在閱讀欄裡左右捲動,其他太寬的東西在視窗邊緣切掉,標題列的 × 一直在右上角。有 3 個以上的標題時有一行「▸ 目錄 · N 節」,點開才是標題清單和小搜尋框(⌘F 直接展開)。內文宋體 16、行距 1.7,閱讀欄最寬 680。
- `pageview-phone` 手機打開的頁面:標題宋體粗體大字,下面一行小字作者和「更新於」;現況、kpis、結論同上;有 3 個以上的標題時多一行「目錄 · N 節」,點開是標題清單,點一個捲到那裡(沒有搜尋框)。內文宋體 16px、行距寬;表格沒有直線和斑馬紋、數字欄靠右;提示框同一種淡底,只有圖示依種類上色。
- `pageview-desktop` 打開的頁面像一份文件(電腦和手機同一套):標題半粗體 28,下面一行小字作者、「更新於」、第幾版和「這一版更新了:…」;一行現況(summary)是開頭段落、不加框;結論(verdict)是淡底的「結論」提示框;kpis 是只有細框的數字卡(每張三行疊著:標籤、數字、變化;四張並排每張太窄時一排兩張;字太長以 … 結尾,滑過看全文)。頁面視窗不會被內容撐寬:太寬的表格在閱讀欄裡左右捲動,其他太寬的東西在視窗邊緣切掉,標題列的 × 一直在右上角。有 3 個以上的標題時有一行「▸ 目錄 · N 節」,點開才是標題清單和小搜尋框(⌘F 直接展開)。內文宋體 16、行距 1.7,閱讀欄最寬 680。
- `pageview-phone` 手機打開的頁面:標題半粗體大字,下面一行小字作者和「更新於」;現況、kpis、結論同上;有 3 個以上的標題時多一行「目錄 · N 節」,點開是標題清單,點一個捲到那裡(沒有搜尋框)。內文 16px(跟介面同一種黑體)、行距寬;表格沒有直線和斑馬紋、數字欄靠右;提示框同一種淡底,只有圖示依種類上色。
## 使用者怎麼到
@ -27,7 +27,7 @@
- **區塊**(covers `pageview-details`、`pageview-stats`、`pageview-steps`、`pageview-callout`、`pageview-phone`):請 Bot 寫一頁各種區塊和結論,點卡片打開,點「目錄」和「證據」。指令:`$CTL phone send '[[call write_page {"title":"區塊","kind":"decision","verdict":"先別買","content":"## 數字\n\u0060\u0060\u0060stats\n訂單 | +3\n退貨 | -2%\n評分 | -\n\u0060\u0060\u0060\n## 進度\n\u0060\u0060\u0060steps\n[x] 審查 | 開過兩次會\n[>] 路測\n[ ] 開放\n\u0060\u0060\u0060\n## 細節\n\u0060\u0060\u0060details 證據\n- 七月會議\n\u0060\u0060\u0060\n> [!WARNING] 先別花錢"}]]' && $CTL phone click '.pcard[data-page="1"]' && $CTL phone wait '.stats .v.up' && $CTL phone wait '.stats .v.dn' && $CTL phone wait 'ul.steps li.now' && $CTL phone wait '.call.k-warning' && $CTL phone wait-text '目錄 · 3 節' --in '#page' && $CTL phone shot pageview-blocks && $CTL phone click 'details.toc summary' && $CTL phone click '[data-toc]' --text 細節 && $CTL phone click 'details.dt summary' --text 證據 && $CTL phone wait-text 七月會議 --in '#page' && $CTL phone shot pageview-open && $CTL api GET /api/pages/1 --jq '{verdict, body}'`。看到:「結論 先別買」提示框;+3 綠、-2% 紅、單獨的 - 不上色;✓ 審查、進行中的路測、還沒到的開放;「先別花錢」警告框;「目錄 · 3 節」點開是三個標題;「證據」原本收著,點了才看到「七月會議」。
- **圖表**(covers `pageview-chart`、`pageview-phone`):回聊天請它寫一頁四張圖,打開看。指令:`$CTL phone click '[data-back]' && $CTL phone send '[[call write_page {"title":"圖表","content":"\u0060\u0060\u0060chart\nbar 水果\n香蕉 | 3\n蘋果 | 9\n芒果 | 5\n\u0060\u0060\u0060\n\u0060\u0060\u0060chart\n長條 月份\n1月 | 3\n2月 | 9\n3月 | 5\n\u0060\u0060\u0060\n\u0060\u0060\u0060chart\nline 功率\n# 瓦\n1 | 1649\n2 | 1700\n3 | 1796\n4 | 1720\n5 | 1680\n6 | 1750\n7 | 1710\n\u0060\u0060\u0060\n\u0060\u0060\u0060chart\npie\n全部 | 5\n\u0060\u0060\u0060"}]]' && $CTL phone click '.pcard[data-page="2"]' && $CTL phone wait-text '數據 · 7 筆' --in '#page' && $CTL phone shot pageview-charts && $CTL phone text '#page'`。看到:四張原生圖,字跟內文差不多大;水果長條排成蘋果、芒果、香蕉,月份照 1、2、3 月;單系列數字標在條上;功率折線 y 軸從 1,6xx 起、看得出起伏,數據表收成「▸ 數據 · 7 筆」;只寫 pie 也畫得出來,一項是整圓。
- **桌面的頁面視窗**(covers `pageview-desktop`、`pageview-chart`):指令:要開視窗——`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot pageview ANYBOT_SHOT_VIEW=page`。看到:示範頁像一份文件:宋體標題、作者和「更新於」、數字卡、進度、警告框、折線和圓餅、「▸ 目錄 · N 節」(點開有搜尋框,⌘F),× 在右上角;加 `ANYBOT_SHOT_THEME=dark` 時頁面視窗也不超出畫面。data 頁四張數字卡排成兩排、十欄寬表格在閱讀欄裡捲動:沒同意就靠 `cargo test layout_audit::`(它畫的就是這種頁)。
- **桌面的頁面視窗**(covers `pageview-desktop`、`pageview-chart`):指令:要開視窗——`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot pageview ANYBOT_SHOT_VIEW=page`。看到:示範頁像一份文件:半粗體標題、作者和「更新於」、數字卡、進度、警告框、折線和圓餅、「▸ 目錄 · N 節」(點開有搜尋框,⌘F),× 在右上角;加 `ANYBOT_SHOT_THEME=dark` 時頁面視窗也不超出畫面。data 頁四張數字卡排成兩排、十欄寬表格在閱讀欄裡捲動:沒同意就靠 `cargo test layout_audit::`(它畫的就是這種頁)。
- 自動測試:`cargo test pages::`(`stat_trend_reads_arrows_and_both_minus_signs`、`a_line_far_from_zero_fits_its_data_and_bars_start_at_zero`)、`cargo test layout_audit::`。
## 陷阱

View File

@ -6,7 +6,7 @@
- `phone-pages` 頁面:Bot 清單(分區、工作中/等你)、聊天(附檔、拍照、語音輸入、插話、停止;叫醒 Bot 的訊息上方標是什麼叫醒的:目標、例行任務、觸發、訊息管道、來自其他 Bot、監看)、允許請求卡片(「一律允許」「允許一次」、「這輪都准」(智慧模式,一直開著;它是主按鈕)、「拒絕」、「全部允許,之後直接操作」;卡片太高時卡在內面自己捲,輸入框不會被頂出螢幕)、問題卡、「需要處理」與接管、Bot 設定、例行任務(詳細頁有最近幾次執行和送出證據)、頁面、記憶、檔案預覽、Bot 的電腦畫面、設定(一般、模型、權限、整合、電腦、保險庫、手機與帳號、更新,能改的比電腦少;開著的設定頁跟著電腦那邊的改變重讀,不用重新整理;直接連線只能收緊、不能放寬,見 [autonomy](autonomy.md))、傳送到其他裝置。智慧模式一直開著,輸入列沒有它的晶片。
- `phone-cards` 手機上的卡(允許、需要處理、問題卡)只答它畫出來的那一張:那張已經在電腦或另一支手機上回答、被停止、或換成下一張時,按了不算,聊天裡寫「手機上的回答沒有用上…」;開了很久沒重新整理的舊頁面也一樣。螢幕電腦上的卡也是;比大腦舊的螢幕電腦答不了任何卡,要在那台 設定 › 更新 換新版(重新整理沒用)。支線的卡沒用上時,寫在主線的聊天。
- `phone-look` 長相(和電腦版同一份設計規格:字級、間距、圓角都是同一組數字):Bot 的回答不放在泡泡裡,像文件一樣直接排在畫面上,用宋體(思源宋體,沒有就用系統的宋體)、16px、行距寬;裡面的表格只有橫向細線、數字欄靠右,提示框([!NOTE] 等)同一種淡底、只有圖示依種類上色,程式碼是淡底圓角塊。你自己的訊息(泡泡)和所有按鈕、清單、設定用黑體。手機沒有字型選項。
- `phone-look` 長相(和電腦版同一份設計規格:字級、間距、圓角都是同一組數字):Bot 的回答不放在泡泡裡,像文件一樣直接排在畫面上,跟介面同一種字(iPhone 是 SF Pro 加蘋方)、16px、行距寬;裡面的表格只有橫向細線、數字欄靠右,提示框([!NOTE] 等)同一種淡底、只有圖示依種類上色,程式碼是淡底圓角塊。標題用半粗體。手機沒有字型選項。
- `phone-colors` 顏色跟電腦版一樣:電腦上 設定 › 一般 › 外觀 的主題(淺色/深色/跟隨系統)、底色、強調色、對比,手機照著穿;手機自己的「外觀」可以選「跟著電腦」(預設)、「跟著手機」、「淺色」、「深色」。狀態列的顏色跟著畫面。舊版的電腦沒送顏色時,手機用內建的「紙」。
- `phone-claude` 像 Claude 的手機 App:上面一條簡單的標題列(Bot 名稱,第二行是它在做什麼或用哪個模型),輸入框是底部一張圓角卡片,回答下面只有時間和複製/重新產生/⋯;按鈕和點的地方至少 44px;清單每列的說明只有一行(太長以 … 結尾);顏色少,強調色只用在連結、選取和新訊息的點。
- `phone-net` 網路慢或斷線都不擋操作:存過這台電腦的資料,打開 App 就用上次的內容進去,不等網路,連上後只補變了的;浮著提示「離線中:顯示的是上次的內容」,拿到就消失。只有第一次(還沒有這台的資料)停在連線畫面:打開 App 時的頭像留在正中間呼吸、外圈漾開,不顯示文字(讀螢幕軟體唸「正在連線」;減少動態時不動),第一份狀態到手才進去。用帳號連、那台不在線上時留在它上次的內容裡,不換到別台。進去之後斷線:浮「連線中斷,正在重新連線…」,自己重試,回到前景或網路恢復時立刻重連。設定、詳細、例行任務先畫手上有的,背景讀新的;要改的先讀到最新的。傳訊息不等網路:按下就出現在聊天裡;連不上標「等連線後送出(點一下拿回來)」,存手機排隊(關 App 也還在),連上後照順序自己送、不限時間,同一則只送一次;點一下連同附件拿回輸入框;連不上時選的附件也排隊。大腦拒收的才標「沒送出,點一下拿回來重送」。從通知打開時按的允許/拒絕等連上才送。只傳有變的部分、文字壓縮;Bot 回答中手機每秒最多更新一次聊天(見 [chat](chat.md) 的開聊天分頁)。頁面和圖示存在手機上:打開直接用,背景問一次換版沒;換了,還在連線畫面就重新載入,已進去就等退到背景、手上沒東西(沒打字、附件、排隊、錄音、選單)才換;重新整理一定先問伺服器。上次的狀態、看過的聊天(合計最多 12 個)、詳細資料、設定、排隊的訊息每台電腦各自存在這個網址的儲存空間,登出(或登入失效)全部清掉。

View File

@ -1,6 +1,6 @@
# 設定總覽
設定視窗有八個分頁(下面由上到下),另外每個 Bot 有自己的「Bot 設定」視窗。這份是地圖:每一項一句話,細節到括號裡那一區看。
設定視窗有九個分頁(下面由上到下,每個前面一個圖示:齒輪、人、星光、格子、螢幕、盾牌、保險庫、麥克風、雲),另外每個 Bot 有自己的「Bot 設定」視窗。這份是地圖:每一項一句話,細節到括號裡那一區看。
## 子功能
@ -11,10 +11,10 @@
- Bot:時區,例行任務和提醒用([routines](routines.md))。
- 帳戶:「登入」或「管理帳戶」打開「手機與帳號」頁;資料放在哪。
- `settings-whose` 左下角(你的名字):名字下面一行寫 Bot 在哪一台——「這台電腦」,或「大腦「名字」」(綠點連得到、灰點連不到)。點一下開「Bot 在哪一台」選單:「這台電腦(這台的名字)」、帳號裡每台可以當大腦的電腦(現在用的打勾,離線的灰、不能點),點一下就換——跟「手機與帳號」頁大腦那一欄的「改用它當大腦」「改回用這台自己的 Bot」一樣([account](account.md));沒登入帳號多一行「登入帳號,才能換到別台大腦…」;分隔線下「所有檔案…」([library](library.md))、「個人資料與用量…」、「設定…」(⌘, 也可以)。
- `settings-me` 「個人資料」:名字、過去一年有幾個活躍日;五張卡——Token(過去一年,不算快取命中)、最活躍的一天、訊息、目前連續天數(今天還沒用不算斷)、最長連續天數;「活動」一年的熱度格子(一週一欄、越忙顏色越深,滑過看日期、token、訊息數);「用量」選 7 天/30 天/90 天/一年:token(新讀、寫、快取讀到)、呼叫次數、花費(模型服務回報的,沒回報寫「未定價」,不是 0 元)、每天一條、依模型、依 Bot。左下角選單也有「個人資料與用量…」。螢幕電腦上算的是大腦的(向大腦要);手機和螢幕的路是 `api/stats`、`api/sync/stats`(擁有者才有)。
- `settings-me` 「個人資料」:名字、過去一年有幾個活躍日;一條沒有框的數字列——Token・一年(不算快取命中)、訊息・一年、連續使用(今天還沒用不算斷)、最長連續,細節在滑過;「活動」一年的熱度格子(一週一欄、越忙顏色越深,滑過看日期、token、訊息數),旁邊一行「最活躍:日期・token」;「用量」選 7 天/30 天/90 天/一年:一個大數字 token(滑過看新讀、寫、快取讀到)、呼叫次數和花費(模型服務回報的,沒回報寫「未定價」,不是 0 元)、每天一條長條,再切「依模型」(一條彩色比例條,每個模型有服務的圖案)或「依 Bot」(頭像和長條),各寫 token 和百分比。左下角選單也有「個人資料與用量…」。螢幕電腦上算的是大腦的(向大腦要);手機和螢幕的路是 `api/stats`、`api/sync/stats`(擁有者才有)。
- `settings-search` 「搜尋設定…」(左欄最上面):打字時頁面清單換成符合的設定(最多 12 個),標題開頭相符的在前,再來標題包含的,再來所在區塊或別的說法(「深色」找到「主題」、「billing」找到「用量」;模型供應商用名字找);每個下面寫在哪(「一般 › Bot」)。點一個或按 Enter 拿第一個:換到那一頁(整合的小分頁、市集、收起來的「更多外觀設定」會跟著打開)、捲到那一列,外框用強調色亮一下(約 2 秒淡掉);Esc 清空。
- `settings-account` 「手機與帳號」頁(從 一般 › 帳戶 進去,[account](account.md)):「AnyBot 帳號」(登入、備份、還原)、大腦和「加一台電腦」([computers](computers.md))、「同一個網路直接連」、「手機可以做什麼」、「直接連線的裝置」、「分享給團隊」([team](team.md))、「帳號裡的電腦」。
- `settings-models` 「模型」:每家 AI 供應商的 API 金鑰、服務網址、新 Bot 預設模型、「測試連線並取得模型清單」([models](models.md));本機或區網的供應商多「看不到圖時,請雲端模型看截圖和附件」(預設關,[chat](chat.md))。「ChatGPT 方案」沒有金鑰和網址欄,改成「ChatGPT 帳號」:登入狀態、「使用 ChatGPT 繼續」「登出」「換帳號」「打開登入頁」「管理用量」;連到別台大腦時多一格貼回登入網址和「完成登入」。
- `settings-models` 「模型」:先是每家 AI 供應商一塊圖塊(自己的圖案、名字、「可以用」或「還沒設定」、雲端/本機),點一塊進去、上面「‹ 模型」回來;裡面是 API 金鑰、服務網址、新 Bot 預設模型、「測試連線並取得模型清單」([models](models.md));本機或區網的供應商多「看不到圖時,請雲端模型看截圖和附件」(預設關,[chat](chat.md))。「ChatGPT 方案」沒有金鑰和網址欄,改成「ChatGPT 帳號」:登入狀態、「使用 ChatGPT 繼續」「登出」「換帳號」「打開登入頁」「管理用量」;連到別台大腦時多一格貼回登入網址和「完成登入」。
- `settings-integrations` 「整合」,三個小分頁:
- 訊息管道:Slack、Discord、Telegram、Teams…([channels](channels.md))。
- 連接器:「連接器(MCP)」和「已加入」清單(每列進到它自己的頁:設定、工具、移除);「瀏覽市集」頁(「連接器市集」、公用市集)、「新增連接器」頁([connectors](connectors.md))。
@ -48,7 +48,7 @@
- 基本前提和「手機已登入」(README),開著 Bot 1 的聊天:`$CTL phone click '.row[data-bot="1"]'`。
- **左下角:Bot 在哪一台**(covers `settings-whose`):前提:要開視窗。指令:`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot whose ANYBOT_SHOT_VIEW=whose ANYBOT_SHOT_SIZE=1000x620 'ANYBOT_SHOT_CLICK=150,592@6' ANYBOT_SHOT_FRAMES=60`(示範資料:已登入、是「雲端大腦」的螢幕、jenny-Host 離線),再不帶 `ANYBOT_SHOT_VIEW` 跑一次(沒登入)。看到:左下角「daniel/● 大腦「雲端大腦」」;選單「Bot 在哪一台」下「這台電腦(…)」「✓ 雲端大腦」「jenny-Host(離線)」(灰),分隔線下「所有檔案…」「個人資料與用量…」「設定…」;沒登入時是「✓ 這台電腦(…)」「登入帳號,才能換到別台大腦…」,分隔線下同樣三項。真的切換要帳號裡有另一台大腦:走不到,和「手機與帳號」頁的按鈕是同一段(`mir.want`、`mir.leave`)。
- **個人資料與用量**(covers `settings-me`):指令:`$CTL api GET /api/stats --jq '{tokens_year, messages_year, streak_now, active_days, d: (.days|length), p: (.periods|keys)}'`;桌面要開視窗:`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot me ANYBOT_SHOT_TAB=me ANYBOT_SHOT_SIZE=1000x900`。看到:API 有 371 天的 days、periods 7/30/90/365;畫面上五張卡、熱度格子、「用量」和那四個期間、依模型、依 Bot。scratch 的假模型不回報用量,token 是 0、花費「未定價」(真的數字靠 `cargo test stats::`)。
- **個人資料與用量**(covers `settings-me`):指令:`$CTL api GET /api/stats --jq '{tokens_year, messages_year, streak_now, active_days, d: (.days|length), p: (.periods|keys)}'`;桌面要開視窗:`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot me ANYBOT_SHOT_TAB=me ANYBOT_SHOT_SIZE=1000x900`。看到:API 有 371 天的 days、periods 7/30/90/365;畫面(示範資料)上數字列、熱度格子、「用量」的大數字、長條、四個期間、依模型的比例條。scratch 的假模型不回報用量,API 的 token 是 0、花費「未定價」(真的數字靠 `cargo test stats::`)。
- **搜尋設定**(covers `settings-search`):前提:要開視窗。指令:`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot set-search ANYBOT_SHOT_TAB=general ANYBOT_SHOT_SIZE=1100x760 ANYBOT_SHOT_FRAMES=60 'ANYBOT_SHOT_CLICK=245,159@20' 'ANYBOT_SHOT_TYPE=自動@30'`;再跑兩次,加 `'ANYBOT_SHOT_KEYS=Enter@40'`、`ANYBOT_SHOT_FRAMES=66`:打 `時區@30`,和從更新頁(`ANYBOT_SHOT_TAB=updates`)打 `對比@30`。看到:「自動更新/電腦 › Bot 的電腦」「自動審核/權限」「自動更新/更新」;時區那次換到一般、捲到「Bot」下的「時區」,那列有強調色外框;對比那次「更多外觀設定」變「收起」、「對比」有外框。
- **Bot 改三樣**(covers `settings-by-bot`、`settings-general`):請 Bot 換深色、只用黑色、時區紐約,再傳一句。指令:`$CTL phone send '改 [[call update_settings {"theme":"dark","accent":"black","timezone":"America/New_York"}]]' && $CTL phone wait-text '時區 → America/New_York' --in '#msgs' && $CTL phone send 幾點 && $CTL phone wait-text 'FAKE-MODEL 回答:幾點' --in '#msgs' && $CTL model 'select(.kind == "turn") | .user' && TZ=America/New_York date +%H:%M`。看到:不用卡片,「已更新:主題 → dark、聊天的顏色 → black、時區 → America/New_York」;Bot 收到的〔送出時間〕是紐約時間。
- **錯的時區**(covers `settings-by-bot`):指令:`$CTL phone send '錯 [[call update_settings {"timezone":"Mars/Base"}]]' && $CTL phone wait-text '不是有效的時區名稱' --in '#msgs' && $CTL state .timezone`。看到:「「Mars/Base」不是有效的時區名稱(例如 Asia/Taipei)」;還是 America/New_York。

Binary file not shown.

Binary file not shown.

View File

@ -1,9 +1,6 @@
[Noto Sans TC](思源黑體,fonts/NotoSansTC-Regular.otf, NotoSansTC-Bold.otf)
Copyright © 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'.
[Noto Serif TC](思源宋體,fonts/NotoSerifTC-Regular.otf, NotoSerifTC-Bold.otf)
Copyright © 2017-2024 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL

View File

@ -37,7 +37,8 @@
--lh-read:1.7;
--sp-1:4px;--sp-2:8px;--sp-3:12px;--sp-4:16px;--sp-5:24px;--sp-6:32px;
--r-s:6px;--r-m:10px;--r-l:14px;
--font-read:"Noto Serif TC","Songti TC","Source Han Serif TC","Noto Serif CJK TC",serif;
/* Answers and pages read in the same calm sans as the interface (Apple's way; they were in a serif). */
--font-read:var(--font);
/* Floating shadows, the sheet's backdrop, the black stage under a screen, words on a strong fill. */
--shade:#00000024;--scrim:#00000066;--stage:#000;--on-stage:#ffffff99;--on-color:#fff;
}
@ -158,7 +159,7 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
:is(.bub,.page,.tk-a) li{margin:0 0 6px}
:is(.bub,.page,.tk-a) li:last-child{margin-bottom:0}
:is(.bub,.page,.tk-a) li.task{list-style:none;margin-left:-1.2em}
:is(.bub,.page) :is(h2,h3,h4){font-family:var(--font-read);font-weight:700;line-height:1.35;color:var(--text)}
:is(.bub,.page) :is(h2,h3,h4){font-family:var(--font-read);font-weight:600;line-height:1.35;color:var(--text)}
.bub h2{font-size:var(--fs-h3);margin:1.2em 0 .4em}
.bub :is(h3,h4){font-size:var(--fs-read);margin:1.1em 0 .3em}
.tk-a :is(h2,h3,h4){font-size:var(--fs-ui);margin:.8em 0 .3em}
@ -507,7 +508,7 @@ textarea.field{min-height:96px;line-height:1.5}
/* ---- page viewer ---- */
.page{padding:var(--sp-2) 18px 40px;max-width:760px;margin:0 auto}
.page h1.pt{font-family:var(--font-read);font-weight:700;font-size:var(--fs-h1);line-height:1.3;margin:var(--sp-3) 0 var(--sp-1)}
.page h1.pt{font-family:var(--font-read);font-weight:600;font-size:var(--fs-h1);line-height:1.3;margin:var(--sp-3) 0 var(--sp-1)}
.page .mt{font-family:var(--font);font-size:var(--fs-caption);color:var(--text3);margin-bottom:var(--sp-4)}
.page h2{font-size:var(--fs-h2);margin:1.6em 0 .5em}
.page h3{font-size:var(--fs-h3);margin:1.4em 0 .4em}

View File

@ -43,6 +43,7 @@ mod voice_ui;
mod drops_ui;
mod tasks_ui;
mod me_ui;
mod models_ui;
mod activity_ui;
mod library_ui;
mod market_ui;
@ -153,7 +154,6 @@ const DRAFT_SAVE_AFTER: std::time::Duration = std::time::Duration::from_millis(1
const WINDOW_SCREEN_MARGIN: f32 = 80.0;
/// Provider names in Settings fit on one line (「自訂(OpenAI 相容)」) (estimated).
// (Wide enough for 「自訂(OpenAI 相容)」 and the 本機/區網/雲端 tag beside it.)
const PROVIDER_LIST_WIDTH: f32 = 212.0;
/// The chat header's 本機/區網/雲端 tag after the bot's name (with its gap).
const HEADER_TAG_W: f32 = 40.0;
/// Settings: dialog width, its left-hand page list, and a steady height so tabs don't jump.
@ -323,6 +323,8 @@ pub struct App {
show_settings: bool,
settings_tab: SettingsTab,
settings_provider: ProviderKind,
/// 設定 › 模型: one service open (its key and address), or false for the grid of all of them.
settings_provider_open: bool,
edit_bot: Option<(Bot, bool)>,
/// The bot as its settings were opened (what 「儲存」 measures the person's changes against).
edit_bot_from: Option<Bot>,
@ -619,6 +621,7 @@ impl App {
show_settings: false,
settings_tab: SettingsTab::General,
settings_provider: ProviderKind::Xai,
settings_provider_open: false,
edit_bot: None,
edit_bot_from: None,
confirm_delete: None,
@ -1038,6 +1041,7 @@ impl App {
app.show_settings = true;
app.settings_tab = SettingsTab::Providers;
app.settings_provider = ProviderKind::Anthropic;
app.settings_provider_open = true;
}
Ok("general") => {
app.show_settings = true;
@ -1440,6 +1444,10 @@ impl App {
if let Some(tab) = tab {
app.show_settings = true;
app.settings_tab = tab;
// 個人資料: a year of sample figures (the demo has no usage of its own).
if tab == SettingsTab::Me {
app.me.demo_fill();
}
}
}
// ANYBOT_SHOT_STATUS=<text>: what a running turn says it is doing (a long retry message).
@ -4497,6 +4505,7 @@ impl App {
self.show_settings = true;
self.settings_tab = SettingsTab::Providers;
self.settings_provider = bot.provider;
self.settings_provider_open = true;
}
}
}
@ -6015,6 +6024,7 @@ impl App {
self.show_settings = true;
self.settings_tab = SettingsTab::Providers;
self.settings_provider = b.provider;
self.settings_provider_open = true;
}
});
}
@ -6305,29 +6315,34 @@ impl App {
}
} else {
use crate::icons::Icon;
for (tab, name, icon) in [(SettingsTab::General, "一般", Icon::Gear), (SettingsTab::Me, "個人資料", Icon::Person), (SettingsTab::Providers, "模型", Icon::Sparkle), (SettingsTab::Channels, "整合", Icon::Chat), (SettingsTab::Computers, "電腦", Icon::Monitor), (SettingsTab::Review, "權限", Icon::Shield), (SettingsTab::Vault, "保險庫", Icon::Vault), (SettingsTab::Voice, "語音", Icon::Mic), (SettingsTab::Updates, "更新", Icon::CloudDownload)] {
for (tab, name, icon) in [(SettingsTab::General, "一般", Icon::Gear), (SettingsTab::Me, "個人資料", Icon::Person), (SettingsTab::Providers, "模型", Icon::Sparkle), (SettingsTab::Channels, "整合", Icon::Apps), (SettingsTab::Computers, "電腦", Icon::Monitor), (SettingsTab::Review, "權限", Icon::Shield), (SettingsTab::Vault, "保險庫", Icon::Vault), (SettingsTab::Voice, "語音", Icon::Mic), (SettingsTab::Updates, "更新", Icon::CloudDownload)] {
let (rect, r) = ui.allocate_exact_size(vec2(ui.available_width(), 38.0), egui::Sense::click());
let on = self.settings_tab == tab || (tab == SettingsTab::General && self.settings_tab == SettingsTab::Remote);
if on || r.hovered() {
ui.painter().rect_filled(rect, R_M, if on { p.active } else { p.hover });
}
let col = if on { p.text } else { p.text2 };
let _ = icon;
// A picture before each name (as OpenBot and System Settings do): the eye
// finds 權限 by its shield before it reads the word.
crate::icons::paint(ui.painter(), egui::Rect::from_center_size(rect.left_center() + vec2(20.0, 0.0), vec2(16.0, 16.0)), icon, if on { p.text } else { p.text3 });
let font = if on { egui::FontId::new(FONT_BASE, crate::bold()) } else { egui::FontId::proportional(FONT_BASE) };
ui.painter().text(rect.left_center() + vec2(12.0, 0.0), egui::Align2::LEFT_CENTER, t(name), font, col);
ui.painter().text(rect.left_center() + vec2(36.0, 0.0), egui::Align2::LEFT_CENTER, t(name), font, col);
// 更新: a newer build is waiting (the yellow that means 「需要你」).
if tab == SettingsTab::Updates && self.newer_build.is_some() && rect.width() > 110.0 {
ui.painter().circle_filled(rect.right_center() - vec2(14.0, 0.0), 5.0, p.attention);
}
if r.on_hover_cursor(egui::CursorIcon::PointingHand).clicked() {
// (模型 opens on its tiles, not the last service looked at.)
if tab == SettingsTab::Providers {
self.settings_provider_open = false;
}
self.settings_tab = tab;
}
}
}
});
});
let r = ui.min_rect();
ui.painter().vline(r.right(), r.y_range(), Stroke::new(1.0, p.border));
// (No line between the list and the page: the list's own tint already parts them.)
ui.vertical(|ui| {
ui.spacing_mut().item_spacing = vec2(8.0, 6.0);
// On a screen of a brain: whose settings this page is — this computer's, the
@ -6775,41 +6790,29 @@ impl App {
});
}
}
SettingsTab::Providers if !self.settings_provider_open => {
// All the services as tiles (a mark, the name, ready or not, where it
// runs) — one column of pages, not a list beside the page beside the
// settings list. A press opens that one.
if let Some(k) = self.provider_grid(ui) {
self.settings_provider = k;
self.settings_provider_open = true;
}
}
SettingsTab::Providers => {
ui.horizontal_top(|ui| {
ui.vertical(|ui| {
ui.set_width(PROVIDER_LIST_WIDTH);
ui.spacing_mut().item_spacing.y = 2.0;
for k in ALL_PROVIDERS {
let ps = self.state.provider(k);
let ready = providers::ready(k, &ps.api_key);
let (rect, r) = ui.allocate_exact_size(vec2(PROVIDER_LIST_WIDTH, 32.0), egui::Sense::click());
let on = self.settings_provider == k;
if on || r.hovered() {
ui.painter().rect_filled(rect, R_M, if on { p.active } else { p.hover });
}
let dot = rect.left_center() + vec2(14.0, 0.0);
// Only the ready ones get a mark (a green dot); an empty ring before
// every other one read as a radio button to pick.
if ready {
ui.painter().circle_filled(dot, 4.0, p.up);
}
ui.painter().text(rect.left_center() + vec2(28.0, 0.0), egui::Align2::LEFT_CENTER, k.label(), egui::FontId::proportional(FONT_BASE), if on { p.text } else { p.text2 });
// Where it runs, at a glance: the ones that keep the chats home in green.
let runs = providers::runs_at(k, &providers::resolve_base(k, &ps.base_url));
let tag = if matches!(runs, providers::RunsAt::Cloud(_)) { p.text3 } else { p.up };
ui.painter().text(rect.right_center() - vec2(10.0, 0.0), egui::Align2::RIGHT_CENTER, t(runs.short()), egui::FontId::proportional(FONT_XS), tag);
let tip = t(if ready { "已可使用" } else if k == ProviderKind::ChatGpt { "還沒用 ChatGPT 登入" } else { "還沒設定金鑰" });
if r.on_hover_text(format!("{tip}\n{}", runs.words(self.brain_for_words().as_deref()))).clicked() {
self.settings_provider = k;
}
}
});
ui.add_space(16.0);
{
if back_link(ui, "模型", p) {
self.settings_provider_open = false;
}
ui.add_space(4.0);
ui.vertical(|ui| {
let k = self.settings_provider;
let w = ui.available_width();
ui.label(RichText::new(k.label()).strong().family(crate::bold()).size(FONT_H3));
ui.horizontal(|ui| {
let (m, _) = ui.allocate_exact_size(vec2(32.0, 32.0), egui::Sense::hover());
crate::icons::provider_mark(ui.painter(), m, k, R_M);
ui.label(RichText::new(k.label()).strong().family(crate::bold()).size(FONT_H3));
});
{
let runs = providers::runs_at(k, &providers::resolve_base(k, &self.state.provider(k).base_url));
runs_line(ui, &runs, self.brain_for_words().as_deref(), p);
@ -6858,7 +6861,7 @@ impl App {
hint(ui, format!("已記住 {count} 個模型"), p);
}
});
});
}
}
}
});

View File

@ -194,21 +194,6 @@ pub(super) fn settings_side_line(ui: &mut egui::Ui, tag: &str, words: &str, p: P
ui.add_space(6.0);
}
/// A figure on its own card (個人資料): what it is, the number, a line under it — `w` wide.
pub(super) fn stat_card(ui: &mut egui::Ui, p: Palette, w: f32, label: &str, value: &str, sub: &str) {
Frame::new().fill(p.elevated).stroke(Stroke::new(1.0, p.border)).corner_radius(R_L).inner_margin(egui::Margin::symmetric(14, 12)).show(ui, |ui| {
// (The 14 px margins and the 1 px border on each side.)
ui.set_width(w - 30.0);
// (Stacked: a row of cards lays things side by side.)
ui.vertical(|ui| {
ui.spacing_mut().item_spacing.y = 4.0;
ui.label(RichText::new(label).size(FONT_SM).color(p.text2));
ui.label(RichText::new(value).size(FONT_H1).strong().family(crate::bold()).color(p.text));
ui.add(egui::Label::new(RichText::new(sub).size(FONT_XS).color(p.text3)).truncate());
});
});
}
/// A rounded group of related settings, like a macOS settings card.
pub(super) fn setting_card<R>(ui: &mut egui::Ui, p: Palette, body: impl FnOnce(&mut egui::Ui) -> R) -> R {
let r = Frame::new()

View File

@ -14,6 +14,16 @@ pub(super) struct MeUi {
error: Option<String>,
/// 用量's period: 7, 30, 90 or 365 days.
span: u16,
/// 用量 split by bot instead of by model.
by_bot: bool,
}
impl MeUi {
/// Sample figures for screenshots (ANYBOT_SHOT_TAB=me on the demo).
pub(super) fn demo_fill(&mut self) {
self.data = Some(demo_figures());
self.at = Some(Instant::now());
}
}
/// How long the figures stand before the page reads them again.
@ -101,7 +111,7 @@ impl App {
}
return;
};
self.me_cards(ui, &d);
self.me_figures(ui, &d);
ui.add_space(18.0);
self.me_heat(ui, &d);
ui.add_space(18.0);
@ -111,31 +121,33 @@ impl App {
}
}
/// The five figures.
fn me_cards(&mut self, ui: &mut egui::Ui, d: &serde_json::Value) {
/// The year in four figures, in one quiet strip — big numbers, a small word under each, no
/// boxes (they were five bordered cards in two or three columns: a wall of text). What each
/// one means in full is in its hover.
fn me_figures(&mut self, ui: &mut egui::Ui, d: &serde_json::Value) {
let p = self.pal;
let g = |k: &str| d[k].as_u64().unwrap_or(0);
let date = |k: &str| d[k].as_str().map(long_date).unwrap_or_default();
let busiest = &d["busiest"];
let cards: Vec<(String, String, String)> = vec![
("Token".into(), crate::stats::wan(g("tokens_year")), t("過去一年(不算快取命中)")),
(t("最活躍的一天"), if busiest.is_object() { crate::stats::wan(busiest["tokens"].as_u64().unwrap_or(0)) } else { "—".into() }, busiest["date"].as_str().map(long_date).unwrap_or_else(|| t("還沒有用量紀錄"))),
(t("訊息"), crate::stats::wan(g("messages_year")), t("過去一年")),
(t("目前連續天數"), format!("{} 天", g("streak_now")), d["streak_now_since"].as_str().map(|s| format!("自 {} 起", short_date(s))).unwrap_or_else(|| t("今天開始就算一天"))),
(t("最長連續天數"), format!("{} 天", g("streak_best")), if g("streak_best") > 0 { format!("{} – {}", date("streak_best_from"), date("streak_best_to")) } else { String::new() }),
let figures: Vec<(String, String, String)> = vec![
(crate::stats::wan(g("tokens_year")), t("Token・一年"), t("過去一年用掉的 token(不算快取命中)")),
(crate::stats::wan(g("messages_year")), t("訊息・一年"), t("過去一年的訊息")),
(format!("{} 天", g("streak_now")), t("連續使用"), d["streak_now_since"].as_str().map(|s| format!("自 {} 起", short_date(s))).unwrap_or_else(|| t("今天開始就算一天"))),
(format!("{} 天", g("streak_best")), t("最長連續"), if g("streak_best") > 0 { format!("{} – {}", date("streak_best_from"), date("streak_best_to")) } else { String::new() }),
];
let gap = 10.0;
let width = ui.available_width();
let cols = if width >= 640.0 { 3 } else { 2 };
let w = ((width - gap * (cols as f32 - 1.0)) / cols as f32).floor();
for row in cards.chunks(cols) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = gap;
for (label, value, sub) in row {
stat_card(ui, p, w, label, value, sub);
}
});
ui.add_space(gap);
let cols = if width >= 420.0 { 4 } else { 2 };
let rows = figures.len().div_ceil(cols);
let cell = vec2(width / cols as f32, 64.0);
let (rect, _) = ui.allocate_exact_size(vec2(width, cell.y * rows as f32 + 16.0), egui::Sense::hover());
ui.painter().rect_filled(rect, R_L, p.muted);
for (i, (value, label, more)) in figures.iter().enumerate() {
let at = rect.min + vec2(8.0 + (i % cols) as f32 * ((width - 16.0) / cols as f32), 8.0 + (i / cols) as f32 * cell.y);
let r = egui::Rect::from_min_size(at, vec2((width - 16.0) / cols as f32, cell.y));
ui.painter().text(r.center_top() + vec2(0.0, 10.0), egui::Align2::CENTER_TOP, value, egui::FontId::new(FONT_H2, crate::bold()), p.text);
ui.painter().text(r.center_top() + vec2(0.0, 40.0), egui::Align2::CENTER_TOP, label, egui::FontId::proportional(FONT_XS), p.text3);
if !more.is_empty() {
ui.interact(r, egui::Id::unique(("me-fig", i)), egui::Sense::hover()).on_hover_text(more);
}
}
}
@ -188,10 +200,20 @@ impl App {
ui.painter().circle_filled(r.center(), 5.0, shade(lvl));
}
ui.label(RichText::new(t("多")).size(FONT_XS).color(p.text3));
// The busiest day, in words beside the legend (it was a card of its own).
let busiest = &d["busiest"];
if busiest.is_object() {
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
let words = format!("{}{}・{} token", t("最活躍:"), short_date(busiest["date"].as_str().unwrap_or("")), crate::stats::wan(busiest["tokens"].as_u64().unwrap_or(0)));
ui.label(RichText::new(words).size(FONT_XS).color(p.text3));
});
}
});
}
/// 用量: a period's tokens and cost, a bar a day, and the models and bots that used them.
/// 用量: the period's tokens as one big number, a bar a day, then what used them — by model
/// (one bar split in colours, each model with its service's mark) or by bot (each with its
/// face). The fine print (new / written / cached, how cost is known) is in the hovers.
fn me_usage(&mut self, ui: &mut egui::Ui, d: &serde_json::Value) {
let p = self.pal;
section_with(ui, "用量", p, |ui| {
@ -201,33 +223,42 @@ impl App {
});
let u = &d["periods"][self.me.span.to_string()];
let g = |k: &str| u[k].as_u64().unwrap_or(0);
let words = format!(
"{} token(新讀 {}、寫 {}、快取讀到 {})· {} 次呼叫 · 花費 {}",
crate::stats::wan(g("tokens")),
// The big number.
let hero = ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 6.0;
ui.label(RichText::new(crate::stats::wan(g("tokens"))).size(FONT_H1).strong().family(crate::bold()).color(p.text));
ui.label(RichText::new("token").size(FONT_SM).color(p.text3));
});
hero.response.on_hover_text(format!(
"新讀 {}、寫 {}、快取讀到 {}",
crate::stats::wan(g("input") + g("cache_write")),
crate::stats::wan(g("output")),
crate::stats::wan(g("cache_read")),
crate::stats::wan(g("calls")),
crate::stats::cost_words(g("cost_micros"), g("unpriced"), g("calls"))
);
ui.add(egui::Label::new(RichText::new(words).size(FONT_SM).color(p.text2)).wrap());
hint(ui, "花費是模型服務自己回報的(例如 OpenRouter);沒回報的寫「未定價」,不是 0 元。", p);
ui.add_space(8.0);
crate::stats::wan(g("cache_read"))
));
let cost = crate::stats::cost_words(g("cost_micros"), g("unpriced"), g("calls"));
ui.label(RichText::new(format!("{} 次呼叫・花費 {cost}", crate::stats::wan(g("calls")))).size(FONT_SM).color(p.text3))
.on_hover_text(t("花費是模型服務自己回報的(例如 OpenRouter);沒回報的寫「未定價」,不是 0 元。"));
ui.add_space(10.0);
// A bar a day.
let daily = u["daily"].as_array().cloned().unwrap_or_default();
if !daily.is_empty() {
let max = daily.iter().filter_map(|x| x[1].as_u64()).max().unwrap_or(0).max(1);
let w = ui.available_width();
let (rect, resp) = ui.allocate_exact_size(vec2(w, 90.0), egui::Sense::hover());
let (rect, resp) = ui.allocate_exact_size(vec2(w, 84.0), egui::Sense::hover());
let paint = ui.painter_at(rect);
paint.hline(rect.x_range(), rect.bottom() - 0.5, Stroke::new(1.0, p.grid));
let slot = w / daily.len() as f32;
let mut hovered: Option<&serde_json::Value> = None;
for (i, x) in daily.iter().enumerate() {
let v = x[1].as_u64().unwrap_or(0);
let h = (v as f32 / max as f32 * (rect.height() - 4.0)).max(if v > 0 { 2.0 } else { 1.0 });
let r = egui::Rect::from_min_max(egui::pos2(rect.left() + i as f32 * slot + slot * 0.15, rect.bottom() - h), egui::pos2(rect.left() + (i as f32 + 1.0) * slot - slot * 0.15, rect.bottom()));
paint.rect_filled(r, 2.0, if v > 0 { p.accent } else { p.hover });
if resp.hover_pos().is_some_and(|q| q.x >= rect.left() + i as f32 * slot && q.x < rect.left() + (i as f32 + 1.0) * slot) {
if v == 0 {
continue;
}
let h = (v as f32 / max as f32 * (rect.height() - 4.0)).max(3.0);
let r = egui::Rect::from_min_max(egui::pos2(rect.left() + i as f32 * slot + slot * 0.18, rect.bottom() - h), egui::pos2(rect.left() + (i as f32 + 1.0) * slot - slot * 0.18, rect.bottom()));
let on = resp.hover_pos().is_some_and(|q| q.x >= rect.left() + i as f32 * slot && q.x < rect.left() + (i as f32 + 1.0) * slot);
paint.rect_filled(r, CornerRadius { nw: R_S / 2, ne: R_S / 2, ..Default::default() }, if on { p.text } else { p.accent });
if on {
hovered = Some(x);
}
}
@ -235,38 +266,119 @@ impl App {
resp.on_hover_text(format!("{}:{} token", long_date(x[0].as_str().unwrap_or("")), crate::stats::wan(x[1].as_u64().unwrap_or(0))));
}
}
ui.add_space(10.0);
for (title, key) in [("依模型", "by_model"), ("依 Bot", "by_bot")] {
let rows = u[key].as_array().cloned().unwrap_or_default();
ui.label(RichText::new(t(title)).size(FONT_SM).strong().color(p.text));
if rows.is_empty() {
hint(ui, "這段時間沒有用量紀錄", p);
ui.add_space(16.0);
// What used them: one at a time (by model, or by bot).
if let Some(b) = segmented(ui, p, self.me.by_bot, &[(false, "依模型"), (true, "依 Bot")]) {
self.me.by_bot = b;
}
ui.add_space(8.0);
let rows = u[if self.me.by_bot { "by_bot" } else { "by_model" }].as_array().cloned().unwrap_or_default();
if rows.is_empty() {
hint(ui, "這段時間沒有用量紀錄", p);
return;
}
let total: u64 = rows.iter().filter_map(|r| r["tokens"].as_u64()).sum::<u64>().max(1);
let rows: Vec<&serde_json::Value> = rows.iter().take(8).collect();
let colour = |i: usize| p.chart_cat[i % p.chart_cat.len()];
// By model: the whole in one bar, a colour each.
if !self.me.by_bot {
let w = ui.available_width();
let (bar, _) = ui.allocate_exact_size(vec2(w, 10.0), egui::Sense::hover());
ui.painter().rect_filled(bar, R_FULL, p.hover);
let mut x = bar.left();
for (i, r) in rows.iter().enumerate() {
let part = r["tokens"].as_u64().unwrap_or(0) as f32 / total as f32 * w;
let seg = egui::Rect::from_min_max(egui::pos2(x, bar.top()), egui::pos2((x + part).min(bar.right()), bar.bottom()));
let round = CornerRadius { nw: if i == 0 { R_FULL } else { 0 }, sw: if i == 0 { R_FULL } else { 0 }, ne: if i + 1 == rows.len() { R_FULL } else { 0 }, se: if i + 1 == rows.len() { R_FULL } else { 0 } };
ui.painter().rect_filled(seg, round, colour(i));
x += part;
}
let top = rows.first().and_then(|r| r["tokens"].as_u64()).unwrap_or(0).max(1);
rows_card(ui, p, |ui| {
for r in rows.iter().take(8) {
let tokens = r["tokens"].as_u64().unwrap_or(0);
ui.horizontal(|ui| {
let w = ui.available_width();
let right = format!("{} · {}", crate::stats::wan(tokens), crate::stats::cost_words(r["cost_micros"].as_u64().unwrap_or(0), 0, 0));
ui.allocate_ui_with_layout(vec2((w * 0.55).max(80.0), 24.0), Layout::left_to_right(Align::Center), |ui| {
ui.set_width((w * 0.55).max(80.0));
ui.add(egui::Label::new(RichText::new(r["name"].as_str().unwrap_or("")).size(FONT_SM).color(p.text)).truncate());
});
let (bar, _) = ui.allocate_exact_size(vec2((w * 0.18).max(30.0), 8.0), egui::Sense::hover());
ui.painter().rect_filled(bar, 3.0, p.hover);
ui.painter().rect_filled(egui::Rect::from_min_size(bar.min, vec2(bar.width() * tokens as f32 / top as f32, bar.height())), 3.0, p.accent);
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.label(RichText::new(right).size(FONT_XS).color(p.text3));
});
});
ui.add_space(10.0);
}
let top = rows.first().and_then(|r| r["tokens"].as_u64()).unwrap_or(0).max(1);
for (i, r) in rows.iter().enumerate() {
let name = r["name"].as_str().unwrap_or("");
let tokens = r["tokens"].as_u64().unwrap_or(0);
let share = (tokens as f32 / total as f32 * 100.0).round();
let (row, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 32.0), egui::Sense::hover());
let paint = ui.painter();
let mark = egui::Rect::from_center_size(egui::pos2(row.left() + 11.0, row.center().y), vec2(22.0, 22.0));
if self.me.by_bot {
match self.state.bots.iter().find(|b| b.name == name) {
Some(b) => crate::avatar::paint(paint, mark, &b.shape, self.bot_color(b)),
None => {
paint.circle_filled(mark.center(), 9.0, p.active);
}
}
});
ui.add_space(8.0);
} else {
let service = name.split(" · ").next().unwrap_or("");
match ALL_PROVIDERS.iter().find(|k| k.label() == service) {
Some(k) => crate::icons::provider_mark(paint, mark, *k, R_S),
None => {
paint.rect_filled(mark, R_S, p.active);
}
}
}
// (By model the name's colour dot ties it to the bar; by bot, a thin bar of its own.)
let right = format!("{}・{share:.0}%", crate::stats::wan(tokens));
let right_w = ui.fonts_mut(|f| f.layout_no_wrap(right.clone(), egui::FontId::proportional(FONT_SM), p.text2).size().x);
let left = mark.right() + 10.0;
let bar_w = if self.me.by_bot { (row.width() * 0.22).clamp(40.0, 140.0) } else { 0.0 };
let room = row.right() - right_w - bar_w - 16.0 - left - if self.me.by_bot { 0.0 } else { 14.0 };
let mut x = left;
if !self.me.by_bot {
paint.circle_filled(egui::pos2(x + 4.0, row.center().y), 4.0, colour(i));
x += 14.0;
}
let shown = sidebar_ui::shorten_width(ui, name, room.max(40.0), FONT_SM);
paint.text(egui::pos2(x, row.center().y), egui::Align2::LEFT_CENTER, shown, egui::FontId::proportional(FONT_SM), p.text);
if self.me.by_bot {
let b = egui::Rect::from_min_size(egui::pos2(row.right() - right_w - 12.0 - bar_w, row.center().y - 3.0), vec2(bar_w, 6.0));
paint.rect_filled(b, R_FULL, p.hover);
paint.rect_filled(egui::Rect::from_min_size(b.min, vec2(b.width() * tokens as f32 / top as f32, b.height())), R_FULL, p.accent);
}
paint.text(row.right_center(), egui::Align2::RIGHT_CENTER, right, egui::FontId::proportional(FONT_SM), p.text2);
resp.on_hover_text(format!("{name}\n{} token・{}", crate::stats::wan(tokens), crate::stats::cost_words(r["cost_micros"].as_u64().unwrap_or(0), 0, 0)));
}
}
}
/// Sample figures for screenshots: a year that ramps up, a few models and bots.
fn demo_figures() -> serde_json::Value {
let today = chrono::Local::now().date_naive();
let day = |back: i64| (today - chrono::Duration::days(back)).format("%Y-%m-%d").to_string();
let wave = |i: i64| -> u64 { let x = ((i * 7919) % 13) as u64; if i % 9 == 4 { 0 } else { 20_000 + x * 9_000 + (365 - i.min(365)) as u64 * 300 } };
let days: Vec<serde_json::Value> = (0..365).rev().map(|i| { let tk = if i > 300 { 0 } else { wave(i) }; serde_json::json!([day(i), tk, tk / 900, if tk == 0 { 0 } else { 1 + (tk / 40_000).min(3) }]) }).collect();
let period = |n: i64| {
let daily: Vec<serde_json::Value> = (0..n).rev().map(|i| serde_json::json!([day(i), wave(i)])).collect();
let tokens: u64 = (0..n).map(wave).sum();
let part = |f: f64| (tokens as f64 * f) as u64;
serde_json::json!({
"tokens": tokens, "input": part(0.55), "cache_write": part(0.05), "output": part(0.12), "cache_read": part(0.28),
"calls": tokens / 2_400, "cost_micros": tokens * 3, "unpriced": 0, "daily": daily,
"by_model": [
{"name": "xAI Grok · grok-4", "tokens": part(0.46), "cost_micros": part(0.46) * 3},
{"name": "Claude · claude-sonnet-5-5", "tokens": part(0.27), "cost_micros": part(0.27) * 4},
{"name": "OpenAI · gpt-5", "tokens": part(0.15), "cost_micros": part(0.15) * 3},
{"name": "Ollama · qwen3:8b", "tokens": part(0.12), "cost_micros": 0},
],
"by_bot": [
{"name": "Bot", "tokens": part(0.41), "cost_micros": part(0.41) * 3},
{"name": "研究助理", "tokens": part(0.33), "cost_micros": part(0.33) * 3},
{"name": "寫作夥伴", "tokens": part(0.16), "cost_micros": part(0.16) * 3},
{"name": "電腦助手", "tokens": part(0.10), "cost_micros": part(0.10) * 3},
],
})
};
serde_json::json!({
"tokens_year": days.iter().filter_map(|d| d[1].as_u64()).sum::<u64>(), "messages_year": 4_812,
"busiest": {"date": day(12), "tokens": 148_200}, "streak_now": 23, "streak_now_since": day(22),
"streak_best": 61, "streak_best_from": day(140), "streak_best_to": day(80), "active_days": 271,
"days": days, "weekday_first": 0,
"periods": {"7": period(7), "30": period(30), "90": period(90), "365": period(365)},
})
}
/// 2025-11-27 → 2025年11月27日.
fn long_date(s: &str) -> String {
let mut it = s.split('-');

53
src/app/models_ui.rs Normal file
View File

@ -0,0 +1,53 @@
// 設定 › 模型: every model service as a tile — its mark, its name, whether it is ready, where it
// runs — in one column with the page (it used to be a list beside the page, beside the settings
// list: three columns of words). A press opens the service's page (its key, address, model).
use super::*;
impl App {
/// The tiles; returns the one pressed.
pub(super) fn provider_grid(&mut self, ui: &mut egui::Ui) -> Option<ProviderKind> {
let p = self.pal;
let mut picked = None;
let gap = 10.0;
let width = ui.available_width();
let cols = if width >= 560.0 { 3 } else { 2 };
let w = ((width - gap * (cols as f32 - 1.0)) / cols as f32).floor();
for row in ALL_PROVIDERS.chunks(cols) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = gap;
for &k in row {
let ps = self.state.provider(k);
let ready = providers::ready(k, &ps.api_key);
let runs = providers::runs_at(k, &providers::resolve_base(k, &ps.base_url));
let (rect, r) = ui.allocate_exact_size(vec2(w, 76.0), egui::Sense::click());
let paint = ui.painter();
paint.rect(rect, R_L, if r.hovered() { p.hover } else { p.elevated }, Stroke::new(1.0, p.border), egui::StrokeKind::Inside);
let mark = egui::Rect::from_min_size(rect.min + vec2(14.0, 14.0), vec2(34.0, 34.0));
crate::icons::provider_mark(paint, mark, k, R_M);
let left = mark.right() + 12.0;
let room = rect.right() - 12.0 - left;
let name = sidebar_ui::shorten_width(ui, k.label(), room, FONT_BASE);
paint.text(egui::pos2(left, mark.top() + 1.0), egui::Align2::LEFT_TOP, name, egui::FontId::new(FONT_BASE, crate::bold()), p.text);
// Ready: a green dot and 可以用; else what is missing, quietly.
let y = mark.top() + 24.0;
let (words, col) = if ready { (t("可以用"), p.text2) } else if k == ProviderKind::ChatGpt { (t("還沒登入"), p.text3) } else { (t("還沒設定"), p.text3) };
let mut x = left;
if ready {
paint.circle_filled(egui::pos2(x + 4.0, y + 8.0), 4.0, p.up);
x += 13.0;
}
paint.text(egui::pos2(x, y), egui::Align2::LEFT_TOP, &words, egui::FontId::proportional(FONT_SM), col);
// Where it runs: the ones that keep the chats at home in green.
let tag = if matches!(runs, providers::RunsAt::Cloud(_)) { p.text3 } else { p.up };
paint.text(rect.right_bottom() - vec2(12.0, 10.0), egui::Align2::RIGHT_BOTTOM, t(runs.short()), egui::FontId::proportional(FONT_XS), tag);
if r.on_hover_text(runs.words(self.brain_for_words().as_deref())).on_hover_cursor(egui::CursorIcon::PointingHand).clicked() {
picked = Some(k);
}
}
});
ui.add_space(gap);
}
picked
}
}

View File

@ -260,6 +260,7 @@ impl App {
Target::Provider(k) => {
self.settings_tab = SettingsTab::Providers;
self.settings_provider = *k;
self.settings_provider_open = true;
}
}
}

View File

@ -165,8 +165,8 @@ impl App {
};
hint(ui, head, p);
ui.add_space(10.0);
for task in &list {
if self.task_card(ui, task, now) {
for (i, task) in list.iter().enumerate() {
if self.task_card(ui, task, i, now) {
open_at = Some((task.bot, task.at));
}
}
@ -195,7 +195,7 @@ impl App {
}
/// One task's card; true when clicked.
fn task_card(&mut self, ui: &mut egui::Ui, task: &Task, now: i64) -> bool {
fn task_card(&mut self, ui: &mut egui::Ui, task: &Task, i: usize, now: i64) -> bool {
let p = self.pal;
let name = self.state.bot(task.bot).map(|b| b.name.clone()).unwrap_or_else(|| t("已刪除的 Bot"));
// (The kit's card: its content's rect, out to the card's edge, is what a click lands on.)
@ -249,7 +249,9 @@ impl App {
}
ui.min_rect().expand2(vec2(16.0, 14.0))
});
let r = ui.interact(card, egui::Id::unique(format!("task-card-{}", task.id)), egui::Sense::click());
// (Its place in the list too: two openings written in the same millisecond share a task
// id, and two cards on one id fought over one press.)
let r = ui.interact(card, egui::Id::unique(("task-card", &task.id, i)), egui::Sense::click());
if r.hovered() {
ui.painter().rect_stroke(card, R_L, Stroke::new(1.0, p.text3), egui::StrokeKind::Inside);
}

View File

@ -84,6 +84,7 @@ impl App {
self.show_settings = true;
self.settings_tab = SettingsTab::Providers;
self.settings_provider = ProviderKind::Xai;
self.settings_provider_open = true;
}
if go_new {
self.new_bot();

View File

@ -342,6 +342,91 @@ pub fn button(ui: &mut egui::Ui, icon: Icon, size: f32, col: Color32, hover_fill
r.on_hover_cursor(egui::CursorIcon::PointingHand)
}
/// 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::*;

View File

@ -131,6 +131,12 @@ fn pingfang_path() -> Option<PathBuf> {
/// PingFang TC Regular inside PingFang.ttc.
const PINGFANG_TC_INDEX: u32 = 2;
/// PingFang TC Semibold inside PingFang.ttc: the bold Apple sets titles in (lighter than Bold).
const PINGFANG_TC_SEMIBOLD_INDEX: u32 = 10;
/// SF Pro, macOS's own Latin face (one variable font: the weight is an axis).
const SF_PRO: &str = "/System/Library/Fonts/SFNS.ttf";
/// The window's first size (screenshot mode can ask for another, e.g. ANYBOT_SHOT_SIZE=760x560).
fn shot_size() -> [f32; 2] {
std::env::var("ANYBOT_SHOT_SIZE").ok().and_then(|v| {
@ -139,45 +145,73 @@ fn shot_size() -> [f32; 2] {
}).unwrap_or([1180.0, 780.0])
}
/// 思源黑體 (Noto Sans TC Regular, SIL OFL 1.1, fonts/OFL.txt): the interface's one font —
/// plain, clear, the same on every computer.
/// 思源黑體 (Noto Sans TC Regular, SIL OFL 1.1, fonts/OFL.txt): the interface's font where the
/// computer has no Apple fonts (Windows, Linux), and what fills in a character the system's lack.
pub const NOTO_TC: &[u8] = include_bytes!("../fonts/NotoSansTC-Regular.otf");
/// 思源黑體's bold weight, for titles, bold words and the main button of a choice.
pub const NOTO_TC_BOLD: &[u8] = include_bytes!("../fonts/NotoSansTC-Bold.otf");
/// 思源宋體 (Noto Serif TC Regular, SIL OFL 1.1): what is read at length — a bot's answer, a
/// page's text — is set in a book face, the way Claude sets its answers.
pub const NOTO_SERIF_TC: &[u8] = include_bytes!("../fonts/NotoSerifTC-Regular.otf");
/// 思源宋體's bold weight: headings and bold words in reading text.
pub const NOTO_SERIF_TC_BOLD: &[u8] = include_bytes!("../fonts/NotoSerifTC-Bold.otf");
/// The family bold interface text is set in (`RichText::family(bold())`, `FontId::new(size, bold())`).
pub fn bold() -> egui::FontFamily {
egui::FontFamily::Name("bold".into())
}
/// The reading family (思源宋體): answers and pages.
/// The reading family: answers and pages. The same face as the interface (Apple's way: one
/// calm sans everywhere; answers used to be in 思源宋體, which read formal and heavy).
pub fn read() -> egui::FontFamily {
egui::FontFamily::Name("read".into())
}
/// The reading family's bold (思源宋體 Bold): headings and bold words in answers and pages.
/// The reading family's bold: headings and bold words in answers and pages.
pub fn read_bold() -> egui::FontFamily {
egui::FontFamily::Name("read-bold".into())
}
/// The fonts, one set for every computer: 思源黑體 for the interface, 思源宋體 for reading, the
/// system's mono for code. The system's CJK font only fills in what the bundled ones lack
/// (symbols, a rare character); egui's own fonts stay last for emoji.
/// The fonts. On a Mac, Apple's own: SF Pro for Latin and 蘋方 (PingFang TC) for Chinese, the
/// pair macOS itself sets text in — Regular, and Semibold for bold (Apple's titles are
/// Semibold, not Bold: lighter, more relaxed). Elsewhere 思源黑體, bundled, so every computer
/// gets a good Chinese face; it also fills in what the Apple fonts lack. The system's mono for
/// code; egui's own fonts stay last for emoji.
pub fn load_fonts(ctx: &egui::Context) {
use std::sync::Arc;
let mut fonts = egui::FontDefinitions::default();
// One font for Chinese *and* English: mixing egui's built-in Latin font with a Chinese
// fallback put the two on different baselines and sizes ("Bot 設定" looked broken).
let mut candidates: Vec<(PathBuf, u32)> = pingfang_path().map(|p| vec![(p, PINGFANG_TC_INDEX)]).unwrap_or_default();
candidates.extend(
[
// Code: the original's `--cursor-font-family-mono` list is ui-monospace, SFMono-Regular, Menlo…
for path in ["/System/Library/Fonts/SFNSMono.ttf", "/System/Library/Fonts/Menlo.ttc"] {
if let Ok(bytes) = std::fs::read(path) {
fonts.font_data.insert("mono".into(), egui::FontData::from_owned(bytes).into());
fonts.families.entry(egui::FontFamily::Monospace).or_default().insert(0, "mono".into());
break;
}
}
// Apple's pair, when this Mac has 蘋方 (a downloadable system asset; nearly always there).
// (SF Pro first: it has the Latin letters and digits, 蘋方 everything Chinese. One file each,
// shared between the weights.)
let mut regular: Vec<String> = vec![];
let mut semibold: Vec<String> = vec![];
// (Read once per run and shared: 蘋方 is 78 MB, and a window or a check may set fonts again.)
static APPLE: std::sync::OnceLock<(Option<egui::epaint::text::Blob>, Option<egui::epaint::text::Blob>)> = std::sync::OnceLock::new();
let (pf, sf) = APPLE.get_or_init(|| {
let blob = |b: Vec<u8>| -> egui::epaint::text::Blob { Arc::new(b) };
(pingfang_path().and_then(|p| std::fs::read(p).ok()).map(blob), std::fs::read(SF_PRO).ok().map(blob))
});
if let Some(pf) = pf.clone() {
if let Some(sf) = sf.clone() {
for (name, wght) in [("sf", 400.0), ("sf-bold", 600.0)] {
let mut d = egui::FontData::from_blob(sf.clone(), 0);
d.tweak.coords = egui::epaint::text::VariationCoords::new([(b"wght", wght)]);
fonts.font_data.insert(name.into(), d.into());
}
regular.push("sf".into());
semibold.push("sf-bold".into());
}
fonts.font_data.insert("pf".into(), egui::FontData::from_blob(pf.clone(), PINGFANG_TC_INDEX).into());
fonts.font_data.insert("pf-bold".into(), egui::FontData::from_blob(pf, PINGFANG_TC_SEMIBOLD_INDEX).into());
regular.push("pf".into());
semibold.push("pf-bold".into());
} else {
// No 蘋方: the system's CJK font only fills in what 思源黑體 lacks (a symbol, a rare character).
let candidates = [
("/System/Library/Fonts/Hiragino Sans GB.ttc", 0),
("/System/Library/Fonts/STHeiti Medium.ttc", 0),
("/System/Library/Fonts/Supplemental/Arial Unicode.ttf", 0),
@ -188,46 +222,43 @@ pub fn load_fonts(ctx: &egui::Context) {
("/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc", 3),
("/usr/share/fonts/google-noto-cjk/NotoSansCJK-Regular.ttc", 3),
("/usr/share/fonts/truetype/wqy/wqy-microhei.ttc", 0),
]
.into_iter()
.map(|(p, i)| (PathBuf::from(p), i)),
);
// Code: the original's `--cursor-font-family-mono` list is ui-monospace, SFMono-Regular, Menlo…
for path in ["/System/Library/Fonts/SFNSMono.ttf", "/System/Library/Fonts/Menlo.ttc"] {
if let Ok(bytes) = std::fs::read(path) {
fonts.font_data.insert("mono".into(), egui::FontData::from_owned(bytes).into());
fonts.families.entry(egui::FontFamily::Monospace).or_default().insert(0, "mono".into());
break;
];
for (path, index) in candidates {
if let Ok(bytes) = std::fs::read(path) {
let mut data = egui::FontData::from_owned(bytes);
data.index = index;
fonts.font_data.insert("cjk".into(), data.into());
break;
}
}
}
for (path, index) in candidates {
if let Ok(bytes) = std::fs::read(&path) {
let mut data = egui::FontData::from_owned(bytes);
data.index = index;
fonts.font_data.insert("cjk".into(), data.into());
fonts.families.entry(egui::FontFamily::Proportional).or_default().insert(0, "cjk".into());
// Code stays in the monospace font; Chinese inside code falls back to the same font.
fonts.families.entry(egui::FontFamily::Monospace).or_default().push("cjk".into());
break;
}
}
for (name, bytes) in [("noto", NOTO_TC), ("noto-bold", NOTO_TC_BOLD), ("serif", NOTO_SERIF_TC), ("serif-bold", NOTO_SERIF_TC_BOLD)] {
for (name, bytes) in [("noto", NOTO_TC), ("noto-bold", NOTO_TC_BOLD)] {
fonts.font_data.insert(name.into(), egui::FontData::from_static(bytes).into());
}
// 思源黑體 first everywhere it has the letter (code: after the mono font, before the system's).
regular.push("noto".into());
semibold.push("noto-bold".into());
if fonts.font_data.contains_key("cjk") {
regular.push("cjk".into());
}
// The interface: the faces in front of egui's own (emoji last).
let base = {
let p = fonts.families.entry(egui::FontFamily::Proportional).or_default();
p.insert(0, "noto".into());
for (i, f) in regular.iter().enumerate() {
p.insert(i, f.clone());
}
p.clone()
};
// Code: after the mono font, the same faces for Chinese inside code.
let mono = fonts.families.entry(egui::FontFamily::Monospace).or_default();
let at = mono.iter().position(|f| f == "cjk").unwrap_or(mono.len());
mono.insert(at, "noto".into());
// Each other family: its face in front of the same list (what it lacks comes from 思源黑體).
let with = |first: &[&str]| first.iter().map(|f| f.to_string()).chain(base.iter().cloned()).collect::<Vec<_>>();
fonts.families.insert(bold(), with(&["noto-bold"]));
fonts.families.insert(read(), with(&["serif"]));
fonts.families.insert(read_bold(), with(&["serif-bold", "noto-bold"]));
for f in &regular {
if f != "sf" {
mono.push(f.clone());
}
}
let bold_list: Vec<String> = semibold.iter().cloned().chain(base.iter().cloned()).collect();
fonts.families.insert(bold(), bold_list.clone());
fonts.families.insert(read(), base);
fonts.families.insert(read_bold(), bold_list);
ctx.set_fonts(fonts);
}

View File

@ -207,8 +207,13 @@ pub fn wan(n: u64) -> String {
let s = n.to_string();
if n >= 1_000 { format!("{},{}", &s[..s.len() - 3], &s[s.len() - 3..]) } else { s }
}
10_000..=99_999_999 => format!("{:.1}萬", n as f64 / 10_000.0),
_ => format!("{:.2}億", n as f64 / 100_000_000.0),
// (No「.0」, and no decimal at all past a thousand 萬: 3,699萬, not 3699.0萬.)
10_000..=9_999_999 => format!("{:.1}萬", n as f64 / 10_000.0).replace(".0萬", "萬"),
10_000_000..=99_999_999 => {
let s = ((n as f64 / 10_000.0).round() as u64).to_string();
format!("{},{}萬", &s[..s.len() - 3], &s[s.len() - 3..])
}
_ => format!("{:.2}億", n as f64 / 100_000_000.0).replace(".00億", "億"),
}
}
@ -287,7 +292,8 @@ mod tests {
#[test]
fn counts_and_costs_are_said_plainly() {
assert_eq!((wan(999), wan(9_999), wan(59_934_000), wan(294_000), wan(120_000_000)), ("999".into(), "9,999".into(), "5993.4萬".into(), "29.4萬".into(), "1.20億".into()));
assert_eq!((wan(999), wan(9_999), wan(59_934_000), wan(294_000), wan(120_000_000)), ("999".into(), "9,999".into(), "5,993萬".into(), "29.4萬".into(), "1.20億".into()));
assert_eq!((wan(20_000), wan(100_000_000)), ("2萬".into(), "1億".into()));
assert_eq!(cost_words(0, 5, 5), "未定價");
assert_eq!(cost_words(1_230_000, 0, 4), "US$1.23");
assert_eq!(cost_words(1_230_000, 2, 4), "US$1.23(另有 2 次呼叫未定價)");