Skip to content

🤖 Open-source, local-first alternative to Grok Bot, OpenAI dots and Claude Duet. Your own AI bots on any model: GPT, Claude, Gemini, Grok, DeepSeek, Kimi, GLM and 70+ more through one Modelflare key. Reach them in the app, WeChat or Feishu; they remember you, work in the background, run commands and use your computer. Pay per use.

Merge origin/master:「需要你」、任务提问、测试去抖(新界面做成中英两种语言)

dyk989367a5c16d51
diff --cc electron/main.ts
index a171225,8710d8a..041a283
--- a/electron/main.ts
+++ b/electron/main.ts
@@@ -4,11 -4,11 +4,12 @@@
* - 在进程内启动 App(机器人运行时 + 渠道 + 管理界面 + 受管 magpie 子进程)
* - 窗口加载本机管理界面(每次启动生成随机令牌,其他本机程序/浏览器无法直接访问)
* - 托盘:显示 / 开机自启 / 退出;关闭窗口=隐藏到托盘(可在设置 → 常规里改为退出);退出时干净关闭 magpie
+ * - 「需要你」:托盘提示和角标是件数(没事时什么都不加),新的一件在窗口不在前台时发一条系统通知(每件最多一次)
* - 设置页里的开机自启、缩放、打开数据目录经 core.desktop 回调到这里(同进程,无需 preload/IPC)
+ * - 托盘菜单和对话框跟着应用语言(src/i18n):跟随系统时取系统首选语言,界面里换了语言托盘菜单立刻重建
* CLI(npm start)与 Docker 走同一套 src/ 代码,本文件只做桌面外壳。
*/
- import { app, BrowserWindow, Menu, Tray, nativeImage, nativeTheme, net, shell, dialog, safeStorage } from "electron";
-import { app, BrowserWindow, Menu, Notification, Tray, nativeImage, net, shell, dialog, safeStorage } from "electron";
++import { app, BrowserWindow, Menu, Notification, Tray, nativeImage, nativeTheme, net, shell, dialog, safeStorage } from "electron";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
@@@ -17,7 -17,7 +18,8 @@@ import { loadConfig } from "../src/conf
import { App } from "../src/app.js";
import { findAppRoot } from "../src/magpie/supervisor.js";
import { initFileLog, logFilePath, logger, registerSecret, setConsoleLog } from "../src/log.js";
+import { normalizeLang, onLangChange, setLangPref, setSystemLang, t } from "../src/i18n/index.js";
+ import { notificationOf, trayTitle, type AttentionItem } from "../src/tasks/attention.js";
const log = logger("desktop");
const SMOKE = process.env.AMB_ELECTRON_SMOKE; // 冒烟测试:截图到该路径后退出
@@@ -118,11 -151,13 +174,13 @@@ function buildTray(): void
const render = () =>
tray!.setContextMenu(
Menu.buildFromTemplate([
+ // 有事在等你时才有这一项
- ...(needsCount ? [{ label: `需要你(${needsCount})`, click: openNeeds }, { type: "separator" as const }] : []),
- { label: `打开 ${PRODUCT}`, click: showWindow },
- { label: "在浏览器中打开", click: () => void shell.openExternal(entryUrl) },
++ ...(needsCount ? [{ label: t("desktop.trayNeeds", { count: needsCount }), click: openNeeds }, { type: "separator" as const }] : []),
+ { label: t("desktop.trayOpen", { product: PRODUCT }), click: showWindow },
+ { label: t("desktop.trayOpenInBrowser"), click: () => void shell.openExternal(entryUrl) },
{ type: "separator" },
{
- label: "开机自启",
+ label: t("desktop.trayAutostart"),
type: "checkbox",
enabled: canAutostart,
checked: canAutostart && app.getLoginItemSettings().openAtLogin,
diff --cc src/agent/approvals.ts
index e009b6b,5d2d2b3..63dffeb
--- a/src/agent/approvals.ts
+++ b/src/agent/approvals.ts
@@@ -167,39 -258,67 +259,67 @@@ export class ApprovalCenter
/**
* 解析渠道里的用户回复(在每用户串行队列之前调用,避免与等待审批的回合互相阻塞):
- * - “y 1234” / “n 1234”(也接受 是/否/同意/拒绝/yes/no/approve/allow/deny/reject;会话中只有一个待批准时可省略编号)
- * - 有待回答的提问时,回复编号(多选用逗号/空格分隔)或直接回复文字
+ * - 引用了任务推来的提示(ctx.quote):这条就是对它的回答
+ * - “y 1234” / “n 1234”(也接受 是/否/同意/拒绝/yes/no);聊天里只有一个待批准、或任务的审批是机器人最后一条消息时可省略编号
+ * - “1234 中文”:以任务提问的编号开头
+ * - 聊天回合在等的提问:回复编号(多选用逗号/空格分隔)或直接回复文字
+ * - 任务的提问是机器人最后一条消息:只认选项编号或选项原文
*/
- handleReply(conversationId: string, text: string, by: string): ReplyResult {
- const s = text.trim();
- if (!s || s.startsWith("/")) return { handled: false };
- const m = /^(y|yes|ok|approve|allow|是|同意|批准|允许|n|no|deny|reject|否|拒绝|不)\s*[#::]?\s*(\d{4})?$/i.exec(s);
- if (m && (m[2] || this.pending(conversationId, "approval").length)) {
- const allow = /^(y|yes|ok|approve|allow|是|同意|批准|允许)$/i.test(m[1]);
- let row: ApprovalRow | undefined;
- if (m[2]) {
- row = this.store.pendingApprovalByCode(m[2]);
- if (!row || row.conversationId !== conversationId || row.kind !== "approval") {
- return { handled: true, ack: t("approvals.noSuchCode", { code: m[2] }) };
- }
- } else {
- const list = this.pending(conversationId, "approval");
- if (list.length === 1) row = list[0];
- else return { handled: true, ack: t("approvals.needCode", { count: list.length, code: list[0].code }) };
+ handleReply(conversationId: string, text: string, by: string, ctx: ReplyContext = {}): ReplyResult {
- const t = text.trim();
- if (!t || t.startsWith("/")) return { handled: false };
++ const msg = text.trim();
++ if (!msg || msg.startsWith("/")) return { handled: false };
+ const all = this.pending(conversationId);
+ const chat = all.filter((r) => !r.taskId);
+ const task = all.filter((r) => r.taskId);
+ // 引用了任务的提示
+ const quote = ctx.quote;
+ const quoted = quote ? task.find((r) => ctx.quotes?.(r, quote)) : undefined;
- if (quoted) return this.replyTo(quoted, (ctx.plain ?? t).trim(), by, ctx);
- const m = YES_NO.exec(t);
++ if (quoted) return this.replyTo(quoted, (ctx.plain ?? msg).trim(), by, ctx);
++ const m = YES_NO.exec(msg);
+ if (m && m[2]) {
+ const row = this.store.pendingApprovalByCode(m[2]);
+ if (!row || row.conversationId !== conversationId || row.kind !== "approval") {
- return { handled: true, ack: `⚠️ 没有编号为 ${m[2]} 的待批准请求(可能已过期或已处理)` };
++ return { handled: true, ack: t("approvals.noSuchCode", { code: m[2] }) };
}
- const ok = this.decide(row.id, allow, by);
- if (!ok) return { handled: true, ack: t("approvals.expiredOrDone", { code: row.code }) };
- return { handled: true, ack: t(allow ? "approvals.approved" : "approvals.rejected", { code: row.code }) };
+ return this.decideReply(row, YES.test(m[1]), by);
}
- const q = this.pending(conversationId, "question")[0];
+ if (m) {
+ const list = [...chat.filter((r) => r.kind === "approval"), ...task.filter((r) => r.kind === "approval" && ctx.latest?.(r))];
+ if (list.length === 1) return this.decideReply(list[0], YES.test(m[1]), by);
- if (list.length > 1) return { handled: true, ack: `有 ${list.length} 个待批准请求,请带上编号回复,例如 y ${list[0].code}` };
++ if (list.length > 1) return { handled: true, ack: t("approvals.needCode", { count: list.length, code: list[0].code }) };
+ }
+ // 「1234 中文」:以任务提问的编号开头
- const c = /^(\d{4})(?:\s*[::,,.。、]\s*|\s+)(\S[\s\S]*)$/.exec(t);
++ const c = /^(\d{4})(?:\s*[::,,.。、]\s*|\s+)(\S[\s\S]*)$/.exec(msg);
+ const byCode = c ? task.find((r) => r.kind === "question" && r.code === c[1]) : undefined;
+ if (c && byCode) return this.replyTo(byCode, c[2], by, ctx);
+ // 聊天回合在等的提问:直接回复就是回答
+ const q = chat.find((r) => r.kind === "question");
if (q) {
- const questions = safeJson<QuestionItem[]>(q.payload, []);
- const answer = parseAnswer(questions, s);
- this.answer(q.id, answer, by);
- this.answer(q.id, parseAnswer(questionsOf(q), t), by);
++ this.answer(q.id, parseAnswer(questionsOf(q), msg), by);
return { handled: true };
}
+ // 任务的提问是机器人最后一条消息:只认选项编号或选项原文
+ const last = task.find((r) => r.kind === "question" && ctx.latest?.(r));
- if (last && isOptionReply(questionsOf(last), t)) return this.replyTo(last, t, by, ctx);
++ if (last && isOptionReply(questionsOf(last), msg)) return this.replyTo(last, msg, by, ctx);
return { handled: false };
}
+
+ private decideReply(row: ApprovalRow, allow: boolean, by: string): ReplyResult {
- if (!this.decide(row.id, allow, by)) return { handled: true, ack: `⚠️ 请求 ${row.code} 已过期或已处理` };
- return { handled: true, ack: allow ? `✅ 已批准 ${row.code}(仅本次)` : `❌ 已拒绝 ${row.code}` };
++ if (!this.decide(row.id, allow, by)) return { handled: true, ack: t("approvals.expiredOrDone", { code: row.code }) };
++ return { handled: true, ack: t(allow ? "approvals.approved" : "approvals.rejected", { code: row.code }) };
+ }
+
+ /** 认定是对这一条的回答:提问记下回答;审批要 y / n */
+ private replyTo(row: ApprovalRow, text: string, by: string, ctx: ReplyContext): ReplyResult {
+ if (row.kind === "approval") {
+ const m = YES_NO.exec(text);
- if (!m || (m[2] && m[2] !== row.code)) return { handled: true, ack: `回复 y ${row.code} 批准,n ${row.code} 拒绝` };
++ if (!m || (m[2] && m[2] !== row.code)) return { handled: true, ack: t("approvals.replyYesNo", { code: row.code }) };
+ return this.decideReply(row, YES.test(m[1]), by);
+ }
- if (!text) return { handled: true, ack: "引用时写上你的回答" };
- if (!this.answerText(row.id, text, by)) return { handled: true, ack: "这个问题已经回答过了" };
++ if (!text) return { handled: true, ack: t("approvals.quoteNeedsAnswer") };
++ if (!this.answerText(row.id, text, by)) return { handled: true, ack: t("approvals.alreadyAnswered") };
+ return { handled: true, ack: ctx.answered?.(row) };
+ }
}
function safeJson<T>(s: string, d: T): T {
@@@ -234,20 -378,44 +379,49 @@@ export function parseAnswer(questions:
export function promptText(row: ApprovalRow): string {
if (row.kind === "approval") {
const cmd = row.detail ? ` \`${row.detail.replace(/`/g, "'").slice(0, 300)}\`` : "";
- const why = row.reason && !row.detail ? `(${row.reason.slice(0, 200)})` : "";
- return `需批准: ${row.tool}${cmd}${why} — 回复 y ${row.code} / n ${row.code}`;
+ const why = row.reason && !row.detail ? t("approvals.promptWhy", { reason: row.reason.slice(0, 200) }) : "";
+ return t("approvals.prompt", { tool: row.tool, cmd, why, code: row.code });
}
- const qs = safeJson<QuestionItem[]>(row.payload, []);
+ const qs = questionsOf(row);
const blocks = qs.map((q, i) => {
const head = `${qs.length > 1 ? `${i + 1}) ` : ""}${q.question}${q.detail ? `\n${q.detail}` : ""}`;
const opts = (q.options ?? []).map((o, j) => ` ${j + 1}. ${o.label}${o.description ? ` — ${o.description}` : ""}`);
return [head, ...opts].join("\n");
});
- const hint = qs.length > 1 ? "(每行回答一个问题:回复编号或直接写答案)" : qs[0]?.options?.length ? `(回复编号${qs[0].multiSelect ? ",可多选用逗号分隔" : ""},或直接写答案)` : "(直接回复答案)";
+ const hint =
+ qs.length > 1
+ ? t("approvals.hintMulti")
+ : qs[0]?.options?.length
+ ? t("approvals.hintOptions", { multi: qs[0].multiSelect ? t("approvals.hintOptionsMulti") : "" })
+ : t("approvals.hintFree");
return `❓ ${blocks.join("\n\n")}\n${hint}`;
}
+
+ /**
+ * 后台任务推给用户的提示(设计第 6 节的消息样式):
+ * 提问「❓「GPU 价格调研」想问你:报告用中文还是英文?\n1. 中文\n2. 英文\n(回复编号,或引用这条消息回答)」;
+ * 审批「需批准(任务「清理旧构建」):`rm -rf build/` — 回复 y 4821 / n 4821」。
+ */
+ export function taskPromptText(row: ApprovalRow, title: string): string {
+ if (row.kind === "approval") {
+ const what = row.detail ? `\`${row.detail.replace(/`/g, "'").slice(0, 300)}\`` : `${row.tool}${row.reason ? `(${row.reason.slice(0, 200)})` : ""}`;
- return `需批准(任务「${title}」):${what} — 回复 y ${row.code} / n ${row.code}`;
++ return t("approvals.taskApproval", { title, what, code: row.code });
+ }
+ const q = questionsOf(row)[0];
+ const opts = (q?.options ?? []).map((o, i) => `${i + 1}. ${o.label}`);
- const hint = opts.length ? `(回复编号${q?.multiSelect ? ",可多选" : ""},或引用这条消息回答)` : "(引用这条消息回答)";
- return [`❓「${title}」想问你:${q?.question ?? row.detail}`, ...opts, hint].join("\n");
++ const hint = opts.length ? t("approvals.taskHintOptions", { multi: q?.multiSelect ? t("approvals.taskHintMulti") : "" }) : t("approvals.taskHintQuote");
++ return [t("approvals.taskQuestion", { title, question: q?.question ?? row.detail }), ...opts, hint].join("\n");
+ }
+
+ /** 卡片渠道(飞书)的按钮:审批是允许 / 拒绝;单选的提问是每个选项一个按钮 */
+ export function promptButtons(row: ApprovalRow): Array<{ label: string; value: Record<string, string>; style: "primary" | "danger" | "default" }> | undefined {
+ if (row.kind === "approval") {
+ return [
- { label: "允许(仅本次)", value: { amb: "approval", id: row.id, decision: "allow" }, style: "primary" },
- { label: "拒绝", value: { amb: "approval", id: row.id, decision: "deny" }, style: "danger" },
++ { label: t("approvals.allowOnce"), value: { amb: "approval", id: row.id, decision: "allow" }, style: "primary" },
++ { label: t("approvals.deny"), value: { amb: "approval", id: row.id, decision: "deny" }, style: "danger" },
+ ];
+ }
+ const qs = questionsOf(row);
+ const single = qs.length === 1 ? qs[0] : undefined;
+ return single?.options?.length && !single.multiSelect ? single.options.map((o, i) => ({ label: o.label, value: { amb: "question", id: row.id, option: String(i + 1) }, style: "default" as const })) : undefined;
+ }
diff --cc src/app.ts
index d82ba5d,5587d81..28bf7ad
--- a/src/app.ts
+++ b/src/app.ts
@@@ -43,7 -43,7 +43,8 @@@ import { MediaService, pickDefault } fr
import { COMPACT_ENDPOINT, serverCompactionEnabled, type CompactEndpoint } from "./agent/server-compaction.js";
import type { BotSettings } from "./agent/settings.js";
import { TaskService } from "./tasks/service.js";
+import { detached, setLangPref, t } from "./i18n/index.js";
+ import { Attention, approvalItems, type AttentionItem } from "./tasks/attention.js";
const log = logger("app");
@@@ -656,7 -672,10 +679,10 @@@ export class App
pollTimeoutMs: this.opts.weixinPollTimeoutMs,
outbox: this.outbox,
});
- ch.weixin.onExpired = () => this.notice("warn", t("app.weixin_expired", { name: bot.name }));
+ ch.weixin.onExpired = () => {
- this.notice("warn", `机器人「${bot.name}」微信登录已过期,请在信息面板的「渠道」里重新扫码`);
++ this.notice("warn", t("app.weixin_expired", { name: bot.name }));
+ this.attention.kick();
+ };
const wx = ch.weixin;
// 代理自己醒来的一轮:经出站队列发给这个微信用户(发送时才查 24 小时窗口和配额)
this.runtime.registerReplier(bot.id, "weixin", (conv, _handle, key) => ({ out: wx.followUp(conv.peerId, key) }));
diff --cc src/core/runtime.ts
index eae4a35,3892ae4..805cc47
--- a/src/core/runtime.ts
+++ b/src/core/runtime.ts
@@@ -264,9 -276,24 +266,24 @@@ export class BotRuntime
};
}
+ /**
+ * 这一轮的回复(和交付的文件)已经交给渠道:清掉重启标记,不等收尾。微信、飞书的回复这时已经落进出站队列,重启后会补发;
+ * 之后还有关"正在输入"(微信要一次网络请求)、让出会话,在那之间退出或崩溃,下次启动不该再说"没处理完,请重新发送"。
+ * 并进这一轮的消息随它一起答完了;会话里还有排着、没答的消息时标记留着。
+ */
- private answered(convId: string, t: Inflight): void {
- if (t.interrupted) return;
- for (const x of this.inflight.get(convId) ?? []) if (x !== t && !x.steered) return;
++ private answered(convId: string, run: Inflight): void {
++ if (run.interrupted) return;
++ for (const x of this.inflight.get(convId) ?? []) if (x !== run && !x.steered) return;
+ try {
+ clearInflight(this.opts.store, convId);
+ } catch {
+ /* 退出时数据库可能已经关了 */
+ }
+ }
+
- private async handleMessage(ev: InboundEvent, out: ReplySession, bot: NonNullable<ReturnType<Store["getBot"]>>, convId: string, t: Inflight, prior: Promise<void> | undefined): Promise<void> {
+ private async handleMessage(ev: InboundEvent, out: ReplySession, bot: NonNullable<ReturnType<Store["getBot"]>>, convId: string, run: Inflight, prior: Promise<void> | undefined): Promise<void> {
const { store } = this.opts;
- const signal = t.abort.signal;
+ const signal = run.abort.signal;
const agent = this.opts.agent;
// 代理模式:收到的图片/文件先进工作区,消息里写路径
if (agent?.available) storeInbound(agent.host(bot.id).workspace, ev);
@@@ -365,9 -392,10 +382,10 @@@
return;
}
log.warn("model call failed", { model, status: err.status, message: err.message });
- const msg = acc ? `${acc}\n\n⚠️ 生成中断:${err.message}` : `⚠️ 模型调用失败(${model}):${err.message}`;
+ const msg = acc ? `${acc}\n\n${t("runtime.interrupted", { error: err.message })}` : t("runtime.modelFailed", { model, error: err.message });
await out.apply({ type: "stream.finish", text: msg });
} finally {
- this.answered(conv.id, t);
++ this.answered(conv.id, run);
await out.apply({ type: "typing", on: false });
}
}
@@@ -464,17 -477,17 +484,17 @@@
cardAction(botId: string, value: Record<string, string>, by: string): { toast: string; ok: boolean } {
const agent = this.opts.agent;
const row = agent && value?.id ? this.opts.store.getApproval(String(value.id)) : undefined;
- if (!agent || !row || row.botId !== botId) return { toast: "请求不存在", ok: false };
- if (row.status !== "pending") return { toast: `请求 ${row.code} 已处理或已过期`, ok: false };
+ if (!agent || !row || row.botId !== botId) return { toast: t("runtime.requestMissing"), ok: false };
+ if (row.status !== "pending") return { toast: t("runtime.requestDone", { code: row.code }), ok: false };
if (value.amb === "approval") {
const allow = value.decision === "allow";
- return agent.approvals.decide(row.id, allow, by) ? { toast: allow ? `已批准 ${row.code}(仅本次)` : `已拒绝 ${row.code}`, ok: true } : { toast: "已过期", ok: false };
+ return agent.approvals.decide(row.id, allow, by) ? { toast: t(allow ? "runtime.approvedOnce" : "runtime.rejected", { code: row.code }), ok: true } : { toast: t("runtime.expired"), ok: false };
}
if (value.amb === "question") {
- const r = agent.approvals.handleReply(row.conversationId, String(value.option ?? ""), by);
- return r.handled ? { toast: t("runtime.submitted"), ok: true } : { toast: t("runtime.submitFailed"), ok: false };
+ // 回答按钮所在的这一个提问(会话里可能同时有几个)
- return agent.approvals.answerText(row.id, String(value.option ?? ""), by) ? { toast: "已提交", ok: true } : { toast: "提交失败", ok: false };
++ return agent.approvals.answerText(row.id, String(value.option ?? ""), by) ? { toast: t("runtime.submitted"), ok: true } : { toast: t("runtime.submitFailed"), ok: false };
}
- return { toast: "未知操作", ok: false };
+ return { toast: t("runtime.unknownAction"), ok: false };
}
/**
diff --cc src/i18n/messages/approvals.ts
index ca2e3c2,0000000..bd68e13
mode 100644,000000..100644
--- a/src/i18n/messages/approvals.ts
+++ b/src/i18n/messages/approvals.ts
@@@ -1,30 -1,0 +1,50 @@@
+// approvals:zh 与 en 的键必须一一对应(en 的类型由 zh 推出,少一个多一个都过不了类型检查)。
+import type { Catalog } from "../types.js";
+
+export const zh = {
+ noSuchCode: "⚠️ 没有编号为 {code} 的待批准请求(可能已过期或已处理)",
+ needCode: "有 {count} 个待批准请求,请带上编号回复,例如 y {code}",
+ expiredOrDone: "⚠️ 请求 {code} 已过期或已处理",
+ approved: "✅ 已批准 {code}(仅本次)",
+ rejected: "❌ 已拒绝 {code}",
+ prompt: "需批准: {tool}{cmd}{why} — 回复 y {code} / n {code}",
+ promptWhy: "({reason})",
+ hintMulti: "(每行回答一个问题:回复编号或直接写答案)",
+ hintOptions: "(回复编号{multi},或直接写答案)",
+ hintOptionsMulti: ",可多选用逗号分隔",
+ hintFree: "(直接回复答案)",
++ replyYesNo: "回复 y {code} 批准,n {code} 拒绝",
++ quoteNeedsAnswer: "引用时写上你的回答",
++ alreadyAnswered: "这个问题已经回答过了",
++ taskApproval: "需批准(任务「{title}」):{what} — 回复 y {code} / n {code}",
++ taskQuestion: "❓「{title}」想问你:{question}",
++ taskHintOptions: "(回复编号{multi},或引用这条消息回答)",
++ taskHintMulti: ",可多选",
++ taskHintQuote: "(引用这条消息回答)",
++ allowOnce: "允许(仅本次)",
++ deny: "拒绝",
+} satisfies Catalog;
+
+export const en: Catalog<typeof zh> = {
+ noSuchCode: "⚠️ No request {code} is awaiting approval (it may have expired or been handled)",
+ needCode: "{count} requests are awaiting approval; reply with the code, e.g. y {code}",
+ expiredOrDone: "⚠️ Request {code} has expired or was already handled",
+ approved: "✅ Approved {code} (this time only)",
+ rejected: "❌ Denied {code}",
+ prompt: "Approval needed: {tool}{cmd}{why} — reply y {code} / n {code}",
+ promptWhy: " ({reason})",
+ hintMulti: "(Answer one question per line: reply with an option number or type your answer)",
+ hintOptions: "(Reply with an option number{multi}, or type your answer)",
+ hintOptionsMulti: " or several separated by commas",
+ hintFree: "(Type your answer)",
++ replyYesNo: "Reply y {code} to approve or n {code} to deny",
++ quoteNeedsAnswer: "Write your answer when you quote the message",
++ alreadyAnswered: "This question has already been answered",
++ taskApproval: "Approval needed (task \"{title}\"): {what} — reply y {code} / n {code}",
++ taskQuestion: "❓ \"{title}\" asks: {question}",
++ taskHintOptions: "(reply with a number{multi}, or quote this message to answer)",
++ taskHintMulti: "; you can pick several",
++ taskHintQuote: "(quote this message to answer)",
++ allowOnce: "Allow (once)",
++ deny: "Deny",
+};
diff --cc src/i18n/messages/desktop.ts
index df18fea,0000000..352c5dd
mode 100644,000000..100644
--- a/src/i18n/messages/desktop.ts
+++ b/src/i18n/messages/desktop.ts
@@@ -1,28 -1,0 +1,30 @@@
+// desktop:Electron 外壳(electron/main.ts)的托盘菜单与对话框。zh 与 en 的键必须一一对应(en 的类型由 zh 推出)。
+import type { Catalog } from "../types.js";
+
+export const zh = {
+ trayOpen: "打开 {product}",
+ trayOpenInBrowser: "在浏览器中打开",
+ trayAutostart: "开机自启",
+ trayOpenDataDir: "打开数据目录",
+ trayQuit: "退出",
+ errorTitle: "{product} 出错了",
+ errorDetail: "{message}\n\n详细信息见日志:{log}",
+ logDisabled: "(未启用)",
+ bootFailed: "{product} 启动失败",
+ uiNotStarted: "管理界面未启动",
++ trayNeeds: "需要你({count})",
+} satisfies Catalog;
+
+export const en: Catalog<typeof zh> = {
+ trayOpen: "Open {product}",
+ trayOpenInBrowser: "Open in browser",
+ trayAutostart: "Launch at login",
+ trayOpenDataDir: "Open data folder",
+ trayQuit: "Quit",
+ errorTitle: "{product} ran into a problem",
+ errorDetail: "{message}\n\nSee the log for details: {log}",
+ logDisabled: "(disabled)",
+ bootFailed: "{product} couldn't start",
+ uiNotStarted: "The local interface didn't start",
++ trayNeeds: "Needs you ({count})",
+};
diff --cc src/web/server.ts
index 9302c74,44c5d59..da9f7f7
--- a/src/web/server.ts
+++ b/src/web/server.ts
@@@ -16,14 -16,12 +16,14 @@@ import { normalizeLine } from "../model
import { SseReply } from "./sse-reply.js";
import { LiveTurns, type LiveTurn } from "./live.js";
import { connectionFromPids } from "../agent/peer-guard.js";
- import type { ApprovalRow } from "../store/db.js";
+ import type { ApprovalRow, Store } from "../store/db.js";
import { normalizeSettings } from "../agent/settings.js";
import { scopeLabel } from "../agent/memory.js";
-import { pwshProbe, type PwshMode } from "../agent/pwsh.js";
+import { pwshProbe, type PwshMode, type PwshStatus } from "../agent/pwsh.js";
import { peerName, shortPeer, whoText } from "../core/access.js";
import type { AccessEntry } from "../store/db.js";
+import { GUIDE_STEPS, deriveGuide, isGuideStep, mergeGuide, normalizeGuide, type GuideState } from "../guide.js";
+import { normalizeLang, requestLang, setLangPref, t, type LangPref } from "../i18n/index.js";
const log = logger("web");
const require = createRequire(import.meta.url);
@@@ -583,25 -566,25 +612,25 @@@ export async function startWebServer(ap
if (seg[0] === "approvals") {
if (seg.length === 1 && m === "GET") {
const status = url.searchParams.get("status") || undefined;
- return send(res, 200, { approvals: app.store.listApprovals({ status: status as any, botId: url.searchParams.get("bot") || undefined, limit: 100 }).map(publicApproval) });
+ return send(res, 200, { approvals: app.store.listApprovals({ status: status as any, botId: url.searchParams.get("bot") || undefined, limit: 100 }).map((r) => publicApproval(r, app.store)) });
}
const row = seg[1] ? app.store.getApproval(decodeURIComponent(seg[1])) : undefined;
- if (!row) throw new HttpError(404, "请求不存在");
+ if (!row) throw new HttpError(404, t("web.requestNotFound"));
- if (seg.length === 2 && m === "GET") return send(res, 200, { approval: publicApproval(row) });
+ if (seg.length === 2 && m === "GET") return send(res, 200, { approval: publicApproval(row, app.store) });
if (seg.length === 3 && m === "POST" && (seg[2] === "approve" || seg[2] === "deny")) {
- if (row.kind !== "approval") throw new HttpError(400, "不是审批请求");
+ if (row.kind !== "approval") throw new HttpError(400, t("web.notApproval"));
const ok = app.agent.approvals.decide(row.id, seg[2] === "approve", "web");
- if (!ok) throw new HttpError(409, "请求已处理或已过期");
+ if (!ok) throw new HttpError(409, t("web.requestDone"));
- return send(res, 200, { approval: publicApproval(app.store.getApproval(row.id)!) });
+ return send(res, 200, { approval: publicApproval(app.store.getApproval(row.id)!, app.store) });
}
if (seg.length === 3 && m === "POST" && seg[2] === "answer") {
- if (row.kind !== "question" || row.status !== "pending") throw new HttpError(409, "请求已处理或已过期");
+ if (row.kind !== "question" || row.status !== "pending") throw new HttpError(409, t("web.requestDone"));
const b = await readJson(req);
const ok = Array.isArray(b.answers)
? app.agent.approvals.answer(row.id, { answers: b.answers.map((a: any) => ({ id: String(a.id), selected: (a.selected ?? []).map(String), ...(a.custom ? { custom: String(a.custom) } : {}) })) }, "web")
- : app.agent.approvals.handleReply(row.conversationId, String(b.text ?? ""), "web").handled;
+ : app.agent.approvals.answerText(row.id, String(b.text ?? ""), "web");
- if (!ok) throw new HttpError(409, "提交失败");
+ if (!ok) throw new HttpError(409, t("web.submitFailed"));
- return send(res, 200, { approval: publicApproval(app.store.getApproval(row.id)!) });
+ return send(res, 200, { approval: publicApproval(app.store.getApproval(row.id)!, app.store) });
}
}
if (seg[0] === "conversations") {
diff --cc test/attention.unit.test.ts
index 0000000,ec09151..2058391
mode 000000,100644..100644
--- a/test/attention.unit.test.ts
+++ b/test/attention.unit.test.ts
@@@ -1,0 -1,126 +1,133 @@@
+ /**
+ * 「需要你」(3b):来源合在一起、排好序;有变化才通知;系统通知每项最多一次(重启也算);健康时什么都没有。
+ * 界面那一半:侧栏的「需要你」行和托盘角标在没事时不画。
+ */
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
+ import { Store } from "../src/store/db.js";
+ import { ApprovalCenter } from "../src/agent/approvals.js";
+ import { Attention, approvalItems, botLine, notificationOf, trayTitle, type AttentionItem } from "../src/tasks/attention.js";
+
+ const item = (o: Partial<AttentionItem> & Pick<AttentionItem, "id" | "kind">): AttentionItem => ({
+ botId: "b",
+ botName: "小蓝",
+ subject: "GPU 价格调研",
+ status: "等你回答",
+ line: "报告用中文还是英文?",
+ since: 1,
+ severity: "warn",
+ actions: [],
+ ...o,
+ });
+
+ /** vnode 里所有的字(只看结构,不渲染) */
+ const textOf = (v: any): string => (v == null || typeof v === "boolean" ? "" : typeof v !== "object" ? String(v) : Array.isArray(v) ? v.map(textOf).join("") : textOf(v.props?.children));
+
+ describe("界面:侧栏的「需要你」行", () => {
+ it("没事时不画这一行;有事时是黄点、「需要你」和件数", async () => {
+ // 界面模块在浏览器里跑:只补上它们加载时要的那一点
- (globalThis as any).window ??= { matchMedia: () => ({ matches: false, addEventListener() {}, removeEventListener() {} }) };
++ (globalThis as any).window ??= { matchMedia: () => ({ matches: false, addEventListener() {}, removeEventListener() {} }), addEventListener() {}, removeEventListener() {} };
+ // @ts-expect-error 界面代码是不经构建的 JS
+ const { NeedsRow } = await import("../ui/screens/needs-you.js");
++ // @ts-expect-error 同上
++ const ui = await import("../ui/lib/i18n.js");
+ expect(NeedsRow({ count: 0 })).toBeNull();
+ expect(NeedsRow({ count: undefined })).toBeNull();
++ ui.setLangPref("zh-CN");
+ const row = NeedsRow({ count: 3, on: true, onClick: () => {} }) as any;
+ expect(row.props.class).toBe("needs-row sel");
+ expect(textOf(row)).toBe("需要你3");
++ // 文字跟着界面语言
++ ui.setLangPref("en");
++ expect(textOf(NeedsRow({ count: 3, on: true, onClick: () => {} }))).toBe("Needs you3");
++ ui.setLangPref("zh-CN");
+ });
+ });
+
+ describe("Attention", () => {
+ let store: Store;
+ let att: Attention;
+ beforeEach(() => {
+ store = new Store(":memory:");
+ att = new Attention({ store, debounceMs: 1, intervalMs: 60_000 });
+ });
+ afterEach(() => {
+ att.stop();
+ store.close();
+ });
+
+ it("健康时什么都没有:没有项、没有件数、托盘只有应用名", () => {
+ att.addSource(() => []);
+ expect(att.list()).toEqual([]);
+ expect(att.count()).toBe(0);
+ expect(att.byBot()).toEqual({});
+ expect(trayTitle("AnyModelBot", 0)).toBe("AnyModelBot");
+ expect(att.takeNew()).toEqual([]);
+ });
+
+ it("排序:提问和审批在前,再是失败、没送到、登录;同一类旧的在前;同一 id 只算一次", () => {
+ att.addSource(() => [item({ id: "login:b:weixin", kind: "login", since: 1 }), item({ id: "task:t2", kind: "failed", since: 2 }), item({ id: "approval:a2", kind: "approval", since: 9 })]);
+ att.addSource(() => [item({ id: "task:t3", kind: "delivery", since: 0 }), item({ id: "approval:a1", kind: "question", since: 5 }), item({ id: "task:t2", kind: "failed", since: 2 })]);
+ expect(att.list().map((x) => x.id)).toEqual(["approval:a1", "approval:a2", "task:t2", "task:t3", "login:b:weixin"]);
+ expect(att.count()).toBe(5);
+ });
+
+ it("每个机器人几件、最早那件(侧栏机器人行的第二行)", () => {
+ att.addSource(() => [item({ id: "a", kind: "question", since: 1 }), item({ id: "b", kind: "failed", since: 2, status: "失败" }), item({ id: "c", kind: "login", botId: "g", botName: "绿草", subject: "微信登录已过期", status: "" })]);
+ expect(att.byBot()).toEqual({ b: { n: 2, line: "GPU 价格调研等你回答" }, g: { n: 1, line: "微信登录已过期" } });
+ });
+
+ it("系统通知每项最多一次,重启后也不再给;处理掉的项从记录里清掉", () => {
+ let items = [item({ id: "approval:a1", kind: "question" })];
+ att.addSource(() => items);
+ expect(att.takeNew().map((x) => x.id)).toEqual(["approval:a1"]);
+ expect(att.takeNew()).toEqual([]);
+ const again = new Attention({ store });
+ again.addSource(() => items);
+ expect(again.takeNew()).toEqual([]);
+ items = [item({ id: "approval:a2", kind: "approval" })];
+ expect(again.takeNew().map((x) => x.id)).toEqual(["approval:a2"]);
+ expect(JSON.parse(store.getKV("attention:notified")!)).toEqual(["approval:a2"]);
+ });
+
+ it("订阅:立即拿到一份;有变化才再通知(kick 合并同一时刻的几次)", async () => {
+ let items: AttentionItem[] = [];
+ att.addSource(() => items);
+ const seen: number[] = [];
+ const off = att.onChange((x) => seen.push(x.length));
+ expect(seen).toEqual([0]);
+ att.kick();
+ await new Promise((r) => setTimeout(r, 20));
+ expect(seen).toEqual([0]);
+ items = [item({ id: "a", kind: "question" })];
+ att.kick();
+ att.kick();
+ await new Promise((r) => setTimeout(r, 20));
+ expect(seen).toEqual([0, 1]);
+ off();
+ items = [];
+ att.kick();
+ await new Promise((r) => setTimeout(r, 20));
+ expect(seen).toEqual([0, 1]);
+ });
+
+ it("系统通知的样子:标题「小蓝 需要你」,正文「GPU 价格调研:报告用中文还是英文?」", () => {
+ expect(notificationOf(item({ id: "a", kind: "question" }))).toEqual({ title: "小蓝 需要你", body: "GPU 价格调研:报告用中文还是英文?" });
+ expect(notificationOf(item({ id: "l", kind: "login", subject: "微信登录已过期", status: "", line: "" }))).toEqual({ title: "小蓝 需要你", body: "微信登录已过期" });
+ expect(botLine(item({ id: "f", kind: "failed", status: "失败" }))).toBe("GPU 价格调研失败");
+ expect(trayTitle("AnyModelBot", 3)).toBe("AnyModelBot · 3 件事需要你");
+ });
+
+ it("审批中心那一份:任务的以任务名为题,聊天里的以渠道为题", () => {
+ store.createBot({ id: "b", name: "小蓝" });
+ store.ensureConversation("b", "weixin", "owner", "owner");
+ const c = new ApprovalCenter(store);
+ const now = Date.now();
+ store.insertTask({ id: "t_1", botId: "b", conversationId: "b:weixin:owner", originMessageId: 0, originRef: "", title: "清理旧构建", brief: "", sessionId: "task-t_1", folder: "tasks/x", model: "m", permission: "workspace", budgetUsd: 1, createdAt: now, updatedAt: now });
+ const a = c.create({ kind: "approval", botId: "b", conversationId: "b:weixin:owner", sessionId: "task-t_1", tool: "bash", detail: "rm -rf build/", reason: "", taskId: "t_1" });
+ const q = c.create({ kind: "question", botId: "b", conversationId: "b:weixin:owner", sessionId: "chat", tool: "ask_user_question", detail: "继续吗?", reason: "", payload: JSON.stringify([{ id: "q", question: "继续吗?" }]) });
+ const items = approvalItems(store, c.pendingAll());
+ expect(items.find((x) => x.id === `approval:${a.id}`)).toMatchObject({ kind: "approval", subject: "清理旧构建", status: "等你批准", line: "rm -rf build/", actions: ["approve", "deny"], taskId: "t_1", code: a.code, channel: "weixin" });
+ expect(items.find((x) => x.id === `approval:${q.id}`)).toMatchObject({ kind: "question", subject: "微信", status: "等你回答", line: "继续吗?", actions: ["answer"], questions: [{ id: "q", question: "继续吗?" }] });
+ expect(items.find((x) => x.id === `approval:${q.id}`)!.taskId).toBeUndefined();
+ });
+ });
diff --cc ui/components/tasks.js
index fae91d4,b160068..9b30867
--- a/ui/components/tasks.js
+++ b/ui/components/tasks.js
@@@ -62,8 -63,8 +64,8 @@@ export function TaskDetail({ task, onCh
setStopping(false);
};
return html`<div class="task-detail">
- ${task.latest && html`<div class="task-line"><span class="t-label">${t("tasks.latest")}</span><span class="v selectable">${task.latest}</span></div>`}
- <div class="task-line"><span class="t-label">${t("tasks.folder")}</span><span class="v mono selectable">${task.folder}</span></div>
- ${view.latest && html`<div class="task-line"><span class="t-label">最新进展</span><span class="v selectable">${view.latest}</span></div>`}
- ${view.folder && html`<div class="task-line"><span class="t-label">文件夹</span><span class="v mono selectable">${view.folder}</span></div>`}
++ ${view.latest && html`<div class="task-line"><span class="t-label">${t("tasks.latest")}</span><span class="v selectable">${view.latest}</span></div>`}
++ ${view.folder && html`<div class="task-line"><span class="t-label">${t("tasks.folder")}</span><span class="v mono selectable">${view.folder}</span></div>`}
${runs.map(
(r, i) => html`<${ActivityLine} key=${r.id + (r.state === "ended" ? ":e" : "")} label=${runLabel(r, i, now)} live=${r.state === "running" || r.state === "settling"} count=${r.steps}
load=${() => api(`/tasks/${encodeURIComponent(task.id)}/runs/${encodeURIComponent(r.id)}/activity`).then((x) => x.steps)} />`,
diff --cc ui/css/settings.css
index 0acfe24,b4a36df..37b7100
--- a/ui/css/settings.css
+++ b/ui/css/settings.css
@@@ -72,14 -48,38 +72,39 @@@
.usage-models div { display: flex; justify-content: space-between; gap: var(--space-3); }
.usage-models .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usage-models .n { color: var(--muted); font-variant-numeric: tabular-nums; }
-.notif { display: grid; gap: var(--space-1); padding: var(--space-3) 0; border-bottom: .5px solid var(--line); }
+.notif { display: grid; gap: var(--space-1); padding: var(--space-3) 0; border-bottom: 1px solid var(--line-2); }
.notif:last-child { border-bottom: 0; }
.notif b { font-weight: var(--fw-semibold); }
-.notif.unread b::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: var(--space-1-5); border-radius: 50%; background: var(--accent-solid); vertical-align: middle; }
+/* 未读点用 --accent(浅色墨、深色黄绿):6px 的黄绿点在浅色玻璃上几乎看不见 */
+.notif.unread b::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: var(--space-1-5); border-radius: 50%; background: var(--accent); vertical-align: middle; }
.notif p { font-size: var(--fs-sm); color: var(--fg-2); white-space: pre-wrap; }
-.notif time { font-size: var(--fs-2xs); color: var(--faint); }
+.notif time { font-size: var(--fs-2xs); color: var(--muted); }
+ /* 需要你(screens/needs-you.js):和设置页同一种页面;一组 .list,一件事一块,块间一条细线。
+ 左边一列是状态点,右边一列从上到下:谁 · 什么 · 状态(可点:展开任务详情)、问题或命令、行内操作 */
+ .needs-list .need {
+ display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--space-2-5); row-gap: var(--space-2);
+ padding: var(--space-3-5) var(--space-4);
+ }
+ .needs-list .need + .need { border-top: 1px solid var(--line-2); }
+ .need > .dot { grid-row: 1; align-self: center; }
+ .need > :not(.dot) { grid-column: 2; }
+ .need-head { display: flex; align-items: center; gap: var(--space-2); min-width: 0; text-align: left; font-size: var(--fs-sm); color: var(--fg-2); }
+ button.need-head { --focus-offset: 2px; border-radius: var(--r-sm); transition: color var(--t-fast); }
+ button.need-head:hover, button.need-head:hover .need-who b { color: var(--fg); }
+ .need-who { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+ .need-who b { font-weight: var(--fw-semibold); color: var(--fg); }
+ .need-when { flex: none; font-size: var(--fs-xs); color: var(--muted); }
+ .need-head .chev { flex: none; color: var(--muted); transition: transform var(--t-fast); }
+ .need.open .need-head .chev { transform: rotate(90deg); }
+ .need-line { font-size: var(--fs-lg); font-weight: var(--fw-medium); color: var(--fg); line-height: var(--lh-snug); overflow-wrap: anywhere; }
+ .need-line.mono { font-family: var(--code); font-size: var(--fs-sm); font-weight: var(--fw-regular); }
+ .need-actions { display: flex; align-items: center; gap: var(--ctl-gap); flex-wrap: wrap; }
+ .need-actions:empty { display: none; }
+ .need-reply { display: flex; align-items: center; gap: var(--ctl-gap); }
+ .need-reply .field { flex: 1; --field-h: var(--ctl-md); }
+ .need-detail .task-detail { margin-top: var(--space-1); }
+
/* 故障排查(screens/troubleshoot.js):状态和检测结果是普通的行;stderr 尾部是组里展开的一块(不再套底);
日志是自己的一块 --well(和代码块同一种面),不描边 */
.ts-state { display: inline-flex; align-items: center; gap: var(--space-1-5); font-size: var(--fs-sm); color: var(--fg-2); white-space: nowrap; }
diff --cc ui/css/shell.css
index 5ac11a2,88b4feb..e91c548
--- a/ui/css/shell.css
+++ b/ui/css/shell.css
@@@ -140,21 -108,24 +140,35 @@@ button.thread:active { background: var(
.thread .avatar-wrap { position: relative; flex: none; }
.thread .working-dot {
position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; /* 微调:压住头像的边 */
- background: var(--green); box-shadow: 0 0 0 2px var(--surface-solid); /* 描边:压在头像上的缺口,不是边框 */
+ background: var(--green); box-shadow: 0 0 0 2px var(--dot-cut, var(--side-solid)); /* 描边:压在头像上的缺口(和行底同色),不是边框 */
animation: breathe var(--dur-pulse) var(--ease-in-out) infinite;
}
+.thread.sel .working-dot { --dot-cut: var(--side-solid-on); }
+/* "更多"(重命名 / 复制 ID / 删除,和右键菜单同一份):叠在行的右上角、和名称同一行;悬停、键盘聚焦、菜单打开时出现,
+ 出现时把时间让出来。按钮的图标右沿落在行文字的右边线上 */
+.thread-item { position: relative; min-width: 0; }
+.thread-more {
+ --ib-size: var(--ctl-sm); --ib-fg: var(--muted);
+ position: absolute; top: var(--space-2); right: var(--space-1-5);
+ opacity: 0; transition: opacity var(--t-fast), background var(--t-fast), color var(--t-fast), transform var(--t-fast);
+}
+.thread-item:hover > .thread-more, .thread-more:focus-visible, .thread-more[aria-expanded="true"] { opacity: 1; }
+.thread-item:is(:hover, :has(> .thread-more:focus-visible), :has(> .thread-more[aria-expanded="true"])) .when { opacity: 0; }
.thread-skel { flex: 1; display: grid; gap: var(--space-1-5); }
+ /* 「需要你」(screens/needs-you.js):机器人列表上方一行,只在有事时出现。黄点在头像那一列的中线上,
+ 文字和机器人名对齐,件数和机器人行的计数在同一条竖线上;选中时和机器人行一样是浮起的玻璃片 */
+ .needs-row {
+ --focus-offset: -2px;
+ display: flex; align-items: center; gap: var(--space-3); width: 100%; height: var(--ctl-xl); padding: 0 var(--side-row-px);
+ border-radius: var(--r-xl); text-align: left; font-size: var(--fs-lg); font-weight: var(--fw-medium); color: var(--fg);
+ transition: background var(--t-fast), box-shadow var(--t-fast);
+ }
+ .needs-row:hover { background: var(--side-hover); }
+ .needs-row:active { background: var(--side-press); }
+ .needs-row.sel, .needs-row.sel:active { background: var(--side-active); box-shadow: var(--shadow-tile); }
+ .needs-row .mark { width: 38px; flex: none; display: grid; place-items: center; } /* 和侧栏头像一样宽 */
+ .needs-row .label { flex: 1; min-width: 0; }
+ .needs-row .badge.count { --badge-bg: var(--amber-soft); --badge-fg: var(--amber); }
.thread .field { --field-h: 30px; }
/* 侧栏空状态:一句话 + 一个按钮,靠留白成组,不套卡片 */
.side-empty {
diff --cc ui/design/gallery.js
index 5748f68,56b4b5f..01e527e
--- a/ui/design/gallery.js
+++ b/ui/design/gallery.js
@@@ -1,9 -1,10 +1,10 @@@
// 设计库样例页:token 表直接解析 tokens/*.css(单一来源,不会和代码脱节),组件用真实实现渲染。
import { render, createContext } from "preact";
import { useContext, useEffect, useLayoutEffect, useRef, useState } from "preact/hooks";
-import { html, Icon, Button, IconButton, Seg, Switch, MenuButton, Menu, Badge, Notice, Skeleton, Spinner, CopyButton, Toasts, DialogHost } from "../components/ui.js";
+import { html, Icon, ICONS, Button, IconButton, Seg, Switch, MenuButton, Menu, Badge, Notice, Skeleton, Spinner, CopyButton, Toasts, DialogHost, Splitter } from "../components/ui.js";
import { BotAvatar, AvatarPicker, AppMark, BOT_CHARS, CHAR_KEYS, MAIN_CHAR } from "../components/avatar.js";
import { TEMPLATES } from "../screens/new-bot.js";
+ import { NeedItem, NeedsRow } from "../screens/needs-you.js";
import { Markdown } from "../components/markdown.js";
import { useStore, toast, saved, failed, confirmSheet } from "../lib/store.js";
import { themeMode, setThemeMode } from "../lib/theme.js";
@@@ -379,8 -371,8 +380,8 @@@ function Gallery()
const nav = [
["原则", [["principles", "分层与约定"]]],
["Token", [["color", "颜色"], ["material", "材质"], ["type", "文字"], ["space", "间距与尺寸"], ["elevation", "投影与层级"], ["motion", "动效"]]],
- ["组件", [["states", "状态矩阵"], ["buttons", "按钮"], ["inputs", "输入"], ["menus", "菜单与分段"], ["status", "状态与反馈"], ["lists", "列表行"], ["overlays", "对话框与提示"], ["avatars", "头像"]]],
+ ["组件", [["states", "状态矩阵"], ["icons", "图标"], ["buttons", "按钮"], ["inputs", "输入"], ["menus", "菜单与分段"], ["status", "状态与反馈"], ["lists", "列表行"], ["splitter", "分隔条"], ["overlays", "对话框与提示"], ["avatars", "头像"]]],
- ["页面模式", [["patterns", "对话"], ["custom", "定制"]]],
+ ["页面模式", [["patterns", "对话"], ["needs", "需要你"], ["custom", "定制"]]],
];
return html`<${Compare.Provider} value=${compare}><div class="gal">
<nav class="gal-nav" aria-label="目录">
diff --cc ui/locales/en/app.js
index b7e89c4,0000000..f9291f4
mode 100644,000000..100644
--- a/ui/locales/en/app.js
+++ b/ui/locales/en/app.js
@@@ -1,39 -1,0 +1,41 @@@
+// app · en
+export default {
+ palette: {
+ title: "Command palette",
+ placeholder: "Type a command or bot name",
+ inputLabel: "Command",
+ empty: "No matching commands",
+ },
+ cmd: {
++ needs: "Needs you ({count})",
++ needsKeys: "needs attention to-do",
+ settings: "Open Settings",
+ settingsKeys: "settings preferences options",
+ newBot: "New bot",
+ newBotKeys: "new bot create add",
+ openInfo: "Open info panel",
+ closeInfo: "Close info panel",
+ infoKeys: "info panel details",
+ botSettings: "Settings for “{name}”",
+ botSettingsKeys: "bot settings configure",
+ modelflare: "Modelflare settings",
+ modelflareKeys: "modelflare key api model",
+ appearance: "Appearance settings",
+ appearanceKeys: "appearance font text size motion animation glass blur width",
+ themeSystem: "Theme: System",
+ themeKeys: "theme appearance",
+ themeLight: "Theme: Light",
+ themeLightKeys: "theme light appearance",
+ themeDark: "Theme: Dark",
+ themeDarkKeys: "theme dark night appearance",
+ lang: "Language: {name}",
+ langKeys: "language english chinese 中文",
+ switchBot: "Switch to “{name}”",
+ },
+ lowBalance: "Your Modelflare balance is down to ${amount}",
+ serviceDown: "Can't reach the local service: {error}",
+ resizeSide: "Resize sidebar",
+ resizePanel: "Resize info panel",
+ botMissing: "Bot not found",
+ backToChat: "Back to chat",
+};
diff --cc ui/locales/en/chat.js
index a203fc6,0000000..158a086
mode 100644,000000..100644
--- a/ui/locales/en/chat.js
+++ b/ui/locales/en/chat.js
@@@ -1,95 -1,0 +1,97 @@@
+// chat · en
+export default {
+ aria: "Conversation with {name}",
+ infoPanel: "Info panel (⌘⇧I)",
+ newConvCmd: "New conversation (/new)",
+ toBottom: "Scroll to bottom",
+ copyMessage: "Copy message",
+ commandsLabel: "Commands",
+ commands: {
+ stop: "Stop the message in progress",
+ tasks: "List background tasks (/stop <number> stops one)",
+ model: "List or switch models",
+ new: "Start a new conversation (archives the old one with a handoff note)",
+ reset: "Clear this conversation's context",
+ status: "Show the current model, mode and progress",
+ help: "Show all commands",
+ },
+ perm: {
+ menu: "File access",
+ title: "File access: {note}",
+ workspace: "Workspace write",
+ workspaceNote: "Can only edit this bot's workspace; asks you before going outside it",
+ readonly: "Read only",
+ readonlyNote: "Can't edit files; commands run in a read-only sandbox",
+ more: "More permission settings…",
+ },
+ approval: {
++ neededTask: "\"{title}\" needs your approval · {code}",
+ needed: "Needs your approval · {code}",
+ fallbackReason: "The bot wants to do something outside its workspace",
+ allowOnce: "Allow once",
+ deny: "Deny",
+ },
+ question: {
++ taskAsks: "\"{title}\" asks",
+ otherOptional: "Something else (optional)",
+ yourAnswer: "Type your answer",
+ orOther: "Or type a different answer",
+ submit: "Submit",
+ },
+ file: {
+ delivered: "Delivered to the bot's workspace · sent directly on WeChat/Feishu",
+ },
+ work: {
+ stopping: "Stopping…{extra}",
+ processedFor: " · ran for {d}",
+ process: "Activity",
+ done: "Worked for {d}",
+ replying: "Replying for {d}",
+ thinkingFor: "Thinking for {d}",
+ thinking: "Thinking",
+ },
+ error: {
+ stopFailed: "Couldn't stop: {error}",
+ fixKey: "Update key",
+ authInvalid: "Your Modelflare key is invalid or has been revoked.",
+ loadHistory: "Couldn't load message history: {error}",
+ },
+ menu: {
+ more: "More actions",
+ switchModel: "Switch model…",
+ newConv: "New conversation",
+ reset: "Clear context",
+ status: "Show status",
+ allCommands: "All commands",
+ },
+ reset: {
+ title: "Clear this conversation's context?",
+ body: "{name} will forget what was said in this web conversation. Long-term memory is kept.",
+ confirm: "Clear",
+ },
+ empty: {
+ guideTitle: "Hi, I'm {name}",
+ guideBody: "Take 5 minutes and walk through the checklist to see what I can do.",
+ title: "Start chatting with {name}",
+ body: "Test your bot right here. Set up Feishu and WeChat channels in the info panel.",
+ sample: "What can you help me with?",
+ helpChip: "/help for commands",
+ },
+ composer: {
+ steer: "Add to the reply in progress",
+ steerTitle: "Add to the reply in progress ({key})",
+ stopping: "Stopping…",
+ placeholder: "Message {name}, or type / for commands",
+ label: "Message",
+ currentModel: "Current model: {model}",
+ pickModel: "Choose model",
+ stop: "Stop generating (Esc)",
+ stopTitle: "Stop (Esc)",
+ send: "Send",
+ sendTitle: "Send ({key})",
+ },
+ model: {
+ followBot: "Use bot default",
+ setDefault: "Set as this bot's default model",
+ },
+};
diff --cc ui/locales/en/index.js
index 2c44af1,0000000..dba0744
mode 100644,000000..100644
--- a/ui/locales/en/index.js
+++ b/ui/locales/en/index.js
@@@ -1,26 -1,0 +1,27 @@@
+// en 文案:每个命名空间一个文件,键 = "命名空间.键"(见 ui/lib/i18n.js)。两种语言的键必须一一对应(test/i18n.unit.test.ts 会查)。
+import common from "./common.js";
+import app from "./app.js";
+import time from "./time.js";
+import settings from "./settings.js";
+import account from "./account.js";
+import pwsh from "./pwsh.js";
+import chat from "./chat.js";
+import info from "./info.js";
+import markdown from "./markdown.js";
+import notify from "./notify.js";
+import troubleshoot from "./troubleshoot.js";
+import onboarding from "./onboarding.js";
+import newBot from "./newBot.js";
+import botSettings from "./botSettings.js";
+import sidebar from "./sidebar.js";
+import avatar from "./avatar.js";
+import models from "./models.js";
+import ui from "./ui.js";
+import guide from "./guide.js";
+import activity from "./activity.js";
+import tasks from "./tasks.js";
++import needs from "./needs.js";
+import access from "./access.js";
+import perms from "./perms.js";
+
- export default { common, app, time, settings, account, pwsh, chat, info, markdown, notify, troubleshoot, onboarding, newBot, botSettings, sidebar, avatar, models, ui, guide, activity, perms, access, tasks };
++export default { common, app, time, settings, account, pwsh, chat, info, markdown, notify, troubleshoot, onboarding, newBot, botSettings, sidebar, avatar, models, ui, guide, activity, perms, access, tasks, needs };
diff --cc ui/locales/en/needs.js
index 0000000,0000000..60bcf2c
new file mode 100644
--- /dev/null
+++ b/ui/locales/en/needs.js
@@@ -1,0 -1,0 +1,16 @@@
++// needs · en
++export default {
++ title: "Needs you",
++ collapse: "Collapse",
++ viewTask: "View task",
++ openChat: "Open conversation",
++ reply: "Reply…",
++ approveOnce: "Approve once",
++ deny: "Deny",
++ stop: "Stop",
++ seen: "Got it",
++ relogin: "Scan again",
++ answerPlaceholder: "Your answer",
++ send: "Send",
++ none: "Nothing needs you right now",
++};
diff --cc ui/locales/en/sidebar.js
index 47cfaf4,0000000..10d3d9d
mode 100644,000000..100644
--- a/ui/locales/en/sidebar.js
+++ b/ui/locales/en/sidebar.js
@@@ -1,36 -1,0 +1,37 @@@
+// sidebar · en: sidebar (screens/sidebar.js)
+export default {
+ localUser: "Local user",
+ settingsTitle: "Settings (⌘,)",
+ openSettings: "Open Settings",
+ balance: "Balance {amount}",
+ lowBalance: "Only {amount} left — top up ↗",
+ renamed: "Renamed",
+ delete: {
+ title: "Delete “{name}”?",
+ body: "This permanently deletes the bot and all its conversations. This can't be undone.",
+ confirm: "Delete permanently",
+ },
+ bots: "Bots",
+ newShortcut: "New bot (⌘N)",
+ search: "Search bots",
+ list: "Bot list",
+ newBot: "New bot",
+ creating: "Creating…",
+ loadFailed: "Couldn't load bots",
+ empty: "No bots yet",
+ create: "New bot",
+ noMatch: "No matching bots",
+ newName: "New name",
+ working: "Working",
+ workingNow: "Working…",
+ noChats: "No conversations yet",
+ pending: { one: "{count} pending approval", other: "{count} pending approvals" },
++ needs: { one: "{count} thing needs you", other: "{count} things need you" },
+ moreFor: "More actions for {name}",
+ actionsFor: "Actions for {name}",
+ menu: {
+ settings: "Bot settings",
+ copyId: "Copy bot ID",
+ delete: "Delete bot",
+ },
+};
diff --cc ui/locales/zh-CN/app.js
index d80906c,0000000..b3015a5
mode 100644,000000..100644
--- a/ui/locales/zh-CN/app.js
+++ b/ui/locales/zh-CN/app.js
@@@ -1,39 -1,0 +1,41 @@@
+// app · zh-CN(ui/main.js:命令面板、全局提示)
+export default {
+ palette: {
+ title: "命令面板",
+ placeholder: "输入命令或机器人名称",
+ inputLabel: "命令",
+ empty: "没有匹配的命令",
+ },
+ cmd: {
++ needs: "需要你({count})",
++ needsKeys: "needs attention 需要你 待办",
+ settings: "打开设置",
+ settingsKeys: "settings preferences 设置 偏好",
+ newBot: "新建机器人",
+ newBotKeys: "new bot 新建 机器人",
+ openInfo: "打开信息面板",
+ closeInfo: "关闭信息面板",
+ infoKeys: "info panel 信息面板",
+ botSettings: "「{name}」的设置",
+ botSettingsKeys: "bot settings 机器人设置",
+ modelflare: "Modelflare 设置",
+ modelflareKeys: "modelflare key 密钥 模型",
+ appearance: "外观设置",
+ appearanceKeys: "appearance 外观 字体 字号 动画 毛玻璃 宽度 font size motion",
+ themeSystem: "主题:跟随系统",
+ themeKeys: "theme appearance 外观 主题",
+ themeLight: "主题:浅色",
+ themeLightKeys: "theme light 外观 主题",
+ themeDark: "主题:深色",
+ themeDarkKeys: "theme dark 外观 主题 暗色",
+ lang: "语言:{name}",
+ langKeys: "language 语言 中文 英文 English",
+ switchBot: "切换到「{name}」",
+ },
+ lowBalance: "Modelflare 余额只剩 {amount} 美元",
+ serviceDown: "无法连接本机服务:{error}",
+ resizeSide: "调整侧栏宽度",
+ resizePanel: "调整信息面板宽度",
+ botMissing: "机器人不存在",
+ backToChat: "返回对话",
+};
diff --cc ui/locales/zh-CN/chat.js
index a033904,0000000..0b985ac
mode 100644,000000..100644
--- a/ui/locales/zh-CN/chat.js
+++ b/ui/locales/zh-CN/chat.js
@@@ -1,97 -1,0 +1,99 @@@
+// chat · zh-CN(screens/chat.js:对话页、输入框、审批 / 提问卡片)
+export default {
+ aria: "和 {name} 的对话",
+ infoPanel: "信息面板(⌘⇧I)",
+ newConvCmd: "开始新的一段对话(/new)",
+ toBottom: "回到底部",
+ copyMessage: "复制这条消息",
+ commandsLabel: "命令",
+ commands: {
+ stop: "中止正在处理的消息",
+ tasks: "列出后台任务(/stop 编号 停止一个)",
+ model: "列出或切换模型",
+ new: "开始新的一段对话(旧对话归档并留交接便条)",
+ reset: "清空本会话上下文",
+ status: "查看当前模型、运行方式和处理进度",
+ help: "显示全部命令",
+ },
+ perm: {
+ menu: "文件权限",
+ title: "文件权限:{note}",
+ workspace: "工作区可写",
+ workspaceNote: "只能改这个机器人的工作区,越界操作先问你",
+ readonly: "只读",
+ readonlyNote: "不能改文件,命令在只读沙箱里运行",
+ more: "更多权限设置…",
+ },
+ approval: {
+ needed: "需要你的批准 · {code}",
++ neededTask: "「{title}」需要你的批准 · {code}",
+ fallbackReason: "机器人想执行一个超出工作区的操作",
+ allowOnce: "允许(仅本次)",
+ deny: "拒绝",
+ },
+ question: {
++ taskAsks: "「{title}」想问你",
+ otherOptional: "其他回答(可选)",
+ yourAnswer: "输入你的回答",
+ orOther: "或者输入其他回答",
+ submit: "提交",
+ },
+ file: {
+ delivered: "已交付到机器人工作区 · 微信/飞书会直接发送",
+ },
+ /** 回复上方的工作状态;{d} 是 fmtDur 的用时 */
+ work: {
+ stopping: "正在停止…{extra}",
+ processedFor: " 已处理 {d}",
+ process: "处理过程",
+ done: "用时 {d}",
+ replying: "正在回复 {d}",
+ thinkingFor: "思考中 {d}",
+ thinking: "思考中",
+ },
+ error: {
+ stopFailed: "停止失败:{error}",
+ fixKey: "去更新",
+ authInvalid: "Modelflare 密钥失效或已被撤销。",
+ loadHistory: "读取历史消息失败:{error}",
+ },
+ menu: {
+ more: "更多操作",
+ switchModel: "切换模型…",
+ newConv: "开始新的一段对话",
+ reset: "清空上下文",
+ status: "查看状态",
+ allCommands: "全部命令",
+ },
+ reset: {
+ title: "清空本会话上下文?",
+ body: "「{name}」会忘掉这段网页对话的内容;长期记忆保留。",
+ confirm: "清空",
+ },
+ empty: {
+ guideTitle: "嗨,我是{name}",
+ guideBody: "花 5 分钟,跟着清单认识一下我能做什么。",
+ title: "和 {name} 开始对话",
+ body: "在这里直接测试机器人;飞书和微信渠道在信息面板里配置。",
+ /** 点一下就发给机器人的示例问题 */
+ sample: "你能帮我做什么?",
+ helpChip: "/help 查看命令",
+ },
+ composer: {
+ steer: "补充给正在进行的回复",
+ steerTitle: "补充给正在进行的回复({key})",
+ stopping: "正在停止…",
+ placeholder: "给「{name}」发消息,/ 查看命令",
+ label: "消息",
+ currentModel: "当前模型:{model}",
+ pickModel: "选择模型",
+ stop: "停止生成(Esc)",
+ stopTitle: "停止(Esc)",
+ send: "发送",
+ sendTitle: "发送({key})",
+ },
+ model: {
+ followBot: "跟随机器人默认",
+ setDefault: "设为此机器人的默认模型",
+ },
+};
diff --cc ui/locales/zh-CN/index.js
index 2325b54,0000000..b7cb44c
mode 100644,000000..100644
--- a/ui/locales/zh-CN/index.js
+++ b/ui/locales/zh-CN/index.js
@@@ -1,26 -1,0 +1,27 @@@
+// zh-CN 文案:每个命名空间一个文件,键 = "命名空间.键"(见 ui/lib/i18n.js)。两种语言的键必须一一对应(test/i18n.unit.test.ts 会查)。
+import common from "./common.js";
+import app from "./app.js";
+import time from "./time.js";
+import settings from "./settings.js";
+import account from "./account.js";
+import pwsh from "./pwsh.js";
+import chat from "./chat.js";
+import info from "./info.js";
+import markdown from "./markdown.js";
+import notify from "./notify.js";
+import troubleshoot from "./troubleshoot.js";
+import onboarding from "./onboarding.js";
+import newBot from "./newBot.js";
+import botSettings from "./botSettings.js";
+import sidebar from "./sidebar.js";
+import avatar from "./avatar.js";
+import models from "./models.js";
+import ui from "./ui.js";
+import guide from "./guide.js";
+import activity from "./activity.js";
+import tasks from "./tasks.js";
++import needs from "./needs.js";
+import access from "./access.js";
+import perms from "./perms.js";
+
- export default { common, app, time, settings, account, pwsh, chat, info, markdown, notify, troubleshoot, onboarding, newBot, botSettings, sidebar, avatar, models, ui, guide, activity, perms, access, tasks };
++export default { common, app, time, settings, account, pwsh, chat, info, markdown, notify, troubleshoot, onboarding, newBot, botSettings, sidebar, avatar, models, ui, guide, activity, perms, access, tasks, needs };
diff --cc ui/locales/zh-CN/needs.js
index 0000000,0000000..4df4348
new file mode 100644
--- /dev/null
+++ b/ui/locales/zh-CN/needs.js
@@@ -1,0 -1,0 +1,16 @@@
++// needs · zh-CN(screens/needs-you.js:「需要你」)
++export default {
++ title: "需要你",
++ collapse: "收起",
++ viewTask: "查看任务",
++ openChat: "打开对话",
++ reply: "回复…",
++ approveOnce: "批准一次",
++ deny: "拒绝",
++ stop: "停止",
++ seen: "知道了",
++ relogin: "重新扫码",
++ answerPlaceholder: "你的回答",
++ send: "发送",
++ none: "没有需要你处理的事",
++};
diff --cc ui/locales/zh-CN/sidebar.js
index 318333e,0000000..3e152af
mode 100644,000000..100644
--- a/ui/locales/zh-CN/sidebar.js
+++ b/ui/locales/zh-CN/sidebar.js
@@@ -1,38 -1,0 +1,39 @@@
+// sidebar · zh-CN:侧栏(screens/sidebar.js)
+export default {
+ /** 没登录、也没有用户名时左下角显示的名字 */
+ localUser: "本机用户",
+ settingsTitle: "设置(⌘,)",
+ openSettings: "打开设置",
+ balance: "余额 {amount}",
+ lowBalance: "余额只剩 {amount},去充值 ↗",
+ renamed: "已重命名",
+ delete: {
+ title: "删除「{name}」?",
+ body: "会永久删除这个机器人及其全部会话,无法恢复。",
+ confirm: "永久删除",
+ },
+ bots: "机器人",
+ newShortcut: "新建机器人(⌘N)",
+ search: "搜索机器人",
+ list: "机器人列表",
+ /** 新建页打开时列表顶部的占位行 */
+ newBot: "新机器人",
+ creating: "正在创建…",
+ loadFailed: "无法读取机器人列表",
+ empty: "还没有机器人",
+ create: "新建机器人",
+ noMatch: "没有匹配的机器人",
+ newName: "新名称",
+ working: "工作中",
+ workingNow: "正在工作…",
+ noChats: "还没有对话",
+ pending: "{count} 个待审批",
++ needs: "{count} 件事需要你",
+ moreFor: "{name} 的更多操作",
+ actionsFor: "{name} 的操作",
+ menu: {
+ settings: "机器人设置",
+ copyId: "复制机器人 ID",
+ delete: "删除机器人",
+ },
+};
diff --cc ui/main.js
index 5ebc8ca,44b6eb3..c243994
--- a/ui/main.js
+++ b/ui/main.js
@@@ -9,18 -9,14 +9,19 @@@ import { InfoPanel } from "./screens/in
import { SettingsScreen, SettingsSide, TABS } from "./screens/settings.js";
import { BotSettingsScreen } from "./screens/bot-settings.js";
import { NewBotScreen } from "./screens/new-bot.js";
+ import { NeedsYouScreen } from "./screens/needs-you.js";
import { BotAvatar, MAIN_CHAR, charOf } from "./components/avatar.js";
import { Onboarding } from "./screens/onboarding.js";
+import { CoachMark } from "./components/guide.js";
import { api } from "./lib/api.js";
+import { loadGuide, setFocus } from "./lib/guide.js";
import { setThemeMode } from "./lib/theme.js";
-import { failed, toast } from "./lib/store.js";
+import { failed, toast, useStore } from "./lib/store.js";
+import { prefs, setPrefs } from "./lib/prefs.js";
+import { usePresence } from "./design/motion.js";
+import { t, useLang, adoptServerLang, changeLang, getLangPref, LANG_NAMES } from "./lib/i18n.js";
- // —— 路由:#/chat/<bot> · #/new · #/settings/<tab>[/<row>] · #/bot/<bot>/settings[/<section>] ——
+ // —— 路由:#/chat/<bot> · #/new · #/needs · #/settings/<tab>[/<row>] · #/bot/<bot>/settings[/<section>] ——
function parseHash() {
const [kind, a, b, c] = location.hash.replace(/^#\/?/, "").split("/").map((x) => decodeURIComponent(x || ""));
if (kind === "settings") return { view: "settings", tab: TABS.some(([t]) => t === a) ? a : "general", row: b || "" };
@@@ -271,11 -251,12 +277,17 @@@ function App()
go(`/chat/${encodeURIComponent(id || (bot && bot.id) || "")}`);
};
const newBot = () => go("/new");
+ // 清单里点一项:回到对话页,引导卡片指着要点的地方
+ const startGuide = (id) => {
+ setFocus(id);
+ if (route.view !== "chat") openChat();
+ };
+ const openNeeds = () => go("/needs");
+ // 「需要你」里的重新扫码:去这个机器人的对话,打开信息面板(渠道在最上面)
+ const relogin = (id) => {
+ openChat(id);
+ setInfoOpen(true);
+ };
useEffect(() => {
if (route.view !== "settings") setSettingsQ("");
}, [route.view]);
@@@ -318,23 -300,17 +331,24 @@@
return () => window.removeEventListener("keydown", key);
}, [connected, route, infoOpen, bot && bot.id]);
+ // keys:搜索用的关键词(不显示),两种语言的词典各有一份
+ const setLang = (l) => changeLang(l).then(() => toast(t("common.saved"))).catch(failed);
const commands = [
- { label: "打开设置", kbd: isMac ? "⌘," : "Ctrl+,", keys: "settings preferences", run: () => openSettings() },
- { label: "新建机器人", kbd: isMac ? "⌘N" : "Ctrl+N", keys: "new bot", run: newBot },
- ...(needs.n > 0 ? [{ label: `需要你(${needs.n})`, keys: "needs attention 需要你 待办", run: openNeeds }] : []),
- ...(route.view === "chat" ? [{ label: infoOpen ? "关闭信息面板" : "打开信息面板", kbd: isMac ? "⌘⇧I" : "Ctrl+Shift+I", keys: "info panel", run: () => setInfoOpen((v) => !v) }] : []),
- ...(bot ? [{ label: `「${bot.name}」的设置`, keys: "bot settings", run: () => openBotSettings(bot.id) }] : []),
- { label: "Modelflare 设置", keys: "modelflare key 密钥 模型", run: () => openSettings("modelflare") },
- { label: "外观:跟随系统", keys: "theme appearance 主题", run: () => setThemeMode("system") },
- { label: "外观:浅色", keys: "theme light 主题", run: () => setThemeMode("light") },
- { label: "外观:深色", keys: "theme dark 主题", run: () => setThemeMode("dark") },
- ...(bots || []).map((b) => ({ label: `切换到「${b.name}」`, keys: "bot switch " + b.id, run: () => openChat(b.id) })),
+ { label: t("app.cmd.settings"), kbd: isMac ? "⌘," : "Ctrl+,", keys: t("app.cmd.settingsKeys"), run: () => openSettings() },
+ { label: t("app.cmd.newBot"), kbd: isMac ? "⌘N" : "Ctrl+N", keys: t("app.cmd.newBotKeys"), run: newBot },
++ ...(needs.n > 0 ? [{ label: t("app.cmd.needs", { count: needs.n }), keys: t("app.cmd.needsKeys"), run: openNeeds }] : []),
+ ...(route.view === "chat" ? [{ label: infoOpen ? t("app.cmd.closeInfo") : t("app.cmd.openInfo"), kbd: isMac ? "⌘⇧I" : "Ctrl+Shift+I", keys: t("app.cmd.infoKeys"), run: () => setInfoOpen((v) => !v) }] : []),
+ ...(bot ? [{ label: t("app.cmd.botSettings", { name: bot.name }), keys: t("app.cmd.botSettingsKeys"), run: () => openBotSettings(bot.id) }] : []),
+ { label: t("app.cmd.modelflare"), keys: t("app.cmd.modelflareKeys"), run: () => openSettings("modelflare") },
+ { label: t("app.cmd.appearance"), keys: t("app.cmd.appearanceKeys"), run: () => openSettings("appearance") },
+ { label: t("app.cmd.themeSystem"), keys: t("app.cmd.themeKeys"), run: () => setThemeMode("system") },
+ { label: t("app.cmd.themeLight"), keys: t("app.cmd.themeLightKeys"), run: () => setThemeMode("light") },
+ { label: t("app.cmd.themeDark"), keys: t("app.cmd.themeDarkKeys"), run: () => setThemeMode("dark") },
+ // 语言:各语言用自己的文字写名字;当前选中的那一项不列
+ ...[["system", t("common.lang.system")], ["zh-CN", LANG_NAMES["zh-CN"]], ["en", LANG_NAMES.en]]
+ .filter(([v]) => v !== getLangPref())
+ .map(([v, name]) => ({ label: t("app.cmd.lang", { name }), keys: t("app.cmd.langKeys"), run: () => setLang(v) })),
+ ...(bots || []).map((b) => ({ label: t("app.cmd.switchBot", { name: b.name }), keys: "bot switch " + b.id, run: () => openChat(b.id) })),
];
// —— 渲染 ——
@@@ -364,9 -339,8 +378,9 @@@
? html`<${SettingsSide} tab=${route.tab} query=${settingsQ} onQuery=${setSettingsQ} onTab=${(t) => openSettings(t)} onBack=${() => openChat()}
username=${status && status.username} account=${managed ? account : null} />`
: html`<${Sidebar} bots=${bots} botsError=${botsErr} reloadBots=${reloadBots} selectedId=${bot && bot.id} view=${view === "chat" && bots && !bots.length ? "new" : view}
- previews=${previews} pending=${pending} working=${working} username=${status && status.username} account=${managed ? account : null}
- onNew=${newBot} onSelect=${openChat} onDeleted=${onDeleted} onOpenSettings=${() => openSettings()} onBotSettings=${openBotSettings} onGuide=${startGuide} />`}
+ previews=${previews} pending=${pending} working=${working} needs=${needs} username=${status && status.username} account=${managed ? account : null}
- onNew=${newBot} onSelect=${openChat} onNeeds=${openNeeds} onDeleted=${onDeleted} onOpenSettings=${() => openSettings()} />`}
++ onNew=${newBot} onSelect=${openChat} onNeeds=${openNeeds} onDeleted=${onDeleted} onOpenSettings=${() => openSettings()} onBotSettings=${openBotSettings} onGuide=${startGuide} />`}
+ <${Splitter} class="split-side" size="--side-w" label=${t("app.resizeSide")} value=${sideW} room=${room("--panel-track")} onCommit=${(v) => setPrefs({ sideW: v })} />
<main class="main">
${view === "chat" && bot && html`<${ChatScreen} key=${bot.id} bot=${bot} models=${models} modelsError=${modelsError} reloadModels=${reloadModels}
defaultModel=${settings && settings.defaultModel} infoOpen=${infoOpen} onToggleInfo=${() => setInfoOpen((v) => !v)}
diff --cc ui/screens/chat.js
index d439cba,a22a785..0c89ee6
--- a/ui/screens/chat.js
+++ b/ui/screens/chat.js
@@@ -95,12 -86,12 +95,12 @@@ export function PromptCard({ requestId
};
if (row.kind === "approval") {
return html`<div class=${`card${pending ? "" : " done"}`}>
- <div class="meta"><span>${t("chat.approval.needed", { code: html`<span class="num">${row.code}</span>` })}</span>${!pending && html`<${Badge} s=${row.status} />`}</div>
- <div class="meta"><span>${row.taskTitle ? `「${row.taskTitle}」` : ""}需要你的批准 · <span class="num">${row.code}</span></span>${!pending && html`<${Badge} s=${row.status} />`}</div>
- <div class="q">${row.reason || "机器人想执行一个超出工作区的操作"}</div>
++ <div class="meta"><span>${t(row.taskTitle ? "chat.approval.neededTask" : "chat.approval.needed", { title: row.taskTitle, code: html`<span class="num">${row.code}</span>` })}</span>${!pending && html`<${Badge} s=${row.status} />`}</div>
+ <div class="q">${row.reason || t("chat.approval.fallbackReason")}</div>
${(row.tool || row.detail) && html`<div class="cmd">${row.tool}${row.detail ? " " + row.detail : ""}</div>`}
${pending && html`<div class="actions">
- <button type="button" class="btn primary" disabled=${busy} onClick=${() => decide(true)}>允许(仅本次)</button>
- <button type="button" class="btn" disabled=${busy} onClick=${() => decide(false)}>拒绝</button>
+ <button type="button" class="btn primary" disabled=${busy} onClick=${() => decide(true)}>${t("chat.approval.allowOnce")}</button>
+ <button type="button" class="btn" disabled=${busy} onClick=${() => decide(false)}>${t("chat.approval.deny")}</button>
</div>`}
</div>`;
}
@@@ -132,6 -123,7 +132,7 @@@
const sendAll = () =>
submit(qs.map((q, i) => ({ id: q.id, selected: picked[q.id] || [], ...(i === qs.length - 1 && custom.trim() ? { custom: custom.trim() } : {}) })));
return html`<div class=${`card${pending ? "" : " done"}`}>
- ${row.taskTitle && html`<div class="meta"><span>「${row.taskTitle}」想问你</span></div>`}
++ ${row.taskTitle && html`<div class="meta"><span>${t("chat.question.taskAsks", { title: row.taskTitle })}</span></div>`}
${qs.map((q) => html`<div class="q-block">
<div class="q">${q.question}</div>
${q.detail && html`<div class="q-detail">${q.detail}</div>`}
diff --cc ui/screens/needs-you.js
index 0000000,9940f0c..807c5c0
mode 000000,100644..100644
--- a/ui/screens/needs-you.js
+++ b/ui/screens/needs-you.js
@@@ -1,0 -1,108 +1,109 @@@
+ // 需要你(3b):所有机器人里在等你的事,一行一件,操作就在行里(回答、批准、重试…);点标题那一行展开详情。
+ // 没事时侧栏没有这一行,直接打开这一页只有一句「没有需要你处理的事」。状态是"点 + 文字":黄 = 等你,红 = 失败 / 登录过期。
+ import { useCallback, useEffect, useRef, useState } from "preact/hooks";
+ import { html, Icon, Button, Skeleton } from "../components/ui.js";
+ import { TaskDetail } from "../components/tasks.js";
+ import { api } from "../lib/api.js";
+ import { failed } from "../lib/store.js";
+ import { fmtAgo } from "../lib/format.js";
++import { t } from "../lib/i18n.js";
+
+ /** 侧栏机器人列表上方的「需要你」:只有件数大于 0 时才有 */
+ export function NeedsRow({ count, on, onClick }) {
+ if (!count) return null;
+ return html`<button type="button" class=${`needs-row${on ? " sel" : ""}`} aria-current=${on ? "page" : undefined} onClick=${onClick}>
- <span class="mark" aria-hidden="true"><span class="dot warn"></span></span><span class="label">需要你</span><span class="badge count warn">${count}</span>
++ <span class="mark" aria-hidden="true"><span class="dot warn"></span></span><span class="label">${t("needs.title")}</span><span class="badge count warn">${count}</span>
+ </button>`;
+ }
+
+ /** 单选、有选项的一个问题:选项直接是按钮;其余(多选、没有选项、几个问题)写一句话回答 */
+ function choices(item) {
+ const qs = item.questions || [];
+ const q = qs.length === 1 ? qs[0] : null;
+ return q && !q.multiSelect && (q.options || []).length ? q.options : null;
+ }
+
+ /**
+ * 一件事:标题行(机器人 · 任务 · 状态 · 时间;只有一个机器人时不写机器人名)、第二行(问题 / 命令 / 原因)、行内操作。
+ * onAct(action, body) 返回 Promise
+ */
+ export function NeedItem({ item, multiBot, onAct, onOpenChat, onRelogin }) {
+ const [busy, setBusy] = useState("");
+ const [open, setOpen] = useState(false);
+ const [writing, setWriting] = useState(false);
+ const [text, setText] = useState("");
+ const input = useRef(null);
+ const opts = item.kind === "question" ? choices(item) : null;
+ useEffect(() => {
+ if (writing) requestAnimationFrame(() => input.current?.focus());
+ }, [writing]);
+ const act = async (action, body = {}, key = action) => {
+ setBusy(key);
+ try {
+ await onAct(action, body);
+ } catch (e) {
+ failed(e);
+ }
+ setBusy("");
+ };
+ const send = () => text.trim() && act("answer", { text: text.trim() }, "text");
+ // 详情一下就能看到:任务的展开处理过程;网页对话里的去对话
+ const canOpen = !!item.taskId || item.channel === "web";
+ const head = () => (item.taskId ? setOpen((v) => !v) : onOpenChat?.(item.botId));
+ const [lead, ...rest] = [multiBot && item.botName, item.subject, item.status].filter(Boolean);
+ const headIn = html`<span class="need-who"><b>${lead}</b>${rest.map((x) => ` · ${x}`).join("")}</span>
+ <span class="need-when num">${fmtAgo(item.since)}</span>
+ ${item.taskId && html`<${Icon} name="chevRight" size=${12} class="chev" />`}`;
+ return html`<div class=${`need${open ? " open" : ""}`}>
+ <span class=${`dot ${item.severity === "err" ? "err" : "warn"}`} aria-hidden="true"></span>
+ ${canOpen
- ? html`<button type="button" class="need-head" aria-expanded=${item.taskId ? open : undefined} title=${item.taskId ? (open ? "收起" : "查看任务") : "打开对话"} onClick=${head}>${headIn}</button>`
++ ? html`<button type="button" class="need-head" aria-expanded=${item.taskId ? open : undefined} title=${item.taskId ? (open ? t("needs.collapse") : t("needs.viewTask")) : t("needs.openChat")} onClick=${head}>${headIn}</button>`
+ : html`<div class="need-head">${headIn}</div>`}
+ ${item.line && html`<div class=${`need-line selectable${item.kind === "approval" ? " mono" : ""}`}>${item.line}</div>`}
+ <div class="need-actions">
+ ${opts && opts.map((o, i) => html`<${Button} loading=${busy === `o${i}`} disabled=${!!busy} onClick=${() => act("answer", { text: String(i + 1) }, `o${i}`)}>${o.label}<//>`)}
- ${item.kind === "question" && !writing && html`<button type="button" class="text" disabled=${!!busy} onClick=${() => setWriting(true)}>回复…</button>`}
- ${item.kind === "approval" && html`<${Button} variant="primary" loading=${busy === "approve"} disabled=${!!busy} onClick=${() => act("approve")}>批准一次<//>
- <${Button} loading=${busy === "deny"} disabled=${!!busy} onClick=${() => act("deny")}>拒绝<//>`}
- ${item.kind === "failed" && html`<${Button} loading=${busy === "retry"} disabled=${!!busy} onClick=${() => act("retry")}>重试<//>
- <button type="button" class="text danger" disabled=${!!busy} onClick=${() => act("stop")}>停止</button>`}
- ${item.kind === "delivery" && html`<${Button} loading=${busy === "seen"} disabled=${!!busy} onClick=${() => act("seen")}>知道了<//>`}
- ${item.kind === "login" && html`<${Button} onClick=${() => onRelogin?.(item.botId)}>重新扫码<//>`}
++ ${item.kind === "question" && !writing && html`<button type="button" class="text" disabled=${!!busy} onClick=${() => setWriting(true)}>${t("needs.reply")}</button>`}
++ ${item.kind === "approval" && html`<${Button} variant="primary" loading=${busy === "approve"} disabled=${!!busy} onClick=${() => act("approve")}>${t("needs.approveOnce")}<//>
++ <${Button} loading=${busy === "deny"} disabled=${!!busy} onClick=${() => act("deny")}>${t("needs.deny")}<//>`}
++ ${item.kind === "failed" && html`<${Button} loading=${busy === "retry"} disabled=${!!busy} onClick=${() => act("retry")}>${t("common.retry")}<//>
++ <button type="button" class="text danger" disabled=${!!busy} onClick=${() => act("stop")}>${t("needs.stop")}</button>`}
++ ${item.kind === "delivery" && html`<${Button} loading=${busy === "seen"} disabled=${!!busy} onClick=${() => act("seen")}>${t("needs.seen")}<//>`}
++ ${item.kind === "login" && html`<${Button} onClick=${() => onRelogin?.(item.botId)}>${t("needs.relogin")}<//>`}
+ </div>
+ ${writing && html`<div class="need-reply">
- <input ref=${input} class="field" placeholder="你的回答" value=${text} disabled=${busy === "text"}
++ <input ref=${input} class="field" placeholder=${t("needs.answerPlaceholder")} value=${text} disabled=${busy === "text"}
+ onInput=${(e) => setText(e.target.value)} onKeyDown=${(e) => {
+ if (e.key === "Enter" && !e.isComposing) send();
+ if (e.key === "Escape") (e.stopPropagation(), setWriting(false));
+ }} />
- <${Button} variant="primary" loading=${busy === "text"} disabled=${!text.trim()} onClick=${send}>发送<//>
++ <${Button} variant="primary" loading=${busy === "text"} disabled=${!text.trim()} onClick=${send}>${t("needs.send")}<//>
+ </div>`}
+ ${open && item.taskId && html`<div class="need-detail"><${TaskDetail} task=${{ id: item.taskId, title: item.subject, stage: { group: "needs" } }} /></div>`}
+ </div>`;
+ }
+
+ /** 主区的「需要你」:每 3 秒看一次;处理掉的那件立刻消失(onChanged 让侧栏的件数也跟上) */
+ export function NeedsYouScreen({ multiBot, onChanged, onOpenChat, onRelogin }) {
+ const [items, setItems] = useState(null);
+ const load = useCallback(() => api("/attention").then((d) => setItems(d.items || [])).catch(() => setItems((v) => v || [])), []);
+ useEffect(() => {
+ load();
- const t = setInterval(() => document.visibilityState === "visible" && load(), 3000);
- return () => clearInterval(t);
++ const timer = setInterval(() => document.visibilityState === "visible" && load(), 3000);
++ return () => clearInterval(timer);
+ }, [load]);
+ const onAct = (it) => async (action, body) => {
+ const d = await api(`/attention/${encodeURIComponent(it.id)}/${action}`, { method: "POST", body });
+ setItems(d.items || []);
+ onChanged?.();
+ };
+ return html`<div class="settings needs view" data-screen="needs">
- <div class="set-head"><h1 class="set-title">需要你</h1></div>
++ <div class="set-head"><h1 class="set-title">${t("needs.title")}</h1></div>
+ <div class="set-body">
+ ${!items && html`<div class="list needs-list"><div class="need"><${Skeleton} w="50%" /><${Skeleton} w="70%" /></div></div>`}
- ${items && !items.length && html`<p class="set-none">没有需要你处理的事</p>`}
++ ${items && !items.length && html`<p class="set-none">${t("needs.none")}</p>`}
+ ${items && items.length > 0 && html`<div class="list needs-list">
+ ${items.map((it) => html`<${NeedItem} key=${it.id} item=${it} multiBot=${multiBot} onAct=${onAct(it)} onOpenChat=${onOpenChat} onRelogin=${onRelogin} />`)}
+ </div>`}
+ </div>
+ </div>`;
+ }
diff --cc ui/screens/sidebar.js
index 7d07175,a300b2e..a362aff
--- a/ui/screens/sidebar.js
+++ b/ui/screens/sidebar.js
@@@ -1,6 -1,6 +1,7 @@@
-// 侧栏 280(参考 Grok Bot):顶部只有新建按钮,常驻搜索框,机器人行(头像 + 名称 + 时间 + 一行预览),左下角账户(打开设置)。
+// 侧栏 280(参考 Grok Bot,宽度可以拖右边的分隔条调整):顶部只有新建按钮,常驻搜索框,
+// 机器人行(头像 + 名称 + 时间 + 一行预览;悬停出现"更多",和右键是同一份菜单),左下角账户(打开设置)。
// 新建在主区的新建页(screens/new-bot.js);新建页打开时列表顶部有一行占位的"新机器人"。
+ // 有事在等你时,机器人列表上方多一行「需要你 N」(没事时没有这一行);机器人行的第二行换成最早那件事。
import { useEffect, useRef, useState } from "preact/hooks";
import { html, Icon, IconButton, Menu, Skeleton } from "../components/ui.js";
import { BotAvatar } from "../components/avatar.js";
@@@ -9,7 -8,7 +10,8 @@@ import { api } from "../lib/api.js"
import { confirmSheet, failed, toast } from "../lib/store.js";
import { fmtAgo } from "../lib/format.js";
import { MF_TOPUP, usd } from "../lib/links.js";
+import { t } from "../lib/i18n.js";
+ import { NeedsRow } from "./needs-you.js";
/** 左下角账户:头像字母 + 名称(登录后是 Modelflare 账户名)与余额 + 齿轮,点开设置 */
export function AccountButton({ username, account, on, onClick }) {
@@@ -30,9 -29,9 +32,9 @@@ function LowBalance({ account })
</a>`;
}
- export function Sidebar({ bots, botsError, reloadBots, selectedId, view, previews, pending, working, username, account, onNew, onSelect, onDeleted, onOpenSettings, onBotSettings, onGuide }) {
-export function Sidebar({ bots, botsError, reloadBots, selectedId, view, previews, pending, working, needs = { n: 0, bots: {} }, username, account, onNew, onSelect, onNeeds, onDeleted, onOpenSettings }) {
++export function Sidebar({ bots, botsError, reloadBots, selectedId, view, previews, pending, working, needs = { n: 0, bots: {} }, username, account, onNew, onSelect, onNeeds, onDeleted, onOpenSettings, onBotSettings, onGuide }) {
const [q, setQ] = useState("");
- const [ctx, setCtx] = useState(null); // { bot, x, y }
+ const [ctx, setCtx] = useState(null); // 行的操作菜单:右键 { bot, x, y },或者"更多"按钮 { bot, el }
const [renaming, setRenaming] = useState("");
const [renameText, setRenameText] = useState("");
const root = useRef(null);
@@@ -67,45 -66,42 +69,48 @@@
const needle = q.trim().toLowerCase();
const list = (bots || []).filter((b) => !needle || b.name.toLowerCase().includes(needle) || (previews[b.id]?.text || "").toLowerCase().includes(needle));
- return html`<aside class="side" ref=${root} aria-label="机器人">
+ return html`<aside class="side" ref=${root} aria-label=${t("sidebar.bots")}>
<div class="side-top">
- <${IconButton} icon="plus" iconSize=${16} label="新建机器人(⌘N)" on=${view === "new"} onClick=${onNew} />
+ <span class="side-brand"><img src="/amb/static/assets/favicon-64.png" alt="" /><span>AnyModelBot</span></span>
+ <${IconButton} icon="plus" iconSize="md" label=${t("sidebar.newShortcut")} on=${view === "new"} onClick=${onNew} />
</div>
<label class="side-search">
- <${Icon} name="search" size=${14} />
- <input ref=${searchRef} type="search" placeholder="搜索" aria-label="搜索机器人" value=${q} onInput=${(e) => setQ(e.target.value)}
+ <${Icon} name="search" size="sm" />
+ <input ref=${searchRef} type="search" placeholder=${t("common.search")} aria-label=${t("sidebar.search")} value=${q} onInput=${(e) => setQ(e.target.value)}
onKeyDown=${(e) => e.key === "Escape" && q && (e.stopPropagation(), setQ(""))} />
</label>
- <nav class="side-list" aria-label="机器人列表">
+ <nav class="side-list" aria-label=${t("sidebar.list")}>
+ <${NeedsRow} count=${needs.n} on=${view === "needs"} onClick=${onNeeds} />
${view === "new" && html`<div class="thread sel" aria-current="page"><${BotAvatar} neutral size=${38} />
- <span class="body"><span class="line"><span class="title">新机器人</span></span><span class="line"><span class="snip">正在创建…</span></span></span></div>`}
- ${botsError && html`<div class="side-empty"><span>无法读取机器人列表</span><button type="button" class="btn" onClick=${reloadBots}>重试</button></div>`}
+ <span class="body"><span class="line"><span class="title">${t("sidebar.newBot")}</span></span><span class="line"><span class="snip">${t("sidebar.creating")}</span></span></span></div>`}
+ ${botsError && html`<div class="side-empty"><span>${t("sidebar.loadFailed")}</span><button type="button" class="btn" onClick=${reloadBots}>${t("common.retry")}</button></div>`}
${!bots && !botsError && [0, 1, 2].map((k) => html`<div class="thread" key=${k}><${Skeleton} w="38px" circle /><span class="thread-skel"><${Skeleton} w="50%" /><${Skeleton} w="75%" /></span></div>`)}
- ${bots && !bots.length && view !== "new" && html`<div class="side-empty"><span>还没有机器人</span><button type="button" class="btn primary" onClick=${onNew}>新建机器人</button></div>`}
- ${bots && needle && !list.length && html`<p class="hint">没有匹配的机器人</p>`}
+ ${bots && !bots.length && view !== "new" && html`<div class="side-empty"><span>${t("sidebar.empty")}</span><button type="button" class="btn primary" onClick=${onNew}>${t("sidebar.create")}</button></div>`}
+ ${bots && needle && !list.length && html`<p class="hint">${t("sidebar.noMatch")}</p>`}
${list.map((b) => {
const sel = (view === "chat" || view === "bot-settings") && b.id === selectedId;
- const n = pending[b.id] || 0;
+ // 等你的:「需要你」里这个机器人的件数和最早那件(没有时退回待审批数)
+ const nd = needs.bots[b.id];
+ const n = nd?.n || pending[b.id] || 0;
if (renaming === b.id)
return html`<div class="thread sel" key=${b.id}><${BotAvatar} bot=${b} size=${38} />
- <input class="field" value=${renameText} aria-label="新名称" ref=${renameRef}
+ <input class="field" value=${renameText} aria-label=${t("sidebar.newName")} ref=${renameRef}
onInput=${(e) => setRenameText(e.target.value)} onBlur=${() => rename(b)}
onKeyDown=${(e) => { if (e.key === "Enter") e.target.blur(); if (e.key === "Escape") { e.stopPropagation(); setRenaming(""); } }} /></div>`;
const pv = previews[b.id];
- return html`<button type="button" key=${b.id} class=${`thread bot-hover${sel ? " sel" : ""}`} aria-current=${sel ? "page" : undefined}
- onClick=${() => onSelect(b.id)} onContextMenu=${(e) => { e.preventDefault(); setCtx({ bot: b, x: e.clientX, y: e.clientY }); }}>
- <span class="avatar-wrap"><${BotAvatar} bot=${b} size=${38} state=${n > 0 ? "waiting" : working[b.id] ? "working" : "idle"} />${working[b.id] && html`<span class="working-dot" title="工作中"></span>`}</span>
- <span class="body">
- <span class="line"><span class="title">${b.name}</span>${pv?.at && html`<span class="when num">${fmtAgo(pv.at)}</span>`}</span>
- <span class="line"><span class="snip">${nd?.line || (working[b.id] ? "正在工作…" : pv?.text || "还没有对话")}</span>${n > 0 && html`<span class="badge count" title=${`${n} 件事需要你`}>${n}</span>`}</span>
- </span>
- </button>`;
+ const menuOpen = !!(ctx && ctx.el && ctx.bot.id === b.id);
+ return html`<div class="thread-item" key=${b.id}>
+ <button type="button" class=${`thread bot-hover${sel ? " sel" : ""}`} aria-current=${sel ? "page" : undefined}
+ onClick=${() => onSelect(b.id)} onContextMenu=${(e) => { e.preventDefault(); setCtx({ bot: b, x: e.clientX, y: e.clientY }); }}>
+ <span class="avatar-wrap"><${BotAvatar} bot=${b} size=${38} state=${n > 0 ? "waiting" : working[b.id] ? "working" : "idle"} />${working[b.id] && html`<span class="working-dot" title=${t("sidebar.working")}></span>`}</span>
+ <span class="body">
+ <span class="line"><span class="title">${b.name}</span>${pv?.at && html`<span class="when num">${fmtAgo(pv.at)}</span>`}</span>
- <span class="line"><span class="snip">${working[b.id] ? t("sidebar.workingNow") : pv?.text || t("sidebar.noChats")}</span>${n > 0 && html`<span class="badge count" title=${t("sidebar.pending", { count: n })}>${n}</span>`}</span>
++ <span class="line"><span class="snip">${nd?.line || (working[b.id] ? t("sidebar.workingNow") : pv?.text || t("sidebar.noChats"))}</span>${n > 0 && html`<span class="badge count" title=${t("sidebar.needs", { count: n })}>${n}</span>`}</span>
+ </span>
+ </button>
+ <${IconButton} icon="more" class="thread-more" label=${t("sidebar.moreFor", { name: b.name })} aria-haspopup="menu" aria-expanded=${menuOpen}
+ onClick=${(e) => { const el = e.currentTarget; setCtx((c) => (c && c.el && c.bot.id === b.id ? null : { bot: b, el })); }} />
+ </div>`;
})}
</nav>
<${LowBalance} account=${account} />