design: 手機網頁顏色跟著電腦版、改成 Claude 手機 App 的感覺,實點修好 12 個問題

- 顏色:api/state 帶出電腦的主題和淺色/深色兩組顏色(theme::shell 換成手機的 CSS 變數);手機「這支手機的外觀」預設「跟著電腦」,也可選跟著手機、淺色、深色;先驗證是 hex 才套用,存一份避免打開時閃預設色;狀態列跟著畫面。舊版電腦沒送顏色時維持「紙」。電腦畫面頁改成暖色深色。
- 感覺:標題列沒有底線、第二行只寫在做什麼或模型;輸入框是底部圓角卡片;回答下只留時間和三個操作;群組、晶片、建議、記憶卡拿掉框線;開關的「開」用墨色;允許卡細框;點擊範圍加大(44/40/36px)。
- 字更少:設定首頁拿掉重複說明;每列說明一行;「模型」頁右邊只寫可以用/未設定;Bot 那列選單少用的收進「更多…」。
- 修好:長 Bot 名字超出 @// 選單;引用顯示原始 Markdown 且沒有長度上限;第 8 個表情換行;.note 在清單裡變灰條;圖片點了跳出 App;上傳吐司蓋住輸入框;「聊天的顏色」永遠沒有 ✓(電腦送 "Quiet",改送 quiet/black/bot_color);「:」後的網址不成連結;深色模式黑頭像看不見;稽核分頁出現 ** 和多行 JSON;頁面卡標題重複;記憶搜尋框 14px 讓 iPhone 放大。
- 問題卡的「略過」、交辦的「跳過」、允許卡的「拒絕」不再是紅字,跟電腦版一樣是一般按鈕。

已驗證:cargo test --bin anybot 523 通過(含 phone_login_and_api 檢查主題和兩組顏色)、relay 22 通過;手機圖表 65/65、通知 9/9、電腦畫面 13/13;playwright 390×844 淺色深色點過登入、首頁、聊天、詳細資訊、Bot 設定、頁面、例行任務、電腦、設定每一頁,沒有 console 錯誤、失敗請求或橫向溢出;電腦換靛藍深色,手機跟著變。
未驗證:真的 iPhone/Android 實機。
This commit is contained in:
王性驊 2026-11-16 23:16:38 +08:00
parent 7c34e5baa0
commit 9de00e244e
6 changed files with 208 additions and 87 deletions

View File

@ -574,7 +574,7 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。
- **「主題」**:「為 AnyBot 選擇淺色或深色外觀」。 - **「主題」**:「為 AnyBot 選擇淺色或深色外觀」。
- 選項:「淺色」「深色」「跟隨系統」。選跟隨系統時,會即時跟著系統切換。 - 選項:「淺色」「深色」「跟隨系統」。選跟隨系統時,會即時跟著系統切換。
- **「聊天的顏色」**:你的訊息泡泡的顏色。 - **「聊天的顏色」**:你的訊息泡泡的顏色。
- 選項:「安靜」(淡灰,預設)、「跟著 Bot」、「只用黑色」。以前預設是「跟著 Bot」:還留著舊預設的設定檔第一次打開時換成「安靜」一次,之後再選回「跟著 Bot」就照你選的。手機的「設定 › 電腦上的 AnyBot › 聊天的顏色」是同一個設定,手機上的泡泡也照它畫。 - 選項:「安靜」(淡灰,預設)、「跟著 Bot」、「只用黑色」。以前預設是「跟著 Bot」:還留著舊預設的設定檔第一次打開時換成「安靜」一次,之後再選回「跟著 Bot」就照你選的。手機的「設定 › 電腦上的 AnyBot › 聊天的顏色」是同一個設定(勾的是電腦上用的那個),手機上的泡泡也照它畫。
- **「通知」**:「Bot 完成任務或等你處理時通知你」。 - **「通知」**:「Bot 完成任務或等你處理時通知你」。
- 勾選框「你不在 AnyBot 前面時,跳出 macOS 通知」,預設開。 - 勾選框「你不在 AnyBot 前面時,跳出 macOS 通知」,預設開。
- 說明:「視窗不在最前面,或 90 秒沒有動鍵盤滑鼠,就會通知。第一次可能要在「系統設定 → 通知」允許「工序指令編寫程式」。」 - 說明:「視窗不在最前面,或 90 秒沒有動鍵盤滑鼠,就會通知。第一次可能要在「系統設定 → 通知」允許「工序指令編寫程式」。」
@ -1540,7 +1540,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
- **標題列**:Bot 的名字在左邊(按一下開對話詳細資訊),右邊「分享」和「⋯」不再有圓框;圖示線條粗一點(2.25)。 - **標題列**:Bot 的名字在左邊(按一下開對話詳細資訊),右邊「分享」和「⋯」不再有圓框;圖示線條粗一點(2.25)。
- **新對話**:Bot 的臉放大、依時段的問候(早安/午安/晚上好/夜深了;看的是 設定 › 一般 的時區,不是這台電腦的系統時區)、一句「嗨,我是 …」和它的描述,下面三個可以直接點的開頭(點了把字放進輸入框)。 - **新對話**:Bot 的臉放大、依時段的問候(早安/午安/晚上好/夜深了;看的是 設定 › 一般 的時區,不是這台電腦的系統時區)、一句「嗨,我是 …」和它的描述,下面三個可以直接點的開頭(點了把字放進輸入框)。
- **設定**:左邊分頁只有文字,選中的淡底粗字;每組設定一張白色細框卡片,一列一件事(左邊名稱、右邊控制項,名稱下最多一行小字,其餘說明在「?」裡);選項是分段按鈕,開關是黑軌白鈕。「一般」的名稱改成白話(聊天的顏色、用意思找記憶、Bot 可以翻的資料夾)。「整合」分成三頁(訊息管道、連接器、技能);訊息管道先列「已連接」(標記、名稱 · 種類、誰回覆、狀態、開關、⋯ 裡移除),「新增管道」是八個方塊,點了才在下面打開那一種的表單。權限頁的「直接操作」「自動審核」也是開關。 - **設定**:左邊分頁只有文字,選中的淡底粗字;每組設定一張白色細框卡片,一列一件事(左邊名稱、右邊控制項,名稱下最多一行小字,其餘說明在「?」裡);選項是分段按鈕,開關是黑軌白鈕。「一般」的名稱改成白話(聊天的顏色、用意思找記憶、Bot 可以翻的資料夾)。「整合」分成三頁(訊息管道、連接器、技能);訊息管道先列「已連接」(標記、名稱 · 種類、誰回覆、狀態、開關、⋯ 裡移除),「新增管道」是八個方塊,點了才在下面打開那一種的表單。權限頁的「直接操作」「自動審核」也是開關。
- **手機**:你的訊息泡泡照「聊天的顏色」(預設淡灰)、Bot 的回覆不用泡泡、允許卡片是黃色、輸入框是墨色框線;工作中在對話最後顯示 Bot 的小臉和跟電腦上一樣的那句「正在…」。 - **手機**:顏色跟電腦一樣(設定 › 一般 › 外觀 的主題、底色、強調色、對比都照著穿;手機的「外觀」預設「跟著電腦」,也可以選跟著手機、淺色、深色)。你的訊息泡泡照「聊天的顏色」(預設淡灰)、Bot 的回覆不用泡泡、允許卡片是黃色細框、輸入框是底部一張圓角卡片;工作中在對話最後顯示 Bot 的小臉和跟電腦上一樣的那句「正在…」。
- **自己進化**:一件事做了 5 步以上(操作電腦、網頁、指令,不算記憶和設定),回答完後在背景回頭看一次:這是在網站或程式上動手操作的事(填表、發文、回留言、上傳下載、改設定),就把這次真的成功的最短做法存成技能(用畫面上的名字,不寫編號和座標;繞路和失敗寫成「注意」;使用者說過的偏好寫進去);已經有同一件事的技能就合併成更好的一版,照著做而且很順就不動。回覆下面會多一行「(學會了新做法「…」)」或「(把做法「…」更新了)」。系統指示要 Bot 開始做事前先看技能清單、有符合的先 use_skill。實測(httpbin 訂 pizza,真的 Grok):第一次 11 步學到技能;第二次先讀技能、10 步 24 秒一次做完,回頭看後判斷不用改。 - **自己進化**:一件事做了 5 步以上(操作電腦、網頁、指令,不算記憶和設定),回答完後在背景回頭看一次:這是在網站或程式上動手操作的事(填表、發文、回留言、上傳下載、改設定),就把這次真的成功的最短做法存成技能(用畫面上的名字,不寫編號和座標;繞路和失敗寫成「注意」;使用者說過的偏好寫進去);已經有同一件事的技能就合併成更好的一版,照著做而且很順就不動。回覆下面會多一行「(學會了新做法「…」)」或「(把做法「…」更新了)」。系統指示要 Bot 開始做事前先看技能清單、有符合的先 use_skill。實測(httpbin 訂 pizza,真的 Grok):第一次 11 步學到技能;第二次先讀技能、10 步 24 秒一次做完,回頭看後判斷不用改。
- **重播學會的做法**(replay_skill):存技能時,模型會挑出這次真的成功、必要、會改變東西的步驟(不含截圖、讀取這類只是看的步驟、不含繞路和失敗),連同每一步點的是哪個東西(「勾選框「自動更新」」,不是編號)一起存下來;內容每次不同的工作(發文的文字、回覆的留言)不存步驟。技能清單裡標「可重播,N 步」。 - **重播學會的做法**(replay_skill):存技能時,模型會挑出這次真的成功、必要、會改變東西的步驟(不含截圖、讀取這類只是看的步驟、不含繞路和失敗),連同每一步點的是哪個東西(「勾選框「自動更新」」,不是編號)一起存下來;內容每次不同的工作(發文的文字、回覆的留言)不存步驟。技能清單裡標「可重播,N 步」。
- 要做的事和技能一模一樣時,Bot 叫 replay_skill,AnyBot 就一步一步照做,中間不問模型:畫面上的步驟在最近的畫面清單裡找同一種、同名的東西換成現在的編號(值和勾選狀態不算),網頁上的步驟改用字找;找不到時先自動截一次圖再找,還是找不到就停下來,告訴 Bot 停在第幾步、找不到什麼,由它接手。 - 要做的事和技能一模一樣時,Bot 叫 replay_skill,AnyBot 就一步一步照做,中間不問模型:畫面上的步驟在最近的畫面清單裡找同一種、同名的東西換成現在的編號(值和勾選狀態不算),網頁上的步驟改用字找;找不到時先自動截一次圖再找,還是找不到就停下來,告訴 Bot 停在第幾步、找不到什麼,由它接手。

View File

