Bot 設定視窗:第一張卡「Bot 資料」統一排版、自訂顏色只在滑動時寫回、色環收進格子;加 ANYBOT_SHOT_EVERY 逐幀截圖查震動

已驗證: 505 測試全過、clippy 31 警告同基線;逐幀 diff(editor 自訂色 40 幀、設定一般頁)對話窗區域零變化,只剩眨眼動畫在動。
未驗證: 使用者機器上實際的「震動」場景是否就是自訂顏色寫回;需本人在真實視窗確認。
This commit is contained in:
daniel wang 2026-11-16 17:53:56 +08:00
parent dcd9bee7d5
commit f975d9f43c
3 changed files with 55 additions and 19 deletions

View File

@ -8,7 +8,7 @@
- 搜尋「搜尋 Bot 和訊息」:上面列名字或描述相符的 Bot,下面「訊息」列你和 Bot 說過的話和附件檔名(含過去的對話,最多 40 筆),點一筆就捲到那則訊息。
- Bot 選單:「釘選」/「取消釘選」、「移至」、「標示為已讀」/「標示為未讀」、「設為主要 Bot」、「編輯 Bot…」、「記憶…」、「開始新對話」、「過去的對話」、「分享與匯出」(「匯出 Bot(分享給別人)…」「匯出文字記錄…」「匯入 Bot…」「複製對話 ID」)、「重新啟動這個 Bot」、「清除聊天記錄」、「刪除」。
- 建立:「新增 Bot」,或「從範本建立」(研究助理、寫作夥伴、電腦助手、客服助理、開發助手)。新 Bot 沿用目前選中 Bot 的供應商和模型,電腦工具關著。
- 「Bot 設定」:「Bot 名稱」「Bot 描述」;「個人檔案」(Soul 與指示、擅長(什麼事找它)、不找它做的事);「頭像」(14 種形狀、10 種顏色和「自訂」);「AI 供應商與模型」(供應商、「模型名稱」、「選擇」、「執行步驟用的模型」、「思考模式」);「電腦操作」;「能力」;「技能」;「記憶」;最下面「釘選到側邊欄」「團隊成員可以使用這個 Bot(看得到它的聊天、頁面和檔案)」。
- 「Bot 設定」:「Bot 資料」(「Bot 名稱」「Bot 描述」和大頭像,同一張卡);「個人檔案」(Soul 與指示、擅長(什麼事找它)、不找它做的事);「頭像」(14 種形狀、10 種顏色和「自訂」);「AI 供應商與模型」(供應商、「模型名稱」、「選擇」、「執行步驟用的模型」、「思考模式」);「電腦操作」;「能力」;「技能」;「記憶」;最下面「釘選到側邊欄」「團隊成員可以使用這個 Bot(看得到它的聊天、頁面和檔案)」。
- Soul 與指示只有它自己讀;描述、擅長、不找它做的事、會的技能、在哪幾台電腦做事會寫進其他 Bot 的同事名冊。
- 能力 11 類:「上網」「瀏覽器」「看螢幕與操作」「檔案與指令」「Mac App」「連接器」「電話、簡訊、X」「例行任務」「頁面」「和其他 Bot 合作」「管理 App」。沒勾的工具不提供給它,也不寫進說明。記憶、技能、問你問題、傳檔案到聊天、表情和卡片每個 Bot 都有。
- 供應商:xAI Grok、OpenAI、Claude、Google Gemini、OpenRouter、OpenCode Go、Ollama(本機)、自訂(OpenAI 相容),每個 Bot 各選各的。

View File

