` : "";
+ if ($("plan-x")) $("plan-x").onclick = async () => {
try { await api(base() + `api/bots/${S.open}/send`, {json: {text: "/plan clear", attachments: []}}); toast("已取消計畫"); loadChat(); } catch (e) { toast(e.message); }
};
const q = b.queued || [];
diff --git a/src/app.rs b/src/app.rs
index 988c72b..59eb196 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -2653,35 +2653,96 @@ impl App {
self.save_now = true;
}
- /// The line above the input while 一律放行 is on (every chat: it is everyone's), with 關閉.
- fn always_bar(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot_id: u64) {
- if !self.always_on() {
- return;
+ /// The modes that are on — 目標, 計畫, 一律放行 (every chat: it is everyone's) — as icons at
+ /// the right of `row` (the face's row above the input), so they take no line of their own:
+ /// hovering one says how it stands, a click opens the same words with the button that ends
+ /// it. Returns the width they took.
+ fn mode_icons(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot, row: egui::Rect) -> f32 {
+ use crate::icons::Icon;
+ #[derive(Clone, Copy)]
+ enum Mode {
+ Goal,
+ Plan,
+ Always,
+ }
+ struct Shown {
+ mode: Mode,
+ icon: Icon,
+ col: Color32,
+ /// Beside the icon: the plan's 「2/5」.
+ count: String,
+ line: String,
+ more: String,
+ end: &'static str,
}
let p = self.pal;
- let mut off = false;
- ui.horizontal(|ui| {
- ui.add_space(14.0);
- ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
- ui.add_space(10.0);
- off = small_button(ui, "關閉", p).clicked();
- ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
- ui.spacing_mut().item_spacing.x = 6.0;
- let (r, _) = ui.allocate_exact_size(vec2(13.0, 14.0), egui::Sense::hover());
- crate::icons::paint(ui.painter(), egui::Rect::from_center_size(r.center(), vec2(12.0, 12.0)), crate::icons::Icon::Zap, p.danger);
- ui.add(egui::Label::new(RichText::new(t(crate::always::BAR)).size(FONT_XS).color(p.text2)).truncate().selectable(false))
- .on_hover_text(t("用 /always-approve 打開的。安全規則一律拒絕的(sudo、rm -rf /、金鑰檔…)照樣擋;別人傳來的訊息照樣等你按;問題卡和「需要處理」照樣等你。"));
- });
- });
- });
- ui.add_space(2.0);
- if off {
- if self.mir.on {
- self.mirror_send(bot_id, "/always-approve off".into(), vec![], None);
- } else {
- self.always_command(ctx, bot_id, crate::always::Command::Off);
+ let mut shown = vec![];
+ if let Some(g) = bot.goal.as_ref() {
+ let line = if g.active() && self.goal_checking.contains(&bot.id) { t("目標 · 正在檢查有沒有達成…") } else { t(&crate::goal::bar_text(g, crate::model::now_ms())) };
+ let mut more = format!("{}{}", t("目標:"), g.condition);
+ if !g.reason.is_empty() {
+ more.push_str(&format!("\n\n{}{}", t("最近一次檢查:"), g.reason));
}
+ shown.push(Shown { mode: Mode::Goal, icon: Icon::Target, col: if g.active() { p.accent } else { p.text3 }, count: String::new(), line, more, end: "清除目標" });
}
+ if let Some(pl) = bot.plan.as_ref() {
+ let doing = pl.stage == crate::plan::Stage::Doing;
+ let mut more = format!("{}{}", t("要做的事:"), pl.task);
+ if doing {
+ more.push_str(&format!("\n\n{}", crate::plan::checklist(&pl.steps)));
+ }
+ let count = if doing { format!("{}/{}", pl.done(), pl.steps.len()) } else { String::new() };
+ shown.push(Shown { mode: Mode::Plan, icon: Icon::Summary, col: p.accent, count, line: t(&crate::plan::bar_text(pl)), more, end: "取消計畫" });
+ }
+ if self.always_on() {
+ let more = t("用 /always-approve 打開的。安全規則一律拒絕的(sudo、rm -rf /、金鑰檔…)照樣擋;別人傳來的訊息照樣等你按;問題卡和「需要處理」照樣等你。");
+ shown.push(Shown { mode: Mode::Always, icon: Icon::Zap, col: p.danger, count: String::new(), line: t(crate::always::BAR), more, end: "關閉一律放行" });
+ }
+ if shown.is_empty() {
+ return 0.0;
+ }
+ let mut end = None;
+ let mut at = ui.new_child(egui::UiBuilder::new().max_rect(row.shrink2(vec2(10.0, 0.0))).layout(Layout::right_to_left(Align::Center)));
+ at.spacing_mut().item_spacing.x = 2.0;
+ // (Right to left: the last one first, and a count before its icon.)
+ for m in shown.iter().rev() {
+ if !m.count.is_empty() {
+ at.add(egui::Label::new(RichText::new(&m.count).size(FONT_XS).color(p.text2)).selectable(false));
+ }
+ // (An id of its own: the popup stays open while cards come and go above.)
+ let (rect, _) = at.allocate_exact_size(vec2(26.0, 26.0), egui::Sense::hover());
+ let r = at.interact(rect, egui::Id::new(("mode", bot.id, m.end)), egui::Sense::click()).on_hover_cursor(egui::CursorIcon::PointingHand);
+ if r.hovered() {
+ at.painter().rect_filled(rect, 7.0, p.hover);
+ }
+ crate::icons::paint(at.painter(), egui::Rect::from_center_size(rect.center(), vec2(16.0, 16.0)), m.icon, m.col);
+ egui::Popup::menu(&r).show(|ui| {
+ ui.set_max_width(300.0);
+ ui.add(egui::Label::new(RichText::new(&m.line).size(FONT_SM).strong().family(crate::bold()).color(p.text)).wrap().selectable(false));
+ ui.add(egui::Label::new(RichText::new(&m.more).size(FONT_XS).color(p.text2)).wrap().selectable(false));
+ ui.add_space(4.0);
+ if menu_ui::item(ui, p, Icon::Close, m.end).clicked() {
+ end = Some(m.mode);
+ ui.close();
+ }
+ });
+ r.on_hover_text(format!("{}\n\n{}\n\n{}{}", m.line, m.more, t("點一下:"), t(m.end)));
+ }
+ let used = at.min_rect().width() + 10.0;
+ if bot.goal.as_ref().is_some_and(|g| g.active()) {
+ // The goal's minutes count on.
+ ctx.request_repaint_after(std::time::Duration::from_secs(30));
+ }
+ match end {
+ Some(Mode::Goal) => self.goal_clear(ctx, bot.id),
+ Some(Mode::Plan) => self.plan_clear(ctx, bot.id),
+ Some(Mode::Always) if self.mir.on => {
+ self.mirror_send(bot.id, "/always-approve off".into(), vec![], None);
+ }
+ Some(Mode::Always) => self.always_command(ctx, bot.id, crate::always::Command::Off),
+ None => {}
+ }
+ used
}
fn local_on(&self) -> bool {
@@ -4058,7 +4119,14 @@ impl App {
/// The bot's face peeking over the input, and beside it what it is doing (see dock_face).
/// Not in an empty chat, where the face is the big one in the middle.
fn face_dock(&mut self, ui: &mut egui::Ui, bot: &Bot) {
+ let ctx = ui.ctx().clone();
if bot.messages.is_empty() {
+ // No face here; modes that are on (一律放行 is on in every chat) still show, in a
+ // slim row of their own.
+ if bot.goal.is_some() || bot.plan.is_some() || self.always_on() {
+ let (row, _) = ui.allocate_exact_size(vec2(ui.available_width(), 28.0), egui::Sense::hover());
+ self.mode_icons(ui, &ctx, bot, row);
+ }
return;
}
let p = self.pal;
@@ -4068,6 +4136,8 @@ impl App {
let (row, _) = ui.allocate_exact_size(vec2(ui.available_width(), 46.0), egui::Sense::hover());
let face = egui::Rect::from_min_size(row.left_top() + vec2(16.0, 4.0), vec2(40.0, 40.0));
self.dock_face(ui, bot, face);
+ // 目標, 計畫, 一律放行: icons at the right of this row.
+ let modes_w = self.mode_icons(ui, &ctx, bot, row);
let now = ui.input(|i| i.time);
let waiting = self.approvals.contains_key(&bot.id);
let asked = self.approvals.get(&bot.id).is_some_and(|a| a.kind == ApprovalKind::Question);
@@ -4075,7 +4145,7 @@ impl App {
if let Some(words) = words {
let col = self.bot_color(bot);
let col = if bot.color == "black" || self.state.accent != Accent::BotColor || waiting { p.text } else { col };
- let mut at = ui.new_child(egui::UiBuilder::new().max_rect(egui::Rect::from_min_max(egui::pos2(face.right() + 10.0, row.top()), row.right_bottom())).layout(Layout::left_to_right(Align::Center)));
+ let mut at = ui.new_child(egui::UiBuilder::new().max_rect(egui::Rect::from_min_max(egui::pos2(face.right() + 10.0, row.top()), row.right_bottom() - vec2(modes_w, 0.0))).layout(Layout::left_to_right(Align::Center)));
let words = sidebar_ui::shorten_width(&at, &words, at.available_width() - 8.0, 13.5);
if waiting {
at.label(RichText::new(words).size(FONT_SM).strong().family(crate::bold()).color(col));
@@ -4359,12 +4429,6 @@ impl App {
self.attachments_poll(ctx, bot.id, had_focus);
self.voice_poll(ctx);
ui.add_space(4.0);
- // 目標: how the goal stands, and 清除目標.
- self.goal_bar(ui, ctx, bot);
- // 計畫: where the plan is, and 取消計畫.
- self.plan_bar(ui, ctx, bot);
- // 一律放行: on in every chat while it lasts, with 關閉.
- self.always_bar(ui, ctx, bot.id);
// Quote and attachments sit just above the pill.
if let Some(q) = self.quoting.get(&bot.id).cloned() {
ui.horizontal(|ui| {
diff --git a/src/app/goal_ui.rs b/src/app/goal_ui.rs
index b431450..ccc35d7 100644
--- a/src/app/goal_ui.rs
+++ b/src/app/goal_ui.rs
@@ -301,42 +301,6 @@ impl App {
self.save_now = true;
}
- /// The line above the input while there is a goal: how it stands (the goal and the newest
- /// check on hover) and 清除目標. The words end in … before the button on a narrow window.
- pub(super) fn goal_bar(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot) {
- let Some(g) = bot.goal.as_ref() else { return };
- let p = self.pal;
- let now = crate::model::now_ms();
- let text = if g.active() && self.goal_checking.contains(&bot.id) { t("目標 · 正在檢查有沒有達成…") } else { goal::bar_text(g, now) };
- let mut tip = format!("{}{}", t("目標:"), g.condition);
- if !g.reason.is_empty() {
- tip.push_str(&format!("\n\n{}{}", t("最近一次檢查:"), g.reason));
- }
- let col = if g.active() { p.text2 } else { p.text3 };
- let mut clear = false;
- ui.horizontal(|ui| {
- ui.add_space(14.0);
- ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
- ui.add_space(10.0);
- clear = small_button(ui, "清除目標", p).clicked();
- ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
- ui.spacing_mut().item_spacing.x = 6.0;
- let (r, _) = ui.allocate_exact_size(vec2(13.0, 14.0), egui::Sense::hover());
- crate::icons::paint(ui.painter(), egui::Rect::from_center_size(r.center(), vec2(12.0, 12.0)), crate::icons::Icon::Target, if g.active() { p.accent } else { col });
- ui.add(egui::Label::new(RichText::new(&text).size(FONT_XS).color(col)).truncate().selectable(false)).on_hover_text(&tip);
- });
- });
- });
- ui.add_space(2.0);
- if clear {
- self.goal_clear(ctx, bot.id);
- }
- if g.active() {
- // The minutes count on.
- ctx.request_repaint_after(std::time::Duration::from_secs(30));
- }
- }
-
/// A goal's line in the chat (AnyBot's, not the bot's): small, in the middle.
pub(super) fn goal_note_row(&self, ui: &mut egui::Ui, m: &Message) {
let p = self.pal;
diff --git a/src/app/layout_audit.rs b/src/app/layout_audit.rs
index 4cebc7d..76268af 100644
--- a/src/app/layout_audit.rs
+++ b/src/app/layout_audit.rs
@@ -182,9 +182,11 @@ fn scenes() -> Vec<(&'static str, Open)> {
}),
),
(
- "聊天:計畫卡(長步驟)與計畫列",
+ "聊天:計畫卡(長步驟)與模式圖示",
Box::new(|a: &mut App| {
let id = a.state.selected;
+ // 目標, 計畫 and 一律放行 at once: three icons beside the face's words.
+ a.state.always_approve = true;
let long = "把客戶服務與售後追蹤小組的每週報表從舊的共用資料夾搬到新的雲端硬碟並保留所有版本紀錄";
let args = |n: &str| serde_json::json!({"summary": format!("{long},做完後兩邊的檔案數量和最後修改時間都一樣。"), "steps": [
{"title": format!("{n}備份舊資料夾到 /Volumes/Backup/very/deep/path/that/keeps/going/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaEND"), "detail": "Extremely-long-unbreakable-detail-token-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaEND"},
@@ -196,6 +198,7 @@ fn scenes() -> Vec<(&'static str, Open)> {
b.messages.push(Message { tool_calls: vec![call("audit-p1", "")], ..Message::assistant("", "模型") });
b.messages.push(Message::tool_result("audit-p1", crate::plan::SUBMIT_TOOL, &crate::plan::approved_result(&[])));
b.messages.push(Message { tool_calls: vec![call("audit-p2", "新版:")], ..Message::assistant("", "模型") });
+ b.goal = Some(crate::goal::Goal::new(long, 0));
b.plan = Some(crate::plan::Plan { task: long.into(), since: 0, stage: crate::plan::Stage::Doing, revisions: 0, steps: vec![
crate::plan::Step { title: "備份舊資料夾到 /Volumes/Backup/very/deep/path/that/keeps/going/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaEND".into(), status: crate::plan::Status::Done },
crate::plan::Step { title: long.into(), status: crate::plan::Status::InProgress },
diff --git a/src/app/plan_ui.rs b/src/app/plan_ui.rs
index b117d0d..0e066f5 100644
--- a/src/app/plan_ui.rs
+++ b/src/app/plan_ui.rs
@@ -118,8 +118,8 @@ impl App {
self.save_now = true;
}
- /// 取消計畫 above the input: on a screen the brain cancels it, as if typed there.
- fn plan_clear(&mut self, ctx: &egui::Context, bot_id: u64) {
+ /// 取消計畫 (the plan's icon above the input): on a screen the brain cancels it, as if typed there.
+ pub(super) fn plan_clear(&mut self, ctx: &egui::Context, bot_id: u64) {
if self.mir.on {
self.mirror_send(bot_id, "/plan clear".into(), vec![], None);
return;
@@ -127,36 +127,6 @@ impl App {
self.plan_command(ctx, bot_id, Command::Clear, "/plan clear", vec![], None);
}
- /// The line above the input while there is a plan: where it is (the steps on hover) and
- /// 取消計畫. The words end in … before the button on a narrow window.
- pub(super) fn plan_bar(&mut self, ui: &mut egui::Ui, ctx: &egui::Context, bot: &Bot) {
- let Some(pl) = bot.plan.as_ref() else { return };
- let p = self.pal;
- let text = t(&plan::bar_text(pl));
- let mut tip = format!("{}{}", t("要做的事:"), pl.task);
- if pl.stage == Stage::Doing {
- tip.push_str(&format!("\n\n{}", plan::checklist(&pl.steps)));
- }
- let mut clear = false;
- ui.horizontal(|ui| {
- ui.add_space(14.0);
- ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
- ui.add_space(10.0);
- clear = small_button(ui, "取消計畫", p).clicked();
- ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
- ui.spacing_mut().item_spacing.x = 6.0;
- let (r, _) = ui.allocate_exact_size(vec2(13.0, 14.0), egui::Sense::hover());
- crate::icons::paint(ui.painter(), egui::Rect::from_center_size(r.center(), vec2(12.0, 12.0)), crate::icons::Icon::Summary, p.accent);
- ui.add(egui::Label::new(RichText::new(&text).size(FONT_XS).color(p.text2)).truncate().selectable(false)).on_hover_text(&tip);
- });
- });
- });
- ui.add_space(2.0);
- if clear {
- self.plan_clear(ctx, bot.id);
- }
- }
-
/// The plan a bot handed in (`submit_plan`), as a card in its reply: waiting on the person,
/// followed (its steps tick as the bot goes: the newest approved plan, while it lasts),
/// changed, or not taken. One sent back or not taken shows only its summary.
diff --git a/src/app/remote_ui.rs b/src/app/remote_ui.rs
index 7df3b38..b409e44 100644
--- a/src/app/remote_ui.rs
+++ b/src/app/remote_ui.rs
@@ -400,8 +400,8 @@ impl App {
},
"thinking": b.thinking, "step_model": b.step_model,
"queued": live.map(|l| l.steer.lock().unwrap().iter().map(|q| q.text.clone()).collect::>()).unwrap_or_default(),
- // 目標: how it stands (the line above the input), worded here so the phone says it the same way.
- // 計畫: where it is (the line above the input), worded here like the window's.
+ // 目標: how it stands (its icon's words above the input), worded here so the phone says it the same way.
+ // 計畫: where it is (its icon's words above the input), worded here like the window's.
"plan": b.plan.as_ref().map(|p| json!({
"task": p.task, "stage": p.stage, "line": crate::plan::bar_text(p),
"steps": if p.stage == crate::plan::Stage::Doing { crate::plan::checklist(&p.steps) } else { String::new() },
diff --git a/src/i18n_table.rs b/src/i18n_table.rs
index c363a86..42e4f22 100644
--- a/src/i18n_table.rs
+++ b/src/i18n_table.rs
@@ -368,6 +368,8 @@ pub const ROWS: &[(&str, &str, &str)] = &[
("● Bot 正在操作", "● A bot is operating", "● Bot が操作中"),
("● 你正在操作,Bot 已暫停", "● You're in control; the bot is paused", "● あなたが操作中、Bot は一時停止中"),
("關閉", "Close", "閉じる"),
+ ("關閉一律放行", "Turn off always-approve", "常に許可をオフにする"),
+ ("點一下:", "Click: ", "クリック:"),
("在瀏覽器用 noVNC 全螢幕開啟", "Open full screen in the browser with noVNC", "ブラウザの noVNC で全画面で開く"),
("停止", "Stop", "停止"),
("網站,例如 github.com", "Site, e.g. github.com", "サイト(例:github.com)"),