立即執行的例行任務,泡泡跟著「聊天的顏色」:叫醒 Bot 的訊息(例行任務時間到、觸發、訊息管道、其他 Bot 傳來、目標的下一輪、工作流的一步)照舊是淡灰的氣泡、上面一行小標——不是你剛打的;你按「立即執行」或請 Bot 立即執行(run_routine_now,告訴 Bot「使用者叫的」)的那則算你的,氣泡跟著聊天的顏色(上面照樣標「例行任務」)。以前也是淡灰,改了聊天的顏色看起來像沒生效(11/22)。電腦(chat_ui::quiet_bubble)和手機(mobile/index.html isRunNow,用同一句 RUN_NOW)一樣。FEATURES、功能地圖 appearance、routines(立即執行那則的字)跟著改。

已驗證: cargo test 全部(918,含新的 a_routine_run_by_hand_wears_the_chats_colour:手按的不是淡灰、仍標例行任務;時間到、觸發、同事、工作流、舊的 ⏰ 是淡灰;手機頁面用同一句、同樣畫)、featuremap::。
未驗證: verify-anybot 照 appearance、routines 的步驟實跑(這次只 commit,沒有開 scratch 跑);電腦版的泡泡顏色要開視窗看。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
王性驊 2026-11-25 14:11:54 +08:00
parent 2abcfc1af4
commit e138152cc1
5 changed files with 44 additions and 8 deletions

View File

@ -219,6 +219,7 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。
- 「安靜」(預設):淡灰的氣泡、一般的黑字,像 Claude。 - 「安靜」(預設):淡灰的氣泡、一般的黑字,像 Claude。
- 「跟著 Bot」:用那個 Bot 的顏色配白字(Bot 本身是黑色時用黑色氣泡)。 - 「跟著 Bot」:用那個 Bot 的顏色配白字(Bot 本身是黑色時用黑色氣泡)。
- 「只用黑色」:黑色氣泡。 - 「只用黑色」:黑色氣泡。
- 叫醒 Bot 的訊息(例行任務時間到、觸發、訊息管道、其他 Bot 傳來、目標的下一輪、工作流的一步)上面一行小標,氣泡不管「聊天的顏色」一律淡灰:不是你剛打的。立即執行的例行任務(你按的,或你請 Bot 立即執行的)算你的,氣泡跟著「聊天的顏色」(上面照樣標「例行任務」;以前也是淡灰,改了顏色看起來像沒生效)。手機一樣。
- 最後一則是你的訊息、而且 Bot 沒有在回覆時(例如 App 在回覆前被關掉),下方會出現小字「還沒有回覆」和小按鈕「重新傳送」。 - 最後一則是你的訊息、而且 Bot 沒有在回覆時(例如 App 在回覆前被關掉),下方會出現小字「還沒有回覆」和小按鈕「重新傳送」。
- 這則訊息有帶記憶給模型時,氣泡下方有小字「帶了 N 條記憶」,提示「這則訊息送給模型時附上的記憶」。點開列出是哪幾條,旁邊有「打開記憶頁」。 - 這則訊息有帶記憶給模型時,氣泡下方有小字「帶了 N 條記憶」,提示「這則訊息送給模型時附上的記憶」。點開列出是哪幾條,旁邊有「打開記憶頁」。
@ -1898,7 +1899,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開)
- 每 1 秒檢查一次。 - 每 1 秒檢查一次。
- Bot 忙的時候,等它閒下來再跑;每個 Bot 一次只觸發一個。 - Bot 忙的時候,等它閒下來再跑;每個 Bot 一次只觸發一個。
- Bot 收到的訊息是「⏰ 例行任務「標題」時間到了:要做的事」,然後像平常一樣工作。按「立即執行」時是「「標題」現在就執行(使用者叫的,不是排定的時間):要做的事」——不說時間到了,Bot 不會以為是排程的時間。 - Bot 收到的訊息是「[例行任務]「標題」時間到了:要做的事」(很舊的聊天存的是「⏰ 」開頭),然後像平常一樣工作。按「立即執行」時是「「標題」現在就執行(使用者叫的,不是排定的時間):要做的事」——不說時間到了,Bot 不會以為是排程的時間。聊天裡它的氣泡跟著「聊天的顏色」(你按的、或請 Bot 立即執行的都算你叫的),時間到自己跑的是淡灰。
- 如果那個 Bot 不在目前畫面上,會標成未讀。 - 如果那個 Bot 不在目前畫面上,會標成未讀。
### 例行任務視窗(頂部「例行任務」按鈕) ### 例行任務視窗(頂部「例行任務」按鈕)