@ -41,7 +41,7 @@ Bot 設定(每個 Bot 一個視窗,[bots](bots.md)):
## 使用者怎麼到
- 設定視窗:⌘,;或側邊欄左下角你的名字(滑過寫「設定(⌘,)」)。右側面板「新增至 Slack」直接到「整合」,側邊欄的連接器市集圖示到 整合 › 連接器。
- Bot 設定:側邊欄對 Bot 按右鍵,或聊天上方的「⋯」,選「編輯 Bot…」;或在右側面板點 Bot 的大頭像。
- Bot 設定:側邊欄對 Bot 按右鍵,或聊天上方的「⋯」,選「編輯 Bot…」;或在右側面板點 Bot 的大頭像。視窗第一張卡是「Bot 資料」(頭像、名稱、描述),和下面的卡片同一種排版。
- 手機:設定頁有同樣的分類(一般、模型、權限、整合、電腦、保險庫、手機與帳號、更新),能改的比較少([phone](phone.md))。
## 怎麼操作

View File

@ -140,6 +140,8 @@ pub struct App {
pal: Palette,
demo: bool,
screenshot: Option<PathBuf>,
/// ANYBOT_SHOT_EVERY: where the next per-frame picture goes (see handle_screenshot).
every_out: Option<PathBuf>,
frames: u32,
shot_requested: bool,
shot: Arc<Mutex<Option<Arc<egui::ColorImage>>>>,
@ -433,6 +435,7 @@ impl App {
pal: LIGHT,
demo,
screenshot,
every_out: None,
frames: 0,
shot_requested: false,
shot: Arc::new(Mutex::new(None)),
@ -855,6 +858,10 @@ impl App {
Ok("editor") => {
app.edit_bot = app.state.bot(5).cloned().map(|mut b| {
b.allow_rules = vec!["edit_file".into(), "shell:npm install".into()];
// The HSV sliders only show for a custom colour; a jitter test needs that state.
if let Ok(c) = std::env::var("ANYBOT_SHOT_EDITOR_COLOR") {
b.color = c;
}
(b, false)
})
}
@ -4621,6 +4628,11 @@ impl App {
let title = if is_new { "建立 Bot" } else { "Bot 設定" };
let dismissed = dialog(ctx, "bot-editor", title, EDITOR_WIDTH, false, p, |ui| {
dialog_body(ui, "bot-editor-body", body_h, |ui| {
// The identity block is a card like every block below it: same margins, same
// title style, so the top of this window doesn't sit at a different rhythm
// than the 頭像 / 供應商 cards under it (or than 設定 › 一般).
setting_card(ui, p, |ui| {
setting_title(ui, "Bot 資料", "", p);
ui.horizontal_top(|ui| {
ui.spacing_mut().item_spacing.x = 16.0;
avatar::avatar(ui, 64.0, &b.shape, avatar::color(&b.color));
@ -4633,6 +4645,7 @@ impl App {
ui.add(egui::TextEdit::multiline(&mut b.description).hint_text(t("它負責做什麼?")).desired_width(w).desired_rows(2));
});
});
});
ui.add_space(16.0);
// 個人檔案 (a group has none: its members answer, each as itself).
if b.members.is_empty() {
@ -4657,7 +4670,7 @@ impl App {
let (rect, r) = ui.allocate_exact_size(vec2(28.0, 28.0), egui::Sense::click());
ui.painter().circle_filled(rect.center(), 10.0, avatar::color(key));
if b.color == key {
ui.painter().circle_stroke(rect.center(), 13.0, Stroke::new(2.0, p.focus));
ui.painter().circle_stroke(rect.center(), 12.0, Stroke::new(2.0, p.focus));
}
if r.on_hover_text(name).clicked() {
b.color = key.into();
@ -4675,7 +4688,7 @@ impl App {
ui.painter().circle_filled(c, 3.0, avatar::color(&avatar::hex_of_hsv([i as f32 / 12.0 * 360.0, 0.85, 0.85])));
}
if avatar::is_custom(&b.color) {
ui.painter().circle_stroke(rect.center(), 13.0, Stroke::new(2.0, p.focus));
ui.painter().circle_stroke(rect.center(), 12.0, Stroke::new(2.0, p.focus));
}
if r.on_hover_text(t("自訂顏色")).clicked() && !avatar::is_custom(&b.color) {
b.color = avatar::hex_of_hsv(avatar::hsv_of(&b.color));
@ -4684,15 +4697,21 @@ impl App {
});
if avatar::is_custom(&b.color) {
let mut hsv = avatar::hsv_of(&b.color);
let mut touched = false;
ui.horizontal(|ui| {
ui.add(egui::Slider::new(&mut hsv[0], 0.0..=360.0).text(t("色相").to_string()));
ui.add(egui::Slider::new(&mut hsv[1], 0.0..=1.0).text(t("飽和").to_string()));
ui.add(egui::Slider::new(&mut hsv[2], 0.0..=1.0).text(t("明度").to_string()));
touched |= ui.add(egui::Slider::new(&mut hsv[0], 0.0..=360.0).text(t("色相").to_string())).changed();
touched |= ui.add(egui::Slider::new(&mut hsv[1], 0.0..=1.0).text(t("飽和").to_string())).changed();
touched |= ui.add(egui::Slider::new(&mut hsv[2], 0.0..=1.0).text(t("明度").to_string())).changed();
let (sr, _) = ui.allocate_exact_size(vec2(24.0, 24.0), egui::Sense::hover());
ui.painter().circle_filled(sr.center(), 9.0, avatar::color(&avatar::hex_of_hsv(hsv)));
});
// Only write back when a slider moved. The hsv→hex→hsv round trip is not
// exactly the identity (8-bit rounding), so assigning every frame made
// the colour (avatar, ring) tick by ±1/255 for as long as the editor was open.
if touched {
b.color = avatar::hex_of_hsv(hsv);
}
}
});
setting_card(ui, p, |ui| {
setting_title(ui, "AI 供應商與模型", "", p);
@ -5547,6 +5566,18 @@ impl App {
let Some(path) = self.screenshot.clone() else { return };
self.frames += 1;
let need = std::env::var("ANYBOT_SHOT_FRAMES").ok().and_then(|v| v.parse().ok()).unwrap_or(SCREENSHOT_FRAMES);
// ANYBOT_SHOT_EVERY=N: 每 N 幀存一張(path.png.fNN)——用来看哪一块在闪。
if let Some(n) = std::env::var("ANYBOT_SHOT_EVERY").ok().and_then(|v| v.parse::<u32>().ok()) {
if n > 0 && self.frames.is_multiple_of(n) && self.frames >= 40 && self.frames <= 80 && !self.shot_requested && self.every_out.is_none() {
self.every_out = Some(path.with_file_name(format!("{}-{:03}.png", path.file_stem().unwrap_or_default().to_string_lossy(), self.frames)));
let slot = self.shot.clone();
let repaint = ctx.clone();
ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot(egui::ScreenshotCallback::new(move |img| {
*slot.lock().unwrap() = Some(img);
repaint.request_repaint();
})));
}
}
// ANYBOT_SHOT_RESIZE=WxH: halfway through, resize the open window (the same path as the
// person dragging its edge), so the picture shows the layout after a live resize.
if self.frames == need / 2 {
@ -5573,6 +5604,8 @@ impl App {
})));
}
let shot = self.shot.lock().unwrap().take();
// only claim the per-frame name when a picture actually arrived with it
let path = if shot.is_some() { self.every_out.take().unwrap_or(path) } else { path };
if let Some(img) = shot {
let [w, h] = img.size;
let bytes: Vec<u8> = img.pixels.iter().flat_map(|c| c.to_array()).collect();
@ -5587,8 +5620,11 @@ impl App {
}
None => eprintln!("screenshot had an unexpected size"),
}
// EVERY mode keeps running until its last frame; otherwise this closes the run.
if !(std::env::var("ANYBOT_SHOT_EVERY").is_ok() && self.frames < 80) {
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
}
}
ctx.request_repaint();
}
}