design: 你的訊息泡泡預設改成「安靜」(淡灰、黑字,像 Claude),電腦和手機同一個設定

- 聊天的顏色多一個「安靜」並設為預設;原本的「跟著 Bot」「只用黑色」保留
- 存著舊預設(跟著 Bot)的設定檔第一次打開時換成安靜一次(bubble_quiet_offered),
  之後再選回跟著 Bot 就照選的;只用黑色本來就是選的,不動
- 手機:泡泡照同一個設定畫(Bot 清單多一個 bubble 欄位);手機設定的「強調色」改名「聊天的顏色」,
  多「安靜」選項;修好一個舊 bug——手機拿到的是 "BotColor"/"Black" 卻跟 "bot_color"/"black" 比,
  勾選永遠停在「Bot 顏色」
- update_settings 的 accent 多 "quiet"

已驗證: cargo test(新增:預設是安靜、舊預設換一次、之後選回保留、黑色不動)、node --check 手機四段腳本
未驗證: 手機實機
This commit is contained in:
王性驊 2026-11-16 22:18:32 +08:00
parent 58413d8580
commit f78513a6ff
8 changed files with 95 additions and 121 deletions

View File

@ -1,101 +0,0 @@
[Kosugi Maru]
Copyright (c) 2010 MOTOYA CO.,LTD.
[Varela Round]
Copyright (c) 2011-2016 The Varela Round Project Authors (https://github.com/alefalefalef/Varela-Round-Hebrew/), with Reserved Font Names 'Varela' and 'Varela Round'.
[jf open huninn]
Copyright (c) 2020-2024 The jf open huninn font is redistributed by justfont Co., LTD., with Reserved Font Names 'open huninn' and 'huninn'. under SIL Open Font License. The Hanzi part of this project was derived from Kosugi Maru under Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0).
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -6,7 +6,7 @@
設定視窗,分頁由上到下: 設定視窗,分頁由上到下:
- 「一般」: - 「一般」:
- 外觀:主題、底色(冷→暖滑桿)、對比(柔和→鮮明滑桿)、強調色(八個點:黏土、靛藍、苔綠、藍綠、玫紅、琥珀、石板、墨黑)、密度(寬鬆/緊湊)、慶祝動畫(開/關,目標達成時撒彩帶)、外殼顏色重設(回預設「紙」;這幾項調了立刻整個殼跟著換,不用重開)、聊天的顏色、語言(選單和 Bot 回答用的語言)。沒有字型選項:介面思源黑體、讀的文字(回答、頁面)思源宋體。 - 外觀:主題、底色(冷→暖滑桿)、對比(柔和→鮮明滑桿)、強調色(八個點:黏土、靛藍、苔綠、藍綠、玫紅、琥珀、石板、墨黑)、密度(寬鬆/緊湊)、慶祝動畫(開/關,目標達成時撒彩帶)、外殼顏色重設(回預設「紙」;這幾項調了立刻整個殼跟著換,不用重開)、聊天的顏色(你的訊息泡泡:安靜=淡灰,預設;跟著 Bot;只用黑色——手機同一個設定)、語言(選單和 Bot 回答用的語言)。沒有字型選項:介面思源黑體、讀的文字(回答、頁面)思源宋體。
- 記憶與文件:用意思找記憶(本機模型/Ollama/關閉)、Bot 可以翻的資料夾([memory](memory.md))。 - 記憶與文件:用意思找記憶(本機模型/Ollama/關閉)、Bot 可以翻的資料夾([memory](memory.md))。
- 通知:Bot 做完或等你時通知、需要你時響一聲([phone](phone.md))。Mac 上的通知是 AnyBot.app 自己發的(貓的圖示),點一下打開那個 Bot;從建置資料夾直接跑(不是 .app)時改用系統的 display notification,圖示會是「工序指令編寫程式」。 - 通知:Bot 做完或等你時通知、需要你時響一聲([phone](phone.md))。Mac 上的通知是 AnyBot.app 自己發的(貓的圖示),點一下打開那個 Bot;從建置資料夾直接跑(不是 .app)時改用系統的 display notification,圖示會是「工序指令編寫程式」。
- Bot:時區,例行任務和提醒用([routines](routines.md))。 - Bot:時區,例行任務和提醒用([routines](routines.md))。