View File

@ -6,7 +6,7 @@ AnyBot 長什麼樣子、用什麼語言,和怎麼聽、怎麼說:設定 ›
- `appearance-style` 風格(外觀最上面一排小圖,每張就是那個風格的樣子):紙(預設)、夜、墨、苔(點點)、海(波浪)、糖(點點)、夕陽(波浪)、終端機(格線)——一套淺色和深色的顏色,加上聊天背景的花紋;電腦和手機一起換(手機 設定 › 一般 最上面同一排)。點下面的強調色或動「底色」回到自訂(小圖下寫「現在是自訂的顏色」)。 - `appearance-style` 風格(外觀最上面一排小圖,每張就是那個風格的樣子):紙(預設)、夜、墨、苔(點點)、海(波浪)、糖(點點)、夕陽(波浪)、終端機(格線)——一套淺色和深色的顏色,加上聊天背景的花紋;電腦和手機一起換(手機 設定 › 一般 最上面同一排)。點下面的強調色或動「底色」回到自訂(小圖下寫「現在是自訂的顏色」)。
- `appearance-theme` 主題:淺色/深色/跟隨系統;手機的外觀預設跟著電腦([phone](phone.md))。 - `appearance-theme` 主題:淺色/深色/跟隨系統;手機的外觀預設跟著電腦([phone](phone.md))。
- `appearance-colors` 強調色(八個點:黏土、靛藍、苔綠、藍綠、玫紅、琥珀、石板、墨黑)、聊天的顏色(你的訊息泡泡:安靜=淡灰,預設;跟著 Bot;只用黑色——手機同一個設定;只有點,選中的有外圈)。 - `appearance-colors` 強調色(八個點:黏土、靛藍、苔綠、藍綠、玫紅、琥珀、石板、墨黑)、聊天的顏色(你的訊息泡泡:安靜=淡灰,預設;跟著 Bot;只用黑色——手機同一個設定;只有點,選中的有外圈;立即執行的例行任務(你按的或請 Bot 跑的)也照它;時間到自己跑的、觸發、其他 Bot 傳來、工作流的一步一律淡灰)。
- `appearance-language` 語言:選單和 Bot 回答用的語言。 - `appearance-language` 語言:選單和 Bot 回答用的語言。
- `appearance-more` 外觀最後一列「更多外觀設定」按「展開」才出現:底色(冷→暖滑桿)、對比(柔和→鮮明滑桿)、密度(寬鬆/緊湊)、慶祝動畫(開/關,目標達成時撒彩帶)、頭像動態(自動/完整/減少:Bot 頭像做事時的呼吸和眼神,減少只換表情;自動在畫面用 CPU 畫的電腦上減少,那時下面寫「這台的畫面用 CPU 畫,自動減少」)、外殼顏色重設(回預設「紙」)。這幾項和上面的一樣,調了立刻整個殼跟著換,不用重開。 - `appearance-more` 外觀最後一列「更多外觀設定」按「展開」才出現:底色(冷→暖滑桿)、對比(柔和→鮮明滑桿)、密度(寬鬆/緊湊)、慶祝動畫(開/關,目標達成時撒彩帶)、頭像動態(自動/完整/減少:Bot 頭像做事時的呼吸和眼神,減少只換表情;自動在畫面用 CPU 畫的電腦上減少,那時下面寫「這台的畫面用 CPU 畫,自動減少」)、外殼顏色重設(回預設「紙」)。這幾項和上面的一樣,調了立刻整個殼跟著換,不用重開。
- `appearance-fonts` 字型:沒有字型選項:跟 Apple 一樣,介面和讀的文字(回答、頁面)都是 SF Pro 加蘋方(PingFang TC),粗體用半粗(Semibold);沒有蘋方的電腦用包在 App 裡的思源黑體。設定列名稱旁的「?」平常不顯示,滑鼠移到那一列才出現;設定下面的說明只有一行,長的滑過看全文。 - `appearance-fonts` 字型:沒有字型選項:跟 Apple 一樣,介面和讀的文字(回答、頁面)都是 SF Pro 加蘋方(PingFang TC),粗體用半粗(Semibold);沒有蘋方的電腦用包在 App 裡的思源黑體。設定列名稱旁的「?」平常不顯示,滑鼠移到那一列才出現;設定下面的說明只有一行,長的滑過看全文。