@ -14,6 +14,8 @@
- 分享給團隊(登入後):把這台的 Bot 分享給帳號伺服器上的其他帳號,選成員或管理員([team](team.md))。 - 分享給團隊(登入後):把這台的 Bot 分享給帳號伺服器上的其他帳號,選成員或管理員([team](team.md))。
- 手機頁面:Bot 清單(分區、工作中/等你)、聊天(附檔、拍照、語音輸入、插話、停止)、允許請求卡片(「一律允許」「允許一次」或「允許」、「拒絕」、「全部允許,之後直接操作」;卡片太高時卡在內面自己捲,輸入框不會被頂出螢幕)、問題卡、「需要處理」與接管、Bot 設定、例行任務(詳細頁有最近幾次執行和送出證據)、頁面、記憶、檔案預覽、Bot 的電腦畫面、設定、傳送到其他裝置。 - 手機頁面:Bot 清單(分區、工作中/等你)、聊天(附檔、拍照、語音輸入、插話、停止)、允許請求卡片(「一律允許」「允許一次」或「允許」、「拒絕」、「全部允許,之後直接操作」;卡片太高時卡在內面自己捲,輸入框不會被頂出螢幕)、問題卡、「需要處理」與接管、Bot 設定、例行任務(詳細頁有最近幾次執行和送出證據)、頁面、記憶、檔案預覽、Bot 的電腦畫面、設定、傳送到其他裝置。
- 長相(和電腦版同一份設計規格:字級、間距、圓角都是同一組數字):Bot 的回答不放在泡泡裡,像文件一樣直接排在畫面上,用宋體(思源宋體,沒有就用系統的宋體)、16px、行距寬;裡面的表格只有橫向細線、數字欄靠右,提示框([!NOTE] 等)同一種淡底、只有圖示依種類上色,程式碼是淡底圓角塊。你自己的訊息(泡泡)和所有按鈕、清單、設定用黑體。手機沒有字型選項。 - 長相(和電腦版同一份設計規格:字級、間距、圓角都是同一組數字):Bot 的回答不放在泡泡裡,像文件一樣直接排在畫面上,用宋體(思源宋體,沒有就用系統的宋體)、16px、行距寬;裡面的表格只有橫向細線、數字欄靠右,提示框([!NOTE] 等)同一種淡底、只有圖示依種類上色,程式碼是淡底圓角塊。你自己的訊息(泡泡)和所有按鈕、清單、設定用黑體。手機沒有字型選項。
- 顏色跟電腦版一樣:電腦上 設定 › 一般 › 外觀 的主題(淺色/深色/跟隨系統)、底色、強調色、對比,手機照著穿;手機自己的「外觀」可以選「跟著電腦」(預設)、「跟著手機」、「淺色」、「深色」。狀態列的顏色跟著畫面。舊版的電腦沒送顏色時,手機用內建的「紙」。
- 像 Claude 的手機 App:上面一條簡單的標題列(Bot 名稱,第二行是它在做什麼或用哪個模型),輸入框是底部一張圓角卡片,回答下面只有時間和複製/重新產生/⋯;按鈕和點的地方至少 44px;清單每列的說明只有一行(太長以 … 結尾);顏色少,強調色只用在連結、選取和新訊息的點。
- 通知:需要你允許、問你、需要你處理,你不在時做完事,例行任務暫停,收到傳來的檔案——推播到開了通知的手機,點了直接打開那個 Bot。每支手機自己選要哪幾種(需要你/做完了/例行任務暫停/收到傳來的檔案),可以送一則測試通知。通知的圖示是 AnyBot 的貓,Android 狀態列是貓的單色剪影;App 圖示上的數字是正在等你的 Bot。 - 通知:需要你允許、問你、需要你處理,你不在時做完事,例行任務暫停,收到傳來的檔案——推播到開了通知的手機,點了直接打開那個 Bot。每支手機自己選要哪幾種(需要你/做完了/例行任務暫停/收到傳來的檔案),可以送一則測試通知。通知的圖示是 AnyBot 的貓,Android 狀態列是貓的單色剪影;App 圖示上的數字是正在等你的 Bot。
- 像 App 一樣:加入主畫面後全螢幕、沒有網址列(瀏海、動態島、底部手勢條、橫放都避開);首頁會提示「把 AnyBot 裝成 App」(Android 直接安裝,iPhone 教你加入主畫面,可以關掉);換畫面會左右滑動;iPhone 主畫面 App 從左邊緣往右滑回上一頁。 - 像 App 一樣:加入主畫面後全螢幕、沒有網址列(瀏海、動態島、底部手勢條、橫放都避開);首頁會提示「把 AnyBot 裝成 App」(Android 直接安裝,iPhone 教你加入主畫面,可以關掉);換畫面會左右滑動;iPhone 主畫面 App 從左邊緣往右滑回上一頁。
@ -21,13 +23,14 @@
- 電腦:設定 › 一般 › 帳戶 ›「登入」(登入後是「管理帳戶」)打開「手機與帳號」頁,左上「‹ 一般」回去。由上到下:「手機與帳號」「AnyBot 帳號」、大腦(登入後)、「同一個網路直接連」「手機可以做什麼」「直接連線的裝置」「分享給團隊」「帳號裡的電腦」(最後兩個登入後才有)。 - 電腦:設定 › 一般 › 帳戶 ›「登入」(登入後是「管理帳戶」)打開「手機與帳號」頁,左上「‹ 一般」回去。由上到下:「手機與帳號」「AnyBot 帳號」、大腦(登入後)、「同一個網路直接連」「手機可以做什麼」「直接連線的裝置」「分享給團隊」「帳號裡的電腦」(最後兩個登入後才有)。
- 手機:打開帳號伺服器的網址用帳號登入;或打開設定頁列出的網址用手機密碼登入。可以「加入主畫面」當 App。 - 手機:打開帳號伺服器的網址用帳號登入;或打開設定頁列出的網址用手機密碼登入。可以「加入主畫面」當 App。
- 手機:左上角帳戶選單 ›「通知」(開關、要通知哪幾種、測試通知)、「安裝成 App」(還沒裝時才有)。 - 手機:左上角帳戶選單 ›「通知」(開關、要通知哪幾種、測試通知)、「安裝成 App」(還沒裝時才有)、「這支手機的外觀」。
- 手機:首頁 Bot 那列的「⋯」有「對話詳細資訊」「釘選」「移至分區」,少用的(標示為未讀、分享給團隊成員、設為主要 Bot、重新啟動)在「更多…」裡,「刪除 Bot」隔一條線。聊天裡的圖片點一下在 App 裡打開預覽。
- 手機的 設定 › 手機與帳號:直接連線的手機;用帳號登入時另有通知、兩步驗證、登入的裝置、「加一台電腦」(擁有者)、「切換到別台 AnyBot」;最下面「登出這支手機」。 - 手機的 設定 › 手機與帳號:直接連線的手機;用帳號登入時另有通知、兩步驗證、登入的裝置、「加一台電腦」(擁有者)、「切換到別台 AnyBot」;最下面「登出這支手機」。
## 怎麼操作 ## 怎麼操作
- Bot:沒有登入、配對或改這一頁的工具。登入帳號後多兩個工具:`send_to_device`(把檔案傳到帳號裡另一台或「手機」)和 `publish_site`(發布成公開網站,見 [files](files.md));開了裝置連結的電腦會出現在它的電腦清單([computers](computers.md))。外面的訊息和團隊成員的訊息拿不到這兩個工具。 - Bot:沒有登入、配對或改這一頁的工具。登入帳號後多兩個工具:`send_to_device`(把檔案傳到帳號裡另一台或「手機」)和 `publish_site`(發布成公開網站,見 [files](files.md));開了裝置連結的電腦會出現在它的電腦清單([computers](computers.md))。外面的訊息和團隊成員的訊息拿不到這兩個工具。
- 驗證:設手機密碼、勾「讓手機直接連這台電腦」,用手機(或另一台的瀏覽器)打開列出的網址、信任憑證、輸入密碼,要看到 Bot 清單;叫 Bot 在你的電腦執行一個要核准的指令,手機出現允許卡片,在手機按「允許一次」(或「允許」)後電腦上的卡片也消失、步驟繼續;用帳號登入的手機開通知、按「送一則測試通知」要跳出貓圖示的通知,關掉「做完了」後 Bot 做完不再推、需要你允許照樣推;「直接連線的裝置」多一行,按「登出」後那支手機要重新登入。自動測試:`cargo test remote::`、`cargo test remote_ui::`、`cargo test httpd::`、`cargo test drops::`;帳號伺服器的通知種類在 `relay/` 的 `cargo test`。 - 驗證:設手機密碼、勾「讓手機直接連這台電腦」,用手機(或另一台的瀏覽器)打開列出的網址、信任憑證、輸入密碼,要看到 Bot 清單;叫 Bot 在你的電腦執行一個要核准的指令,手機出現允許卡片,在手機按「允許一次」(或「允許」)後電腦上的卡片也消失、步驟繼續;用帳號登入的手機開通知、按「送一則測試通知」要跳出貓圖示的通知,關掉「做完了」後 Bot 做完不再推、需要你允許照樣推;「直接連線的裝置」多一行,按「登出」後那支手機要重新登入。在電腦上把 設定 › 一般 › 外觀 的強調色換成靛藍、主題換成深色,手機(外觀「跟著電腦」)重新整理後要變成深色、新訊息的點變靛藍。自動測試:`cargo test remote::`、`cargo test remote_ui::`、`cargo test httpd::`、`cargo test drops::`;帳號伺服器的通知種類在 `relay/` 的 `cargo test`。(`remote::tests::phone_login_and_api` 也檢查 api/state 帶著主題和兩組顏色。)
## 陷阱 ## 陷阱

View File