View File

@ -136,6 +136,7 @@ a{color:var(--accent-ink)}
background-image:linear-gradient(to bottom,var(--spec),transparent);box-shadow:inset 0 .5px 0 var(--spec),inset 0 0 0 .5px var(--line2)} background-image:linear-gradient(to bottom,var(--spec),transparent);box-shadow:inset 0 .5px 0 var(--spec),inset 0 0 0 .5px var(--line2)}
/* The chat takes its bot's colour (--bot, set when the chat opens; a black bot keeps the plain bubble). */ /* The chat takes its bot's colour (--bot, set when the chat opens; a black bot keeps the plain bubble). */
.m.user .bub{background-color:var(--bot,var(--bubble-user));color:var(--bot-ink,var(--bubble-user-ink));white-space:pre-wrap;border-radius:var(--r-l) var(--r-l) var(--r-s) var(--r-l)} .m.user .bub{background-color:var(--bot,var(--bubble-user));color:var(--bot-ink,var(--bubble-user-ink));white-space:pre-wrap;border-radius:var(--r-l) var(--r-l) var(--r-s) var(--r-l)}
.quiet .m.user .bub{background-color:var(--hover);color:var(--text)}
/* The bot's words sit on the page like a document; only an error gets a bubble. */ /* The bot's words sit on the page like a document; only an error gets a bubble. */
.m.bot .bub{background-color:transparent;padding:0;max-width:100%;border-radius:0;box-shadow:none;background-image:none} .m.bot .bub{background-color:transparent;padding:0;max-width:100%;border-radius:0;box-shadow:none;background-image:none}
.m.bot.err .bub{color:var(--danger);background-color:var(--bubble-bot);padding:7px 12px;border-radius:var(--r-l);font-family:var(--font);font-size:var(--fs-ui);line-height:1.5} .m.bot.err .bub{color:var(--danger);background-color:var(--bubble-bot);padding:7px 12px;border-radius:var(--r-l);font-family:var(--font);font-size:var(--fs-ui);line-height:1.5}
@ -1227,9 +1228,12 @@ $("island").onclick = () => go("details", {bot: S.open});
function openChat(id) { function openChat(id) {
if (S.open !== id) { S.msgs = []; S.pending = []; S.quote = null; S.unfold = {}; S.openSteps = {}; S.chatSig = ""; $("msgs").innerHTML = ""; } if (S.open !== id) { S.msgs = []; S.pending = []; S.quote = null; S.unfold = {}; S.openSteps = {}; S.chatSig = ""; $("msgs").innerHTML = ""; }
S.open = id; S.open = id;
// The chat takes its bot's colour: the person's bubble and the send button. // Your bubbles as 聊天的顏色 on the computer says (ob.bubble): "quiet" a light grey with the
// page's ink (the default), "bot" the bot's colour, "black". (An older AnyBot sends no field: its colour.)
const ob = bot(id) || {}, chat = $("v-chat"); const ob = bot(id) || {}, chat = $("v-chat");
if (ob.color && ob.color_key !== "black") { chat.style.setProperty("--bot", ob.color); chat.style.setProperty("--bot-ink", "var(--on-color)"); } const bubble = ob.bubble || "bot";
chat.classList.toggle("quiet", bubble === "quiet");
if (bubble === "bot" && ob.color && ob.color_key !== "black") { chat.style.setProperty("--bot", ob.color); chat.style.setProperty("--bot-ink", "var(--on-color)"); }
else { chat.style.removeProperty("--bot"); chat.style.removeProperty("--bot-ink"); } else { chat.style.removeProperty("--bot"); chat.style.removeProperty("--bot-ink"); }
chatHead(); renderChips(); renderQuote(); loadChat(true); renderDock(); chatHead(); renderChips(); renderQuote(); loadChat(true); renderDock();
api(base() + `api/bots/${id}/read`, {json: {}}).catch(() => {}); api(base() + `api/bots/${id}/read`, {json: {}}).catch(() => {});
@ -2226,7 +2230,7 @@ function drawSettings(kind, quiet) {
} }
if (kind === "general") { if (kind === "general") {
const theme = {system: "跟隨系統", light: "淺色", dark: "深色"}[st.theme] || ""; const theme = {system: "跟隨系統", light: "淺色", dark: "深色"}[st.theme] || "";
h += group("電腦上的 AnyBot", item({icon: "moon", k: "主題", r: theme, tap: 1, data: 'data-s="theme"'}) + item({icon: "sparkles", k: "強調色", r: st.accent === "black" ? "黑色" : "Bot 顏色", tap: 1, data: 'data-s="accent"'})); h += group("電腦上的 AnyBot", item({icon: "moon", k: "主題", r: theme, tap: 1, data: 'data-s="theme"'}) + item({icon: "sparkles", k: "聊天的顏色", r: ({quiet: "安靜", black: "只用黑色", bot_color: "跟著 Bot"})[st.accent] || "安靜", tap: 1, data: 'data-s="accent"'}));
h += group("", item({icon: "globe", k: "時區", v: "例行任務和頁面的時間照這個時區", r: st.timezone || "", tap: 1, data: 'data-s="tz"'}) + item({icon: "bell", k: "通知", v: "Bot 需要你或做完事時通知你", sw: !!st.notify, swdata: 'data-sset="notify"', disabled: !isOwner()})); h += group("", item({icon: "globe", k: "時區", v: "例行任務和頁面的時間照這個時區", r: st.timezone || "", tap: 1, data: 'data-s="tz"'}) + item({icon: "bell", k: "通知", v: "Bot 需要你或做完事時通知你", sw: !!st.notify, swdata: 'data-sset="notify"', disabled: !isOwner()}));
h += group("這支手機", item({icon: "smartphone", k: "外觀", r: (THEMES.find((t) => t[0] === phoneTheme()) || THEMES[0])[1], tap: 1, data: 'data-s="phonetheme"'})); h += group("這支手機", item({icon: "smartphone", k: "外觀", r: (THEMES.find((t) => t[0] === phoneTheme()) || THEMES[0])[1], tap: 1, data: 'data-s="phonetheme"'}));
} }
@ -2442,7 +2446,7 @@ function wireSettings(kind, st) {
on("[data-s]", "onclick", async (x) => { on("[data-s]", "onclick", async (x) => {
const k = x.dataset.s; const k = x.dataset.s;
if (k === "theme") sheet("主題", [["system", "跟隨系統"], ["light", "淺色"], ["dark", "深色"]].map(([v, n]) => ({label: n, check: st.theme === v, on: async () => { if (await app("update_settings", {theme: v})) again(); }}))); if (k === "theme") sheet("主題", [["system", "跟隨系統"], ["light", "淺色"], ["dark", "深色"]].map(([v, n]) => ({label: n, check: st.theme === v, on: async () => { if (await app("update_settings", {theme: v})) again(); }})));
else if (k === "accent") sheet("強調色", [["bot_color", "Bot 顏色"], ["black", "黑色"]].map(([v, n]) => ({label: n, check: (st.accent || "bot_color") === v, on: async () => { if (await app("update_settings", {accent: v})) again(); }}))); else if (k === "accent") sheet("聊天的顏色", [["quiet", "安靜(淡灰泡泡)"], ["bot_color", "跟著 Bot"], ["black", "只用黑色"]].map(([v, n]) => ({label: n, check: (st.accent || "quiet") === v, on: async () => { if (await app("update_settings", {accent: v})) again(); }})));
else if (k === "tz") { else if (k === "tz") {
const zones = [...new Set([TZ, "Asia/Taipei", "Asia/Tokyo", "Asia/Shanghai", "Asia/Hong_Kong", "Asia/Singapore", "Europe/London", "America/New_York", "America/Los_Angeles", "UTC"].filter(Boolean))]; const zones = [...new Set([TZ, "Asia/Taipei", "Asia/Tokyo", "Asia/Shanghai", "Asia/Hong_Kong", "Asia/Singapore", "Europe/London", "America/New_York", "America/Los_Angeles", "UTC"].filter(Boolean))];
sheet("時區", zones.map((z) => ({label: z + (z === TZ ? "(這支手機)" : ""), check: st.timezone === z, on: async () => { if (await app("update_settings", {timezone: z})) again(); }}))); sheet("時區", zones.map((z) => ({label: z + (z === TZ ? "(這支手機)" : ""), check: st.timezone === z, on: async () => { if (await app("update_settings", {timezone: z})) again(); }})));

View File

@ -1314,10 +1314,14 @@ impl App {
c c
} }
fn user_bubble(&self, b: &Bot) -> Color32 { /// Your message's bubble and its words (設定 › 一般 › 聊天的顏色): 安靜 — a light grey with the
/// page's ink, Claude's way and the default; 跟著 Bot — the bot's colour, white words; 只用黑色.
fn user_bubble(&self, b: &Bot) -> (Color32, Color32) {
let p = self.pal;
match self.state.accent { match self.state.accent {
Accent::BotColor if b.color != "black" => self.bot_color(b), Accent::BotColor if b.color != "black" => (self.bot_color(b), Color32::WHITE),
_ => self.pal.bubble_user, Accent::Quiet => (p.hover, p.text),
_ => (p.bubble_user, if p.bubble_user.a() < 0xff { p.text } else { p.on_primary }),
} }
} }
@ -5045,13 +5049,21 @@ impl App {
self.dirty = true; self.dirty = true;
} }
}); });
card_row(ui, p, "聊天的顏色", "", "跟著 Bot:你的訊息、送出鈕和選中的 Bot 用那隻 Bot 的顏色。只用黑色:都是黑的。", |ui| { card_row(ui, p, "聊天的顏色", "", "安靜:你的訊息是淡灰的泡泡、字是一般的黑(像 Claude)。跟著 Bot:你的訊息、送出鈕和選中的 Bot 用那隻 Bot 的顏色。只用黑色:都是黑的。", |ui| {
// Two dots (from the right): black, and the bots' own colours. // Three dots (from the right): the bots' own colours, black, quiet.
for a in [Accent::Black, Accent::BotColor] { let name = |a: Accent| match a {
Accent::Quiet => "安靜",
Accent::Black => "只用黑色",
Accent::BotColor => "跟著 Bot",
};
for a in [Accent::BotColor, Accent::Black, Accent::Quiet] {
let (rect, r) = ui.allocate_exact_size(vec2(30.0, 30.0), egui::Sense::click()); let (rect, r) = ui.allocate_exact_size(vec2(30.0, 30.0), egui::Sense::click());
let c = rect.center(); let c = rect.center();
if a == Accent::Black { if a == Accent::Black {
ui.painter().circle_filled(c, 11.0, p.primary); ui.painter().circle_filled(c, 11.0, p.primary);
} else if a == Accent::Quiet {
ui.painter().circle_filled(c, 11.0, p.hover);
ui.painter().circle_stroke(c, 11.0, Stroke::new(1.0, p.border));
} else { } else {
// (A pie of four bot colours.) // (A pie of four bot colours.)
for (k, name) in ["green", "purple", "blue", "brown"].iter().enumerate() { for (k, name) in ["green", "purple", "blue", "brown"].iter().enumerate() {
@ -5064,12 +5076,12 @@ impl App {
if self.state.accent == a { if self.state.accent == a {
ui.painter().circle_stroke(c, 14.0, Stroke::new(2.0, p.text)); ui.painter().circle_stroke(c, 14.0, Stroke::new(2.0, p.text));
} }
if r.on_hover_text(t(if a == Accent::Black { "只用黑色" } else { "跟著 Bot" })).on_hover_cursor(egui::CursorIcon::PointingHand).clicked() && self.state.accent != a { if r.on_hover_text(t(name(a))).on_hover_cursor(egui::CursorIcon::PointingHand).clicked() && self.state.accent != a {
self.state.accent = a; self.state.accent = a;
self.dirty = true; self.dirty = true;
} }
} }
ui.label(RichText::new(t(if self.state.accent == Accent::Black { "只用黑色" } else { "跟著 Bot" })).size(FONT_SM).color(p.text2)); ui.label(RichText::new(t(name(self.state.accent))).size(FONT_SM).color(p.text2));
}); });
let other_menu = !matches!(crate::i18n::lang().as_str(), "zh-TW" | "zh-CN" | "en" | "ja"); let other_menu = !matches!(crate::i18n::lang().as_str(), "zh-TW" | "zh-CN" | "en" | "ja");
card_row(ui, p, "語言", if other_menu { "選單用英文顯示,Bot 用你選的語言回答" } else { "" }, "AnyBot 的選單和 Bot 回答用的語言", |ui| { card_row(ui, p, "語言", if other_menu { "選單用英文顯示,Bot 用你選的語言回答" } else { "" }, "AnyBot 的選單和 Bot 回答用的語言", |ui| {

View File

@ -571,8 +571,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 = self.user_bubble(bot); let (fill, text_col) = self.user_bubble(bot);
let text_col = if fill != p.bubble_user { Color32::WHITE } else if p.bubble_user.a() < 0xff { p.text } else { p.on_primary };
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);

View File

@ -318,7 +318,13 @@ impl App {
let mut bots: Vec<&Bot> = self.state.bots.iter().collect(); let mut bots: Vec<&Bot> = self.state.bots.iter().collect();
// Pinned first, then the most recently active. // Pinned first, then the most recently active.
bots.sort_by_key(|b| (!b.pinned, -(b.last_turn.as_ref().map(|t| t.settled_at_ms).unwrap_or(0)))); bots.sort_by_key(|b| (!b.pinned, -(b.last_turn.as_ref().map(|t| t.settled_at_ms).unwrap_or(0))));
let accent = serde_json::to_value(self.state.accent).ok().and_then(|v| v.as_str().map(String::from)).unwrap_or_else(|| "bot_color".into()); // 聊天的顏色, in the names update_settings takes (the phone compares and sends these).
let accent = match self.state.accent {
crate::model::Accent::Quiet => "quiet",
crate::model::Accent::Black => "black",
crate::model::Accent::BotColor => "bot_color",
}
.to_string();
let mut view = remote::View { let mut view = remote::View {
host: self.state.remote.host_name.clone(), host: self.state.remote.host_name.clone(),
person: self.person_name(), person: self.person_name(),
@ -371,6 +377,12 @@ impl App {
"threads": b.threads.iter().enumerate().rev().take(20).map(|(i, (title, msgs))| json!({"index": i, "title": title, "count": msgs.len(), "at": msgs.last().map(|m| m.at).unwrap_or(0)})).collect::<Vec<_>>(), "threads": b.threads.iter().enumerate().rev().take(20).map(|(i, (title, msgs))| json!({"index": i, "title": title, "count": msgs.len(), "at": msgs.last().map(|m| m.at).unwrap_or(0)})).collect::<Vec<_>>(),
// The sidebar's sections, the colour by name (the editor), what is queued while it works. // The sidebar's sections, the colour by name (the editor), what is queued while it works.
"folder": b.folder, "color_key": b.color, "order": raw_order.get(&b.id).copied().unwrap_or(0), "folder": b.folder, "color_key": b.color, "order": raw_order.get(&b.id).copied().unwrap_or(0),
// 聊天的顏色 (設定 › 一般): how the phone draws your bubbles — the same choice.
"bubble": match self.state.accent {
crate::model::Accent::Quiet => "quiet",
crate::model::Accent::Black => "black",
crate::model::Accent::BotColor => "bot",
},
"thinking": b.thinking, "step_model": b.step_model, "thinking": b.thinking, "step_model": b.step_model,
"queued": live.map(|l| l.steer.lock().unwrap().iter().map(|q| q.text.clone()).collect::<Vec<_>>()).unwrap_or_default(), "queued": live.map(|l| l.steer.lock().unwrap().iter().map(|q| q.text.clone()).collect::<Vec<_>>()).unwrap_or_default(),
// 目標: how it stands (the line above the input), worded here so the phone says it the same way. // 目標: how it stands (the line above the input), worded here so the phone says it the same way.

View File

@ -153,7 +153,7 @@ pub fn specs() -> Vec<Value> {
"shape": {"type": "string", "description": "squircle, blob, capsule, egg, hex, gem, cloud, arch, star, heart, shield, pebble."}}}}), "shape": {"type": "string", "description": "squircle, blob, capsule, egg, hex, gem, cloud, arch, star, heart, shield, pebble."}}}}),
json!({"name": "update_settings", "description": "Change app settings: theme (light/dark/system), accent (bot_color/black), timezone (IANA). Running tasks on the person's own computer can only be turned on by the person.", json!({"name": "update_settings", "description": "Change app settings: theme (light/dark/system), accent (bot_color/black), timezone (IANA). Running tasks on the person's own computer can only be turned on by the person.",
"parameters": {"type": "object", "properties": { "parameters": {"type": "object", "properties": {
"theme": {"type": "string", "enum": ["light", "dark", "system"]}, "accent": {"type": "string", "enum": ["bot_color", "black"]}, "timezone": {"type": "string"}}}}), "theme": {"type": "string", "enum": ["light", "dark", "system"]}, "accent": {"type": "string", "enum": ["quiet", "bot_color", "black"], "description": "聊天的顏色: quiet = your messages in a light grey bubble (default), bot_color = in the bot's colour, black"}, "timezone": {"type": "string"}}}}),
] ]
.into_iter() .into_iter()
.chain(crate::pages::specs()) .chain(crate::pages::specs())
@ -906,8 +906,12 @@ pub fn apply(state: &mut State, bot_id: u64, name: &str, args: &str) -> Outcome
} }
} }
if let Some(a) = s("accent") { if let Some(a) = s("accent") {
state.accent = if a == "bot_color" { Accent::BotColor } else { Accent::Black }; state.accent = match a.as_str() {
changed.push(format!("強調色 → {a}")); "bot_color" => Accent::BotColor,
"quiet" => Accent::Quiet,
_ => Accent::Black,
};
changed.push(format!("聊天的顏色 → {a}"));
} }
if let Some(z) = s("timezone") { if let Some(z) = s("timezone") {
if z.parse::<chrono_tz::Tz>().is_err() { if z.parse::<chrono_tz::Tz>().is_err() {

View File

@ -566,8 +566,12 @@ pub enum Theme {
#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Debug)]
pub enum Accent { pub enum Accent {
/// Your messages and the send button in the bot's own colour.
BotColor, BotColor,
/// Black (ink) bubbles with white words.
Black, Black,
/// A light grey bubble with the page's ink — Claude's quiet way (the default).
Quiet,
} }
/// 設定 › 語音: who hears the person (聽) and who reads answers aloud (說). It all runs where the /// 設定 › 語音: who hears the person (聽) and who reads answers aloud (說). It all runs where the
@ -640,6 +644,10 @@ pub struct State {
pub next_id: u64, pub next_id: u64,
pub theme: Theme, pub theme: Theme,
pub accent: Accent, pub accent: Accent,
/// 「安靜」 became the default bubble: a settings file from before (with the old default,
/// 跟著 Bot) is moved to it once, on load; set from then on, so a choice made later stays.
#[serde(default)]
pub bubble_quiet_offered: bool,
/// 外殼產生器(設定 › 一般):色調 0 冷…1 暖、強調色名(見 theme::ACCENTS)、對比 0.75 柔和…1.35 鮮明。 /// 外殼產生器(設定 › 一般):色調 0 冷…1 暖、強調色名(見 theme::ACCENTS)、對比 0.75 柔和…1.35 鮮明。
/// 預設 1/clay/1 就是「紙」。舊設定檔沒這幾個欄位時照預設補。 /// 預設 1/clay/1 就是「紙」。舊設定檔沒這幾個欄位時照預設補。
#[serde(default = "default_shell_tone")] #[serde(default = "default_shell_tone")]
@ -894,6 +902,13 @@ impl State {
} }
} }
} }
// The quiet bubble is the new default: the old default turns quiet, once.
if !s.bubble_quiet_offered {
if s.accent == Accent::BotColor {
s.accent = Accent::Quiet;
}
s.bubble_quiet_offered = true;
}
s s
}); });
let mut s = match parsed { let mut s = match parsed {
@ -1191,7 +1206,8 @@ impl State {
selected: 0, selected: 0,
next_id: 1, next_id: 1,
theme: Theme::Light, theme: Theme::Light,
accent: Accent::BotColor, accent: Accent::Quiet,
bubble_quiet_offered: true,
shell_tone: 1.0, shell_tone: 1.0,
shell_accent: "clay".into(), shell_accent: "clay".into(),
shell_contrast: 1.0, shell_contrast: 1.0,
@ -1351,6 +1367,34 @@ pub fn bot_computer_dir(bot_id: u64) -> PathBuf {
mod start_tests { mod start_tests {
use super::*; use super::*;
/// 你的訊息泡泡:新的預設是「安靜」(淡灰)。存著舊預設「跟著 Bot」的設定檔載入時換成安靜一次;
/// 之後自己選回「跟著 Bot」就照你選的(不會每次開都被換掉)。
#[test]
fn the_quiet_bubble_becomes_the_default_once() {
assert_eq!(State::first_run().accent, Accent::Quiet);
let dir = std::env::temp_dir().join(format!("anybot-quiet-bubble-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let p = dir.join("state.json");
let mut old = serde_json::to_value(State::first_run()).unwrap();
old["accent"] = serde_json::json!("BotColor");
old.as_object_mut().unwrap().remove("bubble_quiet_offered");
std::fs::write(&p, old.to_string()).unwrap();
let s = State::load_from(&p);
assert_eq!(s.accent, Accent::Quiet, "the old default turns quiet");
assert!(s.bubble_quiet_offered);
// Picked back afterwards: it stays.
let mut chosen = serde_json::to_value(&s).unwrap();
chosen["accent"] = serde_json::json!("BotColor");
std::fs::write(&p, chosen.to_string()).unwrap();
assert_eq!(State::load_from(&p).accent, Accent::BotColor);
// Black was a choice, never the default: it is kept.
old["accent"] = serde_json::json!("Black");
std::fs::write(&p, old.to_string()).unwrap();
assert_eq!(State::load_from(&p).accent, Accent::Black);
let _ = std::fs::remove_dir_all(&dir);
}
/// The settings are one small file; each chat is its own, written only when it changed, and /// The settings are one small file; each chat is its own, written only when it changed, and
/// a save from before (chats inside the settings) is taken as it is. /// a save from before (chats inside the settings) is taken as it is.
#[test] #[test]