View File

@ -11,7 +11,7 @@ Bot 照排程(每天、每週、每月、只一次)或某件事發生時(P
- `routines-carry` 上次的問題帶進下次:上次失敗,下次的指令會附原因;上次被 AnyBot 關掉打斷,會提醒先確認做過哪些。 - `routines-carry` 上次的問題帶進下次:上次失敗,下次的指令會附原因;上次被 AnyBot 關掉打斷,會提醒先確認做過哪些。
- `routines-pause` 自動暫停:連續失敗 2 次就暫停,聊天裡留一行原因,不在電腦前時跳通知。按「繼續」清掉原因。 - `routines-pause` 自動暫停:連續失敗 2 次就暫停,聊天裡留一行原因,不在電腦前時跳通知。按「繼續」清掉原因。
- `routines-target` 完成條件 `target_sends`:這次要送出幾則。系統自己數:數到就不准再送;做完時不到這個數算失敗;連續兩輪(50 步)沒有新的送出就停下這一輪。 - `routines-target` 完成條件 `target_sends`:這次要送出幾則。系統自己數:數到就不准再送;做完時不到這個數算失敗;連續兩輪(50 步)沒有新的送出就停下這一輪。
- `routines-now` 立即執行。 - `routines-now` 立即執行(你按的或請 Bot 跑的):聊天裡那則的泡泡跟著「聊天的顏色」,時間到自己跑的是淡灰。
## 使用者怎麼到 ## 使用者怎麼到
@ -28,7 +28,7 @@ Bot 照排程(每天、每週、每月、只一次)或某件事發生時(P
- 基本前提和「手機已登入」(README)。例行任務從 #1 編起;同事的 Bot 是 2。 - 基本前提和「手機已登入」(README)。例行任務從 #1 編起;同事的 Bot 是 2。
- **建三條**(covers `routines-schedule`、`routines-target`):首頁「例行任務」›「新增例行任務」建一條每天的;建一個 Bot「同事」,在 Bot 1 的聊天請它建兩條要送 1 則的。指令:`$CTL phone click '[data-q="routines"]' && $CTL phone click '#rt-new' && $CTL phone type '#rt-title' 早報 && $CTL phone type '#rt-prompt' 整理重點 && $CTL phone click '#rt-ok' && $CTL phone wait-text '每天 09:00' --in '#list' && $CTL phone open --listed && $CTL phone click '#b-newbot' && $CTL phone click '#sheet-in .opt' --text '建立 Bot' && $CTL phone type '#ask-in' 同事 && $CTL phone click '#ask-ok' && $CTL phone wait-text 同事 --in '#isl-name' && $CTL phone open --listed && $CTL phone click '.row[data-bot="1"]' && $CTL phone send '[[call create_routine {"title":"回覆","prompt":"回一則","schedule":{"frequency":"weekly","daysOfWeek":["MO","WE"],"time":"10:00"},"target_sends":1}]]' && $CTL phone wait-text '已建立例行任務 #2' --in '#msgs' && $CTL phone send '[[call create_routine {"title":"打招呼","prompt":"跟同事說早安","schedule":{"frequency":"monthly","monthDay":1,"time":"08:00"},"target_sends":1}]]' && $CTL phone wait-text '已建立例行任務 #3' --in '#msgs' && $CTL api GET /api/bots/1/detail --jq '[.routines[] | "\(.title) \(.repeat) \(.when) \(.target)"]'`。看到:「每天 09:00 · 下次 …」;「已建立例行任務 #2 「回覆」:每週…」;三條的排程,後兩條「完成條件:送出 1 則」。 - **建三條**(covers `routines-schedule`、`routines-target`):首頁「例行任務」›「新增例行任務」建一條每天的;建一個 Bot「同事」,在 Bot 1 的聊天請它建兩條要送 1 則的。指令:`$CTL phone click '[data-q="routines"]' && $CTL phone click '#rt-new' && $CTL phone type '#rt-title' 早報 && $CTL phone type '#rt-prompt' 整理重點 && $CTL phone click '#rt-ok' && $CTL phone wait-text '每天 09:00' --in '#list' && $CTL phone open --listed && $CTL phone click '#b-newbot' && $CTL phone click '#sheet-in .opt' --text '建立 Bot' && $CTL phone type '#ask-in' 同事 && $CTL phone click '#ask-ok' && $CTL phone wait-text 同事 --in '#isl-name' && $CTL phone open --listed && $CTL phone click '.row[data-bot="1"]' && $CTL phone send '[[call create_routine {"title":"回覆","prompt":"回一則","schedule":{"frequency":"weekly","daysOfWeek":["MO","WE"],"time":"10:00"},"target_sends":1}]]' && $CTL phone wait-text '已建立例行任務 #2' --in '#msgs' && $CTL phone send '[[call create_routine {"title":"打招呼","prompt":"跟同事說早安","schedule":{"frequency":"monthly","monthDay":1,"time":"08:00"},"target_sends":1}]]' && $CTL phone wait-text '已建立例行任務 #3' --in '#msgs' && $CTL api GET /api/bots/1/detail --jq '[.routines[] | "\(.title) \(.repeat) \(.when) \(.target)"]'`。看到:「每天 09:00 · 下次 …」;「已建立例行任務 #2 「回覆」:每週…」;三條的排程,後兩條「完成條件:送出 1 則」。
- **立即執行、紀錄**(covers `routines-now`、`routines-runs`、`routines-fresh`):點「早報」›「立即執行」,重新整理再點開。指令:`$CTL phone open --listed && $CTL phone click '[data-q="routines"]' && $CTL phone click '[data-rt="1:1"]' && $CTL phone click '#sheet-in .opt' --text 立即執行 && $CTL wait-api /api/bots/1/detail '.routines[0].runs[0].line | test("完成")' && $CTL phone open --listed && $CTL phone click '[data-q="routines"]' && $CTL phone click '[data-rt="1:1"]' && $CTL phone wait-text 最近執行 --in '#sheet-in' && $CTL phone shot routines-run && $CTL api GET /api/bots/1 --jq '[.messages[] | select(.wake) | .text]'`。看到:Bot 1 收到「[例行任務]「早報」時間到了:整理重點」;「最近執行」一行「…完成:FAKE-MODEL 回答:…」、「上次 今天 …」。 - **立即執行、紀錄**(covers `routines-now`、`routines-runs`、`routines-fresh`):點「早報」›「立即執行」,重新整理再點開。指令:`$CTL phone open --listed && $CTL phone click '[data-q="routines"]' && $CTL phone click '[data-rt="1:1"]' && $CTL phone click '#sheet-in .opt' --text 立即執行 && $CTL wait-api /api/bots/1/detail '.routines[0].runs[0].line | test("完成")' && $CTL phone open --listed && $CTL phone click '[data-q="routines"]' && $CTL phone click '[data-rt="1:1"]' && $CTL phone wait-text 最近執行 --in '#sheet-in' && $CTL phone shot routines-run && $CTL api GET /api/bots/1 --jq '[.messages[] | select(.wake) | .text]'`。看到:Bot 1 收到「[例行任務]「早報」現在就執行(使用者叫的,不是排定的時間):整理重點」;「最近執行」一行「…完成:FAKE-MODEL 回答:…」、「上次 今天 …」。
- **不到數算失敗、兩次就暫停、繼續**(covers `routines-target`、`routines-pause`、`routines-carry`、`routines-runs`):「回覆」立即執行兩次,再按「繼續」。指令:`$CTL phone click '[data-back]' && $CTL api POST /api/act/app '{"name":"run_routine_now","args":{"id":2},"bot":1}' && $CTL wait-api /api/bots/1/detail '.routines[1].runs[0].bad' && $CTL api POST /api/act/app '{"name":"run_routine_now","args":{"id":2},"bot":1}' && $CTL wait-api /api/bots/1/detail '.routines[1].paused' && $CTL phone open --listed && $CTL phone click '.row[data-bot="1"]' && $CTL phone wait-text '連續 2 次失敗,AnyBot 先暫停了' --in '#msgs' && $CTL phone click '#island' && $CTL phone click '[data-tab="routines"]' && $CTL phone wait-text 打招呼 --in '#details' && $CTL wait-api /api/bots/1/detail '.routines | length == 3' && $CTL api GET /api/bots/1 --jq '[.messages[] | select(.wake) | .text][-1]' && $CTL phone open --listed && $CTL phone click '[data-q="routines"]' && $CTL phone click '[data-rt="1:2"]' && $CTL phone wait-text '只送出 0/1 則(系統計數)' --in '#sheet-in' && $CTL phone click '#sheet-in .opt' --text 繼續 && $CTL wait-api /api/bots/1/detail '.routines[1] | (.paused | not) and .paused_why == ""'`。看到:兩次都是「失敗:只送出 0/1 則(系統計數):…」;第二次的任務訊息多「(上一次執行沒有成功:只送出 0/1 則…)」;聊天「例行任務「回覆」連續 2 次失敗,AnyBot 先暫停了。…按繼續。」;詳細資訊的「例行任務」有三條;按繼續後不再暫停、原因清掉。 - **不到數算失敗、兩次就暫停、繼續**(covers `routines-target`、`routines-pause`、`routines-carry`、`routines-runs`):「回覆」立即執行兩次,再按「繼續」。指令:`$CTL phone click '[data-back]' && $CTL api POST /api/act/app '{"name":"run_routine_now","args":{"id":2},"bot":1}' && $CTL wait-api /api/bots/1/detail '.routines[1].runs[0].bad' && $CTL api POST /api/act/app '{"name":"run_routine_now","args":{"id":2},"bot":1}' && $CTL wait-api /api/bots/1/detail '.routines[1].paused' && $CTL phone open --listed && $CTL phone click '.row[data-bot="1"]' && $CTL phone wait-text '連續 2 次失敗,AnyBot 先暫停了' --in '#msgs' && $CTL phone click '#island' && $CTL phone click '[data-tab="routines"]' && $CTL phone wait-text 打招呼 --in '#details' && $CTL wait-api /api/bots/1/detail '.routines | length == 3' && $CTL api GET /api/bots/1 --jq '[.messages[] | select(.wake) | .text][-1]' && $CTL phone open --listed && $CTL phone click '[data-q="routines"]' && $CTL phone click '[data-rt="1:2"]' && $CTL phone wait-text '只送出 0/1 則(系統計數)' --in '#sheet-in' && $CTL phone click '#sheet-in .opt' --text 繼續 && $CTL wait-api /api/bots/1/detail '.routines[1] | (.paused | not) and .paused_why == ""'`。看到:兩次都是「失敗:只送出 0/1 則(系統計數):…」;第二次的任務訊息多「(上一次執行沒有成功:只送出 0/1 則…)」;聊天「例行任務「回覆」連續 2 次失敗,AnyBot 先暫停了。…按繼續。」;詳細資訊的「例行任務」有三條;按繼續後不再暫停、原因清掉。
- **送到了、送出證據**(covers `routines-target`、`routines-runs`):「打招呼」立即執行,它傳訊息給同事。指令:`$CTL model-reply '「打招呼」現在就執行' '[[call message_bot {"bot":"同事","text":"早安"}]] 送了' && $CTL api POST /api/act/app '{"name":"run_routine_now","args":{"id":3},"bot":1}' && $CTL wait-api /api/bots/1/detail '.routines[2].runs[0].line | test("完成")' && $CTL api GET /api/bots/1/detail --jq '.routines[2].runs[0]' && $CTL api GET /api/bots/2 --jq '[.messages[].text]'`。看到:「完成(1 步,系統記到送出 1 次):送了」,送出證據一行「傳訊息給其他 Bot 給 同事:早安」(照步驟的名字寫,不是 message_bot);同事收到「[來自 Bot]「驗證小幫手」:早安」。 - **送到了、送出證據**(covers `routines-target`、`routines-runs`):「打招呼」立即執行,它傳訊息給同事。指令:`$CTL model-reply '「打招呼」現在就執行' '[[call message_bot {"bot":"同事","text":"早安"}]] 送了' && $CTL api POST /api/act/app '{"name":"run_routine_now","args":{"id":3},"bot":1}' && $CTL wait-api /api/bots/1/detail '.routines[2].runs[0].line | test("完成")' && $CTL api GET /api/bots/1/detail --jq '.routines[2].runs[0]' && $CTL api GET /api/bots/2 --jq '[.messages[].text]'`。看到:「完成(1 步,系統記到送出 1 次):送了」,送出證據一行「傳訊息給其他 Bot 給 同事:早安」(照步驟的名字寫,不是 message_bot);同事收到「[來自 Bot]「驗證小幫手」:早安」。
- **桌面的例行任務視窗**(covers `routines-runs`、`routines-now`):指令:要開視窗——`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot routines ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_VIEW=panel && ABV_ALLOW_WINDOW=1 $CTL desktop-shot routines-demo ANYBOT_SHOT_VIEW=routines`(第二張是示範資料:真資料的截圖開不了例行任務視窗)。看到:右側面板「例行任務」列出這次建的(標題、時間或「已暫停」);示範視窗只有一張「AI 新聞早報」卡——示範資料沒有暫停原因、完成條件、執行紀錄,這三樣靠上面的步驟和 `cargo test routines::`。 - **桌面的例行任務視窗**(covers `routines-runs`、`routines-now`):指令:要開視窗——`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot routines ANYBOT_SHOT_REAL=1 ANYBOT_SHOT_VIEW=panel && ABV_ALLOW_WINDOW=1 $CTL desktop-shot routines-demo ANYBOT_SHOT_VIEW=routines`(第二張是示範資料:真資料的截圖開不了例行任務視窗)。看到:右側面板「例行任務」列出這次建的(標題、時間或「已暫停」);示範視窗只有一張「AI 新聞早報」卡——示範資料沒有暫停原因、完成條件、執行紀錄,這三樣靠上面的步驟和 `cargo test routines::`。

View File

@ -2376,6 +2376,8 @@ function renderMsgs() {
} }
if (m.role === "user") { if (m.role === "user") {
const wt = m.wake ? wakeTag(m.text) : null; const wt = m.wake ? wakeTag(m.text) : null;
// (Quiet unless the person sent it: a routine they ran by hand wears the chat's colour.)
const quiet = wt && !isRunNow(m.text);
const tag = wt ? `<div class="tag">${ic(wt.icon, 12)} ${esc(wt.label)}</div>` : ""; const tag = wt ? `<div class="tag">${ic(wt.icon, 12)} ${esc(wt.label)}</div>` : "";
if (wt) m = {...m, text: wt.body}; if (wt) m = {...m, text: wt.body};
const q = String(m.text || "").match(/^((?:>.*\n?)+)\n*([\s\S]*)$/); const q = String(m.text || "").match(/^((?:>.*\n?)+)\n*([\s\S]*)$/);
@ -2384,7 +2386,7 @@ function renderMsgs() {
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>` : ""}` : "";
h += `<div class="m user${wt ? " woke" : ""}${fr(i)}" data-msg="${i}">${tag}${m.text ? `<div class="bub">${quote}${esc(text)}</div>` : ""}${(m.attachments || []).map(attHtml).join("")}${reacts}${carried}</div>`; h += `<div class="m user${quiet ? " woke" : ""}${fr(i)}" data-msg="${i}">${tag}${m.text ? `<div class="bub">${quote}${esc(text)}</div>` : ""}${(m.attachments || []).map(attHtml).join("")}${reacts}${carried}</div>`;
return; return;
} }
const t = turnOf[i]; const t = turnOf[i];
@ -2727,6 +2729,11 @@ const COMMANDS = [{name: "goal", description: "設一個目標,一直做到達
* desktop): [tag, icon, label], and the words after it. 監看's tag carries the command's number, so * desktop): [tag, icon, label], and the words after it. 監看's tag carries the command's number, so
* its words stay whole. (Every wake used to say 例行任務 — a 監看's lines, a colleague's message.) */ * its words stay whole. (Every wake used to say 例行任務 — a 監看's lines, a colleague's message.) */
const WAKE_TAGS = [["[目標]", "target", "目標"], ["[例行任務]", "alarm-clock", "例行任務"], ["[觸發]", "zap", "觸發"], ["[訊息管道]", "message", "訊息管道"], ["[來自 Bot]", "bot", "來自其他 Bot"], ["[交付]", "circle-alert", "交付沒顯示"], ["[核對]", "circle-alert", "回覆沒對上"], ["⏰ ", "alarm-clock", "例行任務"], ["⚡ ", "zap", "觸發"], ["💬 ", "message", "訊息管道"], ["📨 ", "bot", "來自其他 Bot"]]; const WAKE_TAGS = [["[目標]", "target", "目標"], ["[例行任務]", "alarm-clock", "例行任務"], ["[觸發]", "zap", "觸發"], ["[訊息管道]", "message", "訊息管道"], ["[來自 Bot]", "bot", "來自其他 Bot"], ["[交付]", "circle-alert", "交付沒顯示"], ["[核對]", "circle-alert", "回覆沒對上"], ["⏰ ", "alarm-clock", "例行任務"], ["⚡ ", "zap", "觸發"], ["💬 ", "message", "訊息管道"], ["📨 ", "bot", "來自其他 Bot"]];
/** What 立即執行 tells the bot in place of 「時間到了」 (appctl::RUN_NOW): the person ran that
* routine (pressed, or asked a bot to), so its bubble wears the chat's colour like what they type;
* the other tagged wakes are quiet (app::chat_ui::quiet_bubble on the desktop). */
const RUN_NOW = "現在就執行(使用者叫的,不是排定的時間):";
const isRunNow = (text) => String(text || "").startsWith("[例行任務]") && String(text).split("\n")[0].includes(RUN_NOW);
function wakeTag(text) { function wakeTag(text) {
const t = String(text || ""); const t = String(text || "");
for (const [tag, icon, label] of WAKE_TAGS) if (t.startsWith(tag)) return {icon, label, body: t.slice(tag.length)}; for (const [tag, icon, label] of WAKE_TAGS) if (t.startsWith(tag)) return {icon, label, body: t.slice(tag.length)};

View File

@ -595,10 +595,10 @@ impl App {
} }
// Messages that woke the bot (a routine, a trigger, a channel, another bot, a workflow's // Messages that woke the bot (a routine, a trigger, a channel, another bot, a workflow's
// step) carry a tag: shown as a small line with an icon above the bubble, not inside it, // step) carry a tag: shown as a small line with an icon above the bubble, not inside it,
// and the bubble is a quiet one — the person didn't type it just now. // and the bubble is a quiet one — the person didn't type it just now (quiet_bubble).
let (tag, body) = wake_tag(&m.text); let (tag, body) = wake_tag(&m.text);
let flow = workflow_tag(&m.text); let flow = workflow_tag(&m.text);
let woke = tag.is_some() || flow.is_some(); let quiet = quiet_bubble(&m.text);
if let Some((icon, label)) = tag { if let Some((icon, label)) = tag {
ui.with_layout(Layout::right_to_left(Align::Min), |ui| { ui.with_layout(Layout::right_to_left(Align::Min), |ui| {
crate::icons::label(ui, icon, &t(label), 12.0, p.text3); crate::icons::label(ui, icon, &t(label), 12.0, p.text3);
@ -619,7 +619,7 @@ impl App {
let hover_id = egui::Id::unique(("hover-user", bot.id, idx)); let hover_id = egui::Id::unique(("hover-user", bot.id, idx));
let was_hovered = ctx.data(|d| d.get_temp::<bool>(hover_id)).unwrap_or(false); let was_hovered = ctx.data(|d| d.get_temp::<bool>(hover_id)).unwrap_or(false);
let row = ui.with_layout(Layout::right_to_left(Align::Center), |ui| { let row = ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
let (fill, text_col) = if woke { (p.hover, p.text) } else { self.user_bubble(bot) }; let (fill, text_col) = if quiet { (p.hover, p.text) } else { self.user_bubble(bot) };
let max_w = message_max_width(ui.available_width()); let max_w = message_max_width(ui.available_width());
// As wide as the words (up to the column's limit), lines reading left to right. // As wide as the words (up to the column's limit), lines reading left to right.
let rich = RichText::new(&shown_text).size(TRANSCRIPT_FONT).line_height(Some(TRANSCRIPT_LINE_HEIGHT)).color(text_col); let rich = RichText::new(&shown_text).size(TRANSCRIPT_FONT).line_height(Some(TRANSCRIPT_LINE_HEIGHT)).color(text_col);
@ -1242,6 +1242,16 @@ pub fn wake_tag(text: &str) -> (Option<(crate::icons::Icon, &'static str)>, &str
(None, text) (None, text)
} }
/// Whether a message to the bot gets the quiet (light grey) bubble whatever 聊天的顏色 says: it
/// woke the bot and the person didn't send it — a routine on its time, a trigger, a channel,
/// another bot, a goal's next turn, a workflow's step. A routine run by hand (立即執行 — pressed,
/// or a bot asked to run_routine_now, which tells the bot 使用者叫的 too) is theirs: it wears the
/// chat's colour like what they type (it stayed grey, and 聊天的顏色 looked broken, 11/22). The
/// phone does the same (mobile/index.html isRunNow).
pub fn quiet_bubble(text: &str) -> bool {
(wake_tag(text).0.is_some() || workflow_tag(text).is_some()) && !crate::appctl::is_run_now(text)
}
/// A workflow's question to a bot: "[工作流「X」第 k/n 步…]…" → the tag's words, and the /// A workflow's question to a bot: "[工作流「X」第 k/n 步…]…" → the tag's words, and the
/// words after it. /// words after it.
pub fn workflow_tag(text: &str) -> Option<(&str, &str)> { pub fn workflow_tag(text: &str) -> Option<(&str, &str)> {
@ -1288,6 +1298,24 @@ mod tests {
assert!(!page.contains("m.via || \"例行任務\"")); assert!(!page.contains("m.via || \"例行任務\""));
} }
/// A routine the person ran by hand (立即執行) wears 聊天的顏色 like what they type; one on its
/// time, a trigger, a colleague, a workflow's step keep the quiet bubble — on the phone too.
#[test]
fn a_routine_run_by_hand_wears_the_chats_colour() {
let r: crate::routines::Routine = serde_json::from_value(serde_json::json!({"id": 1, "title": "早報", "prompt": "整理重點",
"schedule": crate::routines::validate(serde_json::from_value(serde_json::json!({"frequency": "daily", "time": "09:00", "timezone": "Asia/Taipei"})).unwrap()).unwrap(), "created_at": 0})).unwrap();
let by_hand = crate::appctl::run_now_message(&r).text;
assert!(!quiet_bubble(&by_hand), "{by_hand}");
assert_eq!(wake_tag(&by_hand).0.map(|(_, l)| l), Some("例行任務"), "still tagged");
for woke in [crate::appctl::wake_message(&r).text, "[觸發]新信:…".into(), "[來自 Bot]「同事」:早安".into(), crate::workflow::step_message("早報", 1, 2, "整理", ""), "⏰ 提醒:繳電費".into()] {
assert!(quiet_bubble(&woke), "{woke}");
}
assert!(!quiet_bubble("你好") && !quiet_bubble(&format!("{}{}", "幫我", crate::appctl::RUN_NOW)), "what the person types");
let page = include_str!("../../mobile/index.html");
assert!(page.contains(&format!("const RUN_NOW = \"{}\";", crate::appctl::RUN_NOW)), "the phone knows the same words");
assert!(page.contains("const quiet = wt && !isRunNow(m.text);") && page.contains("${quiet ? \" woke\" : \"\"}"), "and draws it the same");
}
/// A workflow's question shows under its own tag, in a quiet bubble, with the previous /// A workflow's question shows under its own tag, in a quiet bubble, with the previous
/// step's result cut short (it read as something the person typed, all of it). /// step's result cut short (it read as something the person typed, all of it).
#[test] #[test]