@ -71,10 +71,10 @@ a{color:var(--accent-ink)}
.scroll{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;min-height:0} .scroll{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;min-height:0}
/* ---- bars ---- */ /* ---- bars ---- */
.bar{display:flex;align-items:center;gap:8px;padding:calc(var(--safe-t) + 8px) 10px 8px;min-height:56px;background:var(--pane);border-bottom:.5px solid var(--line2);flex:none} .bar{display:flex;align-items:center;gap:4px;padding:calc(var(--safe-t) + 4px) 6px 4px;min-height:52px;background:var(--pane);flex:none}
.bar h1{font-size:var(--fs-h3);font-weight:600;margin:0;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .bar h1{font-size:var(--fs-h3);font-weight:600;margin:0;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bar h1 small{font-size:var(--fs-caption);font-weight:400;color:var(--text3);margin-left:6px} .bar h1 small{font-size:var(--fs-caption);font-weight:400;color:var(--text3);margin-left:6px}
.ib{width:36px;height:36px;border-radius:var(--r-m);display:grid;place-items:center;color:var(--text2);flex:none} .ib{width:44px;height:44px;border-radius:var(--r-m);display:grid;place-items:center;color:var(--text2);flex:none}
.ib:active,.ib.on{background:var(--hover)} .ib:active,.ib.on{background:var(--hover)}
.ib .ic{vertical-align:0} .ib .ic{vertical-align:0}
.island{flex:1;min-width:0;display:flex;align-items:center;gap:9px;height:40px;padding:0 10px 0 4px;border-radius:var(--r-m)} .island{flex:1;min-width:0;display:flex;align-items:center;gap:9px;height:40px;padding:0 10px 0 4px;border-radius:var(--r-m)}
@ -99,10 +99,11 @@ a{color:var(--accent-ink)}
.me{width:32px;height:32px;border-radius:50%;background:var(--active);display:grid;place-items:center;font-size:var(--fs-small);font-weight:600;color:var(--text2);flex:none} .me{width:32px;height:32px;border-radius:50%;background:var(--active);display:grid;place-items:center;font-size:var(--fs-small);font-weight:600;color:var(--text2);flex:none}
.searchbox{margin:0 12px 6px;display:none;align-items:center;gap:8px;background:var(--hover);border-radius:var(--r-m);padding:0 10px;height:36px} .searchbox{margin:0 12px 6px;display:none;align-items:center;gap:8px;background:var(--hover);border-radius:var(--r-m);padding:0 10px;height:36px}
.searchbox.on{display:flex} .searchbox.on{display:flex}
.searchbox .ib{width:36px;height:36px}
.searchbox input{flex:1;border:0;background:none;outline:0;font-size:var(--fs-ui);min-width:0} .searchbox input{flex:1;border:0;background:none;outline:0;font-size:var(--fs-ui);min-width:0}
.quick{display:flex;gap:8px;padding:2px 12px 8px;overflow-x:auto;scrollbar-width:none} .quick{display:flex;gap:8px;padding:2px 12px 8px;overflow-x:auto;scrollbar-width:none}
.quick::-webkit-scrollbar{display:none} .quick::-webkit-scrollbar{display:none}
.quick button{flex:none;display:flex;align-items:center;gap:6px;height:32px;padding:0 12px;border-radius:999px;background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);font-size:var(--fs-small);color:var(--text2)} .quick button{flex:none;display:flex;align-items:center;gap:6px;height:36px;padding:0 14px;border-radius:999px;background:var(--elev);font-size:var(--fs-small);color:var(--text2)}
.quick button b{font-weight:600;color:var(--text)} .quick button b{font-weight:600;color:var(--text)}
.quick button .st{width:7px;height:7px;border-radius:50%} .quick button .st{width:7px;height:7px;border-radius:50%}
.sec{display:flex;align-items:center;gap:6px;padding:14px 18px 4px;font-size:var(--fs-caption);font-weight:600;color:var(--text3)} .sec{display:flex;align-items:center;gap:6px;padding:14px 18px 4px;font-size:var(--fs-caption);font-weight:600;color:var(--text3)}
@ -118,7 +119,7 @@ a{color:var(--accent-ink)}
.row .pv{font-size:var(--fs-small);color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .row .pv{font-size:var(--fs-small);color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.row .pv.busy{color:var(--ok)}.row .pv.wait{color:var(--warn)} .row .pv.busy{color:var(--ok)}.row .pv.wait{color:var(--warn)}
.row .tm{font-size:var(--fs-caption);color:var(--text4);align-self:flex-start;margin-top:4px;flex:none} .row .tm{font-size:var(--fs-caption);color:var(--text4);align-self:flex-start;margin-top:4px;flex:none}
.row .more{width:30px;height:30px;border-radius:var(--r-s);display:grid;place-items:center;color:var(--text3);flex:none} .row .more{width:44px;height:44px;margin-right:-8px;border-radius:var(--r-m);display:grid;place-items:center;color:var(--text3);flex:none}
.pill{font-size:var(--fs-caption);font-weight:500;padding:1px 7px;border-radius:999px;background:var(--active);color:var(--text2);flex:none} .pill{font-size:var(--fs-caption);font-weight:500;padding:1px 7px;border-radius:999px;background:var(--active);color:var(--text2);flex:none}
.pill.acc{background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--accent-ink)} .pill.acc{background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--accent-ink)}
.pill.ok{background:color-mix(in srgb,var(--ok) 16%,transparent);color:var(--ok)} .pill.ok{background:color-mix(in srgb,var(--ok) 16%,transparent);color:var(--ok)}
@ -179,14 +180,14 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.who{font-size:var(--fs-caption);color:var(--text3);margin:6px 0 2px 4px} .who{font-size:var(--fs-caption);color:var(--text3);margin:6px 0 2px 4px}
.tag{font-size:var(--fs-caption);color:var(--text3);margin:4px 4px 2px;display:flex;align-items:center;gap:4px} .tag{font-size:var(--fs-caption);color:var(--text3);margin:4px 4px 2px;display:flex;align-items:center;gap:4px}
.meta{font-size:var(--fs-caption);color:var(--text4);margin:3px 6px 0;display:flex;align-items:center;gap:6px;flex-wrap:wrap} .meta{font-size:var(--fs-caption);color:var(--text4);margin:3px 6px 0;display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.meta button{color:var(--text3);display:flex;align-items:center;padding:4px;border-radius:var(--r-s)} .meta button{color:var(--text3);display:grid;place-items:center;width:36px;height:36px;border-radius:var(--r-m)}
.meta button:active{background:var(--hover)} .meta button:active{background:var(--hover)}
.reacts{display:flex;gap:4px;flex-wrap:wrap;margin:3px 4px 0} .reacts{display:flex;gap:4px;flex-wrap:wrap;margin:3px 4px 0}
.reacts button{font-size:var(--fs-small);padding:1px 7px;border-radius:999px;background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line)} .reacts button{font-size:var(--fs-small);padding:1px 8px;min-height:28px;border-radius:999px;background:var(--hover)}
.quote{font-size:var(--fs-small);color:var(--text2);border-left:3px solid var(--line);padding-left:8px;margin:0 0 4px;white-space:pre-wrap} .quote{font-size:var(--fs-small);color:var(--text2);border-left:2px solid var(--line);padding-left:8px;margin:0 0 4px;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;white-space:normal}
/* steps (the desktop's outline rows) */ /* steps (the desktop's outline rows) */
.steps{display:flex;flex-direction:column;gap:4px;margin:4px 0;max-width:min(92%,560px);width:100%} .steps{display:flex;flex-direction:column;gap:4px;margin:4px 0;max-width:min(92%,560px);width:100%}
.step,.fold{border-radius:var(--r-m);background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);font-size:var(--fs-small);overflow:hidden} .step,.fold{border-radius:var(--r-m);background:var(--hover);font-size:var(--fs-small);overflow:hidden}
.step>.h,.fold{display:flex;align-items:center;gap:7px;padding:7px 10px;min-height:34px;width:100%;text-align:left} .step>.h,.fold{display:flex;align-items:center;gap:7px;padding:7px 10px;min-height:34px;width:100%;text-align:left}
.step .l{font-weight:600;flex:none;max-width:45%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .step .l{font-weight:600;flex:none;max-width:45%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.step .d{color:var(--text3);flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .step .d{color:var(--text3);flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@ -246,14 +247,14 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.intro .hi{font-size:var(--fs-h2);font-weight:600;margin-top:8px} .intro .hi{font-size:var(--fs-h2);font-weight:600;margin-top:8px}
.intro .sub{font-size:var(--fs-ui);color:var(--text3)} .intro .sub{font-size:var(--fs-ui);color:var(--text3)}
.sugs{display:flex;flex-direction:column;gap:6px;padding:14px 16px;max-width:520px;margin:0 auto;width:100%} .sugs{display:flex;flex-direction:column;gap:6px;padding:14px 16px;max-width:520px;margin:0 auto;width:100%}
.sug{display:flex;align-items:center;gap:12px;padding:11px 12px;border-radius:var(--r-m);background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);text-align:left} .sug{display:flex;align-items:center;gap:12px;padding:11px 12px;min-height:52px;border-radius:var(--r-m);background:var(--elev);text-align:left}
.sug .ic{color:var(--text2)} .sug .ic{color:var(--text2)}
.sug .tt{font-size:var(--fs-ui);font-weight:500}.sug .dd{font-size:var(--fs-caption);color:var(--text3)} .sug .tt{font-size:var(--fs-ui);font-weight:500}.sug .dd{font-size:var(--fs-caption);color:var(--text3)}
/* the dock: approvals, queued steering, attachments, the composer */ /* the dock: approvals, queued steering, attachments, the composer */
.dock{flex:none;padding:6px 10px calc(var(--safe-b) + 8px);background:linear-gradient(to bottom,transparent,var(--chrome) 40%)} .dock{flex:none;padding:6px 10px calc(var(--safe-b) + 8px);background:linear-gradient(to bottom,transparent,var(--chrome) 40%)}
/* 需要你: yellow is the one colour for what waits for the person. */ /* 需要你: yellow is the one colour for what waits for the person. */
/* Tall cards (long reasons, many choices) scroll inside the card: the composer stays on screen. */ /* Tall cards (long reasons, many choices) scroll inside the card: the composer stays on screen. */
.ask{max-width:560px;margin:0 auto 8px;padding:14px 16px;border-radius:var(--r-l);background:var(--attention-bg);box-shadow:inset 0 0 0 2px var(--attention);max-height:min(48dvh,420px);overflow-y:auto;overscroll-behavior:contain} .ask{max-width:560px;margin:0 auto 8px;padding:14px 16px;border-radius:var(--r-l);background:var(--attention-bg);box-shadow:inset 0 0 0 1px var(--attention);max-height:min(48dvh,420px);overflow-y:auto;overscroll-behavior:contain}
.ask .q{font-weight:600;font-size:var(--fs-ui)} .ask .q{font-weight:600;font-size:var(--fs-ui)}
.ask .why{font-size:var(--fs-small);color:var(--text2);margin:4px 0 10px;white-space:pre-wrap;overflow-wrap:anywhere} .ask .why{font-size:var(--fs-small);color:var(--text2);margin:4px 0 10px;white-space:pre-wrap;overflow-wrap:anywhere}
.ask .thumb{width:100%;border-radius:var(--r-m);margin:2px 0 10px;display:block;background:var(--hover);min-height:60px} .ask .thumb{width:100%;border-radius:var(--r-m);margin:2px 0 10px;display:block;background:var(--hover);min-height:60px}
@ -269,23 +270,23 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.ask .opt.on i::after{content:"";position:absolute;left:6px;top:2.5px;width:4px;height:9px;border:solid var(--elev);border-width:0 2px 2px 0;transform:rotate(45deg)} .ask .opt.on i::after{content:"";position:absolute;left:6px;top:2.5px;width:4px;height:9px;border:solid var(--elev);border-width:0 2px 2px 0;transform:rotate(45deg)}
.ask .own{display:block;width:100%;box-sizing:border-box;min-height:44px;margin:0 0 10px;padding:8px 12px;border:0;border-radius:var(--r-m);background:var(--elev);box-shadow:inset 0 0 0 1px var(--line);color:var(--text);font:inherit;font-size:var(--fs-read)} .ask .own{display:block;width:100%;box-sizing:border-box;min-height:44px;margin:0 0 10px;padding:8px 12px;border:0;border-radius:var(--r-m);background:var(--elev);box-shadow:inset 0 0 0 1px var(--line);color:var(--text);font:inherit;font-size:var(--fs-read)}
.ask .btn[disabled]{opacity:.45} .ask .btn[disabled]{opacity:.45}
.btn{height:36px;padding:0 14px;border-radius:999px;background:var(--hover);font-weight:500;font-size:var(--fs-ui);display:inline-flex;align-items:center;justify-content:center;gap:6px} .btn{height:40px;padding:0 16px;border-radius:999px;background:var(--hover);font-weight:500;font-size:var(--fs-ui);display:inline-flex;align-items:center;justify-content:center;gap:6px}
.btn.main{background:var(--primary);color:var(--on-primary)} .btn.main{background:var(--primary);color:var(--on-primary)}
.btn.no{color:var(--danger)} .btn.no{color:var(--danger)}
.btn.sm{height:30px;padding:0 11px;font-size:var(--fs-small);border-radius:999px} .btn.sm{height:34px;padding:0 12px;font-size:var(--fs-small);border-radius:999px}
.btn:disabled{opacity:.45} .btn:disabled{opacity:.45}
.goalbar{max-width:560px;margin:0 auto 6px;display:flex;align-items:center;gap:8px;font-size:var(--fs-small);color:var(--text2);background:var(--hover);border-radius:var(--r-m);padding:5px 6px 5px 11px} .goalbar{max-width:560px;margin:0 auto 6px;display:flex;align-items:center;gap:8px;font-size:var(--fs-small);color:var(--text2);background:var(--hover);border-radius:var(--r-m);padding:5px 6px 5px 11px}
.goalbar .t{flex:1;min-width:0;display:flex;align-items:center;gap:6px} .goalbar .t{flex:1;min-width:0;display:flex;align-items:center;gap:6px}
.goalbar .t span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .goalbar .t span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.goalbar.on .t .ic{color:var(--accent)} .goalbar.on .t .ic{color:var(--accent)}
.goalbar button{flex:none;font-size:var(--fs-small);color:var(--text2);padding:4px 8px;border-radius:var(--r-s)} .goalbar button{flex:none;font-size:var(--fs-small);color:var(--text2);padding:4px 8px;border-radius:var(--r-s)}
.note{align-self:center;display:flex;gap:6px;max-width:min(560px,100%);margin:6px 0;padding:7px 12px;border-radius:var(--r-m);background:var(--hover);font-size:var(--fs-small);color:var(--text2);white-space:pre-wrap;overflow-wrap:anywhere} .msgs .note{align-self:center;display:flex;gap:6px;max-width:min(560px,100%);margin:6px 0;padding:7px 12px;border-radius:var(--r-m);background:var(--hover);color:var(--text2)}
.note .ic{flex:none;margin-top:2px;color:var(--text3)} .msgs .note .ic{flex:none;margin-top:2px;color:var(--text3)}
.queued{max-width:560px;margin:0 auto 6px;font-size:var(--fs-small);color:var(--text2);background:var(--hover);border-radius:var(--r-m);padding:7px 11px;overflow-wrap:anywhere} .queued{max-width:560px;margin:0 auto 6px;font-size:var(--fs-small);color:var(--text2);background:var(--hover);border-radius:var(--r-m);padding:7px 11px;overflow-wrap:anywhere}
.chips{display:flex;gap:6px;flex-wrap:wrap;max-width:760px;margin:0 auto} .chips{display:flex;gap:6px;flex-wrap:wrap;max-width:760px;margin:0 auto}
.chip{display:inline-flex;align-items:center;gap:5px;font-size:var(--fs-small);padding:4px 6px 4px 10px;border-radius:999px;background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);margin-bottom:6px;max-width:100%} .chip{display:inline-flex;align-items:center;gap:5px;font-size:var(--fs-small);padding:4px 6px 4px 10px;border-radius:999px;background:var(--elev);margin-bottom:6px;max-width:100%}
.chip span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:180px} .chip span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:180px}
.chip button{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;color:var(--text3)} .chip button{display:grid;place-items:center;width:28px;height:28px;margin:-4px -2px;border-radius:50%;color:var(--text3)}
/* 記憶: the composer's suggestions, the tag under a message, the memory tab */ /* 記憶: the composer's suggestions, the tag under a message, the memory tab */
.memchips{display:flex;gap:6px;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;align-items:center;max-width:760px;margin:0 auto} .memchips{display:flex;gap:6px;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;align-items:center;max-width:760px;margin:0 auto}
.memchips::-webkit-scrollbar{display:none} .memchips::-webkit-scrollbar{display:none}
@ -294,12 +295,12 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.memchips .lbl{font-size:var(--fs-caption);color:var(--text3);display:inline-flex;gap:4px;align-items:center} .memchips .lbl{font-size:var(--fs-caption);color:var(--text3);display:inline-flex;gap:4px;align-items:center}
.mchip{font-size:var(--fs-small);padding:4px 10px;border-radius:999px;box-shadow:inset 0 0 0 .5px var(--line);color:var(--text2);max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .mchip{font-size:var(--fs-small);padding:4px 10px;border-radius:999px;box-shadow:inset 0 0 0 .5px var(--line);color:var(--text2);max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mchip.on{background:color-mix(in srgb,var(--accent) 14%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 55%,transparent);color:var(--text)} .mchip.on{background:color-mix(in srgb,var(--accent) 14%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 55%,transparent);color:var(--text)}
.slash{max-width:760px;margin:0 auto 6px;padding:4px;max-height:min(272px,38vh);overflow-y:auto;border-radius:var(--r-l);background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line),0 6px 24px -6px var(--shade)} .slash{max-width:760px;margin:0 auto 6px;padding:4px;max-height:min(272px,38vh);overflow-y:auto;border-radius:var(--r-l);background:var(--elev);box-shadow:0 6px 24px -6px var(--shade)}
.slash:empty{display:none} .slash:empty{display:none}
.slash .hd{font-size:var(--fs-caption);color:var(--text3);padding:6px 10px 4px} .slash .hd{font-size:var(--fs-caption);color:var(--text3);padding:6px 10px 4px}
.slash button{display:flex;align-items:center;gap:8px;width:100%;min-height:40px;padding:6px 10px;border-radius:var(--r-m);text-align:left} .slash button{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:6px 10px;border-radius:var(--r-m);text-align:left}
.slash button.on{background:var(--active)} .slash button.on{background:var(--active)}
.slash b{flex:none;font-size:var(--fs-ui);font-weight:600} .slash b{flex:none;max-width:62%;font-size:var(--fs-ui);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.slash span{min-width:0;font-size:var(--fs-small);color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .slash span{min-width:0;font-size:var(--fs-small);color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.memtok{font-size:var(--fs-caption);color:var(--text3)} .memtok{font-size:var(--fs-caption);color:var(--text3)}
.carried{font-size:var(--fs-caption);color:var(--text3);margin:3px 6px 0;display:inline-flex;gap:4px;align-items:center} .carried{font-size:var(--fs-caption);color:var(--text3);margin:3px 6px 0;display:inline-flex;gap:4px;align-items:center}
@ -308,13 +309,13 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.memhead b{color:var(--text);font-weight:600;margin:0 12px 0 3px} .memhead b{color:var(--text);font-weight:600;margin:0 12px 0 3px}
.memhead .sub{font-size:var(--fs-caption)} .memhead .sub{font-size:var(--fs-caption)}
.memsearch{display:flex;gap:8px;padding:10px 12px 6px} .memsearch{display:flex;gap:8px;padding:10px 12px 6px}
.memsearch input{flex:1;min-width:0;height:38px;border-radius:999px;padding:0 14px;background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);font-size:var(--fs-ui);color:var(--text);border:0;outline:none} .memsearch input{flex:1;min-width:0;height:40px;border-radius:999px;padding:0 14px;background:var(--elev);font-size:var(--fs-read);color:var(--text);border:0;outline:none}
.memsearch button{flex:none;height:38px;padding:0 14px;border-radius:999px;background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);font-size:var(--fs-ui);color:var(--accent-ink);display:inline-flex;gap:4px;align-items:center} .memsearch button{flex:none;height:40px;padding:0 14px;border-radius:999px;background:var(--elev);font-size:var(--fs-ui);color:var(--accent-ink);display:inline-flex;gap:4px;align-items:center}
.memfilters{display:flex;gap:6px;padding:4px 12px 10px;overflow-x:auto;scrollbar-width:none} .memfilters{display:flex;gap:6px;padding:4px 12px 10px;overflow-x:auto;scrollbar-width:none}
.memfilters::-webkit-scrollbar{display:none} .memfilters::-webkit-scrollbar{display:none}
.memfilters button{flex:none;height:30px;padding:0 12px;border-radius:999px;font-size:var(--fs-small);color:var(--text2);box-shadow:inset 0 0 0 .5px var(--line)} .memfilters button{flex:none;height:30px;padding:0 12px;border-radius:999px;font-size:var(--fs-small);color:var(--text2);box-shadow:inset 0 0 0 .5px var(--line)}
.memfilters button.on{background:var(--active);color:var(--text);font-weight:500;box-shadow:none} .memfilters button.on{background:var(--active);color:var(--text);font-weight:500;box-shadow:none}
.mcard{margin:0 12px 8px;padding:11px 14px 8px;border-radius:var(--r-l);background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line)} .mcard{margin:0 12px 8px;padding:11px 14px 8px;border-radius:var(--r-l);background:var(--elev)}
.mcard.pin{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 45%,transparent)} .mcard.pin{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 45%,transparent)}
.mcard .mt{font-size:var(--fs-ui);white-space:pre-wrap;word-break:break-word;line-height:1.5} .mcard .mt{font-size:var(--fs-ui);white-space:pre-wrap;word-break:break-word;line-height:1.5}
.mcard .mm{font-size:var(--fs-caption);color:var(--text3);margin-top:6px;display:flex;align-items:center;gap:6px;flex-wrap:wrap} .mcard .mm{font-size:var(--fs-caption);color:var(--text3);margin-top:6px;display:flex;align-items:center;gap:6px;flex-wrap:wrap}
@ -331,12 +332,12 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.memmore button{color:var(--accent-ink);font-size:var(--fs-small)} .memmore button{color:var(--accent-ink);font-size:var(--fs-small)}
.quoting{max-width:760px;margin:0 auto 6px;display:flex;align-items:center;gap:8px;font-size:var(--fs-small);color:var(--text2);border-left:3px solid var(--line);padding-left:8px} .quoting{max-width:760px;margin:0 auto 6px;display:flex;align-items:center;gap:8px;font-size:var(--fs-small);color:var(--text2);border-left:3px solid var(--line);padding-left:8px}
.quoting span{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .quoting span{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.composer{max-width:760px;margin:0 auto;display:flex;align-items:flex-end;gap:6px;background:var(--elev);border-radius:var(--r-l);padding:8px 8px 8px 8px;box-shadow:inset 0 0 0 1.5px var(--text3)} .composer{max-width:760px;margin:0 auto;display:flex;align-items:flex-end;gap:4px;background:var(--elev);border-radius:var(--r-l);padding:6px;box-shadow:inset 0 0 0 1px var(--line),0 2px 10px -2px var(--shade)}
.composer:focus-within{box-shadow:inset 0 0 0 1.5px var(--text)} .composer:focus-within{box-shadow:inset 0 0 0 1px var(--text4),0 2px 10px -2px var(--shade)}
.composer.tall{border-radius:var(--r-l)} .composer.tall{border-radius:var(--r-l)}
.composer textarea{flex:1;border:0;outline:0;background:none;resize:none;font-size:var(--fs-read);line-height:22px;max-height:140px;min-height:28px;padding:3px 4px} .composer textarea{flex:1;border:0;outline:0;background:none;resize:none;font-size:var(--fs-read);line-height:22px;max-height:140px;min-height:28px;padding:3px 4px}
.cbtn{width:28px;height:28px;border-radius:var(--r-m);display:grid;place-items:center;flex:none;color:var(--text2)} .cbtn{width:36px;height:36px;border-radius:var(--r-m);display:grid;place-items:center;flex:none;color:var(--text2)}
.cbtn.plus{background:var(--hover);box-shadow:inset 0 0 0 .5px var(--line)} .cbtn.plus{background:none}
.cbtn.go{background:var(--bot,var(--primary));color:var(--bot-ink,var(--on-primary))} .cbtn.go{background:var(--bot,var(--primary));color:var(--bot-ink,var(--on-primary))}
.cbtn.go:disabled{opacity:.35} .cbtn.go:disabled{opacity:.35}
.cbtn.rec{color:var(--danger)} .cbtn.rec{color:var(--danger)}
@ -352,7 +353,7 @@ details.dt>.dt-in{padding-left:var(--sp-4);margin-top:var(--sp-2)}
.tabs::-webkit-scrollbar{display:none} .tabs::-webkit-scrollbar{display:none}
.tabs button{flex:none;height:32px;padding:0 13px;border-radius:999px;font-size:var(--fs-ui);color:var(--text2)} .tabs button{flex:none;height:32px;padding:0 13px;border-radius:999px;font-size:var(--fs-ui);color:var(--text2)}
.tabs button.on{background:var(--active);color:var(--text);font-weight:500} .tabs button.on{background:var(--active);color:var(--text);font-weight:500}
.group{margin:8px 12px 14px;border-radius:var(--r-l);background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);overflow:hidden} .group{margin:8px 12px 14px;border-radius:var(--r-l);background:var(--elev);overflow:hidden}
.gt{font-size:var(--fs-caption);font-weight:600;color:var(--text3);padding:12px 18px 4px;display:flex;align-items:center;gap:6px} .gt{font-size:var(--fs-caption);font-weight:600;color:var(--text3);padding:12px 18px 4px;display:flex;align-items:center;gap:6px}
.gt button{margin-left:auto;font-weight:500;color:var(--accent-ink);font-size:var(--fs-small)} .gt button{margin-left:auto;font-weight:500;color:var(--accent-ink);font-size:var(--fs-small)}
.item{display:flex;align-items:center;gap:12px;padding:11px 14px;min-height:48px;border-top:.5px solid var(--line2);width:100%;text-align:left} .item{display:flex;align-items:center;gap:12px;padding:11px 14px;min-height:48px;border-top:.5px solid var(--line2);width:100%;text-align:left}
@ -361,16 +362,17 @@ button.item:active,.item.tap:active{background:var(--hover)}
.item .ic{color:var(--text2)} .item .ic{color:var(--text2)}
.item .mid{flex:1;min-width:0} .item .mid{flex:1;min-width:0}
.item .k{font-size:var(--fs-ui)} .item .k{font-size:var(--fs-ui)}
.item .v{font-size:var(--fs-small);color:var(--text3);white-space:pre-wrap;word-break:break-word} .item .v{font-size:var(--fs-small);color:var(--text3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.item .r{font-size:var(--fs-ui);color:var(--text3);flex:none;max-width:45%;text-align:right;white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .item .r{font-size:var(--fs-ui);color:var(--text3);flex:none;max-width:45%;text-align:right;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.item.danger .k,.item.danger .ic{color:var(--danger)} .item.danger .k,.item.danger .ic{color:var(--danger)}
.item .chev{color:var(--text4)} .item .chev{color:var(--text4)}
.note{font-size:var(--fs-small);color:var(--text3);padding:6px 18px 10px;line-height:1.55} .note{font-size:var(--fs-small);color:var(--text3);padding:6px 18px 10px;line-height:1.55;white-space:pre-wrap;overflow-wrap:anywhere}
.sw{position:relative;width:46px;height:28px;flex:none} .sw{position:relative;width:46px;height:28px;flex:none}
.sw input{opacity:0;position:absolute;inset:0;margin:0} .sw input{opacity:0;position:absolute;inset:0;margin:0}
.sw i{position:absolute;inset:0;border-radius:999px;background:var(--active);transition:.15s} .sw i{position:absolute;inset:0;border-radius:999px;background:var(--active);transition:.15s}
.sw i::after{content:"";position:absolute;left:3px;top:3px;width:22px;height:22px;border-radius:50%;background:var(--on-color);box-shadow:0 1px 3px var(--shade);transition:.15s} .sw i::after{content:"";position:absolute;left:3px;top:3px;width:22px;height:22px;border-radius:50%;background:var(--on-color);box-shadow:0 1px 3px var(--shade);transition:.15s}
.sw input:checked+i{background:var(--ok)} .sw input:checked+i{background:var(--primary)}
.sw input:checked+i::after{background:var(--on-primary)}
.sw input:checked+i::after{transform:translateX(18px)} .sw input:checked+i::after{transform:translateX(18px)}
.sw input:disabled+i{opacity:.4} .sw input:disabled+i{opacity:.4}
.field{display:block;width:100%;border:0;outline:0;background:var(--hover);border-radius:var(--r-m);padding:10px 12px;font-size:var(--fs-read);resize:vertical} .field{display:block;width:100%;border:0;outline:0;background:var(--hover);border-radius:var(--r-m);padding:10px 12px;font-size:var(--fs-read);resize:vertical}
@ -423,9 +425,9 @@ textarea.field{min-height:96px;line-height:1.5}
.drop-bar{height:4px;border-radius:999px;background:var(--line);overflow:hidden;margin-top:4px} .drop-bar{height:4px;border-radius:999px;background:var(--line);overflow:hidden;margin-top:4px}
.drop-bar i{display:block;height:100%;background:var(--primary)} .drop-bar i{display:block;height:100%;background:var(--primary)}
.sheet .grp{font-size:var(--fs-caption);font-weight:600;color:var(--text3);padding:12px 20px 4px} .sheet .grp{font-size:var(--fs-caption);font-weight:600;color:var(--text3);padding:12px 20px 4px}
.emojis{display:flex;gap:6px;padding:6px 16px 10px;flex-wrap:wrap} .emojis{display:grid;grid-template-columns:repeat(8,1fr);gap:6px;padding:6px 16px 10px}
.emojis button{font-size:var(--fs-h2);width:44px;height:44px;border-radius:var(--r-m);background:var(--hover)} .emojis button{font-size:var(--fs-h2);height:44px;min-width:0;border-radius:var(--r-m);background:var(--hover)}
.toast{position:fixed;left:50%;bottom:calc(var(--safe-b) + 90px);transform:translate(-50%,20px);background:var(--primary);color:var(--on-primary);padding:9px 16px;border-radius:999px;font-size:var(--fs-ui);opacity:0;pointer-events:none;transition:.2s;z-index:40;max-width:86vw;text-align:center} .toast{position:fixed;left:50%;top:calc(var(--safe-t) + 60px);transform:translate(-50%,-12px);background:var(--primary);color:var(--on-primary);padding:9px 16px;border-radius:999px;font-size:var(--fs-ui);opacity:0;pointer-events:none;transition:.2s;z-index:40;max-width:86vw;text-align:center}
.toast.on{opacity:1;transform:translate(-50%,0)} .toast.on{opacity:1;transform:translate(-50%,0)}
/* ---- sign in ---- */ /* ---- sign in ---- */
@ -532,7 +534,7 @@ button,.row,.ib,.island,.opt,.chip,.tab,label.sw,[role="button"]{-webkit-user-se
/* The iPhone home-screen app has no browser to swipe back with: the edge swipe moves the screen. */ /* The iPhone home-screen app has no browser to swipe back with: the edge swipe moves the screen. */
.view.dragging{transition:none!important;box-shadow:-12px 0 24px var(--shade)} .view.dragging{transition:none!important;box-shadow:-12px 0 24px var(--shade)}
/* Put AnyBot on the home screen (shown once, until installed or dismissed). */ /* Put AnyBot on the home screen (shown once, until installed or dismissed). */
.install{margin:2px 12px 8px;padding:12px 14px;border-radius:var(--r-l);background:var(--elev);box-shadow:inset 0 0 0 .5px var(--line);display:none;gap:12px;align-items:center} .install{margin:2px 12px 8px;padding:12px 14px;border-radius:var(--r-l);background:var(--elev);display:none;gap:12px;align-items:center}
.install.on{display:flex} .install.on{display:flex}
.install img{width:44px;height:44px;border-radius:var(--r-m);flex:none} .install img{width:44px;height:44px;border-radius:var(--r-m);flex:none}
.install .mid{flex:1;min-width:0} .install .mid{flex:1;min-width:0}
@ -575,7 +577,7 @@ button,.row,.ib,.island,.opt,.chip,.tab,label.sw,[role="button"]{-webkit-user-se
<button class="ib" id="b-search" title="搜尋"></button> <button class="ib" id="b-search" title="搜尋"></button>
<button class="ib" id="b-newbot" title="新 Bot"></button> <button class="ib" id="b-newbot" title="新 Bot"></button>
</div> </div>
<div class="searchbox" id="searchbox"><span id="search-ic"></span><input id="search" placeholder="搜尋 Bot" enterkeyhint="search"><button class="ib" id="b-search-x" style="width:28px;height:28px"></button></div> <div class="searchbox" id="searchbox"><span id="search-ic"></span><input id="search" placeholder="搜尋 Bot" enterkeyhint="search"><button class="ib" id="b-search-x"></button></div>
<div class="install" id="install"></div> <div class="install" id="install"></div>
<div class="quick" id="quick"></div> <div class="quick" id="quick"></div>
<div class="scroll" id="home"></div> <div class="scroll" id="home"></div>
@ -789,10 +791,40 @@ function dayLabel(ms) {
function plain(t) { return String(t || "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/[*_`#>]/g, "").replace(/\s+/g, " ").trim(); } function plain(t) { return String(t || "").replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/[*_`#>]/g, "").replace(/\s+/g, " ").trim(); }
// 外觀 of this phone: follow it, or light or dark by hand. // 外觀 of this phone: follow it, or light or dark by hand.
const THEMES = [["", "跟著手機"], ["light", "淺色"], ["dark", "深色"]]; // 外觀 of this phone: the computer's (設定 › 一般 › 外觀 › 主題, the default), the phone's own, or light
// or dark by hand.
const THEMES = [["", "跟著電腦"], ["system", "跟著手機"], ["light", "淺色"], ["dark", "深色"]];
// What the computer said last (kept, so the next start wears it before the brain answers).
const DESK = {theme: ""};
function phoneTheme() { try { return localStorage.getItem("anybot.theme") || ""; } catch (_) { return ""; } } function phoneTheme() { try { return localStorage.getItem("anybot.theme") || ""; } catch (_) { return ""; } }
function applyTheme() { const t = phoneTheme(); if (t) document.documentElement.dataset.theme = t; else delete document.documentElement.dataset.theme; if (typeof barColor === "function") barColor(); } function applyTheme() {
const pick = phoneTheme();
const t = pick === "light" || pick === "dark" ? pick : pick === "system" ? "" : ["light", "dark"].includes(DESK.theme) ? DESK.theme : "";
if (t) document.documentElement.dataset.theme = t; else delete document.documentElement.dataset.theme;
if (typeof barColor === "function") barColor();
}
// The computer's colours (底色, 強調色, 對比 — theme::shell, light and dark) as this page's CSS
// variables. Only names and #hex colours go in; an older brain sends none and the built-in 紙 stays.
function paletteCss(p) {
if (!p || typeof p !== "object") return "";
const block = (o) => Object.entries(o && typeof o === "object" ? o : {}).filter(([k, v]) => /^[a-z0-9-]{2,20}$/.test(k) && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(String(v))).map(([k, v]) => `--${k}:${v}`).join(";");
const l = block(p.light), d = block(p.dark);
if (!l || !d) return "";
return `:root{${l}}:root[data-theme="light"]{${l}}@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${d}}}:root[data-theme="dark"]{${d}}`;
}
function applyPalette(p) {
const css = paletteCss(p);
let el = document.getElementById("desk-palette");
if (!el) { el = document.createElement("style"); el.id = "desk-palette"; document.head.appendChild(el); }
if (el.textContent === css) return;
el.textContent = css;
try { if (css) localStorage.setItem("anybot.palette", JSON.stringify(p)); else localStorage.removeItem("anybot.palette"); } catch (_) {}
if (typeof barColor === "function") barColor();
}
try { DESK.theme = localStorage.getItem("anybot.desk-theme") || ""; applyPalette(JSON.parse(localStorage.getItem("anybot.palette") || "null")); } catch (_) {}
applyTheme(); applyTheme();
// The phone switching light/dark while open: the status bar follows.
try { matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => barColor()); } catch (_) {}
const S = { sending: [], voice: {}, const S = { sending: [], voice: {},
relay: false, token: localStorage.getItem("anybot.token") || "", host: localStorage.getItem("anybot.host") || "", relay: false, token: localStorage.getItem("anybot.token") || "", host: localStorage.getItem("anybot.host") || "",
@ -855,7 +887,9 @@ function avatarSvg(shape, hex) {
const rgb = [1, 3, 5].map((i) => parseInt(col.slice(i, i + 2), 16)); const rgb = [1, 3, 5].map((i) => parseInt(col.slice(i, i + 2), 16));
const eye = rgb[0] + rgb[1] + rgb[2] > 600 ? "#1c1c1c" : "#fcfcfc"; const eye = rgb[0] + rgb[1] + rgb[2] > 600 ? "#1c1c1c" : "#fcfcfc";
const eyes = [-0.27, 0.27].map((x) => `<ellipse cx="${x}" cy="0.02" rx="0.11" ry="0.22" transform="rotate(-20 ${x} 0.02)"/>`).join(""); const eyes = [-0.27, 0.27].map((x) => `<ellipse cx="${x}" cy="0.02" rx="0.11" ry="0.22" transform="rotate(-20 ${x} 0.02)"/>`).join("");
return `<svg viewBox="-1.1 -1.1 2.2 2.2" aria-hidden="true"><g fill="${col}">${body}</g><g fill="${eye}">${eyes}</g></svg>`; // A near-black bot gets a hairline edge: in dark it was only two eyes floating on the page.
const edge = rgb[0] + rgb[1] + rgb[2] < 150 ? ` style="stroke:var(--line)" stroke-width="0.08"` : "";
return `<svg viewBox="-1.1 -1.1 2.2 2.2" aria-hidden="true"><g fill="${col}"${edge}>${body}</g><g fill="${eye}">${eyes}</g></svg>`;
} }
const face = (b, cls = "") => `<div class="av ${cls}">${avatarSvg(b.shape, b.color)}</div>`; const face = (b, cls = "") => `<div class="av ${cls}">${avatarSvg(b.shape, b.color)}</div>`;
@ -1047,6 +1081,9 @@ function apply(v) {
S.bots = v.bots || []; S.approvals = v.approvals || []; S.hostName = v.host || ""; S.mac = !!v.mac; S.bots = v.bots || []; S.approvals = v.approvals || []; S.hostName = v.host || ""; S.mac = !!v.mac;
S.box = v.box || ""; S.boxOn = !!v.box_available; S.pages = v.pages || []; S.models = v.models || []; S.sections = v.sections || null; S.role = v.role || "owner"; S.box = v.box || ""; S.boxOn = !!v.box_available; S.pages = v.pages || []; S.models = v.models || []; S.sections = v.sections || null; S.role = v.role || "owner";
S.voice = v.voice || {}; micShown(); appBadge(); S.voice = v.voice || {}; micShown(); appBadge();
// The computer's 外觀 (an older brain sends neither: the built-in look stays).
if (v.palettes) applyPalette(v.palettes);
if (typeof v.theme === "string" && v.theme !== DESK.theme) { DESK.theme = v.theme; try { localStorage.setItem("anybot.desk-theme", v.theme); } catch (_) {} applyTheme(); }
const t = cur(); const t = cur();
if (t.v === "home") renderHome(); if (t.v === "home") renderHome();
else if (t.v === "chat") { else if (t.v === "chat") {
@ -1132,18 +1169,17 @@ function renderHome() {
// The sidebar row's menu, as on the desktop. // The sidebar row's menu, as on the desktop.
function botMenu(id) { function botMenu(id) {
const b = bot(id); if (!b || !owner()) return; const b = bot(id); if (!b || !owner()) return;
const items = [ // What is used often first; the rest under 「更多…」 (a tap on the row already opens the chat).
{icon: "message", label: "開啟對話", on: () => go("chat", {bot: id})}, const items = [{icon: "info", label: "對話詳細資訊", on: () => go("details", {bot: id})}];
{icon: "info", label: "對話詳細資訊", on: () => go("details", {bot: id})}, const more = [{icon: b.unread ? "check" : "bell", label: b.unread ? "標示為已讀" : "標示為未讀", on: () => b.unread ? api(base() + `api/bots/${id}/read`, {json: {}}).then(() => toast("已標示為已讀")).catch((e) => toast(e.message)) : act("bot", {bot: id, key: "unread", value: true}, "已標示為未讀")}];
{icon: b.unread ? "check" : "bell", label: b.unread ? "標示為已讀" : "標示為未讀", on: () => b.unread ? api(base() + `api/bots/${id}/read`, {json: {}}).then(() => toast("已標示為已讀")).catch((e) => toast(e.message)) : act("bot", {bot: id, key: "unread", value: true}, "已標示為未讀")},
];
// (Changing bots is the owner's; an admin opens, reads and restarts them.) // (Changing bots is the owner's; an admin opens, reads and restarts them.)
if (isOwner()) items.push({icon: "pin", label: b.pinned ? "取消釘選" : "釘選", on: () => act("bot", {bot: id, key: "pinned", value: !b.pinned}, b.pinned ? "已取消釘選" : "已釘選")}, {icon: "folder", label: "移至分區", on: () => moveToFolder(b)}); if (isOwner()) items.push({icon: "pin", label: b.pinned ? "取消釘選" : "釘選", on: () => act("bot", {bot: id, key: "pinned", value: !b.pinned}, b.pinned ? "已取消釘選" : "已釘選")}, {icon: "folder", label: "移至分區", on: () => moveToFolder(b)});
// 團隊: whether teammates may use this bot (they see its chat, pages and files). // 團隊: whether teammates may use this bot (they see its chat, pages and files).
if (isOwner() && !b.members) items.push({icon: "users", label: b.team ? "不再分享給團隊成員" : "分享給團隊成員", on: () => act("bot", {bot: id, key: "team", value: !b.team}, b.team ? "團隊成員看不到這個 Bot 了" : "團隊成員現在可以使用這個 Bot")}); if (isOwner() && !b.members) more.push({icon: "users", label: b.team ? "不再分享給團隊成員" : "分享給團隊成員", on: () => act("bot", {bot: id, key: "team", value: !b.team}, b.team ? "團隊成員看不到這個 Bot 了" : "團隊成員現在可以使用這個 Bot")});
if (!b.primary && isOwner()) items.push({icon: "star", label: "設為主要 Bot", on: () => act("bot", {bot: id, key: "primary", value: true}, "已設為主要 Bot")}); if (!b.primary && isOwner()) more.push({icon: "star", label: "設為主要 Bot", on: () => act("bot", {bot: id, key: "primary", value: true}, "已設為主要 Bot")});
items.push({icon: "refresh", label: "重新啟動這個 Bot", on: () => act("restart_bot", {bot: id})}); more.push({icon: "refresh", label: "重新啟動這個 Bot", on: () => act("restart_bot", {bot: id})});
if (isOwner()) items.push({icon: "trash", label: "刪除 Bot", danger: true, on: () => deleteBot(b)}); items.push({icon: "ellipsis", label: "更多…", on: () => sheet(b.name, more)});
if (isOwner()) items.push({sep: true}, {icon: "trash", label: "刪除 Bot", danger: true, on: () => deleteBot(b)});
sheet(b.name, items); sheet(b.name, items);
} }
async function moveToFolder(b) { async function moveToFolder(b) {
@ -1216,7 +1252,7 @@ function chatSub(b) {
const a = S.approvals.find((x) => x.bot === b.id); const a = S.approvals.find((x) => x.bot === b.id);
if (a) return ["wait", a.kind === "handoff" ? "需要你的輸入" : a.kind === "question" ? "等你回答" : "需要你核准"]; if (a) return ["wait", a.kind === "handoff" ? "需要你的輸入" : a.kind === "question" ? "等你回答" : "需要你核准"];
if (b.busy) return ["busy", b.status || "工作中…"]; if (b.busy) return ["busy", b.status || "工作中…"];
return ["", b.via || ""]; return ["", b.model || ""];
} }
function chatHead() { function chatHead() {
const b = bot(S.open); if (!b) return; const b = bot(S.open); if (!b) return;
@ -1283,7 +1319,7 @@ function thinkHtml(m) {
} }
function attHtml(a) { function attHtml(a) {
if (!a.path) return `<div class="filec">${ic(a.image ? "image" : "file", 16)}<span class="fn">${esc(a.name)}</span></div>`; if (!a.path) return `<div class="filec">${ic(a.image ? "image" : "file", 16)}<span class="fn">${esc(a.name)}</span></div>`;
if (a.image) return `<div class="attimg" data-file="${esc(a.path)}">${FILES[a.path] ? `<img alt="${esc(a.name)}" src="${FILES[a.path]}">` : `<div class="wait">${ic("image", 14)} ${esc(a.name)}</div>`}</div>`; if (a.image) return `<div class="attimg" data-file="${esc(a.path)}" data-name="${esc(a.name)}">${FILES[a.path] ? `<img alt="${esc(a.name)}" src="${FILES[a.path]}">` : `<div class="wait">${ic("image", 14)} ${esc(a.name)}</div>`}</div>`;
return `<a class="filec" data-file="${esc(a.path)}" data-name="${esc(a.name)}">${ic("file", 18)}<span style="min-width:0"><div class="fn">${esc(a.name)}</div><div style="font-size:var(--fs-caption);color:var(--text3)">${esc(a.kind || "檔案")}${a.bytes ? " · " + kb(a.bytes) : ""} · 點一下開啟</div></span></a>`; return `<a class="filec" data-file="${esc(a.path)}" data-name="${esc(a.name)}">${ic("file", 18)}<span style="min-width:0"><div class="fn">${esc(a.name)}</div><div style="font-size:var(--fs-caption);color:var(--text3)">${esc(a.kind || "檔案")}${a.bytes ? " · " + kb(a.bytes) : ""} · 點一下開啟</div></span></a>`;
} }
const kb = (n) => n >= 1048576 ? (n / 1048576).toFixed(1) + " MB" : Math.max(1, Math.round(n / 1024)) + " KB"; const kb = (n) => n >= 1048576 ? (n / 1048576).toFixed(1) + " MB" : Math.max(1, Math.round(n / 1024)) + " KB";
@ -1320,8 +1356,9 @@ function card(c) {
} }
const GLYPH = (h = 34) => `<svg width="${Math.round(h * .8)}" height="${h}" viewBox="0 0 24 30" style="flex:none"><rect x=".5" y=".5" width="23" height="29" rx="4" style="fill:var(--hover);stroke:var(--line)"/><path d="M5 7h9M5 11h6" style="stroke:var(--text3)" stroke-width="2" stroke-linecap="round"/><rect x="5" y="20" width="2.6" height="5" rx=".6" style="fill:var(--cat3)"/><rect x="9" y="18" width="2.6" height="7" rx=".6" style="fill:var(--cat4)"/><rect x="13" y="16" width="2.6" height="9" rx=".6" style="fill:var(--cat1)"/><rect x="17" y="14" width="2.6" height="11" rx=".6" style="fill:var(--cat2)"/></svg>`; const GLYPH = (h = 34) => `<svg width="${Math.round(h * .8)}" height="${h}" viewBox="0 0 24 30" style="flex:none"><rect x=".5" y=".5" width="23" height="29" rx="4" style="fill:var(--hover);stroke:var(--line)"/><path d="M5 7h9M5 11h6" style="stroke:var(--text3)" stroke-width="2" stroke-linecap="round"/><rect x="5" y="20" width="2.6" height="5" rx=".6" style="fill:var(--cat3)"/><rect x="9" y="18" width="2.6" height="7" rx=".6" style="fill:var(--cat4)"/><rect x="13" y="16" width="2.6" height="9" rx=".6" style="fill:var(--cat1)"/><rect x="17" y="14" width="2.6" height="11" rx=".6" style="fill:var(--cat2)"/></svg>`;
function pageCard(p) { function pageCard(p) {
const lines = (p.preview || []).map((l, i, a) => `<div class="l" style="opacity:${1 - (i / Math.max(a.length, 1)) * .6}">${esc(l)}</div>`).join(""); const lines = (p.preview || []).slice(0, 3).map((l, i, a) => `<div class="l" style="opacity:${1 - (i / Math.max(a.length, 1)) * .6}">${esc(l)}</div>`).join("");
return `<div class="pcard" data-page="${p.id}"><div class="top"><div class="t">${esc(p.title)}</div>${lines}</div><div class="foot">${GLYPH()}<div style="min-width:0"><div class="n">${esc(p.title)}</div><div class="x">頁面 · ${esc(p.updated)}${p.revision > 1 ? " · 已更新" : ""}</div></div></div></div>`; // (The title once: the foot only says what it is and when.)
return `<div class="pcard" data-page="${p.id}"><div class="top"><div class="t">${esc(p.title)}</div>${lines}</div><div class="foot">${GLYPH(22)}<div class="x">頁面 · ${esc(p.updated)}${p.revision > 1 ? " · 已更新" : ""}</div></div></div>`;
} }
function renderMsgs() { function renderMsgs() {
const b = bot(S.open) || {}; const b = bot(S.open) || {};
@ -1368,7 +1405,7 @@ function renderMsgs() {
if (goal) m = {...m, text: m.text.slice(GOAL_TAG.length)}; if (goal) m = {...m, text: m.text.slice(GOAL_TAG.length)};
const q = String(m.text || "").match(/^((?:>.*\n?)+)\n*([\s\S]*)$/); const q = String(m.text || "").match(/^((?:>.*\n?)+)\n*([\s\S]*)$/);
const text = q ? q[2] : m.text; const text = q ? q[2] : m.text;
const quote = q ? `<div class="quote">${esc(q[1].replace(/^> ?/gm, "").trim())}</div>` : ""; const quote = q ? `<div class="quote">${esc(plain(q[1].replace(/^> ?/gm, "")).replace(/\|/g, " ").replace(/\s+/g, " ").trim())}</div>` : "";
const mems = m.memories || []; const mems = m.memories || [];
const open = S.carried.has(String(m.at || i)); const open = S.carried.has(String(m.at || i));
const carried = mems.length ? `<button class="carried" data-carried="${esc(String(m.at || i))}">${ic("bookmark", 12)} 帶了 ${mems.length} 條記憶 ${ic(open ? "chevron-up" : "chevron-down", 12)}</button>${open ? `<div class="carried-list">${mems.map((x) => "• " + esc(x)).join("<br>")}</div>` : ""}` : ""; const carried = mems.length ? `<button class="carried" data-carried="${esc(String(m.at || i))}">${ic("bookmark", 12)} 帶了 ${mems.length} 條記憶 ${ic(open ? "chevron-up" : "chevron-down", 12)}</button>${open ? `<div class="carried-list">${mems.map((x) => "• " + esc(x)).join("<br>")}</div>` : ""}` : "";
@ -1393,7 +1430,7 @@ function renderMsgs() {
const think = m.thinking ? thinkHtml(m) : ""; const think = m.thinking ? thinkHtml(m) : "";
const bub = m.text ? `<div class="bub">${pageMd(m.text, 0)}</div>` : ""; const bub = m.text ? `<div class="bub">${pageMd(m.text, 0)}</div>` : "";
const atts = (m.attachments || []).map(attHtml).join(""); const atts = (m.attachments || []).map(attHtml).join("");
const meta = end && m.text ? `<div class="meta">${esc(m.via || "")}${m.at ? " · " + clock(m.at) : ""}<button data-copy="${i}" title="複製">${ic("copy", 14)}</button>${owner() && m === lastBot && t === lastTurn ? `<button data-regen="1" title="重新產生">${ic("refresh", 14)}</button>` : ""}<button data-more="${i}" title="更多">${ic("ellipsis", 14)}</button></div>` : ""; const meta = end && m.text ? `<div class="meta">${m.at ? esc(clock(m.at)) : ""}<button data-copy="${i}" title="複製">${ic("copy", 14)}</button>${owner() && m === lastBot && t === lastTurn ? `<button data-regen="1" title="重新產生">${ic("refresh", 14)}</button>` : ""}<button data-more="${i}" title="更多">${ic("ellipsis", 14)}</button></div>` : "";
h += `<div class="m bot ${m.error ? "err" : ""}" data-msg="${i}">${who}${think}${bub}${steps ? `<div class="steps">${steps}</div>` : ""}${extra}${atts}${reacts}${meta}</div>`; h += `<div class="m bot ${m.error ? "err" : ""}" data-msg="${i}">${who}${think}${bub}${steps ? `<div class="steps">${steps}</div>` : ""}${extra}${atts}${reacts}${meta}</div>`;
}); });
// Still working: what it is doing now; a message nobody answered yet can be sent again. // Still working: what it is doing now; a message nobody answered yet can be sent again.
@ -1478,11 +1515,11 @@ function renderDock() {
else if (!owner()) $("ask").innerHTML = `<div class="ask"><div class="q">${esc(a.title)}</div><div class="why">等擁有者或管理員決定</div></div>`; else if (!owner()) $("ask").innerHTML = `<div class="ask"><div class="q">${esc(a.title)}</div><div class="why">等擁有者或管理員決定</div></div>`;
else if (a.kind === "handoff") { else if (a.kind === "handoff") {
const own = /的電腦$/.test(a.computer || "") && S.boxOn; const own = /的電腦$/.test(a.computer || "") && S.boxOn;
$("ask").innerHTML = `<div class="ask"><div class="q">${ic("hand", 16)} 需要處理 · ${esc(a.computer || "")}</div><div class="why">${esc(a.reason)}</div>${own ? `<img class="thumb" id="hand-thumb" alt="">` : ""}<div class="btns"><button class="btn" data-screen="1">${ic("monitor", 15)} 接管</button><button class="btn main" data-a="once">我完成了</button><button class="btn no" data-a="reject">跳過</button></div></div>`; $("ask").innerHTML = `<div class="ask"><div class="q">${ic("hand", 16)} 需要處理 · ${esc(a.computer || "")}</div><div class="why">${esc(a.reason)}</div>${own ? `<img class="thumb" id="hand-thumb" alt="">` : ""}<div class="btns"><button class="btn" data-screen="1">${ic("monitor", 15)} 接管</button><button class="btn main" data-a="once">我完成了</button><button class="btn" data-a="reject">跳過</button></div></div>`;
$("ask").querySelector("[data-screen]").onclick = () => openBox(true); $("ask").querySelector("[data-screen]").onclick = () => openBox(true);
if (own) { const load = () => boxThumb($("hand-thumb")); load(); thumbTimer = setInterval(load, 3000); } if (own) { const load = () => boxThumb($("hand-thumb")); load(); thumbTimer = setInterval(load, 3000); }
} else { } else {
$("ask").innerHTML = `<div class="ask"><div class="q">${esc(a.title)}</div><div class="why">${esc(a.reason)}</div><div class="btns">${a.can_always ? `<button class="btn main" data-a="always">一律允許</button><button class="btn" data-a="once">允許一次</button>` : `<button class="btn main" data-a="once">允許</button>`}<button class="btn no" data-a="reject">拒絕</button></div>${isOwner() ? `<a class="all" data-direct="1">${ic("zap", 13)} 全部允許,之後直接操作</a>` : ""}</div>`; $("ask").innerHTML = `<div class="ask"><div class="q">${esc(a.title)}</div><div class="why">${esc(a.reason)}</div><div class="btns">${a.can_always ? `<button class="btn main" data-a="always">一律允許</button><button class="btn" data-a="once">允許一次</button>` : `<button class="btn main" data-a="once">允許</button>`}<button class="btn" data-a="reject">拒絕</button></div>${isOwner() ? `<a class="all" data-direct="1">${ic("zap", 13)} 全部允許,之後直接操作</a>` : ""}</div>`;
} }
$("ask").querySelectorAll("button[data-a]").forEach((x) => x.onclick = async () => { $("ask").querySelectorAll("button[data-a]").forEach((x) => x.onclick = async () => {
$("ask").innerHTML = ""; $("ask").innerHTML = "";
@ -1515,7 +1552,7 @@ function renderQuestion(a, force) {
const i = ASKF.step, q = qs[i], opts = q.options || [], last = i + 1 === qs.length; const i = ASKF.step, q = qs[i], opts = q.options || [], last = i + 1 === qs.length;
ASKF.drawn = i; ASKF.drawn = i;
const own = !!(ASKF.typed[i] || "").trim(); const own = !!(ASKF.typed[i] || "").trim();
$("ask").innerHTML = `<div class="ask"><div class="asknum">${esc(a.title)}${qs.length > 1 ? ` · ${i + 1}/${qs.length}` : ""}</div><div class="q">${esc(q.question)}</div><div class="why">${q.multiple ? "可以選好幾個" : ""}</div>${opts.map((o, k) => `<button class="opt ${q.multiple ? "many" : ""} ${ASKF.picks[i].includes(k) && (q.multiple || !own) ? "on" : ""}" data-k="${k}"><i></i><span>${esc(o)}</span></button>`).join("")}<input class="own" enterkeyhint="${last ? "send" : "next"}" placeholder="${opts.length ? "自己回答" : "輸入回答"}" value="${esc(ASKF.typed[i])}"><div class="btns"><button class="btn main" data-go="next">${last ? "送出" : "下一題"}</button>${i > 0 ? `<button class="btn" data-go="back">上一題</button>` : ""}<button class="btn no" data-go="skip">略過</button></div></div>`; $("ask").innerHTML = `<div class="ask"><div class="asknum">${esc(a.title)}${qs.length > 1 ? ` · ${i + 1}/${qs.length}` : ""}</div><div class="q">${esc(q.question)}</div><div class="why">${q.multiple ? "可以選好幾個" : ""}</div>${opts.map((o, k) => `<button class="opt ${q.multiple ? "many" : ""} ${ASKF.picks[i].includes(k) && (q.multiple || !own) ? "on" : ""}" data-k="${k}"><i></i><span>${esc(o)}</span></button>`).join("")}<input class="own" enterkeyhint="${last ? "send" : "next"}" placeholder="${opts.length ? "自己回答" : "輸入回答"}" value="${esc(ASKF.typed[i])}"><div class="btns"><button class="btn main" data-go="next">${last ? "送出" : "下一題"}</button>${i > 0 ? `<button class="btn" data-go="back">上一題</button>` : ""}<button class="btn" data-go="skip">略過</button></div></div>`;
const box = $("ask"), field = box.querySelector(".own"), go = box.querySelector('[data-go="next"]'); const box = $("ask"), field = box.querySelector(".own"), go = box.querySelector('[data-go="next"]');
const ready = () => { go.disabled = !askAnswer(q, i); }; const ready = () => { go.disabled = !askAnswer(q, i); };
ready(); ready();
@ -1839,7 +1876,7 @@ function tabBody(b, d) {
if (S.tab === "audit") { if (S.tab === "audit") {
const a = S.audit[b.id]; const a = S.audit[b.id];
if (a === undefined) { loadAudit(b.id); return `<div class="note" style="padding:14px 16px">載入中…</div>`; } if (a === undefined) { loadAudit(b.id); return `<div class="note" style="padding:14px 16px">載入中…</div>`; }
if (!a.turns.length) return `<div class="empty">現在沒有進行中的工作。稽核時間軸記的是**這回合**做了什麼:每次問模型、每個工具的參數與結果、你插入的話、停止。這裡記的是最近 30 天的每一回合;更早的故事在聊天記錄裡。</div>`; if (!a.turns.length) return `<div class="empty">最近 30 天沒有工作紀錄。</div>`;
const OUT = {completed: "已結束", aborted: "被你停止", failed: "失敗"}; const OUT = {completed: "已結束", aborted: "被你停止", failed: "失敗"};
const ST = {done: "完成", running: "進行中…", waiting: "等核准", denied: "沒有完成(拒絕或停止)", failed: "失敗"}; const ST = {done: "完成", running: "進行中…", waiting: "等核准", denied: "沒有完成(拒絕或停止)", failed: "失敗"};
const TI = {computer: "zap", menu_click: "zap", fill_form: "zap", wait_for: "clock", run_cmd: "zap", web_fetch: "globe", browser: "globe"}; const TI = {computer: "zap", menu_click: "zap", fill_form: "zap", wait_for: "clock", run_cmd: "zap", web_fetch: "globe", browser: "globe"};
@ -1851,7 +1888,7 @@ function tabBody(b, d) {
if (x.type === "queue") return item({icon: "message", k: "你插進來的話", v: x.text, r: x.state === "waiting" ? "排隊中" : x.state === "consumed" ? "已送達" : "已取消"}); if (x.type === "queue") return item({icon: "message", k: "你插進來的話", v: x.text, r: x.state === "waiting" ? "排隊中" : x.state === "consumed" ? "已送達" : "已取消"});
return item({icon: "stop", k: "你按了停止"}); return item({icon: "stop", k: "你按了停止"});
}).join(""); }).join("");
h += group(`〈${(t.prompt || "(無訊息的回合)").slice(0, 30)}〉 ${ago(t.at)} · ${OUT[t.outcome] || "進行中…"}`, steps); // (group() escapes the title itself) h += group(`${plain(t.prompt || "(無訊息的回合)").slice(0, 24)} · ${ago(t.at)} · ${OUT[t.outcome] || "進行中…"}`, steps); // (group() escapes the title itself)
} }
return h; return h;
} }
@ -1986,7 +2023,7 @@ async function memOverview() {
const st = m.ov.stats || {}, n = (k) => st[k] || 0; const st = m.ov.stats || {}, n = (k) => st[k] || 0;
const files = (m.ov.files || []).map((f) => `${f.name} ${f.bytes > 1048576 ? (f.bytes / 1048576).toFixed(1) + " MB" : Math.max(1, Math.round(f.bytes / 1024)) + " KB"}`).join(" · "); const files = (m.ov.files || []).map((f) => `${f.name} ${f.bytes > 1048576 ? (f.bytes / 1048576).toFixed(1) + " MB" : Math.max(1, Math.round(f.bytes / 1024)) + " KB"}`).join(" · ");
const head = $("mem-head"); const head = $("mem-head");
if (head) head.innerHTML = m.bot === 0 ? `記得的事<b>${n("facts")}</b>最近刪除<b>${n("trash")}</b><div class="sub">${esc(files)}</div>` : `記得的事<b>${n("facts")}</b>做過的事<b>${n("events") + n("rollups")}</b>釘選<b>${n("pinned")}</b>最近刪除<b>${n("trash")}</b><div class="sub">釘選的每次都帶(約 ${n("pinned_tokens")} token);其他的只在相關時帶 · ${esc(files)}</div><div class="sub">${ic("brain", 12)} 語意搜尋:${esc(m.ov.engine || "")}</div>`; if (head) head.innerHTML = m.bot === 0 ? `記得的事<b>${n("facts")}</b>最近刪除<b>${n("trash")}</b>` : `記得的事<b>${n("facts")}</b>做過的事<b>${n("events") + n("rollups")}</b>釘選<b>${n("pinned")}</b>最近刪除<b>${n("trash")}</b><div class="sub">釘選的每次都帶,其他的相關時才帶</div>`;
memSugg(); memSugg();
} }
function memSugg() { function memSugg() {
@ -2228,23 +2265,23 @@ function drawSettings(kind, quiet) {
["general", "settings", "一般", "外觀、時區、通知"], ["models", "sparkles", "模型", "可以用的 AI 服務"], ["perms", "shield", "權限", st.direct_mode ? "直接操作:開" : "Bot 做事前的規則"], ["general", "settings", "一般", "外觀、時區、通知"], ["models", "sparkles", "模型", "可以用的 AI 服務"], ["perms", "shield", "權限", st.direct_mode ? "直接操作:開" : "Bot 做事前的規則"],
["integrations", "plug", "整合", "訊息管道、連接器、技能"], ["computers", "monitor", "電腦", "Bot 的電腦和你帳號裡的電腦"], ["vault", "lock", "保險庫", "密碼和卡號"], ["integrations", "plug", "整合", "訊息管道、連接器、技能"], ["computers", "monitor", "電腦", "Bot 的電腦和你帳號裡的電腦"], ["vault", "lock", "保險庫", "密碼和卡號"],
["account", "smartphone", "手機與帳號", "登入的手機、通知"], ["updates", "download", "更新", st.version || ""], ["account", "smartphone", "手機與帳號", "登入的手機、通知"], ["updates", "download", "更新", st.version || ""],
].map(([k, i, n, v]) => item({icon: i, k: n, v, tap: 1, data: `data-go="${k}"`})).join("")); ].map(([k, i, n, v]) => item({icon: i, k: n, r: k === "updates" ? v : "", tap: 1, data: `data-go="${k}"`})).join(""));
h += `<div class="note" style="text-align:center">${esc(st.host || S.hostName)} · ${esc(st.version || "")}</div>`;
} }
if (kind === "general") { if (kind === "general") {
st.accent = ({Quiet: "quiet", BotColor: "bot_color", Black: "black"})[st.accent] || st.accent;
const theme = {system: "跟隨系統", light: "淺色", dark: "深色"}[st.theme] || ""; const theme = {system: "跟隨系統", light: "淺色", dark: "深色"}[st.theme] || "";
h += group("電腦上的 AnyBot", item({icon: "moon", k: "主題", r: theme, tap: 1, data: 'data-s="theme"'}) + item({icon: "sparkles", k: "聊天的顏色", r: ({quiet: "安靜", black: "只用黑色", bot_color: "跟著 Bot"})[st.accent] || "安靜", tap: 1, data: 'data-s="accent"'})); h += group("電腦上的 AnyBot", item({icon: "moon", k: "主題", r: theme, tap: 1, data: 'data-s="theme"'}) + item({icon: "sparkles", k: "聊天的顏色", r: ({quiet: "安靜", black: "只用黑色", bot_color: "跟著 Bot"})[st.accent] || "安靜", tap: 1, data: 'data-s="accent"'}));
h += group("", item({icon: "globe", k: "時區", v: "例行任務和頁面的時間照這個時區", r: st.timezone || "", tap: 1, data: 'data-s="tz"'}) + item({icon: "bell", k: "通知", v: "Bot 需要你或做完事時通知你", sw: !!st.notify, swdata: 'data-sset="notify"', disabled: !isOwner()})); h += group("", item({icon: "globe", k: "時區", r: st.timezone || "", tap: 1, data: 'data-s="tz"'}) + item({icon: "bell", k: "通知", sw: !!st.notify, swdata: 'data-sset="notify"', disabled: !isOwner()}));
h += group("這支手機", item({icon: "smartphone", k: "外觀", r: (THEMES.find((t) => t[0] === phoneTheme()) || THEMES[0])[1], tap: 1, data: 'data-s="phonetheme"'})); h += group("這支手機", item({icon: "smartphone", k: "外觀", r: (THEMES.find((t) => t[0] === phoneTheme()) || THEMES[0])[1], tap: 1, data: 'data-s="phonetheme"'}));
} }
if (kind === "models") { if (kind === "models") {
h += group("AI 服務", (st.providers || []).map((p, i) => item({icon: p.ready ? "circle-check" : "circle-x", k: p.label, v: p.ready ? (p.default_model ? "新 Bot 預設:" + p.default_model : "可以用") : "還沒有設定金鑰", tap: isOwner() ? 1 : 0, data: `data-prov="${i}"`})).join("")); h += group("AI 服務", (st.providers || []).map((p, i) => item({k: p.label, v: p.ready && p.default_model ? p.default_model : "", r: p.ready ? "可以用" : "未設定", tap: isOwner() ? 1 : 0, data: `data-prov="${i}"`})).join(""));
h += `<div class="note">金鑰只存在這台 AnyBot:手機只能寫入新的金鑰,看不到原本的。每個 Bot 用哪個模型,在 Bot 設定 › 模型 裡選。</div>`; h += `<div class="note">金鑰只存在這台 AnyBot,手機寫得進去、看不到。</div>`;
} }
if (kind === "perms") { if (kind === "perms") {
h += group("", item({icon: "zap", k: "直接操作", v: st.direct_locked ? "已由管理員關閉" : "Bot 直接做事,只有危險操作和「一律詢問」規則會先問你", sw: !!st.direct_mode, swdata: 'data-sset="direct_mode"', disabled: !isOwner() || st.direct_locked}) + item({icon: "shield", k: "自動審核", v: "照下面的規則自動允許或先問你", sw: !!st.auto_review, swdata: 'data-sset="auto_review"', disabled: !isOwner()})); h += group("", item({icon: "zap", k: "直接操作", v: st.direct_locked ? "已由管理員關閉" : "Bot 直接做事,只有危險操作和「一律詢問」規則會先問你", sw: !!st.direct_mode, swdata: 'data-sset="direct_mode"', disabled: !isOwner() || st.direct_locked}) + item({icon: "shield", k: "自動審核", v: "照下面的規則自動允許或先問你", sw: !!st.auto_review, swdata: 'data-sset="auto_review"', disabled: !isOwner()}));
h += rulesGroup("一律詢問(優先)", st.ask_rules, "ask") + rulesGroup("無需詢問直接允許", st.allow_rules, "allow"); h += rulesGroup("一律詢問(優先)", st.ask_rules, "ask") + rulesGroup("無需詢問直接允許", st.allow_rules, "allow");
h += `<div class="note">規則用一般的話寫,例如「發文、寄信、付款前先問我」。兩邊都符合時,「一律詢問」優先。</div>`; h += `<div class="note">用一般的話寫,例如「付款前先問我」。兩邊都符合時先問。</div>`;
} }
if (kind === "integrations") { if (kind === "integrations") {
const dot = (ok, on) => `<span style="width:8px;height:8px;border-radius:50%;flex:none;background:${!on ? "var(--text4)" : ok ? "var(--ok)" : "var(--warn)"}"></span>`; const dot = (ok, on) => `<span style="width:8px;height:8px;border-radius:50%;flex:none;background:${!on ? "var(--text4)" : ok ? "var(--ok)" : "var(--warn)"}"></span>`;
@ -2577,8 +2614,8 @@ async function loadFiles() {
} }
} }
document.addEventListener("click", async (e) => { document.addEventListener("click", async (e) => {
const img = e.target.closest && e.target.closest(".attimg img"); const img = e.target.closest && e.target.closest(".attimg[data-file]");
if (img) { window.open(img.src, "_blank"); return; } if (img) { e.preventDefault(); openFile(img.dataset.file, img.dataset.name); return; }
const f = e.target.closest && e.target.closest("a[data-file]"); const f = e.target.closest && e.target.closest("a[data-file]");
if (!f) return; if (!f) return;
e.preventDefault(); e.preventDefault();
@ -2666,7 +2703,7 @@ function inl(s) {
.replace(/~~([^~]+)~~/g, "<s>$1</s>") .replace(/~~([^~]+)~~/g, "<s>$1</s>")
.replace(/\[([^\]]+)\]\(page:(\d+)\)/g, (_, t, id) => `<a class="plink" data-page="${id}">${t}</a>`) .replace(/\[([^\]]+)\]\(page:(\d+)\)/g, (_, t, id) => `<a class="plink" data-page="${id}">${t}</a>`)
.replace(/\[([^\]]+)\]\((https?:[^)\s]+)\)/g, '<a href="$2" target="_blank" rel="noopener">$1</a>') .replace(/\[([^\]]+)\]\((https?:[^)\s]+)\)/g, '<a href="$2" target="_blank" rel="noopener">$1</a>')
.replace(/(^|[\s((])(https?:\/\/[^\s<))]+)/g, '$1<a href="$2" target="_blank" rel="noopener">$2</a>'); .replace(/(^|[\s((::,、「])(https?:\/\/[^\s<))」,。]+)/g, '$1<a href="$2" target="_blank" rel="noopener">$2</a>');
} }
const CALL = {note: "說明", tip: "提示", warning: "注意", important: "重要"}; const CALL = {note: "說明", tip: "提示", warning: "注意", important: "重要"};
// A call-out's icon: the one coloured thing in it (the tint is the same for every kind). // A call-out's icon: the one coloured thing in it (the tint is the same for every kind).

View File

@ -3,21 +3,22 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, user-scalable=no"> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, user-scalable=no">
<meta name="theme-color" content="#101010"> <meta name="theme-color" content="#1e1d1b">
<title>Bot 的電腦</title> <title>Bot 的電腦</title>
<link rel="icon" href="icon.svg"> <link rel="icon" href="icon.svg">
<style> <style>
:root { :root {
--bg: #0d0d0d; /* The app's dark 「紙」 (src/theme.rs shell, dark): the screen sits on the same warm night. */
--bar: #161616; --bg: #151412;
--elev: #222222; --bar: #1e1d1b;
--hover: rgba(245, 245, 245, 0.08); --elev: #262422;
--line: rgba(245, 245, 245, 0.12); --hover: rgba(242, 240, 235, 0.08);
--text: #f5f5f5; --line: rgba(242, 240, 235, 0.12);
--dim: rgba(245, 245, 245, 0.58); --text: #f2f0eb;
--accent: #1884fc; --dim: rgba(242, 240, 235, 0.58);
--warn: #ffc83d; --accent: #d88366;
--ok: #10ab61; --warn: #d9a441;
--ok: #6fb97d;
--font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Segoe UI", system-ui, sans-serif; --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
} }
* { box-sizing: border-box; } * { box-sizing: border-box; }
@ -33,7 +34,7 @@
header .state { color: var(--dim); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 6px; } header .state { color: var(--dim); font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; } .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 171, 97, 0.18); } .dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 171, 97, 0.18); }
.dot.hold { background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 200, 61, 0.2); } .dot.hold { background: var(--warn); box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.2); }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; } .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
button { button {
font: inherit; font-size: 13px; font-weight: 500; color: var(--text); font: inherit; font-size: 13px; font-weight: 500; color: var(--text);
@ -45,7 +46,7 @@
button:hover { background: var(--hover); } button:hover { background: var(--hover); }
button.main { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } button.main { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.main:hover { filter: brightness(1.08); } button.main:hover { filter: brightness(1.08); }
button.hold-on { background: rgba(255, 200, 61, 0.18); border-color: var(--warn); color: var(--warn); font-weight: 600; } button.hold-on { background: rgba(217, 164, 65, 0.18); border-color: var(--warn); color: var(--warn); font-weight: 600; }
button.icon { width: 30px; padding: 0; border-radius: 9px; background: transparent; border-color: transparent; color: var(--dim); } button.icon { width: 30px; padding: 0; border-radius: 9px; background: transparent; border-color: transparent; color: var(--dim); }
button.icon:hover { background: var(--hover); color: var(--text); } button.icon:hover { background: var(--hover); color: var(--text); }
#screen { flex: 1; min-height: 0; position: relative; background: #000; } #screen { flex: 1; min-height: 0; position: relative; background: #000; }

View File

@ -72,6 +72,12 @@ fn approval_json(bot: &Bot, a: &Approval) -> serde_json::Value {
/// A teammate's messages waiting for a busy bot (more than this are not taken). /// A teammate's messages waiting for a busy bot (more than this are not taken).
const MAX_WAITING_FROM_MEMBERS: usize = 8; const MAX_WAITING_FROM_MEMBERS: usize = 8;
/// 設定 › 一般 › 外觀 as the phone's colours: the shell the desktop draws, light and dark.
pub(super) fn phone_palettes(st: &crate::model::State) -> serde_json::Value {
let one = |dark| remote::palette_json(&crate::theme::shell(st.shell_tone, &st.shell_accent, st.shell_contrast, dark));
json!({"light": one(false), "dark": one(true)})
}
impl App { impl App {
pub(super) fn remote_start(&mut self, ctx: &egui::Context) { pub(super) fn remote_start(&mut self, ctx: &egui::Context) {
if self.demo || self.rm.started { if self.demo || self.rm.started {
@ -270,6 +276,8 @@ impl App {
self.state.timezone.hash(&mut h); self.state.timezone.hash(&mut h);
self.scr.cfg_hash.hash(&mut h); self.scr.cfg_hash.hash(&mut h);
(&self.state.folders, self.state.loose_index, &self.state.pin_order, self.state.accent as u8, self.newer_build.is_some()).hash(&mut h); (&self.state.folders, self.state.loose_index, &self.state.pin_order, self.state.accent as u8, self.newer_build.is_some()).hash(&mut h);
// 外觀: the phone wears the desktop's theme and colours.
(self.state.theme as u8, &self.state.shell_accent, self.state.shell_tone.to_bits(), self.state.shell_contrast.to_bits()).hash(&mut h);
for b in &self.state.bots { for b in &self.state.bots {
(b.id, &b.name, &b.color, b.unread, b.messages.len(), &b.thinking, &b.step_model).hash(&mut h); (b.id, &b.name, &b.color, b.unread, b.messages.len(), &b.thinking, &b.step_model).hash(&mut h);
// (What the phone's home, editor and reactions show.) // (What the phone's home, editor and reactions show.)
@ -332,6 +340,13 @@ impl App {
pin_order: self.pinned_ids(), pin_order: self.pinned_ids(),
newer: self.newer_build.is_some(), newer: self.newer_build.is_some(),
sections: self.section_order(), sections: self.section_order(),
theme: match self.state.theme {
crate::model::Theme::Light => "light",
crate::model::Theme::Dark => "dark",
crate::model::Theme::System => "system",
}
.to_string(),
palettes: phone_palettes(&self.state),
..Default::default() ..Default::default()
}; };
let peers = self.rm.peers.lock().unwrap().clone(); let peers = self.rm.peers.lock().unwrap().clone();
@ -1703,7 +1718,13 @@ impl App {
"role": if owner { "owner" } else { "admin" }, "role": if owner { "owner" } else { "admin" },
"host": st.remote.host_name, "version": crate::version::LABEL, "built": crate::version::epoch_ms(self.exe_built), "newer": self.newer_build.is_some(), "host": st.remote.host_name, "version": crate::version::LABEL, "built": crate::version::epoch_ms(self.exe_built), "newer": self.newer_build.is_some(),
"theme": match st.theme { Theme::Light => "light", Theme::Dark => "dark", Theme::System => "system" }, "theme": match st.theme { Theme::Light => "light", Theme::Dark => "dark", Theme::System => "system" },
"accent": serde_json::to_value(st.accent).unwrap_or_default(), // 聊天的顏色 in the words update_settings takes (the phone ticks the one in use; the
// enum's own names, "Quiet", matched none of them).
"accent": match st.accent {
crate::model::Accent::Quiet => "quiet",
crate::model::Accent::Black => "black",
crate::model::Accent::BotColor => "bot_color",
},
"timezone": st.timezone, "notify": st.notify, "language": st.language, "timezone": st.timezone, "notify": st.notify, "language": st.language,
"direct_mode": st.direct_mode, "direct_locked": !self.managed.direct.allows() || !self.managed.local.allows(), "direct_mode": st.direct_mode, "direct_locked": !self.managed.direct.allows() || !self.managed.local.allows(),
"auto_review": st.auto_review, "allow_rules": st.review_allow_rules, "ask_rules": st.review_ask_rules, "auto_review": st.auto_review, "allow_rules": st.review_allow_rules, "ask_rules": st.review_ask_rules,

View File

@ -241,6 +241,12 @@ pub struct View {
pub models: Vec<Value>, pub models: Vec<Value>,
/// The sidebar's 分區 in order (None = 未分區), empty ones too, as the desktop shows them. /// The sidebar's 分區 in order (None = 未分區), empty ones too, as the desktop shows them.
pub sections: Vec<Option<String>>, pub sections: Vec<Option<String>>,
/// 設定 › 一般 › 外觀 › 主題: "light", "dark" or "system" — the phone follows it unless the
/// person picked this phone's own.
pub theme: String,
/// The desktop's colours as the phone's CSS variables ({"light": {...}, "dark": {...}}, see
/// palette_json): 底色, 強調色 and 對比 reach the phone too. Null from an older brain.
pub palettes: Value,
pub version: u64, pub version: u64,
} }
@ -563,6 +569,8 @@ pub fn handle(req: Req, via_relay: bool) -> Resp {
"pages": pages, "pages": pages,
"models": if role == "member" { vec![] } else { v.models.clone() }, "models": if role == "member" { vec![] } else { v.models.clone() },
"sections": v.sections, "sections": v.sections,
// The desktop's 外觀 (主題 and the shell's colours), for the phone to wear.
"theme": v.theme, "palettes": v.palettes,
// 語音: the mic shows only when this brain can hear (and read aloud). // 語音: the mic shows only when this brain can hear (and read aloud).
"voice": {"listen": hub().voice().listen.is_some(), "speak": hub().voice().speak.is_some()}, "voice": {"listen": hub().voice().listen.is_some(), "speak": hub().voice().speak.is_some()},
}); });
@ -2110,6 +2118,45 @@ pub fn sync_file(s: &Settings, path: &str) -> Result<Vec<u8>, String> {
Ok(bytes) Ok(bytes)
} }
/// One of the desktop's palettes (theme::shell) as the phone page's CSS variables: "#rrggbb" or
/// "#rrggbbaa", the names mobile/index.html's :root uses. The few the desktop has no field for are
/// made the way the phone's own 紙 values were (chrome between pane and sidebar, text4 and line2
/// fainter, accent-ink toward the text).
pub fn palette_json(p: &crate::theme::Palette) -> Value {
use eframe::egui::Color32;
let hex = |c: Color32| {
let [r, g, b, a] = c.to_srgba_unmultiplied();
if a == 255 {
format!("#{r:02x}{g:02x}{b:02x}")
} else {
format!("#{r:02x}{g:02x}{b:02x}{a:02x}")
}
};
let mix = |a: Color32, b: Color32, t: f32| {
let [ar, ag, ab, _] = a.to_srgba_unmultiplied();
let [br, bg, bb, _] = b.to_srgba_unmultiplied();
let m = |x: u8, y: u8| (x as f32 + (y as f32 - x as f32) * t).round() as u8;
Color32::from_rgb(m(ar, br), m(ag, bg), m(ab, bb))
};
let fade = |c: Color32, k: f32| {
let [r, g, b, a] = c.to_srgba_unmultiplied();
Color32::from_rgba_unmultiplied(r, g, b, (a as f32 * k).round() as u8)
};
let mut v = json!({
"pane": hex(p.pane), "chrome": hex(mix(p.pane, p.sidebar, 0.4)), "side": hex(p.sidebar), "elev": hex(p.elevated),
"hover": hex(p.hover), "active": hex(p.active), "primary": hex(p.primary), "on-primary": hex(p.on_primary),
"text": hex(p.text), "text2": hex(p.text2), "text3": hex(p.text3), "text4": hex(fade(p.text, 0.4)),
"line": hex(p.border), "line2": hex(fade(p.border, 0.78)), "focus": hex(p.focus), "accent": hex(p.accent),
"accent-ink": hex(mix(p.accent, p.text, 0.18)), "danger": hex(p.danger), "ok": hex(p.up), "up": hex(p.up),
"bubble-user": hex(p.bubble_user), "bubble-user-ink": hex(if p.bubble_user.a() == 255 { p.on_primary } else { p.text }), "bubble-bot": hex(p.hover), "card": hex(p.elevated), "muted": hex(p.muted),
"attention": hex(p.attention), "attention-bg": hex(p.attention_bg), "grid": hex(p.grid),
});
for (i, c) in p.chart_cat.iter().enumerate() {
v[format!("cat{}", i + 1)] = json!(hex(*c));
}
v
}
/// A notification on the person's phones (through the relay; phones that turned them on). /// A notification on the person's phones (through the relay; phones that turned them on).
pub fn notify(kind: Notice, title: &str, body: &str, bot: u64) { pub fn notify(kind: Notice, title: &str, body: &str, bot: u64) {
let s = hub().settings(); let s = hub().settings();
@ -2634,13 +2681,25 @@ mod tests {
let ok = handle(Req { method: "POST".into(), path: "/api/login".into(), body: br#"{"password":"pw-123","device":"iPhone"}"#.to_vec(), ..Default::default() }, false); let ok = handle(Req { method: "POST".into(), path: "/api/login".into(), body: br#"{"password":"pw-123","device":"iPhone"}"#.to_vec(), ..Default::default() }, false);
assert_eq!(ok.status, 200); assert_eq!(ok.status, 200);
let token = serde_json::from_slice::<Value>(&ok.body).unwrap()["token"].as_str().unwrap().to_string(); let token = serde_json::from_slice::<Value>(&ok.body).unwrap()["token"].as_str().unwrap().to_string();
hub().publish(View { host: "測試 Mac".into(), bots: vec![json!({"id": 1, "name": "小助理"})], ..Default::default() }); let colours = json!({"light": palette_json(&crate::theme::shell(1.0, "clay", 1.0, false)), "dark": palette_json(&crate::theme::shell(1.0, "clay", 1.0, true))});
hub().publish(View { host: "測試 Mac".into(), bots: vec![json!({"id": 1, "name": "小助理"})], theme: "dark".into(), palettes: colours, ..Default::default() });
let mut req = Req { method: "GET".into(), path: "/api/state".into(), ..Default::default() }; let mut req = Req { method: "GET".into(), path: "/api/state".into(), ..Default::default() };
req.headers.insert("authorization".into(), format!("Bearer {token}")); req.headers.insert("authorization".into(), format!("Bearer {token}"));
let st = handle(req.clone(), false); let st = handle(req.clone(), false);
assert_eq!(st.status, 200, "{}", String::from_utf8_lossy(&st.body)); assert_eq!(st.status, 200, "{}", String::from_utf8_lossy(&st.body));
let v: Value = serde_json::from_slice(&st.body).unwrap(); let v: Value = serde_json::from_slice(&st.body).unwrap();
assert_eq!(v["bots"][0]["name"], "小助理"); assert_eq!(v["bots"][0]["name"], "小助理");
// The desktop's 外觀 rides along: its 主題, and its colours as the phone's CSS variables.
assert_eq!(v["theme"], "dark");
for side in ["light", "dark"] {
for k in ["pane", "side", "elev", "hover", "text", "text2", "text3", "line", "accent", "accent-ink", "danger", "attention", "attention-bg", "bubble-user", "bubble-user-ink", "grid", "up", "cat1", "cat6"] {
let c = v["palettes"][side][k].as_str().unwrap_or_else(|| panic!("{side} {k} missing"));
assert!(c.starts_with('#') && (c.len() == 7 || c.len() == 9) && c[1..].chars().all(|x| x.is_ascii_hexdigit()), "{side} {k}: {c}");
}
}
// The shipped 紙 is what the phone had built in; dark is dark.
assert_eq!(v["palettes"]["light"]["pane"], "#faf9f6");
assert_ne!(v["palettes"]["dark"]["pane"], v["palettes"]["light"]["pane"]);
// Sending queues a command for the app. // Sending queues a command for the app.
let mut send = Req { method: "POST".into(), path: "/api/bots/1/send".into(), body: r#"{"text":"你好"}"#.as_bytes().to_vec(), ..Default::default() }; let mut send = Req { method: "POST".into(), path: "/api/bots/1/send".into(), body: r#"{"text":"你好"}"#.as_bytes().to_vec(), ..Default::default() };
send.headers = req.headers.clone(); send.headers = req.headers.clone();