AnyBot/src/app/kit.rs

360 lines
19 KiB
Rust
Raw Normal View History

2026-11-16 14:07:07 +00:00
//! 共用元件:每個畫面都從這裡拿,不自己畫框、不自己定字級。
//!
//! 依 Claude 的設計原則(卡片樣式按角色用、重複的元素長得一樣)與設計規格(theme.rs):
//!
//! - **區段** `section` / `section_with`:13 px 灰色粗體小標,上方 24、下方 8。設定的每一頁都用它。
//! - **群組** `rows_card`:一張卡(elevated 底、細框、圓角 14),裝一組**設定列**;列與列之間
//! 自動一條細線。一頁的設定就是「區段+群組」一組一組往下排。
//! - **設定列** `card_row`:左邊名稱(14)、可選的一行狀態(13 灰)和「?」說明,右邊控制項;
//! 控制項先排、名稱拿剩下的寬度(太長就「…」)。高 52,有狀態 62。
//! - **卡片** `setting_card` + `setting_title`:給一整塊有標題、有欄位的內容(Bot 設定的幾段)。
//! 卡片裡放列、欄位、文字——**不再放卡片**(卡中卡是畫面亂的主因)。
//! - **欄位** `form_row`:名稱在上(13 px 灰)、輸入框在下滿寬——整個 App 只有這一種標法;
//! 兩個短欄位並排用 `form_pair`(帳號/密碼)。`field_label` 是單獨的欄位名稱。
//! - **狀態列** `status_row`:清單裡有即時狀態的一列(連接器、訊息管道):名稱、色點+一行狀態、右邊控制項。
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
//! - **說明** `hint`:13 px 灰字,**一行**(長的結尾「…」,滑過看全文)。`help_mark` 是名稱旁的「?」,
//! 設定列上的只在滑鼠移到那一列時出現。
2026-11-16 14:07:07 +00:00
//! - **按鈕** `primary_button`(實心,一個畫面一顆)、`secondary_button`(淡底)、`danger_button`;
//! 刪除這種不能回頭的,用紅字無底按鈕並按兩次確認(由呼叫的地方做)。
design: 全畫面審查第一輪——修傳送按鈕破版、提示改灰、等你的卡片統一、允許卡片精簡、頁面卡片一張、Bot 設定進階收起 依 Anthropic 的設計原則逐一看過 39 個畫面,這一輪改: - 傳送到其他裝置:「移除/複製/再試一次」寫死寬度,字一大就斷成兩行——改成照字量寬 - 輸入框下的提示(已排入…、已複製…)用強調色像錯誤——改成灰字 - 等你的卡片統一成 kit::needs_you_card(允許、問題、交給你處理):同一種黃;「需要處理」以前是強調色框看起來像紅色 - 允許卡片:一句「它想在你的電腦上執行:」+指令,三個短按鈕「允許/一律允許/拒絕」(一律允許會打開什麼放在滑過說明), 「直接操作」改成灰字一行;標題字級回到規格(藏著的 17/14) - 聊天裡的頁面卡片:一張精簡卡(圖示、標題一次、一行重點、一行灰字),以前標題出現兩次加四行預覽 - Bot 設定:電腦操作/能力/技能/記憶 預設收起,一行顯示目前怎麼設(kit::fold_title); 「執行步驟用的模型」「思考模式」改成名稱在上、說明在「?」(kit::form_row_help),不再兩段灰字 - 權限:「新增規則」那列不再撐滿剩下的高度(大片空白) - 看守:自己畫的卡片上限 17 → 13 已驗證: cargo test 523 全過(排版檢查、規格看守)、改過的畫面截圖目視
2026-11-16 14:57:13 +00:00
//! - **等你的卡片** `needs_you_card`:允許、問題、交給你處理的步驟——同一種黃(黃=需要你)。
2026-11-16 14:07:07 +00:00
//! - **分段選擇** `segmented`;**對話框底部** `dialog_footer`(左:影響內容本身的;右:完成)。
use super::*;
use crate::theme::sp;
/// A group heading inside a settings page (like the original's section titles).
pub(super) fn section(ui: &mut egui::Ui, title: &str, p: Palette) {
section_with(ui, title, p, |_| {});
}
/// A section heading with something at its right end (a name, a button).
pub(super) fn section_with(ui: &mut egui::Ui, title: &str, p: Palette, accessory: impl FnOnce(&mut egui::Ui)) {
ui.add_space(sp::S5);
ui.horizontal(|ui| {
ui.add_space(sp::S1);
ui.label(RichText::new(t(title)).size(FONT_SM).family(crate::bold()).color(p.text2));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
ui.add_space(sp::S1);
accessory(ui);
});
});
ui.add_space(sp::S2);
}
/// A small「?」after a setting's name. Its explanation shows as soon as the pointer is on it (no
/// waiting for the pointer to be still), and a click keeps it open until the next click.
pub(super) fn help_mark(ui: &mut egui::Ui, text: &str, p: Palette) {
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
help_mark_when(ui, text, p, true);
}
/// The 「?」 of a settings row: drawn only while the pointer is on its row (`visible`) or its
/// note is pinned open — a page of rows doesn't show a page of question marks. Its place is
/// kept either way, so the name beside it never moves.
pub(super) fn help_mark_when(ui: &mut egui::Ui, text: &str, p: Palette, visible: bool) {
2026-11-16 14:07:07 +00:00
if text.trim().is_empty() {
return;
}
let (rect, r) = ui.allocate_exact_size(vec2(18.0, 18.0), egui::Sense::click());
let pinned_id = r.id.with("pinned");
let mut pinned = ui.ctx().data(|d| d.get_temp::<bool>(pinned_id)).unwrap_or(false);
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
if !visible && !pinned && !r.hovered() {
return;
}
2026-11-16 14:07:07 +00:00
if r.clicked() {
pinned = !pinned;
} else if pinned && ui.input(|i| i.pointer.any_pressed()) && !r.hovered() {
pinned = false;
}
ui.ctx().data_mut(|d| d.insert_temp(pinned_id, pinned));
let show = r.hovered() || pinned;
let col = if show { p.text } else { p.text3 };
ui.painter().circle_stroke(rect.center(), 6.5, Stroke::new(1.1, col));
// (A glyph sized to its 14 px ring, an icon rather than text on the type scale.)
const HELP_GLYPH: f32 = 10.0;
ui.painter().text(rect.center() + vec2(0.0, 0.5), egui::Align2::CENTER_CENTER, "?", egui::FontId::proportional(HELP_GLYPH), col);
if show {
let text = t(text);
egui::Area::new(r.id.with("help"))
.order(egui::Order::Tooltip)
.fixed_pos(rect.left_bottom() + vec2(-4.0, 6.0))
.constrain(true)
.interactable(false)
.show(ui.ctx(), |ui| {
Frame::popup(ui.style()).corner_radius(R_M).inner_margin(Margin::symmetric(12, 10)).show(ui, |ui| {
ui.set_max_width(300.0);
ui.add(egui::Label::new(RichText::new(text).size(FONT_SM).color(p.text)).wrap());
});
});
}
r.on_hover_cursor(egui::CursorIcon::Help);
}
/// A group of settings: one quiet card, its rows (`card_row`) divided by hairlines.
pub(super) fn rows_card(ui: &mut egui::Ui, p: Palette, rows: impl FnOnce(&mut egui::Ui)) {
Frame::new().fill(p.elevated).stroke(Stroke::new(1.0, p.border)).corner_radius(R_L).inner_margin(Margin::symmetric(16, 1)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.spacing_mut().item_spacing.y = 0.0;
rows(ui);
});
}
/// One setting in a card: its name (and at most one small line under it) on the left, its
/// control on the right; anything longer is behind the ? (`help`).
pub(super) fn card_row(ui: &mut egui::Ui, p: Palette, label: &str, sub: &str, help: &str, control: impl FnOnce(&mut egui::Ui)) {
let top = ui.cursor().top();
if top > ui.max_rect().top() + 1.0 {
ui.painter().hline(ui.max_rect().x_range(), top, Stroke::new(1.0, p.border));
}
let h = if sub.is_empty() { 52.0 } else { 62.0 };
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), h), egui::Sense::hover());
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
let row_hovered = ui.rect_contains_pointer(rect);
2026-11-16 14:07:07 +00:00
// The control first, from the right edge; the words get the room that is left.
let mut right = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(Layout::right_to_left(Align::Center)));
right.spacing_mut().item_spacing.x = 8.0;
control(&mut right);
let words = egui::Rect::from_min_max(rect.min, egui::pos2((right.min_rect().left() - 12.0).max(rect.left() + 80.0), rect.bottom()));
if sub.is_empty() {
let mut left = ui.new_child(egui::UiBuilder::new().max_rect(words).layout(Layout::left_to_right(Align::Center)));
left.spacing_mut().item_spacing.x = 4.0;
left.add(egui::Label::new(RichText::new(t(label)).size(FONT_BASE).color(p.text)).truncate());
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
help_mark_when(&mut left, help, p, row_hovered);
2026-11-16 14:07:07 +00:00
} else {
let mut left = ui.new_child(egui::UiBuilder::new().max_rect(words).layout(Layout::top_down(Align::Min)));
left.spacing_mut().item_spacing = vec2(4.0, 1.0);
left.add_space((h - 42.0) / 2.0);
left.horizontal(|ui| {
ui.add(egui::Label::new(RichText::new(t(label)).size(FONT_BASE).color(p.text)).truncate());
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
help_mark_when(ui, help, p, row_hovered);
2026-11-16 14:07:07 +00:00
});
left.add(egui::Label::new(RichText::new(t(sub)).size(FONT_SM).color(p.text2)).truncate());
}
}
/// A choice among a few: the one chosen is the raised, bold one. Returns a new choice.
pub(super) fn segmented<T: PartialEq + Copy>(ui: &mut egui::Ui, p: Palette, cur: T, options: &[(T, &str)]) -> Option<T> {
let mut picked = None;
Frame::new().fill(p.active).corner_radius(R_M).inner_margin(Margin::same(3)).show(ui, |ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
// (In a row laid out from the right, the first choice is still the left one.)
let reversed = ui.layout().prefer_right_to_left();
let order: Vec<&(T, &str)> = if reversed { options.iter().rev().collect() } else { options.iter().collect() };
for (v, label) in order {
let on = *v == cur;
let text = RichText::new(t(label)).size(FONT_SM).color(if on { p.text } else { p.text2 });
let text = if on { text.family(crate::bold()) } else { text };
if ui.add(egui::Button::new(text).fill(if on { p.elevated } else { Color32::TRANSPARENT }).stroke(Stroke::NONE).corner_radius(R_M).min_size(vec2(0.0, 26.0))).clicked() && !on {
picked = Some(*v);
}
}
});
});
picked
}
pub(super) fn setting_title(ui: &mut egui::Ui, title: &str, desc: &str, p: Palette) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 4.0;
ui.label(RichText::new(t(title)).strong().family(crate::bold()).size(FONT_BASE));
help_mark(ui, desc, p);
});
ui.add_space(4.0);
}
/// Small grey text under a setting.
pub(super) fn hint(ui: &mut egui::Ui, text: impl Into<String>, p: Palette) {
design: 設定減字+頁面照 Anthropic 的報告寫法(寫法規則、存檔前檢查、可收起的細節) 設定頁(字太多): - 設定列的「?」平常不顯示,滑鼠移到那一列才出現(位置保留,名稱不跳動) - 設定下面的說明只顯示一行,長的結尾「…」,滑過看全文 - 外觀只留主題、強調色、聊天的顏色、語言;底色、對比、密度、慶祝動畫、重設收進「更多外觀設定」 - 聊天的顏色只有點(選中的有外圈),不再加一段文字;「你的電腦已是最新版本」改成灰字一行,不再是橘框 頁面(內容太亂、字太多): - 給 Bot 的寫法規則改成 Anthropic 的寫法:標題就是結論、第一句補理由、最多三點;數字放 stats/表格; 一節最多一處粗體;不用「→」、分隔線、標題編號;待辦用 steps、指令放程式碼;細節放 details - 存檔前檢查(pages::review):段落太長、粗體太多、括號裡一串數字、標題編號、分隔線、「→」、表格裡的指令、 很長卻沒有 details——退回一次並列出每一處;同一頁第二次照存,不會卡住 - 新頁面區塊 ```details 標題:預設收起的一行「▸ 標題」,點了展開(電腦和手機) 已驗證: cargo test 523 全過(新增:寫法檢查抓得到那頁的毛病、乾淨的頁面不報;退回一次第二次照存; details 標題與收起)、clippy 21=基線、手機四段腳本 node --check、深色設定頁截圖目視 未驗證: 真的模型照新規則寫出來的頁面長怎樣(要等 Bot 下次寫頁面)
2026-11-16 14:28:37 +00:00
// One line: a settings page is names and controls, not paragraphs. A longer note ends in
// 「…」 and shows whole under the pointer.
ui.add(egui::Label::new(RichText::new(t(&text.into())).size(FONT_SM).color(p.text2)).truncate());
2026-11-16 14:07:07 +00:00
}
/// A rounded group of related settings, like a macOS settings card.
pub(super) fn setting_card<R>(ui: &mut egui::Ui, p: Palette, body: impl FnOnce(&mut egui::Ui) -> R) -> R {
let r = Frame::new()
.fill(p.elevated)
.stroke(Stroke::new(1.0, p.border))
.corner_radius(R_L)
.inner_margin(Margin::symmetric(16, 14))
.show(ui, |ui| {
ui.set_width(ui.available_width());
body(ui)
})
.inner;
ui.add_space(12.0);
r
}
/// A label column so form rows line up.
/// A form field: its name above (13 px grey), the input below at full width. The app's one way
/// to label an input (a label column on the left, a label inline, or none at all made a form
/// whose boxes started at different places).
2026-11-16 14:07:07 +00:00
pub(super) fn form_row(ui: &mut egui::Ui, label: &str, p: Palette, body: impl FnOnce(&mut egui::Ui)) {
field_label(ui, label, p);
ui.horizontal(|ui| body(ui));
}
/// Guidance in a flow (開始使用, a form's how-to): 13 px grey that wraps — unlike `hint`, which is
/// one line on a settings page. For the few places where the explanation is the point.
pub(super) fn note(ui: &mut egui::Ui, text: impl Into<String>, p: Palette) {
ui.add(egui::Label::new(RichText::new(t(&text.into())).size(FONT_SM).color(p.text2)).wrap());
}
design: 全畫面審查第一輪——修傳送按鈕破版、提示改灰、等你的卡片統一、允許卡片精簡、頁面卡片一張、Bot 設定進階收起 依 Anthropic 的設計原則逐一看過 39 個畫面,這一輪改: - 傳送到其他裝置:「移除/複製/再試一次」寫死寬度,字一大就斷成兩行——改成照字量寬 - 輸入框下的提示(已排入…、已複製…)用強調色像錯誤——改成灰字 - 等你的卡片統一成 kit::needs_you_card(允許、問題、交給你處理):同一種黃;「需要處理」以前是強調色框看起來像紅色 - 允許卡片:一句「它想在你的電腦上執行:」+指令,三個短按鈕「允許/一律允許/拒絕」(一律允許會打開什麼放在滑過說明), 「直接操作」改成灰字一行;標題字級回到規格(藏著的 17/14) - 聊天裡的頁面卡片:一張精簡卡(圖示、標題一次、一行重點、一行灰字),以前標題出現兩次加四行預覽 - Bot 設定:電腦操作/能力/技能/記憶 預設收起,一行顯示目前怎麼設(kit::fold_title); 「執行步驟用的模型」「思考模式」改成名稱在上、說明在「?」(kit::form_row_help),不再兩段灰字 - 權限:「新增規則」那列不再撐滿剩下的高度(大片空白) - 看守:自己畫的卡片上限 17 → 13 已驗證: cargo test 523 全過(排版檢查、規格看守)、改過的畫面截圖目視
2026-11-16 14:57:13 +00:00
/// 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;
let w = ((ui.available_width() - gap) / 2.0).max(80.0);
ui.horizontal_top(|ui| {
ui.spacing_mut().item_spacing.x = gap;
ui.vertical(|ui| {
ui.set_width(w);
field_label(ui, left_label, p);
ui.horizontal(|ui| left(ui));
});
ui.vertical(|ui| {
ui.set_width(w);
field_label(ui, right_label, p);
ui.horizontal(|ui| right(ui));
});
});
}
design: 全畫面審查第一輪——修傳送按鈕破版、提示改灰、等你的卡片統一、允許卡片精簡、頁面卡片一張、Bot 設定進階收起 依 Anthropic 的設計原則逐一看過 39 個畫面,這一輪改: - 傳送到其他裝置:「移除/複製/再試一次」寫死寬度,字一大就斷成兩行——改成照字量寬 - 輸入框下的提示(已排入…、已複製…)用強調色像錯誤——改成灰字 - 等你的卡片統一成 kit::needs_you_card(允許、問題、交給你處理):同一種黃;「需要處理」以前是強調色框看起來像紅色 - 允許卡片:一句「它想在你的電腦上執行:」+指令,三個短按鈕「允許/一律允許/拒絕」(一律允許會打開什麼放在滑過說明), 「直接操作」改成灰字一行;標題字級回到規格(藏著的 17/14) - 聊天裡的頁面卡片:一張精簡卡(圖示、標題一次、一行重點、一行灰字),以前標題出現兩次加四行預覽 - Bot 設定:電腦操作/能力/技能/記憶 預設收起,一行顯示目前怎麼設(kit::fold_title); 「執行步驟用的模型」「思考模式」改成名稱在上、說明在「?」(kit::form_row_help),不再兩段灰字 - 權限:「新增規則」那列不再撐滿剩下的高度(大片空白) - 看守:自己畫的卡片上限 17 → 13 已驗證: cargo test 523 全過(排版檢查、規格看守)、改過的畫面截圖目視
2026-11-16 14:57:13 +00:00
/// 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::<bool>(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<R>(ui: &mut egui::Ui, p: Palette, body: impl FnOnce(&mut egui::Ui) -> R) -> egui::InnerResponse<R> {
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)) {
let top = ui.cursor().top();
if top > ui.max_rect().top() + 1.0 {
ui.painter().hline(ui.max_rect().x_range(), top, Stroke::new(1.0, p.border));
}
let (rect, _) = ui.allocate_exact_size(vec2(ui.available_width(), 62.0), egui::Sense::hover());
let mut right = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(Layout::right_to_left(Align::Center)));
right.spacing_mut().item_spacing.x = sp::S2;
control(&mut right);
let words = egui::Rect::from_min_max(rect.min, egui::pos2((right.min_rect().left() - 12.0).max(rect.left() + 80.0), rect.bottom()));
let mut left = ui.new_child(egui::UiBuilder::new().max_rect(words).layout(Layout::top_down(Align::Min)));
left.spacing_mut().item_spacing = vec2(6.0, 2.0);
left.add_space(10.0);
left.add(egui::Label::new(RichText::new(label).size(FONT_BASE).family(crate::bold()).color(p.text)).truncate());
left.horizontal(|ui| {
let (r, _) = ui.allocate_exact_size(vec2(8.0, 14.0), egui::Sense::hover());
ui.painter().circle_filled(r.center(), 3.5, dot);
let col = if dot == p.danger { p.danger } else { p.text2 };
ui.add(egui::Label::new(RichText::new(status).size(FONT_SM).color(col)).truncate());
2026-11-16 14:07:07 +00:00
});
}
feat: 連接器、技能改成「清單+各自的頁」,不再一整頁攤開 照 Claude、ChatGPT 設定頁的做法: - 連接器:最上面「連接器(MCP)」和「瀏覽市集」「新增連接器」兩個按鈕;「已加入」每列只有名稱、 狀態、開關和 ›。點一列進到它自己的頁:狀態、登入、重新連線、開關,「工具(N)」只列它自己的 工具(多時可搜尋),「設定」欄位,最下面「移除這個連接器」(再確認一次)。拿掉把所有工具攤在 一起的「可以用的工具」。市集和新增表單各是一頁;從市集加需要金鑰的,直接打開填好的新增頁; 新增後到新連接器的頁看它連線。 - 技能:「已加入(N)」每列名稱、一行說明、開關、›(超過 8 個可搜尋);點進去看完整說明、 可重播步數、隨附檔案、內容和刪除;內建技能包、Anthropic 開源技能、從網址安裝收進「瀏覽市集」頁。 - 螢幕電腦收到的工具清單改成每個連接器最多 80 個(原本全部合計 60 個,大的連接器會把別的擠掉)。 - 截圖模式:ANYBOT_SHOT_MCP_PAGE、ANYBOT_SHOT_SKILL_PAGE、ANYBOT_SHOT_MCP_TOOLS。 已驗證: cargo test 全綠(含 featuremap::、layout_audit:: 新加的五個頁面);截圖看過清單、連接器頁 (含 12 個工具)、市集、技能清單、技能頁、技能市集。 未驗證: 螢幕電腦連大腦時的連接器頁(工具清單從大腦來);手機的整合頁沒改。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3KhvSzysuKUobKUTR
2026-11-17 09:43:09 +00:00
/// A row that opens a page of its own (a connector, a skill), as other apps' settings lists do:
/// the name and one line under it (with a coloured dot when it is a live state), its quick
/// control (a switch) and a › on the right. A press anywhere else on the row opens it: true.
pub(super) fn nav_row(ui: &mut egui::Ui, p: Palette, label: &str, sub: &str, dot: Option<Color32>, control: impl FnOnce(&mut egui::Ui)) -> bool {
let top = ui.cursor().top();
if top > ui.max_rect().top() + 1.0 {
ui.painter().hline(ui.max_rect().x_range(), top, Stroke::new(1.0, p.border));
}
let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 58.0), egui::Sense::click());
if resp.hovered() {
ui.painter().rect_filled(rect.shrink2(vec2(-8.0, 3.0)), R_M, p.hover);
}
let mut right = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(Layout::right_to_left(Align::Center)));
right.spacing_mut().item_spacing.x = sp::S2;
// (Not selectable: a press on it opens the row too.)
right.add(egui::Label::new(RichText::new("›").size(FONT_H3).color(p.text3)).selectable(false));
feat: 連接器、技能改成「清單+各自的頁」,不再一整頁攤開 照 Claude、ChatGPT 設定頁的做法: - 連接器:最上面「連接器(MCP)」和「瀏覽市集」「新增連接器」兩個按鈕;「已加入」每列只有名稱、 狀態、開關和 ›。點一列進到它自己的頁:狀態、登入、重新連線、開關,「工具(N)」只列它自己的 工具(多時可搜尋),「設定」欄位,最下面「移除這個連接器」(再確認一次)。拿掉把所有工具攤在 一起的「可以用的工具」。市集和新增表單各是一頁;從市集加需要金鑰的,直接打開填好的新增頁; 新增後到新連接器的頁看它連線。 - 技能:「已加入(N)」每列名稱、一行說明、開關、›(超過 8 個可搜尋);點進去看完整說明、 可重播步數、隨附檔案、內容和刪除;內建技能包、Anthropic 開源技能、從網址安裝收進「瀏覽市集」頁。 - 螢幕電腦收到的工具清單改成每個連接器最多 80 個(原本全部合計 60 個,大的連接器會把別的擠掉)。 - 截圖模式:ANYBOT_SHOT_MCP_PAGE、ANYBOT_SHOT_SKILL_PAGE、ANYBOT_SHOT_MCP_TOOLS。 已驗證: cargo test 全綠(含 featuremap::、layout_audit:: 新加的五個頁面);截圖看過清單、連接器頁 (含 12 個工具)、市集、技能清單、技能頁、技能市集。 未驗證: 螢幕電腦連大腦時的連接器頁(工具清單從大腦來);手機的整合頁沒改。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uirha3KhvSzysuKUobKUTR
2026-11-17 09:43:09 +00:00
control(&mut right);
let words = egui::Rect::from_min_max(rect.min, egui::pos2((right.min_rect().left() - 12.0).max(rect.left() + 80.0), rect.bottom()));
let mut left = ui.new_child(egui::UiBuilder::new().max_rect(words).layout(Layout::top_down(Align::Min)));
left.spacing_mut().item_spacing = vec2(6.0, 2.0);
left.add_space(if sub.is_empty() { 19.0 } else { 9.0 });
left.add(egui::Label::new(RichText::new(label).size(FONT_BASE).color(p.text)).truncate().selectable(false));
if !sub.is_empty() {
left.horizontal(|ui| {
if let Some(dot) = dot {
let (r, _) = ui.allocate_exact_size(vec2(8.0, 14.0), egui::Sense::hover());
ui.painter().circle_filled(r.center(), 3.5, dot);
}
let col = if dot == Some(p.danger) { p.danger } else { p.text2 };
ui.add(egui::Label::new(RichText::new(sub).size(FONT_SM).color(col)).truncate().selectable(false));
});
}
resp.on_hover_cursor(egui::CursorIcon::PointingHand).clicked()
}
/// 「‹ 連接器」: back from a page of its own to the list it came from.
pub(super) fn back_link(ui: &mut egui::Ui, text: &str, p: Palette) -> bool {
ui.add(egui::Button::new(RichText::new(format!("‹ {}", t(text))).size(FONT_SM).color(p.text2)).frame(false)).on_hover_cursor(egui::CursorIcon::PointingHand).clicked()
}
2026-11-16 14:07:07 +00:00
pub(super) fn field_label(ui: &mut egui::Ui, text: &str, p: Palette) {
ui.add_space(sp::S2);
ui.label(RichText::new(t(text)).size(FONT_SM).color(p.text2));
ui.add_space(sp::S1 * 0.5);
}
pub(super) fn primary_button(text: &str, p: Palette) -> egui::Button<'static> {
egui::Button::new(RichText::new(t(text)).color(p.on_primary).strong().family(crate::bold())).fill(p.primary).corner_radius(R_M).min_size(vec2(72.0, 30.0))
}
pub(super) fn secondary_button(text: &str) -> egui::Button<'static> {
egui::Button::new(t(text)).corner_radius(R_M).min_size(vec2(64.0, 30.0))
}
pub(super) fn danger_button(text: &str, p: Palette) -> egui::Button<'static> {
egui::Button::new(RichText::new(t(text)).color(Color32::WHITE).strong().family(crate::bold())).fill(p.danger).corner_radius(R_M).min_size(vec2(72.0, 30.0))
}
/// The bottom bar of a dialog: a line above, buttons laid out right to left.
pub(super) fn dialog_footer(ui: &mut egui::Ui, p: Palette, body: impl FnOnce(&mut egui::Ui)) {
let top = ui.cursor().top();
ui.painter().hline(ui.max_rect().x_range(), top, Stroke::new(1.0, p.border));
Frame::new().inner_margin(Margin::symmetric(20, 12)).show(ui, |ui| {
ui.set_width(ui.available_width());
ui.spacing_mut().item_spacing.y = 6.0;
ui.horizontal(|ui| body(ui));
});
}