From 22c070fe72c9f44ede0ca506f9ce4b0ddb51cb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Mon, 16 Nov 2026 22:57:13 +0800 Subject: [PATCH] =?UTF-8?q?design:=20=E5=85=A8=E7=95=AB=E9=9D=A2=E5=AF=A9?= =?UTF-8?q?=E6=9F=A5=E7=AC=AC=E4=B8=80=E8=BC=AA=E2=80=94=E2=80=94=E4=BF=AE?= =?UTF-8?q?=E5=82=B3=E9=80=81=E6=8C=89=E9=88=95=E7=A0=B4=E7=89=88=E3=80=81?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=94=B9=E7=81=B0=E3=80=81=E7=AD=89=E4=BD=A0?= =?UTF-8?q?=E7=9A=84=E5=8D=A1=E7=89=87=E7=B5=B1=E4=B8=80=E3=80=81=E5=85=81?= =?UTF-8?q?=E8=A8=B1=E5=8D=A1=E7=89=87=E7=B2=BE=E7=B0=A1=E3=80=81=E9=A0=81?= =?UTF-8?q?=E9=9D=A2=E5=8D=A1=E7=89=87=E4=B8=80=E5=BC=B5=E3=80=81Bot=20?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E9=80=B2=E9=9A=8E=E6=94=B6=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 依 Anthropic 的設計原則逐一看過 39 個畫面,這一輪改: - 傳送到其他裝置:「移除/複製/再試一次」寫死寬度,字一大就斷成兩行——改成照字量寬 - 輸入框下的提示(已排入…、已複製…)用強調色像錯誤——改成灰字 - 等你的卡片統一成 kit::needs_you_card(允許、問題、交給你處理):同一種黃;「需要處理」以前是強調色框看起來像紅色 - 允許卡片:一句「它想在你的電腦上執行:」+指令,三個短按鈕「允許/一律允許/拒絕」(一律允許會打開什麼放在滑過說明), 「直接操作」改成灰字一行;標題字級回到規格(藏著的 17/14) - 聊天裡的頁面卡片:一張精簡卡(圖示、標題一次、一行重點、一行灰字),以前標題出現兩次加四行預覽 - Bot 設定:電腦操作/能力/技能/記憶 預設收起,一行顯示目前怎麼設(kit::fold_title); 「執行步驟用的模型」「思考模式」改成名稱在上、說明在「?」(kit::form_row_help),不再兩段灰字 - 權限:「新增規則」那列不再撐滿剩下的高度(大片空白) - 看守:自己畫的卡片上限 17 → 13 已驗證: cargo test 523 全過(排版檢查、規格看守)、改過的畫面截圖目視 --- FEATURES.md | 4 +- docs/feature-map/bots.md | 2 +- docs/feature-map/pages.md | 2 +- docs/feature-map/safety.md | 2 +- src/app.rs | 68 +++++++++++++++++++--------------- src/app/drops_ui.rs | 16 +++++--- src/app/kit.rs | 48 ++++++++++++++++++++++++ src/app/pages_ui.rs | 76 ++++++++++++++++---------------------- src/app/profile_ui.rs | 10 ++++- src/i18n_table.rs | 3 ++ src/theme.rs | 2 +- 11 files changed, 145 insertions(+), 88 deletions(-) diff --git a/FEATURES.md b/FEATURES.md index e7aa188..5240696 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -357,7 +357,7 @@ AnyBot 是一個桌面聊天 App,介面和運作方式照 Grok Bot 重做。 - 指令類直接顯示指令,例如「npm install」 - 沒有可以記住的類別時,不顯示這顆按鈕。 - 「拒絕」。 -- 「⚡ 全部允許,之後直接操作(像 Grok Bot 一樣)」 +- 「⚡ 之後都直接操作,不再一個個問」(灰字,不搶主要按鈕;以前是橘色的「全部允許,之後直接操作」) - 只在「直接操作」還沒開、而且管理員沒鎖住時出現。 - 提示文字:「打開「直接操作」:Bot 可以直接使用這台電腦和瀏覽器,不再一個個問你。危險指令、密碼檔和你的「一律詢問」規則仍會擋下來。可在設定 → 電腦關掉。」 - 按下會允許這一筆,並打開直接操作(第 8 節)。 @@ -1564,7 +1564,7 @@ computer_use_screenshot、click、mouse_move、mouse_button(按住/放開) ### 頁面(Bot 做、Bot 持續更新的報告) -- 你請 Bot 追蹤、整理、比較一件之後還會回來看的事(例如「幫我追蹤一下台灣 FSD 狀況」),它用 `write_page` 做成一頁:先寫現況,再寫細節和來源(附日期)。回答裡用「[標題](page:ID)」連到它,回答下面出現頁面卡片(標題、開頭幾行、頁面圖示、「頁面 · 更新時間」、最近一次更新了什麼),點一下打開。 +- 你請 Bot 追蹤、整理、比較一件之後還會回來看的事(例如「幫我追蹤一下台灣 FSD 狀況」),它用 `write_page` 做成一頁:先寫現況,再寫細節和來源(附日期)。回答裡用「[標題](page:ID)」連到它,回答下面出現頁面卡片(一張精簡卡:頁面圖示、標題、一行它說什麼或這次改了什麼、一行灰字的種類和時間),點一下打開。 - 頁面可以放表格、Mermaid 圖表(圓餅、長條、折線、時間軸…白底卡節點、細灰連線),以及頁面專用的區塊:```stats 數字卡片(數字大字,超過 10 個字的值縮成小一號;值和備註開頭 ↑/+ 綠色、↓/−/- 紅色,「+」「-」後面要緊接著東西才算,單獨一個「-」當作沒資料;電腦和手機同一套規則)、```steps 進度(✓ 完成、◉ 進行中、○ 還沒到)、```chart 原生圖表(bar 長條、line 折線、pie 圓餅;只畫淡水平參考線,長條自動由大到小排序——月份/年份等自有順序的標籤不排;單系列把數字直接標在圖上、不畫 y 軸;多條線在線尾標系列名;懸停看數值、拖曳平移、右鍵框選放大、雙擊還原,圖下自動附數據表,不會破版;多系列用 `| 1月 | 2月` 當表頭;第一行可以是「圖型 標題」、只寫圖型(bar/line/pie 或 長條/折線/圓餅)或只寫標題,`#` 開頭的行是註解,`|---|` 分隔列略過,少填的格子當 0——電腦和手機同一套讀法;手機看同一頁也畫同樣樣式的原生 SVG 圖:照手機寬度畫、字不會縮小,折線和多系列長條有 y 軸數字,圖下同樣附數據表,只有一項的圓餅畫成整圓,圖例項目再多也都畫得到,負數的數字不會壓到下面的標籤)、`> [!NOTE]`/`[!TIP]`/`[!WARNING]`/`[!IMPORTANT]` 提示框。這些區塊在聊天裡也能用。所有圖表(含 Mermaid 圓餅)共用同一套低飽和六色色板,深淺兩主題各一組。 - **細節區塊** ```details 標題:預設收起,只顯示一行灰色「▸ 標題」(沒寫標題就是「細節」),點了展開裡面的 Markdown。讓第一屏只有結論、數字和下一步;證據、長清單、指令收在下面。 - **寫法檢查**:Bot 存頁面時程式先看一遍(Anthropic 的報告寫法:結論先講、句子短、少粗體、數字放卡片或表格、不用裝飾)。段落超過 120 字、一節超過一處粗體、括號裡一串數字、標題編號、分隔線、用「→」帶結論、表格裡放指令、正文很長卻沒有收起的細節——有就退回一次、列出每一處要怎麼改;同一頁第二次照存,不會卡住。 diff --git a/docs/feature-map/bots.md b/docs/feature-map/bots.md index 8e7a270..c688bb0 100644 --- a/docs/feature-map/bots.md +++ b/docs/feature-map/bots.md @@ -8,7 +8,7 @@ - 搜尋「搜尋 Bot 和訊息」:上面列名字或描述相符的 Bot,下面「訊息」列你和 Bot 說過的話和附件檔名(含過去的對話,最多 40 筆),點一筆就捲到那則訊息。 - Bot 選單:「釘選」/「取消釘選」、「移至」、「標示為已讀」/「標示為未讀」、「設為主要 Bot」、「編輯 Bot…」、「記憶…」、「開始新對話」、「過去的對話」、「分享與匯出」(「匯出 Bot(分享給別人)…」「匯出文字記錄…」「匯入 Bot…」「複製對話 ID」)、「重新啟動這個 Bot」、「清除聊天記錄」、「刪除」。 - 建立:「新增 Bot」,或「從範本建立」(研究助理、寫作夥伴、電腦助手、客服助理、開發助手)。新 Bot 沿用目前選中 Bot 的供應商和模型,電腦工具關著。 -- 「Bot 設定」:「Bot 資料」(「Bot 名稱」「Bot 描述」和大頭像,同一張卡);「個人檔案」(Soul 與指示、擅長(什麼事找它)、不找它做的事);「頭像」(14 種形狀平均排成兩列;10 種顏色和「自訂」同一列;按「自訂」出現一格一格的色盤——12 個色相各四種深淺加一列灰階,直接點,沒有滑桿——和「色碼」欄,打完整的 #rrggbb 才換色);「AI 供應商與模型」(供應商、「模型名稱」、「選擇」、「執行步驟用的模型」、「思考模式」);「電腦操作」;「能力」;「技能」;「記憶」;最下面「釘選到側邊欄」「團隊成員可以使用這個 Bot」(「?」說明:團隊成員看得到它的聊天、頁面和檔案)。 +- 「Bot 設定」:「Bot 資料」(「Bot 名稱」「Bot 描述」和大頭像,同一張卡);「個人檔案」(Soul 與指示、擅長(什麼事找它)、不找它做的事);「頭像」(14 種形狀平均排成兩列;10 種顏色和「自訂」同一列;按「自訂」出現一格一格的色盤——12 個色相各四種深淺加一列灰階,直接點,沒有滑桿——和「色碼」欄,打完整的 #rrggbb 才換色);「AI 供應商與模型」(供應商、「模型名稱」、「選擇」、「執行步驟用的模型」、「思考模式」——欄位名稱在上,說明在名稱旁的「?」);接著「電腦操作」「能力」「技能」「記憶」四張預設收起,各只有一行:名稱、目前怎麼設(例如「11 / 11 類」「會 8 / 8」「還沒有」)和 ▸,點了才展開;最下面「釘選到側邊欄」「團隊成員可以使用這個 Bot」(「?」說明:團隊成員看得到它的聊天、頁面和檔案)。 - Soul 與指示只有它自己讀;描述、擅長、不找它做的事、會的技能、在哪幾台電腦做事會寫進其他 Bot 的同事名冊。 - 能力 11 類:「上網」「瀏覽器」「看螢幕與操作」「檔案與指令」「Mac App」「連接器」「電話、簡訊、X」「例行任務」「頁面」「和其他 Bot 合作」「管理 App」。沒勾的工具不提供給它,也不寫進說明。記憶、技能、問你問題、傳檔案到聊天、表情和卡片每個 Bot 都有。 - 供應商:xAI Grok、OpenAI、Claude、Google Gemini、OpenRouter、OpenCode Go、Ollama(本機)、自訂(OpenAI 相容),每個 Bot 各選各的。 diff --git a/docs/feature-map/pages.md b/docs/feature-map/pages.md index 3a3ffb5..b74a137 100644 --- a/docs/feature-map/pages.md +++ b/docs/feature-map/pages.md @@ -14,7 +14,7 @@ Bot 把要追蹤、整理、比較的事寫成一頁,之後一直更新同一 ## 使用者怎麼到 -- 回覆裡的 [標題](page:ID) 連結,和回覆下面的頁面卡片(標題、開頭幾行、「頁面 · 時間」、種類;更新過的寫「已更新」和「最近更新:…」):點一下打開。 +- 回覆裡的 [標題](page:ID) 連結,和回覆下面的頁面卡片(一張精簡卡:頁面圖示、標題一次、一行它說什麼——更新過的是「已更新:改了什麼」,否則是現況那句——和一行灰字「種類 · 頁面 · 時間 · 第 N 版」):點一下打開。 - 右側面板的「資料庫」分頁,最上面的「頁面」:這個 Bot 的頁面,最近改過的在前面。 - 打開的頁面像一份文件(和手機同一套):標題宋體粗體 28,下面一行小字作者、「更新於」、第幾版和「這一版更新了:…」;一行現況(summary)是開頭段落、不加框;結論(verdict)是淡底的「結論」提示框;kpis 是只有細框的數字卡。有 3 個以上的標題時有一行「▸ 目錄 · N 節」,點開才是標題清單和小搜尋框(⌘F 直接展開)。內文宋體 16、行距 1.7,閱讀欄最寬 680。下方左邊「版本紀錄」(看舊版時有「回到最新版」)和「刪除」(按兩次),右邊「複製」(Markdown)、「存成檔案」(存成 .md 到「下載」)、「完成」。 - 手機:首頁上面一排的「頁面」列出所有頁面;聊天裡的頁面卡片;打開的頁面的「⋯」有「複製 Markdown」「其他版本」,一條細線下面才是「刪除頁面」。 diff --git a/docs/feature-map/safety.md b/docs/feature-map/safety.md index 364d1af..61a03ac 100644 --- a/docs/feature-map/safety.md +++ b/docs/feature-map/safety.md @@ -5,7 +5,7 @@ Bot 要動到你的電腦、對外送出或做收不回來的事時,先問你 ## 子功能 - 允許請求:黃色卡片停在輸入框上方,「允許 {Bot} {動作}嗎?」加細節框。按鈕:「允許」、「一律允許{類別}」(有能記住的類別才有)、「拒絕」。電腦工具沒開時是「允許這一次」「一律允許這個 Bot 使用電腦」;「在這台電腦上執行」沒開時是「一律允許(打開「在這台電腦上執行」)」。輸入框空著時 Enter 允許、Esc 拒絕。 -- 「全部允許,之後直接操作」:卡片下面一行,允許這一筆並打開直接操作(還沒開、管理員沒鎖時才有)。 +- 允許卡片:一句「它想在你的電腦上執行:」+指令,三個按鈕「允許」「一律允許」(滑過說明它會打開什麼)「拒絕」;下面一行灰字「之後都直接操作,不再一個個問」:允許這一筆並打開直接操作(還沒開、管理員沒鎖時才有)。等你的卡片(允許、問題、交給你處理)都是同一種黃:淡黃底、細黃框。 - 一律允許記在那個 Bot 身上(例如「修改檔案」、「npm install」、某個連接器),Bot 設定 ›「電腦操作」的「已設定「一律允許」」看得到,按 × 移除。 - 拒絕後停下:同一輪裡 Bot 再提一模一樣的操作(同一個工具、同樣的參數),直接替你拒絕、不再問,直到你再傳一則訊息(工作中插話也算)。按停止、關視窗不算拒絕。 - 直接操作:打開時一次做完——打開「在這台電腦上執行」、自動審核、所有 Bot 的電腦工具;「一律詢問」規則是空的就填三條預設(刪除檔案或資料夾/付款、購買或轉帳/用我的帳號發文、留言,或傳訊息給別人);進行中的工作下一步起不再問;別的 Bot 在等的「可以用電腦嗎」自動允許。 diff --git a/src/app.rs b/src/app.rs index 05e751c..1b49dbf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -3518,16 +3518,16 @@ impl App { ApprovalKind::Question => format!("{} 問你", bot.name), }; let note = match kind { - ApprovalKind::EnableTools => Some("這個 Bot 的電腦工具還沒打開。它想做的事:"), - ApprovalKind::EnableThisComputer => Some("「在這台電腦上執行」還沒打開,Bot 平常只在它自己的電腦上做事。它想在你的電腦上:"), + ApprovalKind::EnableTools => Some("它想做的事:"), + ApprovalKind::EnableThisComputer => Some("它想在你的電腦上執行:"), ApprovalKind::Action | ApprovalKind::Handoff | ApprovalKind::Question => None, }; let mut answer = None; - ui.label(RichText::new(title).strong().family(crate::bold()).size(if big { 17.0 } else { 14.0 })); + ui.label(RichText::new(title).strong().family(crate::bold()).size(if big { FONT_READ } else { FONT_BASE })); ui.add_space(2.0); let (head, detail) = reason.split_once(':').unwrap_or(("", reason.as_str())); match note { - Some(n) => ui.label(RichText::new(n).size(FONT_SM).color(p.text2)), + Some(n) => ui.label(RichText::new(t(n)).size(FONT_SM).color(p.text2)), None if !head.is_empty() => ui.label(RichText::new(head).size(FONT_XS).color(p.text3)), None => ui.label(""), }; @@ -3535,26 +3535,27 @@ impl App { ui.set_width(ui.available_width()); ui.add(egui::Label::new(RichText::new(detail).monospace().size(FONT_SM).color(p.text)).wrap()); }); - if !machine.is_empty() && kind != ApprovalKind::Action { + // Where, unless the title already says it. + if !machine.is_empty() && !matches!(kind, ApprovalKind::Action | ApprovalKind::EnableThisComputer) { ui.label(RichText::new(format!("在:{machine}")).size(FONT_XS).color(p.text3)); } ui.add_space(6.0); // (Wrapped: in a narrow window the long 「一律允許…」 goes to the next line instead of // running out of the card.) ui.horizontal_wrapped(|ui| { - let once = if kind == ApprovalKind::Action { "允許" } else { "允許這一次" }; + // Three short choices (允許 · 一律允許 · 拒絕); what 一律允許 switches on is in its hover. ui.spacing_mut().button_padding = vec2(14.0, 7.0); - if ui.add(egui::Button::new(RichText::new(once).strong().family(crate::bold()).color(p.on_primary)).fill(p.primary).corner_radius(R_M).min_size(vec2(0.0, if big { 34.0 } else { 0.0 }))).clicked() { + if ui.add(egui::Button::new(RichText::new(t("允許")).strong().family(crate::bold()).color(p.on_primary)).fill(p.primary).corner_radius(R_M).min_size(vec2(0.0, if big { 34.0 } else { 0.0 }))).clicked() { answer = Some(ApprovalAnswer::Once); } let always = match kind { - ApprovalKind::EnableTools => Some("一律允許這個 Bot 使用電腦".to_string()), - ApprovalKind::EnableThisComputer => Some("一律允許(打開「在這台電腦上執行」)".to_string()), - ApprovalKind::Action if !grant.is_empty() => Some(format!("一律允許{}", grant_label(&grant))), + ApprovalKind::EnableTools => Some(("一律允許".to_string(), "之後這個 Bot 用電腦工具不再問你".to_string())), + ApprovalKind::EnableThisComputer => Some(("一律允許".to_string(), "打開「在這台電腦上執行」:之後它在你的電腦上做事不再問你(設定 › 電腦可以關掉)".to_string())), + ApprovalKind::Action if !grant.is_empty() => Some((format!("一律允許{}", grant_label(&grant)), "之後同樣的操作不再問你(設定 › 權限可以刪掉這條規則)".to_string())), ApprovalKind::Action | ApprovalKind::Handoff | ApprovalKind::Question => None, }; - if let Some(label) = always { - if ui.button(label).clicked() { + if let Some((label, why)) = always { + if ui.button(t(&label)).on_hover_text(t(&why)).clicked() { answer = Some(ApprovalAnswer::Always(grant.clone())); } } @@ -3565,7 +3566,8 @@ impl App { // One click to work like the reference assistant: allow this and stop asking from now on. if !self.direct_on() && self.managed.direct.allows() && self.managed.local.allows() { ui.add_space(4.0); - let b = crate::icons::label(ui, crate::icons::Icon::Zap, &t("全部允許,之後直接操作"), 13.5, p.accent).interact(egui::Sense::click()).on_hover_cursor(egui::CursorIcon::PointingHand); + // (A way out of asking, offered quietly: grey, not a second call to action.) + let b = crate::icons::label(ui, crate::icons::Icon::Zap, &t("之後都直接操作,不再一個個問"), FONT_SM, p.text2).interact(egui::Sense::click()).on_hover_cursor(egui::CursorIcon::PointingHand); if b.on_hover_text(t("打開「直接操作」:Bot 可以直接使用這台電腦和瀏覽器,不再一個個問你。危險指令、密碼檔和你的「一律詢問」規則仍會擋下來。可在設定 → 權限關掉。")).clicked() { self.want_direct.set(true); answer = Some(ApprovalAnswer::Always(grant.clone())); @@ -3607,7 +3609,7 @@ impl App { let reason = self.approvals.get(&bot.id).map(|a| a.reason.clone()).unwrap_or_default(); let cap = (ui.ctx().content_rect().height() * 0.45).max(160.0); let body = ask_dock_height(&reason, ui.available_width(), cap); - Frame::new().fill(p.attention_bg).stroke(Stroke::new(2.0, p.attention)).corner_radius(R_L).inner_margin(Margin::symmetric(16, 14)).show(ui, |ui| { + needs_you_card(ui, p, |ui| { ui.set_width(ui.available_width()); egui::ScrollArea::vertical().id_salt(("ask-dock", bot.id)).max_height(body).min_scrolled_height(body).auto_shrink([false, false]).show(ui, |ui| { answer = self.approval_body(ui, bot, true); @@ -3676,7 +3678,7 @@ impl App { // (選項再多也不許把輸入框頂出螢幕:卡面照內容估高、照視窗高度封頂,裡面在卡面裡往下捲。) let cap = (ui.ctx().content_rect().height() * 0.45).max(160.0); let body = ask_card_height(q, ui.available_width(), cap); - Frame::new().fill(p.attention_bg).stroke(Stroke::new(2.0, p.attention)).corner_radius(R_L).inner_margin(Margin::symmetric(16, 14)).show(ui, |ui| { + needs_you_card(ui, p, |ui| { ui.set_width(ui.available_width()); egui::ScrollArea::vertical().id_salt(("ask-dock", bot.id, call_id.clone())).max_height(body).min_scrolled_height(body).auto_shrink([false, false]).show(ui, |ui| { if qs.len() > 1 { @@ -3826,7 +3828,7 @@ impl App { let mut act = None; ui.horizontal_top(|ui| { ui.add_space(32.0); - Frame::new().fill(p.elevated).stroke(Stroke::new(2.0, p.accent)).corner_radius(R_L).inner_margin(Margin::symmetric(14, 12)).show(ui, |ui| { + needs_you_card(ui, p, |ui| { ui.vertical(|ui| { ui.set_width(width); ui.horizontal(|ui| { @@ -4260,14 +4262,15 @@ impl App { self.notice = None; } ui.with_layout(Layout::left_to_right(Align::Center).with_main_wrap(true), |ui| { - ui.add(egui::Label::new(RichText::new(n).size(FONT_SM).color(p.accent)).wrap()); + // Information, in the quiet grey (the accent read as an error here). + ui.add(egui::Label::new(RichText::new(n).size(FONT_SM).color(p.text2)).wrap()); }); }); } if !queued.is_empty() { let first: String = queued.last().unwrap().chars().take(30).collect(); let more = if queued.len() > 1 { format!(" 等 {} 則", queued.len()) } else { String::new() }; - ui.add(egui::Label::new(RichText::new(format!("已排入「{first}」{more},Bot 會在下一步看到")).size(FONT_SM).color(p.accent)).wrap()); + ui.add(egui::Label::new(RichText::new(format!("已排入「{first}」{more},Bot 會在下一步看到")).size(FONT_SM).color(p.text2)).wrap()); } }); ui.add_space(10.0); @@ -4751,7 +4754,7 @@ impl App { }); }); // 想的跟做的分開: this model plans and checks; a quick one carries out the steps. - ui.horizontal(|ui| { + form_row_help(ui, "執行步驟用的模型", "上面的模型負責想計畫、遇到問題和最後確認;中間照計畫做的步驟交給這個比較快的模型。", p, |ui| { let auto = b.provider.quick_model(&b.model); let shown = match b.step_model.trim() { "" => match auto { @@ -4761,7 +4764,6 @@ impl App { "off" => "不分開(每一步都用上面的模型)".into(), m => m.to_string(), }; - ui.label(RichText::new(t("執行步驟用的模型")).size(FONT_XS).color(p.text3)); egui::ComboBox::from_id_salt("bot_step_model").selected_text(shown).width(ui.available_width() - 8.0).show_ui(ui, |ui| { if ui.selectable_label(b.step_model.is_empty(), t("自動")).clicked() { b.step_model.clear(); @@ -4776,11 +4778,9 @@ impl App { } }); }); - ui.label(RichText::new(t("上面的模型負責想計畫、遇到問題和最後確認;中間照計畫做的步驟交給這個比較快的模型。")).size(FONT_XS).color(p.text3)); // 思考模式: how long the bot's own model thinks before it answers. - ui.horizontal(|ui| { + form_row_help(ui, "思考模式", "想得越久越仔細,也越慢、越花額度。不支援這個設定的模型會照它原本的方式回答。", p, |ui| { let shown = providers::EFFORTS.iter().find(|(v, _)| *v == b.thinking.trim()).map(|(_, n)| *n).unwrap_or(providers::EFFORTS[0].1); - ui.label(RichText::new(t("思考模式")).size(FONT_XS).color(p.text3)); egui::ComboBox::from_id_salt("bot_thinking").selected_text(t(shown)).width(ui.available_width() - 8.0).show_ui(ui, |ui| { for (v, n) in providers::EFFORTS { if ui.selectable_label(b.thinking.trim() == v, t(n)).clicked() { @@ -4789,7 +4789,6 @@ impl App { } }); }); - ui.label(RichText::new(t("想得越久越仔細,也越慢、越花額度。不支援這個設定的模型會照它原本的方式回答。")).size(FONT_XS).color(p.text3)); let ps = self.state.provider(b.provider); if b.provider.needs_key() && providers::resolve_key(b.provider, &ps.api_key).is_empty() { ui.horizontal(|ui| { @@ -4803,7 +4802,10 @@ impl App { } }); setting_card(ui, p, |ui| { - setting_title(ui, "電腦操作", "", p); + let summary = if b.tools_enabled { t("可以查看、修改檔案和執行指令") } else { t("關閉") }; + if !fold_title(ui, p, ("computer", b.id), "電腦操作", &summary, "") { + return; + } ui.checkbox(&mut b.tools_enabled, t("讓這個 Bot 查看、修改檔案和執行指令")); if b.tools_enabled { ui.add_space(6.0); @@ -4883,7 +4885,11 @@ impl App { }); } setting_card(ui, p, |ui| { - setting_title(ui, "記憶", "Bot 記得的事和做過的事。釘選的每次聊天都帶著;其他的只在和你說的話有關時帶上,打字時就看得到會帶哪幾條。", p); + let n = b.memories.len(); + let summary = if n == 0 { t("還沒有") } else { format!("記得 {n} 件事") }; + if !fold_title(ui, p, ("memory", b.id), "記憶", &summary, "Bot 記得的事和做過的事。釘選的每次聊天都帶著;其他的只在和你說的話有關時帶上,打字時就看得到會帶哪幾條。") { + return; + } ui.horizontal(|ui| { let n = b.memories.len(); ui.label(RichText::new(if n == 0 { t("還沒有記得的事。跟 Bot 說「記住我喜歡靠窗的座位」試試看。") } else { format!("記得 {n} 件事") }).size(FONT_SM).color(p.text2)); @@ -5351,8 +5357,10 @@ impl App { Frame::new().fill(p.elevated).corner_radius(R_M).inner_margin(Margin::symmetric(10, 4)).show(ui, |ui| { ui.set_width(ui.available_width()); // 刪除 keeps its place at the right; a long rule wraps - // in the room left of it (it ran under 刪除). - ui.with_layout(Layout::right_to_left(Align::Center), |ui| { + // in the room left of it (it ran under 刪除). (A row of + // its own height: a bare right-to-left layout took all the + // height left on the page.) + ui.allocate_ui_with_layout(vec2(ui.available_width(), 24.0), Layout::right_to_left(Align::Center), |ui| { if ui.add(egui::Button::new(RichText::new(t("刪除")).size(FONT_XS).color(p.text3)).frame(false)).clicked() { remove = Some(i); } @@ -5369,8 +5377,8 @@ impl App { let draft = if which == 0 { &mut self.new_allow_rule } else { &mut self.new_ask_rule }; ui.add_space(2.0); // The button first (its own width in any font), the field - // takes the rest. - ui.with_layout(Layout::right_to_left(Align::Center), |ui| { + // takes the rest — in a row as tall as the field (see above). + ui.allocate_ui_with_layout(vec2(ui.available_width(), 30.0), Layout::right_to_left(Align::Center), |ui| { if ui.add_enabled(!draft.trim().is_empty(), secondary_button("新增規則")).clicked() { rules.push(draft.trim().to_string()); draft.clear(); diff --git a/src/app/drops_ui.rs b/src/app/drops_ui.rs index 13087e1..76aa08b 100644 --- a/src/app/drops_ui.rs +++ b/src/app/drops_ui.rs @@ -352,23 +352,27 @@ impl App { crate::icons::paint(ui.painter(), egui::Rect::from_center_size(rect.left_center() + vec2(12.0, 0.0), vec2(18.0, 18.0)), icon, p.text3); // Buttons on the right, then the words in what is left. let mut right = rect.right(); - let mut button = |ui: &mut egui::Ui, label: &str, w: f32| -> bool { + // (Each as wide as its words plus the button's padding — fixed widths broke 「移除」 + // onto two lines once the type grew.) + let mut button = |ui: &mut egui::Ui, label: &str| -> bool { + let words = t(label); + let w = ui.painter().layout_no_wrap(words.clone(), egui::FontId::proportional(FONT_XS), p.text).size().x + ui.spacing().button_padding.x * 2.0 + 4.0; let r = egui::Rect::from_min_size(egui::pos2(right - w, rect.center().y - 13.0), vec2(w, 26.0)); right -= w + 6.0; - ui.put(r, egui::Button::new(RichText::new(t(label)).size(FONT_XS)).corner_radius(R_M)).clicked() + ui.put(r, egui::Button::new(RichText::new(words).size(FONT_XS)).wrap_mode(egui::TextWrapMode::Extend).corner_radius(R_M)).clicked() }; - if button(ui, "移除", 44.0) { + if button(ui, "移除") { acts.push(("remove", id.clone())); } - if bad && button(ui, "再試一次", 68.0) { + if bad && button(ui, "再試一次") { acts.push(("retry", id.clone())); } if !words.is_empty() { - if button(ui, "複製", 44.0) { + if button(ui, "複製") { acts.push(("copy", words.to_string())); } } else if let Some(path) = here.get(&id).filter(|f| std::path::Path::new(f).exists()) { - if button(ui, "顯示", 44.0) { + if button(ui, "顯示") { acts.push(("reveal", path.clone())); } } diff --git a/src/app/kit.rs b/src/app/kit.rs index b243ce8..1cacc53 100644 --- a/src/app/kit.rs +++ b/src/app/kit.rs @@ -16,6 +16,7 @@ //! 設定列上的只在滑鼠移到那一列時出現。 //! - **按鈕** `primary_button`(實心,一個畫面一顆)、`secondary_button`(淡底)、`danger_button`; //! 刪除這種不能回頭的,用紅字無底按鈕並按兩次確認(由呼叫的地方做)。 +//! - **等你的卡片** `needs_you_card`:允許、問題、交給你處理的步驟——同一種黃(黃=需要你)。 //! - **分段選擇** `segmented`;**對話框底部** `dialog_footer`(左:影響內容本身的;右:完成)。 use super::*; @@ -192,6 +193,19 @@ pub(super) fn form_row(ui: &mut egui::Ui, label: &str, p: Palette, body: impl Fn ui.horizontal(|ui| body(ui)); } +/// A form field whose name has a 「?」 beside it (what the field does, on hover) instead of a +/// sentence under the box. +pub(super) fn form_row_help(ui: &mut egui::Ui, label: &str, help: &str, p: Palette, body: impl FnOnce(&mut egui::Ui)) { + ui.add_space(sp::S2); + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = sp::S1; + ui.label(RichText::new(t(label)).size(FONT_SM).color(p.text2)); + help_mark(ui, help, p); + }); + ui.add_space(sp::S1 * 0.5); + ui.horizontal(|ui| body(ui)); +} + /// Two short fields side by side (帳號 and 密碼), each with its name above it. pub(super) fn form_pair(ui: &mut egui::Ui, p: Palette, left_label: &str, left: impl FnOnce(&mut egui::Ui), right_label: &str, right: impl FnOnce(&mut egui::Ui)) { let gap = sp::S3; @@ -211,6 +225,40 @@ pub(super) fn form_pair(ui: &mut egui::Ui, p: Palette, left_label: &str, left: i }); } +/// A card's title row that folds the card: the title, one grey line of how it is set (「11/11 +/// 類」), the 「?」 (on hover) and ▸/▾ at the right end. Folded until clicked — what most people +/// never change stays one line. Returns whether the card is open. +pub(super) fn fold_title(ui: &mut egui::Ui, p: Palette, id: impl std::hash::Hash + std::fmt::Debug, title: &str, summary: &str, help: &str) -> bool { + let id = egui::Id::unique(("fold", id)); + let mut open = ui.data(|d| d.get_temp::(id)).unwrap_or(false); + let (rect, r) = ui.allocate_exact_size(vec2(ui.available_width(), 24.0), egui::Sense::click()); + let hovered = r.hovered(); + if r.on_hover_cursor(egui::CursorIcon::PointingHand).clicked() { + open = !open; + ui.data_mut(|d| d.insert_temp(id, open)); + } + let mut row = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(Layout::left_to_right(Align::Center))); + row.spacing_mut().item_spacing.x = sp::S1; + row.label(RichText::new(t(title)).strong().family(crate::bold()).size(FONT_BASE)); + help_mark_when(&mut row, help, p, hovered); + if !summary.is_empty() { + row.add_space(sp::S1); + row.add(egui::Label::new(RichText::new(summary).size(FONT_SM).color(p.text3)).truncate()); + } + ui.painter().text(rect.right_center() - vec2(4.0, 0.0), egui::Align2::RIGHT_CENTER, if open { "▾" } else { "▸" }, egui::FontId::proportional(FONT_READ), p.text3); + if open { + ui.add_space(sp::S2); + } + open +} + +/// The card of something waiting for you — an approval, a question, a step handed to you on a +/// computer: the one yellow (yellow means 「需要你」 everywhere), a soft tint and a thin edge. +/// One look for all three (the hand-off card used to be outlined in the accent and read as red). +pub(super) fn needs_you_card(ui: &mut egui::Ui, p: Palette, body: impl FnOnce(&mut egui::Ui) -> R) -> egui::InnerResponse { + Frame::new().fill(p.attention_bg).stroke(Stroke::new(1.5, p.attention)).corner_radius(R_L).inner_margin(Margin::symmetric(16, 14)).show(ui, body) +} + /// A row of a list with a live state: the name, then a coloured dot and the state in one grey /// line under it (an error in red), the controls on the right — a connector, a channel. pub(super) fn status_row(ui: &mut egui::Ui, p: Palette, label: &str, status: &str, dot: Color32, control: impl FnOnce(&mut egui::Ui)) { diff --git a/src/app/pages_ui.rs b/src/app/pages_ui.rs index f07b4c8..927ca06 100644 --- a/src/app/pages_ui.rs +++ b/src/app/pages_ui.rs @@ -1,5 +1,5 @@ -// 頁面 in the window: the card under a reply (like the original's chat card — the title, a few -// lines of the page fading out, then a footer row with the page icon, its name and 「頁面」), the +// 頁面 in the window: the card under a reply (one compact card — icon, title, one line of what it +// says, one grey line of what it is), the // page itself in a large dialog (the whole page drawn with the chat's Markdown, the version picker // and 存成檔案), and the list under 資料庫 in the right panel. @@ -17,49 +17,37 @@ impl App { }; let now = crate::model::now_ms(); let w = ui.available_width().min(CARD_W); - let resp = Frame::new().fill(p.pane).stroke(Stroke::new(1.0, p.border)).corner_radius(R_L).show(ui, |ui| { - ui.set_width(w); - ui.spacing_mut().item_spacing.y = 0.0; - // The page's beginning: the title, then a few lines fading out. - Frame::new().inner_margin(Margin { left: 18, right: 18, top: 16, bottom: 12 }).show(ui, |ui| { - ui.set_width(ui.available_width()); - ui.add(egui::Label::new(RichText::new(&page.title).size(FONT_H3).strong().family(crate::bold()).color(p.text)).wrap()); - ui.add_space(8.0); - let lines = crate::pages::preview(&page, 4); - let n = lines.len().max(1) as f32; - for (i, l) in lines.iter().enumerate() { - let fade = 1.0 - (i as f32 / n) * 0.65; - let c = if i == 0 && !page.summary.is_empty() { p.text } else { p.text2 }; - ui.add(egui::Label::new(RichText::new(l).size(FONT_SM).color(c.gamma_multiply(fade))).truncate()); - ui.add_space(4.0); - } - }); - let r = ui.min_rect(); - ui.painter().hline(r.x_range(), r.bottom(), Stroke::new(1.0, p.border)); - // The footer row: page icon, name, 「頁面 · 第 N 版 · 更新」. - Frame::new().inner_margin(Margin::symmetric(18, 12)).show(ui, |ui| { - ui.set_width(ui.available_width()); - ui.horizontal(|ui| { - let (ir, _) = ui.allocate_exact_size(vec2(30.0, 36.0), egui::Sense::hover()); - page_glyph(ui.painter(), ir, p); - ui.add_space(8.0); - ui.vertical(|ui| { - ui.spacing_mut().item_spacing.y = 2.0; - ui.add(egui::Label::new(RichText::new(&page.title).size(FONT_BASE).color(p.text)).truncate()); - let mut meta = format!("{} · {}", t("頁面"), crate::pages::ago(page.updated, now)); - if let Some(k) = crate::pages::kind_label(&page.kind) { - meta = format!("{k} · {meta}"); - } - if page.revision > 1 { - meta = format!("{meta} · {}", t("已更新")); - } - ui.label(RichText::new(meta).size(FONT_XS).color(p.text3)); - }); + // One compact card, the way Claude shows a document in a chat: the page's icon, its + // title once, one line of what it says (what changed, when it was updated), and one grey + // line of what it is. (It used to show the title twice and four fading lines of the page.) + let gist = if page.revision > 1 && !page.note.is_empty() { + format!("{}:{}", t("已更新"), page.note) + } else if !page.summary.is_empty() { + page.summary.clone() + } else { + crate::pages::preview(&page, 1).into_iter().next().unwrap_or_default() + }; + let mut meta = format!("{} · {}", t("頁面"), crate::pages::ago(page.updated, now)); + if let Some(k) = crate::pages::kind_label(&page.kind) { + meta = format!("{k} · {meta}"); + } + if page.revision > 1 { + meta = format!("{meta} · {} {} {}", t("第"), page.revision, t("版")); + } + let resp = Frame::new().fill(p.pane).stroke(Stroke::new(1.0, p.border)).corner_radius(R_L).inner_margin(Margin::symmetric(14, 12)).show(ui, |ui| { + ui.set_width(w - 28.0); + ui.horizontal_top(|ui| { + ui.spacing_mut().item_spacing.x = crate::theme::sp::S3; + let (ir, _) = ui.allocate_exact_size(vec2(30.0, 36.0), egui::Sense::hover()); + page_glyph(ui.painter(), ir, p); + ui.vertical(|ui| { + ui.spacing_mut().item_spacing.y = 2.0; + ui.add(egui::Label::new(RichText::new(&page.title).size(FONT_BASE).family(crate::bold()).color(p.text)).truncate()); + if !gist.is_empty() { + ui.add(egui::Label::new(RichText::new(&gist).size(FONT_SM).color(p.text2)).truncate()); + } + ui.label(RichText::new(meta).size(FONT_XS).color(p.text3)); }); - if page.revision > 1 && !page.note.is_empty() { - ui.add_space(6.0); - ui.add(egui::Label::new(RichText::new(format!("{}:{}", t("最近更新"), page.note)).size(FONT_SM).color(p.text2)).wrap()); - } }); }); let r = ui.interact(resp.response.rect, egui::Id::unique(("page-card", id, self.msg_index)), egui::Sense::click()); diff --git a/src/app/profile_ui.rs b/src/app/profile_ui.rs index ada6df4..b9f6852 100644 --- a/src/app/profile_ui.rs +++ b/src/app/profile_ui.rs @@ -29,8 +29,11 @@ impl App { pub(super) fn profile_abilities_card(&mut self, ui: &mut egui::Ui, b: &mut Bot) { let p = self.pal; setting_card(ui, p, |ui| { - setting_title(ui, "能力", "這個 Bot 可以用哪幾類工具。沒勾的不會提供給它,也不會寫進它的說明:每一步都比較省 token,也比較安全。記憶、技能、問你問題、傳檔案到聊天每個 Bot 都有。", p); let mut on: Vec = b.abilities.clone().unwrap_or_else(|| crate::profile::ABILITIES.iter().map(|a| a.0.to_string()).collect()); + let summary = format!("{} / {} {}", crate::profile::ABILITIES.iter().filter(|a| on.iter().any(|o| o == a.0)).count(), crate::profile::ABILITIES.len(), t("類")); + if !fold_title(ui, p, ("abilities", b.id), "能力", &summary, "這個 Bot 可以用哪幾類工具。沒勾的不會提供給它,也不會寫進它的說明:每一步都比較省 token,也比較安全。記憶、技能、問你問題、傳檔案到聊天每個 Bot 都有。") { + return; + } let mut changed = false; egui::Grid::new(("abilities", b.id)).num_columns(2).spacing([16.0, 4.0]).show(ui, |ui| { for (i, (key, label, what)) in crate::profile::ABILITIES.iter().enumerate() { @@ -65,8 +68,11 @@ impl App { return; } setting_card(ui, p, |ui| { - setting_title(ui, "技能", "從技能庫勾選這個 Bot 會的技能。它的說明裡只列這些,用到時才讀完整做法。它自己學會(存成)的技能會自動加進來。", p); let mut mine: Vec = b.skills.clone().unwrap_or_else(|| all.iter().map(|k| k.0.clone()).collect()); + let summary = format!("{} {} / {}", t("會"), all.iter().filter(|k| mine.contains(&k.0)).count(), all.len()); + if !fold_title(ui, p, ("skills", b.id), "技能", &summary, "從技能庫勾選這個 Bot 會的技能。它的說明裡只列這些,用到時才讀完整做法。它自己學會(存成)的技能會自動加進來。") { + return; + } let mut changed = false; ui.horizontal(|ui| { let n = all.iter().filter(|k| mine.contains(&k.0)).count(); diff --git a/src/i18n_table.rs b/src/i18n_table.rs index ee7882f..c363a86 100644 --- a/src/i18n_table.rs +++ b/src/i18n_table.rs @@ -51,6 +51,9 @@ pub const ROWS: &[(&str, &str, &str)] = &[ ("在下一則訊息引用這段", "Quote this in the next message", "次のメッセージで引用"), ("拒絕", "Deny", "拒否"), ("⚡ 全部允許,之後直接操作", "⚡ Allow everything and act directly from now on", "⚡ すべて許可し、以後は直接操作"), + ("之後都直接操作,不再一個個問", "Act directly from now on, without asking each time", "以後は一つずつ聞かずに直接操作"), + ("它想在你的電腦上執行:", "It wants to run on your computer:", "あなたのコンピュータで実行しようとしています:"), + ("它想做的事:", "What it wants to do:", "やろうとしていること:"), ("打開「直接操作」:Bot 可以直接使用這台電腦和瀏覽器,不再一個個問你。危險指令、密碼檔和你的「一律詢問」規則仍會擋下來。可在設定 → 權限關掉。", "Turn on Direct mode: bots use this computer and the browser directly without asking each time. Dangerous commands, password files and your “always ask” rules are still stopped. You can turn it off in Settings → Permissions.", "「直接操作」をオン:Bot はこのコンピューターとブラウザを毎回確認せずに使います。危険なコマンド、パスワードファイル、「常に確認」ルールは引き続き止められます。設定 → 権限でオフにできます。"), ("先關掉這個視窗;聊天裡的卡片還在,Bot 會一直等你", "Close this window for now; the card stays in the chat and the bot keeps waiting", "このウィンドウをいったん閉じます。カードはチャットに残り、Bot は待ち続けます"), ("傳訊息給 {name}", "Message {name}", "{name} にメッセージ"), diff --git a/src/theme.rs b/src/theme.rs index 04dae1b..77fb6de 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -438,7 +438,7 @@ mod spec_tests { const COLOURS_LEFT: usize = 66; // Frames drawn as a card (a fill and a border) outside the kit: only ever fewer — a // card is the kit's `setting_card` / `rows_card`, and never inside another card. - const CARDS_LEFT: usize = 17; + const CARDS_LEFT: usize = 13; let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src"); let mut files = vec![dir.join("app.rs")]; for e in std::fs::read_dir(dir.join("app")).unwrap().flatten() {