diff --git a/FEATURES.md b/FEATURES.md index 9f1dcc3..d683add 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -1588,6 +1588,11 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開) - 檔案不在原處(刪掉或搬走):灰字、紅字「不見了」,點不開。其他點一下用 AnyBot 的檢視器打開(Markdown、表格、圖片、PDF、影音、程式碼;用其他 App 打開、下載)。 - 螢幕電腦看的是從大腦抓過來的副本。手機還沒有(只有每個對話的「資料庫」)。功能地圖新的一區 library.md。 +### 頭像的表情(側邊欄、釘選、右側面板、任務卡) + +- 輸入框上方那張臉本來就看狀態換表情;現在其他地方的 Bot 頭像也一樣(計畫 C2):等你允許或回答時往上看你;上網時眼睛左右掃、看畫面時往右上看、寫字時往下看、想事情或讀結果時往左上看、其他步驟慢慢左右讀;做事時微微呼吸(2.6 秒一次、3%,從腳往上);上一輪失敗是兩條平的眼睛(以前側邊欄看不出失敗),剛做完笑兩秒;閒著時跟著滑鼠。做事時一個樣子至少停 1.4 秒。 +- 設定 › 一般 › 更多外觀設定 ›「頭像動態」:自動/完整/減少。減少只換表情、不動,也不為了動畫一直重畫;自動在畫面用 CPU 畫的電腦(沒有顯示卡加速)減少。是這台自己的設定(跟外觀一起,螢幕電腦不被大腦蓋掉)。截圖用 `ANYBOT_SHOT_MOTION=calm|full`。 + ### 搜尋設定(設定視窗左欄) - 左欄最上面「搜尋設定…」。打字時頁面清單換成符合的設定,最多 12 個:標題開頭相符的在前,再來標題包含的,再來所在區塊或別的說法(每個設定登記了人會打的字:「深色」→ 主題、「billing」「花費」→ 用量、「Wi-Fi」「Tailscale」→ 同一個網路直接連;模型供應商用名字找)。每個下面一行寫在哪(「一般 › Bot」「整合 › 連接器」)。 diff --git a/docs/feature-map/appearance.md b/docs/feature-map/appearance.md index 9969f5d..49cf410 100644 --- a/docs/feature-map/appearance.md +++ b/docs/feature-map/appearance.md @@ -7,7 +7,7 @@ AnyBot 長什麼樣子、用什麼語言,和怎麼聽、怎麼說:設定 › - `appearance-theme` 主題:淺色/深色/跟隨系統;手機的外觀預設跟著電腦([phone](phone.md))。 - `appearance-colors` 強調色(八個點:黏土、靛藍、苔綠、藍綠、玫紅、琥珀、石板、墨黑)、聊天的顏色(你的訊息泡泡:安靜=淡灰,預設;跟著 Bot;只用黑色——手機同一個設定;只有點,選中的有外圈)。 - `appearance-language` 語言:選單和 Bot 回答用的語言。 -- `appearance-more` 外觀最後一列「更多外觀設定」按「展開」才出現:底色(冷→暖滑桿)、對比(柔和→鮮明滑桿)、密度(寬鬆/緊湊)、慶祝動畫(開/關,目標達成時撒彩帶)、外殼顏色重設(回預設「紙」)。這幾項和上面的一樣,調了立刻整個殼跟著換,不用重開。 +- `appearance-more` 外觀最後一列「更多外觀設定」按「展開」才出現:底色(冷→暖滑桿)、對比(柔和→鮮明滑桿)、密度(寬鬆/緊湊)、慶祝動畫(開/關,目標達成時撒彩帶)、頭像動態(自動/完整/減少:Bot 頭像做事時的呼吸和眼神,減少只換表情;自動在畫面用 CPU 畫的電腦上減少,那時下面寫「這台的畫面用 CPU 畫,自動減少」)、外殼顏色重設(回預設「紙」)。這幾項和上面的一樣,調了立刻整個殼跟著換,不用重開。 - `appearance-fonts` 字型:沒有字型選項:介面思源黑體、讀的文字(回答、頁面)思源宋體。設定列名稱旁的「?」平常不顯示,滑鼠移到那一列才出現;設定下面的說明只有一行,長的滑過看全文。 - `appearance-voice` 語音:「語音服務」一張清單,「聽(語音轉文字)」把說的話變文字(語音輸入、語音聊天、會議錄音),「說(朗讀)」把回答唸出來;各自在右邊選服務,選了在那一列下面展開要填的欄位(快速填入、網址、金鑰、模型;「說」還有「聲音」選單),能用了列上寫「可以用」,並有「試試看(說一句話)」或「試聽」。沒設定時沒有語音輸入,請 AnyBot 唸會說「還沒設定語音」。 - `appearance-voices` 「聲音」選單:第一項「預設(eve)」,下面是服務列出的聲音,選了試唸一句;拿不到清單時寫原因,可以直接輸入名稱或「再試一次」。每個 Bot 的 對話詳細資訊 › 語音聊天 ›「聲音」是同一個選單(預設是這裡選的)。 @@ -36,7 +36,7 @@ AnyBot 長什麼樣子、用什麼語言,和怎麼聽、怎麼說:設定 › ## 陷阱 -- 連到別台大腦的螢幕電腦上,語音是大腦的設定,改了存在大腦;主題、外觀(底色、強調色、對比、密度、慶祝動畫)、聊天的顏色還是這台自己的:存在這台,更新重開、大腦的設定傳來都不會蓋掉(以前外觀不算這台的,更新後強調色總是變回橘色)。外觀改了也告訴大腦,手機跟著大腦的。 +- 連到別台大腦的螢幕電腦上,語音是大腦的設定,改了存在大腦;主題、外觀(底色、強調色、對比、密度、慶祝動畫、頭像動態)、聊天的顏色還是這台自己的:存在這台,更新重開、大腦的設定傳來都不會蓋掉(以前外觀不算這台的,更新後強調色總是變回橘色)。外觀改了也告訴大腦,手機跟著大腦的。 - 語音轉文字、朗讀不能用 ChatGPT 方案,要 OpenAI 的 API 金鑰(或別的服務,[models](models.md))。 - 手機的設定頁不會自己更新:Bot 或電腦上改了主題,要重新整理 設定 › 一般 才看得到新的值(畫面的顏色會自己跟上)。 - (驗證)`ANYBOT_SHOT_VIEW=voicesettings` 帶著示範的 xAI 金鑰,「聲音」那一列一畫出來就去問 xAI 的聲音清單(連網),驗證不要用。 diff --git a/docs/feature-map/bots.md b/docs/feature-map/bots.md index 1225943..716a430 100644 --- a/docs/feature-map/bots.md +++ b/docs/feature-map/bots.md @@ -5,6 +5,7 @@ ## 子功能 - `bots-sidebar` 側邊欄:最上面是主要 Bot(大頭像),接著是釘選的格子(把 Bot 拖進去就釘選,格子裡可以拖曳排序),再來是各分區和「未分區」(分區見 [team](team.md))。每一列第二行是「正在工作…」「需要你允許」「等你回答」「等你處理」,或最後一則訊息。選中的 Bot 整列淺底(比滑過深一階),左邊沒有色條。 +- `bots-moods` 頭像的表情:側邊欄、釘選格子、右側面板和任務卡上的 Bot 頭像跟輸入框上方那張臉一樣看狀態——等你允許或回答時往上看你;上網時眼睛左右掃,看畫面時往右上看,寫字時往下看,想事情或讀回來的結果時往左上看,其他步驟慢慢左右讀;做事時微微呼吸(2.6 秒一次);上一輪失敗是兩條平的眼睛,剛做完笑兩秒;閒著時眼睛跟著滑鼠。做事時一個樣子至少停 1.4 秒,步驟換得快也不會一直閃。設定 › 一般 › 更多外觀設定 ›「頭像動態」選「減少」(「自動」在畫面用 CPU 畫的電腦上也是)只換表情、不動([appearance](appearance.md))。 - `bots-search` 搜尋「搜尋 Bot 和訊息」:上面列名字或描述相符的 Bot,下面「訊息」列你和 Bot 說過的話和附件檔名(含過去的對話,最多 40 筆),點一筆就捲到那則訊息。按 🔍 或 ⌘F 打開時游標在搜尋框;之後點輸入框打字,字就留在輸入框(搜尋框開著也不會把游標搶回去)。 - `bots-menu` Bot 選單:「釘選」/「取消釘選」、「移至」、「標示為已讀」/「標示為未讀」、「設為主要 Bot」、「編輯 Bot…」、「記憶…」、「開始新對話」、「過去的對話」、「分享與匯出」(「匯出 Bot(分享給別人)…」「匯出文字記錄…」「匯入 Bot…」「複製對話 ID」)、「重新啟動這個 Bot」、「清除聊天記錄」、「刪除」。 - `bots-create` 建立:「新增 Bot」,或「從範本建立」(研究助理、寫作夥伴、電腦助手、客服助理、開發助手)。新 Bot 沿用目前選中 Bot 的供應商和模型,電腦工具關著。 @@ -31,6 +32,7 @@ - **選單**(covers `bots-menu`、`bots-sidebar`):研究員那列「⋯」› 釘選、「更多…」› 標示為未讀;寫作夥伴 ›「刪除 Bot」。指令:`$CTL phone click '[data-botmenu="2"]' && $CTL phone click '#sheet-in .opt' --text 釘選 && $CTL phone wait-text '已釘選的 Bot' --in '#home' && $CTL phone click '[data-botmenu="2"]' && $CTL phone click '#sheet-in .opt' --text 更多 && $CTL phone click '#sheet-in .opt' --text 標示為未讀 && $CTL wait-api '/api/state?since=0' '.bots[] | select(.name == "研究員") | .pinned and .unread' && $CTL phone click '[data-botmenu="3"]' && $CTL phone click '#sheet-in .opt' --text '刪除 Bot' && $CTL phone wait-text '此操作無法復原' --in '#sheet-in' && $CTL phone click '#sheet-in .opt' --text 刪除 && $CTL wait-api '/api/state?since=0' '[.bots[].name] | index("寫作夥伴") == null' && $CTL phone shot bots-menu`。看到:研究員移到「已釘選的 Bot」、有未讀的點;刪除先問「這會刪除它和它的聊天記錄。此操作無法復原。」,刪掉後清單和大腦都沒有它。 - **重開還在**(covers `bots-create`、`bots-sidebar`):指令:`$CTL restart && $CTL phone open --listed && $CTL phone wait-text '已釘選的 Bot' --in '#home' && $CTL state '[.bots[] | {name, pinned}]'`。看到:小幫手二號、研究員(還是釘選)、研究助理都還在。 - **桌面**(covers `bots-sidebar`、`bots-search`、`bots-menu`、`bots-create`):指令:要開視窗——`$CTL stop && ABV_ALLOW_WINDOW=1 $CTL desktop-shot bots-find ANYBOT_SHOT_VIEW=find ANYBOT_SHOT_FIND=台南`。看到:搜尋下面「訊息」列說過的話(含過去的對話);選中那列淺底、沒有色條;釘選格子的拖曳、桌面的選單項目(分享與匯出…)、「建立 Bot」視窗(填 Soul 與指示、擅長,名字或模型空白按不下去)靠自動測試。 +- **頭像的表情**(covers `bots-moods`):指令:要開視窗——`$CTL stop && (for m in failed web done; do ABV_ALLOW_WINDOW=1 $CTL desktop-shot mood-$m ANYBOT_SHOT_VIEW=mood ANYBOT_SHOT_MOOD=$m ANYBOT_SHOT_SIZE=900x560 ANYBOT_SHOT_FRAMES=40 || exit 1; done)`;動不動:`ANYBOT_SHOT_MOOD=web` 加 `ANYBOT_SHOT_MOTION=full`,再換 `=calm`,各截第 70、80 幀(`ANYBOT_SHOT_FRAMES`),比側邊欄 Bot 頭像那一塊(約 40,70–110,130)。看到:failed 側邊欄的 Bot 是兩條平的眼睛,done 是笑眼;完整的兩幀眼睛位置不同,減少的兩幀一樣(最多差 1,反鋸齒)。 - 自動測試:`cargo test appctl::`、`cargo test app::sidebar_ui::`、`cargo test app::tests::`、`cargo test find::`。 ## 陷阱 diff --git a/docs/feature-map/settings.md b/docs/feature-map/settings.md index eb3a5f9..e69019a 100644 --- a/docs/feature-map/settings.md +++ b/docs/feature-map/settings.md @@ -5,7 +5,7 @@ ## 子功能 - `settings-general` 「一般」: - - 外觀:主題、強調色、聊天的顏色、語言,「更多外觀設定」(底色、對比、密度、慶祝動畫、外殼顏色重設)([appearance](appearance.md))。 + - 外觀:主題、強調色、聊天的顏色、語言,「更多外觀設定」(底色、對比、密度、慶祝動畫、頭像動態、外殼顏色重設)([appearance](appearance.md))。 - 記憶與文件:用意思找記憶(本機模型/Ollama/關閉)、Bot 可以翻的資料夾([memory](memory.md))。 - 通知:Bot 做完或等你時通知、需要你時響一聲([account](account.md))。Mac 上的通知是 AnyBot.app 自己發的(貓的圖示),點一下打開那個 Bot;從建置資料夾直接跑(不是 .app)時改用系統的 display notification,圖示是「工序指令編寫程式」。 - Bot:時區,例行任務和提醒用([routines](routines.md))。 diff --git a/docs/plan-2026-11-openbot.md b/docs/plan-2026-11-openbot.md index c0b3008..e9d7cb4 100644 --- a/docs/plan-2026-11-openbot.md +++ b/docs/plan-2026-11-openbot.md @@ -122,7 +122,7 @@ 詳細頁由上而下:標題列(狀態+動作)→ 錯誤/警告 → 「試試看」範例句(點了直接帶進聊天)→ 連線與權限 → 資訊 → 危險區。 技能安裝記在大腦上一份有雜湊的鎖檔,手機看得出哪個被手改過。 -**C2. 頭像動畫**:每個 Bot 一個「心情」,照順序取第一個成立的:上一輪失敗 → 等你允許/回答 → 正在做事 → +**C2. 頭像動畫**(11/21 做了:側邊欄等處的頭像照心情換眼神、失敗平眼、完成笑眼、做事呼吸、一個樣子停 1.4 秒、「頭像動態」自動/完整/減少;睡著(暫停)、連線中的表情、手機頁面還沒做):每個 Bot 一個「心情」,照順序取第一個成立的:上一輪失敗 → 等你允許/回答 → 正在做事 → (現況:`src/app/mood_ui.rs` 已經有 10 種表情(閒著、思考、看網頁、看畫面、寫字、等你、完成、失敗…),但只出現在打開的那個聊天的大臉上;側邊欄只有工作中、等你(黃點)、未讀(藍點),沒有失敗;手機是不會動的 SVG+狀態點。) 你不在時回完了 → 閒著;暫停的是睡著、連線中另一個表情。做事時依步驟種類換臉(搜尋、看網頁、讀檔、跑指令、改檔、交給別的 Bot), 一張臉至少停 1.4 秒;忙的時候輕微呼吸(2.6 秒、縮放 ±3%);「減少動態」開關,CPU 繪圖時預設關。 diff --git a/src/app.rs b/src/app.rs index 97d7390..4126a17 100644 --- a/src/app.rs +++ b/src/app.rs @@ -74,6 +74,15 @@ pub fn set_drawn_by_cpu(on: bool) { /// frame. Each frame is the whole window drawn again: on a 2-core virtual machine drawing it on the /// processor, 20 frames a second while a bot worked took most of a core, beside the bot's own /// browser, and over a remote desktop the window flickered. There, 4 a second: still moving. +/// 頭像動態 set to 減少 — or left on 自動 on a computer whose screen the CPU draws. +pub(crate) fn calm_motion(motion: &str) -> bool { + match motion { + "calm" => true, + "full" => false, + _ => DRAWN_BY_CPU.load(Ordering::Relaxed), + } +} + pub(crate) fn anim_after(ms: u64) -> std::time::Duration { std::time::Duration::from_millis(if DRAWN_BY_CPU.load(Ordering::Relaxed) { ms.max(CPU_FRAME_MS) } else { ms }) } @@ -428,6 +437,8 @@ pub struct App { pen_run: HashMap, /// Per bot: the mood its face above the input shows, and since when (mood_ui). dock_moods: HashMap, + /// The faces elsewhere (sidebar, pins, panel, tasks): each bot's mood and since when. + side_moods: HashMap, /// When each bot's request card was first shown (Enter answers it only after a moment). ask_shown: HashMap, /// 問題卡: the question whose field was last given the caret (once per question). @@ -655,6 +666,7 @@ impl App { think_len: HashMap::new(), pen_run: HashMap::new(), dock_moods: HashMap::new(), + side_moods: HashMap::new(), ask_shown: HashMap::new(), ask_forms: HashMap::new(), ask_focus: None, @@ -1327,6 +1339,10 @@ impl App { app.approvals.clear(); app.streams.clear(); } + // ANYBOT_SHOT_MOTION=calm|full: 頭像動態 減少 or 完整 (left out: 自動). + if let Ok(m) = std::env::var("ANYBOT_SHOT_MOTION") { + app.state.motion = m; + } // ANYBOT_SHOT_NEWER=: a newer build is waiting (重新啟動以更新), built that // long ago (0: just now). if let Ok(h) = std::env::var("ANYBOT_SHOT_NEWER") { @@ -1649,6 +1665,7 @@ impl App { self.cheer.remove(&id); self.faces.remove(&id); self.dock_moods.remove(&id); + self.side_moods.remove(&id); self.group_queue.remove(&id); self.group_spoken.remove(&id); self.sending.remove(&id); @@ -6032,6 +6049,14 @@ impl App { self.dirty = true; } }); + let cpu = self.state.motion.is_empty() && DRAWN_BY_CPU.load(Ordering::Relaxed); + card_row(ui, p, "頭像動態", if cpu { "這台的畫面用 CPU 畫,自動減少" } else { "" }, "Bot 做事時,頭像微微呼吸,眼睛跟著做的事看(上網、看畫面、寫字…)。減少:只換表情(失敗、完成、等你),不動。自動:畫面用 CPU 畫的電腦(沒有顯示卡加速)減少,其他完整。", |ui| { + let cur = self.state.motion.clone(); + if let Some(v) = segmented(ui, p, cur.as_str(), &[("", "自動"), ("full", "完整"), ("calm", "減少")]) { + self.state.motion = v.to_string(); + self.dirty = true; + } + }); card_row(ui, p, "外殼顏色重設", "", "底色、強調色、對比回到預設(紙)。", |ui| { if ui.button(t("重設")).clicked() { self.state.shell_tone = 1.0; diff --git a/src/app/mirror_ui.rs b/src/app/mirror_ui.rs index bfb60d3..efcf4bc 100644 --- a/src/app/mirror_ui.rs +++ b/src/app/mirror_ui.rs @@ -24,7 +24,7 @@ const LOCAL_KEYS: &[&str] = &["remote", "theme", "accent", "sidebar_collapsed", /// time, so the 強調色 picked here was orange again. Still sent to the brain when changed here: the /// phone wears the brain's. #[cfg(test)] -const LOOK_KEYS: &[&str] = &["shell_tone", "shell_accent", "shell_contrast", "dense", "celebrate"]; +const LOOK_KEYS: &[&str] = &["shell_tone", "shell_accent", "shell_contrast", "dense", "celebrate", "motion"]; /// This computer's own settings (LOCAL_KEYS but `selected`, which names a bot of one side, and /// LOOK_KEYS) from `from` onto `to`. The one list of them: four hand-kept lists had drifted apart. @@ -44,6 +44,7 @@ fn copy_own(to: &mut State, from: &State) { to.shell_contrast = from.shell_contrast; to.dense = from.dense; to.celebrate = from.celebrate; + to.motion = from.motion.clone(); } /// Bot fields the brain alone changes (its chat, and what a turn leaves behind). const BOT_RUNTIME: &[&str] = &["id", "messages", "threads", "unread", "last_turn", "tasks", "context_tokens", "goal", "plan", "regen_undo", "branches", "branch_of"]; @@ -2863,6 +2864,7 @@ mod tests { from.shell_contrast = 0.75; from.dense = !from.dense; from.celebrate = !from.celebrate; + from.motion = "calm".into(); let (base, want) = (serde_json::to_value(State::first_run()).unwrap(), serde_json::to_value(&from).unwrap()); let mut to = State::first_run(); copy_own(&mut to, &from); diff --git a/src/app/mood_ui.rs b/src/app/mood_ui.rs index c0935ba..b0ed85e 100644 --- a/src/app/mood_ui.rs +++ b/src/app/mood_ui.rs @@ -41,7 +41,7 @@ impl Mood { const ALL: [Mood; 10] = [Mood::Idle, Mood::Thinking, Mood::Between, Mood::Web, Mood::Screen, Mood::Step, Mood::Writing, Mood::Waiting, Mood::Done, Mood::Failed]; /// The moods of a running turn: they hold a moment before the next takes over. - fn busy(self) -> bool { + pub(super) fn busy(self) -> bool { matches!(self, Mood::Thinking | Mood::Between | Mood::Web | Mood::Screen | Mood::Step | Mood::Writing) } @@ -266,6 +266,8 @@ impl App { _ => true, }; // (Its own state, apart from the same bot's face in the sidebar, which looks elsewhere.) + // 頭像動態 減少: the face keeps its mood but doesn't keep the window drawing. + let moving = moving && !calm_motion(&self.state.motion); let mut pose = self.settle_face(&ctx, !bot.id, target, moving, false); if mood == Mood::Waiting { ctx.request_repaint_after(std::time::Duration::from_millis(200)); diff --git a/src/app/settings_find.rs b/src/app/settings_find.rs index cee3958..9bb4012 100644 --- a/src/app/settings_find.rs +++ b/src/app/settings_find.rs @@ -72,6 +72,7 @@ pub(super) const INDEX: &[Entry] = &[ o(S::General, "外觀", "對比", "分層 細線 文字階級 contrast", more_look), o(S::General, "外觀", "密度", "緊湊 行距 按鈕大小 density", more_look), o(S::General, "外觀", "慶祝動畫", "彩帶 動畫 完成", more_look), + o(S::General, "外觀", "頭像動態", "減少動態 動畫 呼吸 眼睛 表情 reduce motion", more_look), o(S::General, "外觀", "外殼顏色重設", "預設 紙 還原 reset", more_look), e(S::General, "記憶與文件", "記憶與文件", ""), e(S::General, "記憶與文件", "用意思找記憶", "語意搜尋 向量 embedding 本機模型 Ollama 關閉"), diff --git a/src/app/sidebar_ui.rs b/src/app/sidebar_ui.rs index f5e640e..7712f40 100644 --- a/src/app/sidebar_ui.rs +++ b/src/app/sidebar_ui.rs @@ -68,6 +68,12 @@ fn bump(e: f32, a: f32, b: f32) -> f32 { } use std::f32::consts::PI; +use super::mood_ui::Mood; + +/// How long a working face keeps its look before the next step's may replace it (seconds). +const SIDE_HOLD: f64 = 1.4; +/// One breath of a working face (seconds). +const BREATH_SECS: f32 = 2.6; /// Pseudo-random 0..1 from a seed (blinks don't all happen together). fn rand01(seed: u64) -> f64 { @@ -98,17 +104,59 @@ impl App { } _ => egui::Vec2::ZERO, }; - // What the eyes say: working → they read slowly left and right; waiting for you → they - // look up at you; otherwise they follow the pointer. - let target = if waiting { - vec2(0.0, 0.85) - } else if working { - let ph = (now * 1.1 + id as f64) as f32; - vec2(ph.sin() * 0.75, -0.35 + 0.08 * (ph * 2.0).sin()) - } else { - pointer_target + // The mood (mood_ui::mood_of, as the face above the input has it), held a moment while + // it works so quick steps don't make it flicker. + let cheer = self.cheer.get(&id).map(|t| t.elapsed().as_secs_f32()).filter(|s| *s < super::mood_ui::CHEER_SECS); + let want = self.state.bot(id).map(|b| super::mood_ui::mood_of(b, working, waiting, cheer.is_some())).unwrap_or(Mood::Idle); + let mood = self.side_mood(ctx, id, want, now); + // 頭像動態 減少 (or 自動 on a CPU-drawn screen): the look of each mood, still. + let calm = super::calm_motion(&self.state.motion); + let ph = if calm { 0.0 } else { (now * 1.1 + id as f64) as f32 }; + // What the eyes say: waiting for you → up at you; on the web → sweeping across; on a + // screen → up and to the side, at it; writing → down at the words; thinking or reading + // what came back → up and away; any other step → reading slowly left and right; + // failed → down; otherwise they follow the pointer. + let target = match mood { + Mood::Waiting => vec2(0.0, 0.85), + Mood::Web => vec2(if calm { 0.6 } else { ((now * 2.0 + id as f64) as f32).sin() * 0.85 }, -0.1), + Mood::Screen => vec2(0.55 + 0.2 * ph.sin(), 0.4), + Mood::Writing => vec2(0.35 * ph.sin(), -0.75), + Mood::Thinking | Mood::Between => vec2(-0.45 + 0.1 * ph.sin(), 0.5), + Mood::Step => vec2(ph.sin() * 0.75, -0.35 + 0.08 * (ph * 2.0).sin()), + Mood::Failed => vec2(0.0, -0.45), + Mood::Done | Mood::Idle => pointer_target, }; - self.settle_face(ctx, id, target, working, false) + let mut pose = self.settle_face(ctx, id, target, working && !calm, false); + pose.eyes = match mood { + Mood::Done => avatar::Eyes::Smile, + Mood::Failed => avatar::Eyes::Flat, + _ => avatar::Eyes::Open, + }; + // While it works it breathes: a slow rise and fall from its feet (2.6 s, 3%). + if working && !calm { + let b = (now as f32 * std::f32::consts::TAU / BREATH_SECS + id as f32).sin(); + pose.squash = vec2(pose.squash.x * (1.0 - 0.015 * b), pose.squash.y * (1.0 + 0.03 * b)); + } + // The smile ends by itself: draw once more when it does. + if let Some(s) = cheer { + ctx.request_repaint_after(std::time::Duration::from_secs_f32((super::mood_ui::CHEER_SECS - s).max(0.05))); + } + pose + } + + /// The mood a face elsewhere shows: a working one holds SIDE_HOLD before another working one + /// replaces it; anything else changes at once. + fn side_mood(&mut self, ctx: &egui::Context, id: u64, want: Mood, now: f64) -> Mood { + let shown = self.side_moods.entry(id).or_insert((want, now)); + if shown.0 != want { + let held = now - shown.1; + if shown.0.busy() && want.busy() && held < SIDE_HOLD { + ctx.request_repaint_after(std::time::Duration::from_secs_f64(SIDE_HOLD - held)); + } else { + *shown = (want, now); + } + } + shown.0 } /// A face (kept under `key`) turning its eyes toward `target`, blinking now and then, and diff --git a/src/model.rs b/src/model.rs index b1a0464..6eff2ee 100644 --- a/src/model.rs +++ b/src/model.rs @@ -749,6 +749,10 @@ pub struct State { /// 工作完成時的慶祝動畫(設定 › 一般)。 #[serde(default = "default_true")] pub celebrate: bool, + /// 頭像動態(設定 › 一般 › 更多外觀設定):Bot 頭像做事時的呼吸和眼神。"" 自動(畫面用 CPU + /// 畫的電腦減少)、"full" 完整、"calm" 減少(只換表情,不動)。 + #[serde(default)] + pub motion: String, #[serde(default)] pub providers: std::collections::BTreeMap, #[serde(default)] @@ -1395,6 +1399,7 @@ impl State { shell_contrast: 1.0, dense: false, celebrate: true, + motion: String::new(), providers: Default::default(), sidebar_collapsed: false, embed_model: String::new(),