A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Add a flat message layout
chimney3d118e6d900a
diff --git a/docs/plans/2026-10-22-message-layout.md b/docs/plans/2026-10-22-message-layout.mdindex b1e1ea49..12c954e0 100644--- a/docs/plans/2026-10-22-message-layout.md+++ b/docs/plans/2026-10-22-message-layout.md@@ -1,26 +1,37 @@-# 消息宽度+# 消息布局和宽度- 日期:2026-10-22-- 相关:#380+- 相关:#380、#446## 为什么-Bot 回复的气泡最宽写死在 560px。宽屏下正文列是 960px,Bot 气泡只占 58%,比用户气泡(列宽的 70.2%,674px)还窄。长回答、代码块和表格因此被挤成一窄条,频繁换行。#380 希望能调宽度。+Bot 回复的气泡最宽写死在 560px。宽屏下正文列是 960px,Bot 气泡只占 58%,比用户气泡(列宽的 70.2%,674px)还窄。长回答、代码块和表格因此被挤成一窄条,频繁换行。#380 希望能调宽度;也有用户习惯另一种读法:Bot 的话不套气泡,像文档一样整列铺开,每条上面写着是谁、什么时候说的。取舍:-- 气泡跟着正文列按比例走,不再有像素上限,Bot 和用户的气泡用同一个比例,默认 80%。-- 宽度用滑块按百分比调,不填像素:换窗口大小、打开右侧面板时仍然成比例。几档预设太粗,滑块能调到每个人顺手的宽度。+- 宽度用滑块按正文列的百分比调,不填像素:换窗口大小、打开右侧面板时仍然成比例。三档太粗,滑块能调到每个人顺手的宽度。+- 两种布局可切换:气泡和平铺。平铺时 Bot 的话没有容器,宽度和气泡共用一个值的话,气泡顺手的 80% 放到平铺里只会右边空一块,看着像没底色的气泡。所以平铺的 Bot 正文单独一个宽度,默认铺满整列。- 和主题、强调色、Bot 动画一样存在团队设置里,所有设备共用。- 不改正文列本身(960px,见 #28)。## 已定的行为-- 设置 → 通用 → 外观里有「气泡宽度」滑块:50%–100%,每格 5%,默认 80%,旁边显示当前百分比。拖动停下 350ms 后保存(和自定义强调色一样);还没保存就关掉设置,也照样保存。-- 气泡宽度是正文列宽的百分比,管所有气泡:Bot 气泡、思考过程和用户气泡,私聊、群聊、Bot 之间的对话框都一样。-- Bot 气泡右侧总是留出 82px 给悬停工具栏(6px 间距,加上三个 24px 按钮和它们之间 2px 的间隔),所以宽度调到 100% 时,Bot 气泡是整列宽减 82px。群聊里带头像的消息按(列宽 − 30px)的比例算,再加上 30px 的头像列。-- 服务端只收 50–100 的整数 `width`,其他值报错;默认值 80 不存。页面认不出的值按默认处理。-- 宽度写成 `body` 上的 `--bt-msg-w`(0.5–1)。拿到团队状态之前,先用本机缓存的上一次设置,避免先闪一下默认样式。+- 设置 → 通用 → 外观:+ - 「消息布局」:气泡 / 平铺的分段按钮,默认气泡,点了马上生效。+ - 「正文宽度」:只在平铺布局下出现,滑块 50%–100%,默认 100%。+ - 「气泡宽度」:滑块 50%–100%,默认 80%。+ - 两个滑块每格 5%,旁边显示当前百分比。拖动停下 350ms 后保存(和自定义强调色一样);还没保存就关掉设置,也照样保存。+- 宽度都是正文列宽的百分比,私聊、群聊、Bot 之间的对话框都一样:+ - 气泡宽度管所有气泡:气泡布局里的 Bot 气泡和思考过程,以及两种布局里的用户气泡。+ - 正文宽度管平铺布局里 Bot 的正文和思考过程。+- 气泡布局:Bot 气泡右侧总是留出 82px 给悬停工具栏(6px 间距,加上三个 24px 按钮和它们之间 2px 的间隔),所以宽度调到 100% 时,Bot 气泡是整列宽减 82px。群聊里带头像的消息按(列宽 − 30px)的比例算,再加上 30px 的头像列。+- 平铺布局:+ - Bot 的话上面有一行:头像、名字(正文色,加粗)、时间;群聊里还有管理员标签和用时。正文在下面,从头像的左边开始,没有底色和内边距。+ - 私聊里每一轮回复出一次这一行,放在这一轮最先出现的地方:先出思考过程就在它上面,先出正文就在正文上面;更早的分段里的回复也一样。群聊和 Bot 之间的对话里,同一个 Bot 连着的几条消息共用一行,之间隔 10px。+ - 悬停工具栏浮在消息的右上角,不占宽度。+ - 用户消息仍是靠右的气泡。+- 服务端只收这些值:`layout` 为 `bubble` 或 `flat`;`width` 和 `flatWidth` 为 50–100 的整数。其他值报错;默认值(`bubble`、`80`、`100`)不存。页面认不出的值按默认处理。+- 布局写在 `body[data-bt-layout]` 上,两个宽度写成 `body` 上的 `--bt-msg-w` 和 `--bt-flat-w`(0.5–1)。拿到团队状态之前,先用本机缓存的上一次设置,避免先闪一下默认样式。## 不做什么@@ -31,4 +42,5 @@ Bot 回复的气泡最宽写死在 560px。宽屏下正文列是 960px,Bot 气## 已知限制-- Bot 气泡最宽到整列宽减 82px:960px 的列大约在 91% 封顶,再往右拖只有用户气泡还在变宽。手机这类窄屏上更早封顶。+- 平铺布局里,悬停工具栏会盖住第一行最后几个字,鼠标移开就没了。+- 气泡布局里,Bot 气泡最宽到整列宽减 82px:960px 的列大约在 91% 封顶,再往右拖只有用户气泡还在变宽。手机这类窄屏上更早封顶。diff --git a/docs/plans/README.md b/docs/plans/README.mdindex 0bad3dbe..294ed9c2 100644--- a/docs/plans/README.md+++ b/docs/plans/README.md@@ -46,4 +46,4 @@| [桌面应用](2026-10-16-desktop-app.md) | 壳、引擎和界面怎么分;锁定的 DSH 版本、独立的数据位置、首次启动和导入、插件怎么兼容 DSH、安装和更新 || [Bot 之间派活](2026-10-16-bot-handoffs.md) | Bot 看得到对方的状态;没读的消息合成一条;派活树:下面的活交回后才往上交,不许发给在等结果的 Bot;不设总量和链长上限 || [Bot 视图](2026-10-20-widget-views.md) | Bot 在聊天里画结构化的视图卡:固定组件目录的 JSON 蓝图,自己渲染;提问卡回路的泛化 |-| [消息宽度](2026-10-22-message-layout.md) | 气泡跟着正文列按比例走,默认 80%;气泡宽度用滑块按百分比调;Bot 气泡给悬停工具栏留 82px |+| [消息布局和宽度](2026-10-22-message-layout.md) | 气泡 / 平铺两种布局;平铺时 Bot 的话带头像、名字、时间;气泡宽度和平铺正文宽度各用一个滑块,按正文列的百分比调 |diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 27136a19..98b6dcb8 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -416,7 +416,11 @@ var ZH = {"Unread marks, badges, and the brand mark.": "未读标记、徽标和品牌标志。","Theme accent": "主题强调色","Custom accent": "自定义强调色",+ "Message layout": "消息布局",+ Bubble: "气泡",+ Flat: "平铺","Bubble width": "气泡宽度",+ "Text width": "正文宽度","Bots · {count}": "Bot · {count}","First in the sidebar. Pick another Bot to hand it the role; {name} then stops being a Main Bot.": "排在侧栏最上面。选另一个 Bot 就会把主 Bot 交给它,{name} 随之不再是主 Bot。","Choose a Bot…": "选择一个 Bot…",@@ -1693,7 +1697,9 @@ function registerTheme(id, theme) {var allThemes = () => ({ ...THEMES, ...customThemes });var MESSAGE_WIDTH = { min: 50, max: 100, step: 5 };var percent = (value, initial) => Number.isInteger(value) && value >= MESSAGE_WIDTH.min && value <= MESSAGE_WIDTH.max ? value : initial;+var layoutOf = (prefs) => prefs?.layout === "flat" ? "flat" : "bubble";var widthOf = (prefs) => percent(prefs?.width, 80);+var flatWidthOf = (prefs) => percent(prefs?.flatWidth, 100);// src/shared/mentions.jsvar ALL_WORDS = ["all", "everyone", "所有人", "全体"];@@ -2360,8 +2366,8 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}.bt-pill[data-memory=updated]:is(:hover,:focus-visible,[aria-expanded=true]) .bt-pill-go{width:0;margin-left:-8px;opacity:0;filter:blur(6px);transform:translateX(-6px)}@media (prefers-reduced-motion:reduce){.bt-pill,.bt-pill-go,.bt-pill-go svg{transition:none!important}.bt-pill-go{filter:none}.bt-pill:active{transform:none}}-/* The bubble width setting: the share of the column a chat bubble may take. */-body{--bt-msg-w:.8}+/* The width settings: the share of the column a bubble may take, and the flat text. */+body{--bt-msg-w:.8;--bt-flat-w:1}.bt-astack{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin:0}.bt-bubble{max-width:min(calc(var(--bt-msg-w) * 100%),calc(100% - 82px));background:var(--bt-bubble);color:var(--bt-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);box-sizing:border-box;overflow-wrap:anywhere}.bt-msg:not(:first-child)>.bt-msg-line>.bt-bubble{border-start-start-radius:6px}@@ -2380,6 +2386,8 @@ button.bt-lead{border:0;background:none;padding:0;cursor:pointer}/* Rows without the avatar start where the bubble beside it starts: 22px avatar + 8px gap. */.bt-astack[data-lead]>.bt-msg:not(:last-child)>.bt-msg-line,.bt-astack[data-lead] .bt-reacts{margin-left:30px}.bt-group-name{font-size:12px;line-height:16px;font-weight:500;margin-left:42px}+.bt-group-name:has(>.bt-lead){display:flex;align-items:center;margin:0 0 2px;font-size:13px;line-height:22px;font-weight:600;color:var(--bt-ink)}+.bt-group-name>.bt-lead{margin:0 8px 0 0}.bt-group-time,.bt-group-took{margin-left:6px;font-size:11px;line-height:16px;font-weight:400;color:var(--bt-ink-2);font-variant-numeric:tabular-nums;white-space:nowrap}.bt-x{border:0;background:none;color:var(--bt-ink-2);cursor:pointer;width:24px;height:24px;border-radius:6px;font-size:16px;line-height:24px;padding:0;transition:background-color .12s ease,color .12s ease,${spring(SPRING_TAP, "scale")}}.bt-x:hover{background:var(--bt-hover);color:var(--bt-ink)}@@ -2767,6 +2775,13 @@ ${SKIN_FOOT}>div:has(> [data-slot="sidebar.settings"]){order:-1!important;flex:n.bt-tools{position:absolute;top:50%;left:100%;margin-left:6px;transform:translateY(-50%);display:flex;gap:2px;opacity:0;visibility:hidden;transition:opacity .12s ease,visibility .12s}.bt-tools::after{content:"";position:absolute;top:-8px;bottom:-8px;right:100%;width:128px;z-index:-1}.bt-msg:hover>.bt-msg-line>.bt-tools,.bt-msg:focus-within>.bt-msg-line>.bt-tools,.bt-tools[data-open]{opacity:1;visibility:visible}+/* The flat layout: a Bot's text has no bubble and takes its own share of the column+ (the whole of it unless set). The toolbar floats over the message's top right. */+body[data-bt-layout=flat] .bt-astack{align-items:stretch;gap:10px}+body[data-bt-layout=flat] .bt-msg,body[data-bt-layout=flat] .bt-astack[data-lead]>.bt-msg{align-items:stretch;max-width:calc(var(--bt-flat-w) * 100%)}+body[data-bt-layout=flat] .bt-bubble{background:none;padding:0;border-radius:0}+body[data-bt-layout=flat] .bt-tools{top:-14px;right:0;left:auto;margin-left:0;transform:none;padding:2px;border-radius:999px;background:var(--bt-card);box-shadow:inset 0 0 0 .5px var(--bt-line-2),0 4px 14px rgba(0,0,0,.14)}+body[data-bt-layout=flat] .bt-tools::after{display:none}.bt-tool{width:24px;height:24px;border:0;padding:0;border-radius:6px;background:none;color:var(--bt-ink-2);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .12s ease,color .12s ease}.bt-tool:hover,.bt-tool[aria-expanded=true]{background:var(--bt-hover);color:var(--bt-ink)}.bt-tool:active{background:var(--bt-active)}@@ -2880,7 +2895,7 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}.bt-add:hover,.bt-addlist .bt-option:hover{background:var(--bt-hover);color:var(--bt-ink)}.bt-addlist{display:flex;flex-direction:column;margin-top:4px;padding:4px;border:1px solid var(--bt-line);border-radius:10px;background:var(--bt-card);animation:bt-rise .16s ease-out}.bt-seg{position:relative;display:flex;gap:2px;padding:2px;border-radius:10px;background:var(--bt-hover)}-.bt-motion-seg{width:216px}+.bt-motion-seg,.bt-look-seg{width:216px}/* A range input: the track fills with the accent up to the thumb (--bt-fill). */.bt-range{display:flex;align-items:center;gap:10px;width:216px}.bt-range input{flex:1;min-width:0;height:20px;margin:0;background:none;-webkit-appearance:none;appearance:none;cursor:pointer}@@ -3043,6 +3058,7 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}`;var CONVERSATION_CSS = `.bt-think{font-size:13px;line-height:18px;color:var(--bt-ink-2);margin:2px 0 4px;max-width:calc(var(--bt-msg-w) * 100%)}+body[data-bt-layout=flat] .bt-think{max-width:calc(var(--bt-flat-w) * 100%)}.bt-think summary{cursor:pointer;list-style:none;display:inline-flex;align-items:center;gap:6px}.bt-think summary::-webkit-details-marker{display:none}.bt-think-time{font-variant-numeric:tabular-nums;white-space:nowrap}@@ -4955,6 +4971,11 @@ function turnReasoning(steps, current) {if (members.findLast((step) => stepReasoning(step) !== "")?.step !== current.step) return "";return members.map(stepReasoning).filter(Boolean).join("\n\n");}+function opensReply(steps, current) {+ const members = steps.length ? steps : [current];+ const reasoner = members.findLast((step) => stepReasoning(step) !== "");+ return members.find((step) => texts(step).length > 0 || step === reasoner)?.step === current.step;+}var thinkingStep = (steps) => steps.find(thinkingLive);var thinkingLive = (step) => step.status === "running" && texts(step).length === 0 && step.blocks.some((block) => block.kind === "reasoning");var texts = (step) => step.blocks.filter((block) => block.kind === "text" && block.text.trim() !== "");@@ -5275,6 +5296,8 @@ function AssistantCell({ node, groupPart, sessionId, openFile, fileMentions, useconst relays = relayPart(data, groupPart) ? relaysBefore(contexts, steps, data) : [];if (texts2.length === 0 && !reasoning && relays.length === 0) return null;const selfId = roster.byId[sessionId]?.id ?? sessionId;+ const speaker = layoutOf(roster.prefs) === "flat" ? roster.byId[sessionId] : void 0;+ const head = speaker !== void 0 && opensReply(steps, data) && (reasoning !== "" || texts2.length > 0 && !(groupPart === "response" && turnReasoning(steps, data) !== ""));return (0, import_react9.createElement)(import_react9.Fragment,null,@@ -5291,6 +5314,7 @@ function AssistantCell({ node, groupPart, sessionId, openFile, fileMentions, usewhole: true});}),+ head ? (0, import_react9.createElement)(SpeakerHead, { bot: speaker, time: data.time }) : null,reasoning ? (0, import_react9.createElement)(ThinkingRow, {text: reasoning,live: thinking !== void 0,@@ -5329,25 +5353,36 @@ function EventLine({ prefix, bots, joiner = t("and"), onOpen, whole = false }) {});return (0, import_react9.createElement)("div", { className: "bt-event" }, parts);}+function SpeakerHead({ bot, time }) {+ return (0, import_react9.createElement)(+ "div",+ { className: "bt-group-name" },+ (0, import_react9.createElement)("span", { className: "bt-lead" }, (0, import_react9.createElement)(BotMark, { bot, size: 22 })),+ bot.name,+ Number.isFinite(time) ? (0, import_react9.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null+ );+}function GroupMessage({ bot, text, texts: texts2 = [text], room: room2, roster, actions, msgKey, useUi, whole, time, duration }) {const lead = (0, import_react9.createElement)("button",{ type: "button", className: "bt-lead", "aria-label": t("Open {name}'s chat", { name: bot.name }), onClick: () => actions.openSession(bot.id) },(0, import_react9.createElement)(BotMark, { bot, size: 22 }));+ const flat = layoutOf(roster.prefs) === "flat";const took = Number.isFinite(duration) ? elapsedLabel(duration) : void 0;return (0, import_react9.createElement)("div",{ className: "bt-group-msg" },(0, import_react9.createElement)("span",- { className: "bt-group-name", style: { color: inkText(colorOf(bot)) } },+ { className: "bt-group-name", style: flat ? void 0 : { color: inkText(colorOf(bot)) } },+ flat ? lead : null,bot.name,room2?.admin === bot.id ? (0, import_react9.createElement)("span", { className: "bt-group-role" }, t("Admin")) : null,Number.isFinite(time) ? (0, import_react9.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null,took ? (0, import_react9.createElement)("span", { className: "bt-group-took", title: t("Ran for {duration}", { duration: took }) }, took) : null),- (0, import_react9.createElement)(Bubbles, { texts: texts2, roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead, whole })+ (0, import_react9.createElement)(Bubbles, { texts: texts2, roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead: flat ? null : lead, whole }));}function stackReplies(replies) {@@ -5489,8 +5524,11 @@ function chatRow(row, key, { sessionId, selfId, roster, actions, useUi }) {return (0, import_react9.createElement)(EarlierUser, { key, row });case "answer":return (0, import_react9.createElement)(AnsweredReply, { key, node: { data: row } });- case "bot":- return (0, import_react9.createElement)(Bubbles, { key, texts: row.texts, roster, selfId, actions, sessionId: useUi ? sessionId : void 0, msgKey: useUi ? `${sessionId}:${row.time}` : void 0, useUi, fold: FOLD_HUGE });+ case "bot": {+ const bubbles = (0, import_react9.createElement)(Bubbles, { key, texts: row.texts, roster, selfId, actions, sessionId: useUi ? sessionId : void 0, msgKey: useUi ? `${sessionId}:${row.time}` : void 0, useUi, fold: FOLD_HUGE });+ const speaker = layoutOf(roster.prefs) === "flat" ? roster.byId[selfId] : void 0;+ return speaker ? (0, import_react9.createElement)(import_react9.Fragment, { key }, (0, import_react9.createElement)(SpeakerHead, { bot: speaker, time: row.time }), bubbles) : bubbles;+ }case "event": {if (row.role === "report") return (0, import_react9.createElement)(GroupEvent, { key, prefix: t("Replies from"), room: roster.roomsById[row.roomId], name: t("a group chat"), roster, actions });const other = roster.byId[row.botId] ?? { id: row.botId, name: row.name ?? t("a Bot"), color: "gray" };@@ -10350,6 +10388,7 @@ function ExchangeDialog({ pair, roster, actions }) {}, [pair[0], pair[1]]);const left = roster.byId[pair[0]];const right = roster.byId[pair[1]];+ const flat = layoutOf(roster.prefs) === "flat";let lastDay = 0;const paneLeft = usePaneLeft();return (0, import_react24.createElement)(@@ -10378,6 +10417,7 @@ function ExchangeDialog({ pair, roster, actions }) {const showDay = entry.time - lastDay > 30 * 60 * 1e3;lastDay = entry.time;const whole = entry.length === void 0 ? void 0 : { length: entry.length, load: () => actions.exchangeText(entry.id) };+ const lead = (0, import_react24.createElement)("span", { className: "bt-lead" }, (0, import_react24.createElement)(BotMark, { bot, size: 22 }));return (0, import_react24.createElement)(import_react24.Fragment,{ key: entry.id },@@ -10385,8 +10425,8 @@ function ExchangeDialog({ pair, roster, actions }) {(0, import_react24.createElement)("div",{ className: "bt-group-msg" },- (0, import_react24.createElement)("span", { className: "bt-group-name", style: { color: inkText(colorOf(bot)) } }, bot.name),- (0, import_react24.createElement)(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: (0, import_react24.createElement)("span", { className: "bt-lead" }, (0, import_react24.createElement)(BotMark, { bot, size: 22 })) })+ (0, import_react24.createElement)("span", { className: "bt-group-name", style: flat ? void 0 : { color: inkText(colorOf(bot)) } }, flat ? lead : null, bot.name),+ (0, import_react24.createElement)(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: flat ? null : lead })));})@@ -12741,6 +12781,17 @@ function SetRow({ label, hint, children }) {children ? (0, import_react33.createElement)("div", { className: "bt-set-control" }, children) : null);}+var LAYOUTS = [["bubble", "Bubble"], ["flat", "Flat"]];+function Choice({ label, value, options, pick: pick2 }) {+ return (0, import_react33.createElement)(Segmented, { label, value, className: "bt-look-seg" }, options.map(([id, text]) => (0, import_react33.createElement)("button", {+ key: id,+ type: "button",+ "aria-pressed": value === id,+ onClick: () => {+ if (value !== id) pick2(id);+ }+ }, t(text))));+}function WidthSlider({ label, value, save }) {const [width, setWidth] = (0, import_react33.useState)(value);const pending = (0, import_react33.useRef)(null);@@ -12822,6 +12873,9 @@ function GeneralPage({ roster, actions, run }) {))),+ (0, import_react33.createElement)(SetRow, { label: t("Message layout") }, (0, import_react33.createElement)(Choice, { label: t("Message layout"), value: layoutOf(prefs), options: LAYOUTS, pick: (id) => run(actions.setPrefs({ layout: id })) })),+ // The flat layout's text has a width of its own; the bubble width stays for the user's messages.+ layoutOf(prefs) === "flat" ? (0, import_react33.createElement)(SetRow, { label: t("Text width") }, (0, import_react33.createElement)(WidthSlider, { label: t("Text width"), value: flatWidthOf(prefs), save: (flatWidth) => run(actions.setPrefs({ flatWidth })) })) : null,(0, import_react33.createElement)(SetRow, { label: t("Bubble width") }, (0, import_react33.createElement)(WidthSlider, { label: t("Bubble width"), value: widthOf(prefs), save: (width) => run(actions.setPrefs({ width })) }))),actions.setSurface ? (0, import_react33.createElement)(@@ -15760,10 +15814,14 @@ function apply(ctx) {const id = themes[prefs.theme] ? prefs.theme : "deepseek";const accent = isHex(prefs.accent) ? prefs.accent : void 0;const motion = prefs.motion === "quiet" || prefs.motion === "lively" ? prefs.motion : "normal";+ const layout = layoutOf(prefs);const width = widthOf(prefs);+ const flatWidth = flatWidthOf(prefs);document.body.dataset.btMotion = motion;+ document.body.dataset.btLayout = layout;document.body.style.setProperty("--bt-msg-w", String(width / 100));- const next = `${id}|${accent ?? ""}|${motion}|${width}|${registry.getSnapshot()}`;+ document.body.style.setProperty("--bt-flat-w", String(flatWidth / 100));+ const next = `${id}|${accent ?? ""}|${motion}|${layout}|${width}|${flatWidth}|${registry.getSnapshot()}`;if (next === key) return;key = next;style.textContent = themeCss(themes[id], accent);@@ -15772,7 +15830,7 @@ function apply(ctx) {if (typeof release === "function") release();if (snapshot.ready) {try {- localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, width: prefs.width }));+ localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth }));} catch {}}@@ -15787,7 +15845,9 @@ function apply(ctx) {if (typeof releaseTokens === "function") releaseTokens();} finally {delete document.body.dataset.btMotion;+ delete document.body.dataset.btLayout;document.body.style.removeProperty("--bt-msg-w");+ document.body.style.removeProperty("--bt-flat-w");style.remove();}};diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.jsindex b9ae28fb..c6d4b9c7 100644--- a/ds-bot/src/client/cells.js+++ b/ds-bot/src/client/cells.js@@ -11,10 +11,11 @@ import { SecretToolCell } from './secret-card.js'import { t } from './i18n.js'import { call } from './api.js'import { failureLabel } from './diagnostics.js'-import { turnReasoning, thinkingStep } from './turn-reasoning.js'+import { turnReasoning, thinkingStep, opensReply } from './turn-reasoning.js'import { FOLD_AT, FOLD_HUGE, stripLongNote, useFold } from './fold.js'import { noHover, useViewport, viewBottom } from './motion.js'import { heldCardKey } from './sources.js'+import { layoutOf } from './themes.js'export { clockLabel }@@ -238,6 +239,11 @@ export function AssistantCell({ node, groupPart, sessionId, openFile, fileMentioconst relays = relayPart(data, groupPart) ? relaysBefore(contexts, steps, data) : []if (texts.length === 0 && !reasoning && relays.length === 0) return nullconst selfId = roster.byId[sessionId]?.id ?? sessionId+ // The flat layout heads a reply with who speaks, once per Turn: in the step that opens+ // it, in that step's reasoning part when the reasoning shows there.+ const speaker = layoutOf(roster.prefs) === 'flat' ? roster.byId[sessionId] : undefined+ const head = speaker !== undefined && opensReply(steps, data)+ && (reasoning !== '' || (texts.length > 0 && !(groupPart === 'response' && turnReasoning(steps, data) !== '')))return h(Fragment, null,relays.map(relay => {const source = relay.source@@ -250,6 +256,7 @@ export function AssistantCell({ node, groupPart, sessionId, openFile, fileMentiowhole: true,})}),+ head ? h(SpeakerHead, { bot: speaker, time: data.time }) : null,reasoning ? h(ThinkingRow, {text: reasoning, live: thinking !== undefined, viewKey: `${sessionId}:${data.turn}`,// The live clock counts the settled steps too: backing `at` by the settled@@ -275,18 +282,27 @@ function EventLine({ prefix, bots, joiner = t('and'), onOpen, whole = false }) {return h('div', { className: 'bt-event' }, parts)}+// The flat layout's head over a Bot's reply in its own chat: avatar, name, time.+function SpeakerHead({ bot, time }) {+ return h('div', { className: 'bt-group-name' },+ h('span', { className: 'bt-lead' }, h(BotMark, { bot, size: 22 })), bot.name,+ Number.isFinite(time) ? h('span', { className: 'bt-group-time', title: clockLabel(time) }, messageClock(time)) : null)+}+// One Bot message inside a group chat: avatar, name (with its group role), when it ran-// and how long it took, bubble.+// and how long it took, bubble. The flat layout moves the avatar from beside the last+// bubble to the head of the name row, so the text below runs the whole width.function GroupMessage({ bot, text, texts = [text], room, roster, actions, msgKey, useUi, whole, time, duration }) {const lead = h('button', { type: 'button', className: 'bt-lead', 'aria-label': t("Open {name}'s chat", { name: bot.name }), onClick: () => actions.openSession(bot.id) },h(BotMark, { bot, size: 22 }))+ const flat = layoutOf(roster.prefs) === 'flat'const took = Number.isFinite(duration) ? elapsedLabel(duration) : undefinedreturn h('div', { className: 'bt-group-msg' },- h('span', { className: 'bt-group-name', style: { color: inkText(colorOf(bot)) } }, bot.name,+ h('span', { className: 'bt-group-name', style: flat ? undefined : { color: inkText(colorOf(bot)) } }, flat ? lead : null, bot.name,room?.admin === bot.id ? h('span', { className: 'bt-group-role' }, t('Admin')) : null,Number.isFinite(time) ? h('span', { className: 'bt-group-time', title: clockLabel(time) }, messageClock(time)) : null,took ? h('span', { className: 'bt-group-took', title: t('Ran for {duration}', { duration: took }) }, took) : null),- h(Bubbles, { texts, roster, selfId: bot.id, actions, sessionId: room?.id, msgKey, useUi, lead, whole }))+ h(Bubbles, { texts, roster, selfId: bot.id, actions, sessionId: room?.id, msgKey, useUi, lead: flat ? null : lead, whole }))}// A member's messages in a row, as one block under its name: what it says while it@@ -435,7 +451,11 @@ function chatRow(row, key, { sessionId, selfId, roster, actions, useUi }) {case 'divider': return h(PartLine, { key, time: row.time })case 'user': return h(EarlierUser, { key, row })case 'answer': return h(AnsweredReply, { key, node: { data: row } })- case 'bot': return h(Bubbles, { key, texts: row.texts, roster, selfId, actions, sessionId: useUi ? sessionId : undefined, msgKey: useUi ? `${sessionId}:${row.time}` : undefined, useUi, fold: FOLD_HUGE })+ case 'bot': {+ const bubbles = h(Bubbles, { key, texts: row.texts, roster, selfId, actions, sessionId: useUi ? sessionId : undefined, msgKey: useUi ? `${sessionId}:${row.time}` : undefined, useUi, fold: FOLD_HUGE })+ const speaker = layoutOf(roster.prefs) === 'flat' ? roster.byId[selfId] : undefined+ return speaker ? h(Fragment, { key }, h(SpeakerHead, { bot: speaker, time: row.time }), bubbles) : bubbles+ }case 'event': {if (row.role === 'report') return h(GroupEvent, { key, prefix: t('Replies from'), room: roster.roomsById[row.roomId], name: t('a group chat'), roster, actions })const other = roster.byId[row.botId] ?? { id: row.botId, name: row.name ?? t('a Bot'), color: 'gray' }diff --git a/ds-bot/src/client/exchange.js b/ds-bot/src/client/exchange.jsindex 05a4c317..bf8fdce1 100644--- a/ds-bot/src/client/exchange.js+++ b/ds-bot/src/client/exchange.js@@ -5,6 +5,7 @@ import { colorOf, BotMark } from './mark.js'import { Bubbles } from './cells.js'import { stripLongNote } from './fold.js'import { useEscape, usePaneLeft } from './overlay-hooks.js'+import { layoutOf } from './themes.js'import { t } from './i18n.js'const SHEET_EXIT_MS = 220@@ -42,6 +43,7 @@ export function ExchangeDialog({ pair, roster, actions }) {}, [pair[0], pair[1]])const left = roster.byId[pair[0]]const right = roster.byId[pair[1]]+ const flat = layoutOf(roster.prefs) === 'flat'let lastDay = 0const paneLeft = usePaneLeft()return h('div', { className: 'bt-pane bt-exchange', style: { left: paneLeft }, 'data-leaving': leaving || undefined },@@ -62,11 +64,12 @@ export function ExchangeDialog({ pair, roster, actions }) {lastDay = entry.time// A long message comes with its start only; the rest is read on request.const whole = entry.length === undefined ? undefined : { length: entry.length, load: () => actions.exchangeText(entry.id) }+ const lead = h('span', { className: 'bt-lead' }, h(BotMark, { bot: bot, size: 22 }))return h(Fragment, { key: entry.id },showDay ? h('time', { className: 'bt-time' }, dayLabel(entry.time)) : null,h('div', { className: 'bt-group-msg' },- h('span', { className: 'bt-group-name', style: { color: inkText(colorOf(bot)) } }, bot.name),- h(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: h('span', { className: 'bt-lead' }, h(BotMark, { bot: bot, size: 22 })) })))+ h('span', { className: 'bt-group-name', style: flat ? undefined : { color: inkText(colorOf(bot)) } }, flat ? lead : null, bot.name),+ h(Bubbles, { texts: [stripLongNote(entry.text)], roster, selfId: bot.id, actions, whole, lead: flat ? null : lead })))})),h('div', { className: 'bt-dialog-foot' }, h('button', { type: 'button', className: 'bt-soft', onClick: close }, t('Close Chat')))))}diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex 54afcf64..bfde48e4 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -354,7 +354,11 @@ const ZH = {'Unread marks, badges, and the brand mark.': '未读标记、徽标和品牌标志。','Theme accent': '主题强调色','Custom accent': '自定义强调色',+ 'Message layout': '消息布局',+ Bubble: '气泡',+ Flat: '平铺','Bubble width': '气泡宽度',+ 'Text width': '正文宽度','Bots · {count}': 'Bot · {count}','First in the sidebar. Pick another Bot to hand it the role; {name} then stops being a Main Bot.': '排在侧栏最上面。选另一个 Bot 就会把主 Bot 交给它,{name} 随之不再是主 Bot。','Choose a Bot…': '选择一个 Bot…',diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.jsindex 8bf39d77..1724a652 100644--- a/ds-bot/src/client/index.js+++ b/ds-bot/src/client/index.js@@ -3,7 +3,7 @@ import { isHex, inkText, paintCss } from './inks.js'import { DEFAULT_MASK, SHAPES, markupCache, maskOf } from './characters.js'import { createSource, EMPTY_ROSTER, indexRoster, isAgentSession } from './sources.js'import { teamActions } from './team-actions.js'-import { themeCss, shellTokens, registry, registerShape, registerTheme, allThemes, widthOf } from './themes.js'+import { themeCss, shellTokens, registry, registerShape, registerTheme, allThemes, layoutOf, widthOf, flatWidthOf } from './themes.js'import { MENTION_ORIGIN, currentPart } from './text.js'import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } from './styles.js'import { lookOf } from './mark.js'@@ -293,10 +293,14 @@ export function apply(ctx) {const id = themes[prefs.theme] ? prefs.theme : 'deepseek'const accent = isHex(prefs.accent) ? prefs.accent : undefinedconst motion = prefs.motion === 'quiet' || prefs.motion === 'lively' ? prefs.motion : 'normal'+ const layout = layoutOf(prefs)const width = widthOf(prefs)+ const flatWidth = flatWidthOf(prefs)document.body.dataset.btMotion = motion+ document.body.dataset.btLayout = layoutdocument.body.style.setProperty('--bt-msg-w', String(width / 100))- const next = `${id}|${accent ?? ''}|${motion}|${width}|${registry.getSnapshot()}`+ document.body.style.setProperty('--bt-flat-w', String(flatWidth / 100))+ const next = `${id}|${accent ?? ''}|${motion}|${layout}|${width}|${flatWidth}|${registry.getSnapshot()}`if (next === key) returnkey = nextstyle.textContent = themeCss(themes[id], accent)@@ -304,7 +308,7 @@ export function apply(ctx) {releaseTokens = ctx.theme.overrideTokens('ds-bot', shellTokens(themes[id]))if (typeof release === 'function') release()if (snapshot.ready) {- try { localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, width: prefs.width })) } catch { /* storage unavailable */ }+ try { localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, layout: prefs.layout, width: prefs.width, flatWidth: prefs.flatWidth })) } catch { /* storage unavailable */ }}}render()@@ -317,7 +321,9 @@ export function apply(ctx) {if (typeof releaseTokens === 'function') releaseTokens()} finally {delete document.body.dataset.btMotion+ delete document.body.dataset.btLayoutdocument.body.style.removeProperty('--bt-msg-w')+ document.body.style.removeProperty('--bt-flat-w')style.remove()}}diff --git a/ds-bot/src/client/settings.js b/ds-bot/src/client/settings.jsindex 0552a17f..0bbf6320 100644--- a/ds-bot/src/client/settings.js+++ b/ds-bot/src/client/settings.js@@ -1,7 +1,7 @@import { createElement as h, useCallback, useEffect, useRef, useState } from 'react'import { ACCENT_INKS, INKS } from './inks.js'import { isMainOf } from './sources.js'-import { MESSAGE_WIDTH, allThemes, widthOf } from './themes.js'+import { MESSAGE_WIDTH, allThemes, flatWidthOf, layoutOf, widthOf } from './themes.js'import { CloseIcon, ChevronLeftIcon, ChevronRightIcon, ClockIcon, ConnectorIcon, InfoIcon, PlugIcon, PlusIcon, SlidersIcon, SETTINGS_ICONS } from './icons.js'import { AdminStar, BotAvatar, RoomAvatar } from './mark.js'import { useEscape } from './overlay-hooks.js'@@ -37,6 +37,15 @@ function SetRow({ label, hint, children }) {children ? h('div', { className: 'bt-set-control' }, children) : null)}+const LAYOUTS = [['bubble', 'Bubble'], ['flat', 'Flat']]++function Choice({ label, value, options, pick }) {+ return h(Segmented, { label, value, className: 'bt-look-seg' }, options.map(([id, text]) => h('button', {+ key: id, type: 'button', 'aria-pressed': value === id,+ onClick: () => { if (value !== id) pick(id) },+ }, t(text))))+}+// A width in percent of the column. A drag saves once it rests, as the custom accent// does; a change still waiting when the dialog closes is saved, not dropped.function WidthSlider({ label, value, save }) {@@ -90,6 +99,9 @@ function GeneralPage({ roster, actions, run }) {})),h('label', { className: 'bt-swatch bt-swatch-custom', title: t('Custom accent'), 'data-on': Boolean(prefs.accent) && !ACCENT_INKS.some(ink => INKS[ink][0] === prefs.accent) },h('input', { type: 'color', value: custom, 'aria-label': t('Custom accent'), onChange: event => pickCustom(event.target.value) })))),+ h(SetRow, { label: t('Message layout') }, h(Choice, { label: t('Message layout'), value: layoutOf(prefs), options: LAYOUTS, pick: id => run(actions.setPrefs({ layout: id })) })),+ // The flat layout's text has a width of its own; the bubble width stays for the user's messages.+ layoutOf(prefs) === 'flat' ? h(SetRow, { label: t('Text width') }, h(WidthSlider, { label: t('Text width'), value: flatWidthOf(prefs), save: flatWidth => run(actions.setPrefs({ flatWidth })) })) : null,h(SetRow, { label: t('Bubble width') }, h(WidthSlider, { label: t('Bubble width'), value: widthOf(prefs), save: width => run(actions.setPrefs({ width })) }))),actions.setSurface ? h(SetSection, { key: 'mode', title: t('Mode') },h(SetRow, { label: t('Classic Agent mode') },diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex 7d33aaca..82e669b5 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -178,8 +178,8 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}.bt-pill[data-memory=updated]:is(:hover,:focus-visible,[aria-expanded=true]) .bt-pill-go{width:0;margin-left:-8px;opacity:0;filter:blur(6px);transform:translateX(-6px)}@media (prefers-reduced-motion:reduce){.bt-pill,.bt-pill-go,.bt-pill-go svg{transition:none!important}.bt-pill-go{filter:none}.bt-pill:active{transform:none}}-/* The bubble width setting: the share of the column a chat bubble may take. */-body{--bt-msg-w:.8}+/* The width settings: the share of the column a bubble may take, and the flat text. */+body{--bt-msg-w:.8;--bt-flat-w:1}.bt-astack{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin:0}.bt-bubble{max-width:min(calc(var(--bt-msg-w) * 100%),calc(100% - 82px));background:var(--bt-bubble);color:var(--bt-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);box-sizing:border-box;overflow-wrap:anywhere}.bt-msg:not(:first-child)>.bt-msg-line>.bt-bubble{border-start-start-radius:6px}@@ -198,6 +198,8 @@ button.bt-lead{border:0;background:none;padding:0;cursor:pointer}/* Rows without the avatar start where the bubble beside it starts: 22px avatar + 8px gap. */.bt-astack[data-lead]>.bt-msg:not(:last-child)>.bt-msg-line,.bt-astack[data-lead] .bt-reacts{margin-left:30px}.bt-group-name{font-size:12px;line-height:16px;font-weight:500;margin-left:42px}+.bt-group-name:has(>.bt-lead){display:flex;align-items:center;margin:0 0 2px;font-size:13px;line-height:22px;font-weight:600;color:var(--bt-ink)}+.bt-group-name>.bt-lead{margin:0 8px 0 0}.bt-group-time,.bt-group-took{margin-left:6px;font-size:11px;line-height:16px;font-weight:400;color:var(--bt-ink-2);font-variant-numeric:tabular-nums;white-space:nowrap}.bt-x{border:0;background:none;color:var(--bt-ink-2);cursor:pointer;width:24px;height:24px;border-radius:6px;font-size:16px;line-height:24px;padding:0;transition:background-color .12s ease,color .12s ease,${spring(SPRING_TAP, 'scale')}}.bt-x:hover{background:var(--bt-hover);color:var(--bt-ink)}@@ -585,6 +587,13 @@ ${SKIN_FOOT}>div:has(> [data-slot="sidebar.settings"]){order:-1!important;flex:n.bt-tools{position:absolute;top:50%;left:100%;margin-left:6px;transform:translateY(-50%);display:flex;gap:2px;opacity:0;visibility:hidden;transition:opacity .12s ease,visibility .12s}.bt-tools::after{content:"";position:absolute;top:-8px;bottom:-8px;right:100%;width:128px;z-index:-1}.bt-msg:hover>.bt-msg-line>.bt-tools,.bt-msg:focus-within>.bt-msg-line>.bt-tools,.bt-tools[data-open]{opacity:1;visibility:visible}+/* The flat layout: a Bot's text has no bubble and takes its own share of the column+ (the whole of it unless set). The toolbar floats over the message's top right. */+body[data-bt-layout=flat] .bt-astack{align-items:stretch;gap:10px}+body[data-bt-layout=flat] .bt-msg,body[data-bt-layout=flat] .bt-astack[data-lead]>.bt-msg{align-items:stretch;max-width:calc(var(--bt-flat-w) * 100%)}+body[data-bt-layout=flat] .bt-bubble{background:none;padding:0;border-radius:0}+body[data-bt-layout=flat] .bt-tools{top:-14px;right:0;left:auto;margin-left:0;transform:none;padding:2px;border-radius:999px;background:var(--bt-card);box-shadow:inset 0 0 0 .5px var(--bt-line-2),0 4px 14px rgba(0,0,0,.14)}+body[data-bt-layout=flat] .bt-tools::after{display:none}.bt-tool{width:24px;height:24px;border:0;padding:0;border-radius:6px;background:none;color:var(--bt-ink-2);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:background-color .12s ease,color .12s ease}.bt-tool:hover,.bt-tool[aria-expanded=true]{background:var(--bt-hover);color:var(--bt-ink)}.bt-tool:active{background:var(--bt-active)}@@ -698,7 +707,7 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}.bt-add:hover,.bt-addlist .bt-option:hover{background:var(--bt-hover);color:var(--bt-ink)}.bt-addlist{display:flex;flex-direction:column;margin-top:4px;padding:4px;border:1px solid var(--bt-line);border-radius:10px;background:var(--bt-card);animation:bt-rise .16s ease-out}.bt-seg{position:relative;display:flex;gap:2px;padding:2px;border-radius:10px;background:var(--bt-hover)}-.bt-motion-seg{width:216px}+.bt-motion-seg,.bt-look-seg{width:216px}/* A range input: the track fills with the accent up to the thumb (--bt-fill). */.bt-range{display:flex;align-items:center;gap:10px;width:216px}.bt-range input{flex:1;min-width:0;height:20px;margin:0;background:none;-webkit-appearance:none;appearance:none;cursor:pointer}@@ -862,6 +871,7 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}export const CONVERSATION_CSS = `.bt-think{font-size:13px;line-height:18px;color:var(--bt-ink-2);margin:2px 0 4px;max-width:calc(var(--bt-msg-w) * 100%)}+body[data-bt-layout=flat] .bt-think{max-width:calc(var(--bt-flat-w) * 100%)}.bt-think summary{cursor:pointer;list-style:none;display:inline-flex;align-items:center;gap:6px}.bt-think summary::-webkit-details-marker{display:none}.bt-think-time{font-variant-numeric:tabular-nums;white-space:nowrap}diff --git a/ds-bot/src/client/themes.js b/ds-bot/src/client/themes.jsindex b1d4da9a..49e80f38 100644--- a/ds-bot/src/client/themes.js+++ b/ds-bot/src/client/themes.js@@ -117,8 +117,11 @@ export function registerTheme(id, theme) {}export const allThemes = () => ({ ...THEMES, ...customThemes })-// The bubble width: the percent of the column a chat bubble may take. A value the plugin-// does not know reads as the default.+// How chat messages are drawn; a value the plugin does not know reads as the default.+// A width is a percent of the column: the bubbles' in either layout, the text's in the+// flat one.export const MESSAGE_WIDTH = { min: 50, max: 100, step: 5 }const percent = (value, initial) => (Number.isInteger(value) && value >= MESSAGE_WIDTH.min && value <= MESSAGE_WIDTH.max ? value : initial)+export const layoutOf = prefs => (prefs?.layout === 'flat' ? 'flat' : 'bubble')export const widthOf = prefs => percent(prefs?.width, 80)+export const flatWidthOf = prefs => percent(prefs?.flatWidth, 100)diff --git a/ds-bot/src/client/turn-reasoning.js b/ds-bot/src/client/turn-reasoning.jsindex c8a529ff..839235d3 100644--- a/ds-bot/src/client/turn-reasoning.js+++ b/ds-bot/src/client/turn-reasoning.js@@ -7,6 +7,14 @@ export function turnReasoning(steps, current) {return members.map(stepReasoning).filter(Boolean).join('\n\n')}+// Whether `current` opens the Turn's reply in the chat: the first step with reply text,+// or the one that shows the Turn's reasoning, whichever comes first.+export function opensReply(steps, current) {+ const members = steps.length ? steps : [current]+ const reasoner = members.findLast(step => stepReasoning(step) !== '')+ return members.find(step => texts(step).length > 0 || step === reasoner)?.step === current.step+}+// A step still streaming reasoning with no reply text yet is thinking: the row// counts its clock from `step.time`, the time its first visible chunk arrived.export const thinkingStep = steps => steps.find(thinkingLive)diff --git a/ds-bot/src/host/channel.js b/ds-bot/src/host/channel.jsindex 66c81dfb..90ce7f4c 100644--- a/ds-bot/src/host/channel.js+++ b/ds-bot/src/host/channel.js@@ -102,11 +102,21 @@ export function install(rt) {else if (body.motion === 'quiet' || body.motion === 'lively') state.prefs.motion = body.motionelse throw invalid('Motion must be quiet, normal or lively')}+ if (body.layout !== undefined) {+ if (body.layout === null || body.layout === 'bubble') delete state.prefs.layout+ else if (body.layout === 'flat') state.prefs.layout = body.layout+ else throw invalid('Layout must be bubble or flat')+ }if (body.width !== undefined) {if (body.width === null || body.width === 80) delete state.prefs.widthelse if (Number.isInteger(body.width) && body.width >= 50 && body.width <= 100) state.prefs.width = body.widthelse throw invalid('Width must be a whole percent from 50 to 100')}+ if (body.flatWidth !== undefined) {+ if (body.flatWidth === null || body.flatWidth === 100) delete state.prefs.flatWidth+ else if (Number.isInteger(body.flatWidth) && body.flatWidth >= 50 && body.flatWidth <= 100) state.prefs.flatWidth = body.flatWidth+ else throw invalid('Flat text width must be a whole percent from 50 to 100')+ }return rt.save()}diff --git a/ds-bot/test/install.test.js b/ds-bot/test/install.test.jsindex 7ab8f844..904f2afd 100644--- a/ds-bot/test/install.test.js+++ b/ds-bot/test/install.test.js@@ -152,12 +152,18 @@ test('the client channel answers from the saved state', async (t) => {assert.equal((await call('set-prefs', { motion: 'lively' })).value.motion, 'lively')assert.equal('motion' in (await call('set-prefs', { motion: 'normal' })).value, false)assert.deepEqual((await call('set-prefs', { motion: 'wild' })).error, { code: 'bot/invalid', message: 'Motion must be quiet, normal or lively', details: {} })- // So is the bubble width, a whole percent from 50 to 100.+ // So are the message layout and width, each with only its own values.+ assert.equal((await call('set-prefs', { layout: 'flat' })).value.layout, 'flat')+ assert.equal('layout' in (await call('set-prefs', { layout: 'bubble' })).value, false)+ assert.deepEqual((await call('set-prefs', { layout: 'grid' })).error, { code: 'bot/invalid', message: 'Layout must be bubble or flat', details: {} })assert.equal((await call('set-prefs', { width: 95 })).value.width, 95)assert.equal('width' in (await call('set-prefs', { width: 80 })).value, false)for (const width of [120, 49, 72.5, '90']) {assert.deepEqual((await call('set-prefs', { width })).error, { code: 'bot/invalid', message: 'Width must be a whole percent from 50 to 100', details: {} }, String(width))}+ assert.equal((await call('set-prefs', { flatWidth: 70 })).value.flatWidth, 70)+ assert.equal('flatWidth' in (await call('set-prefs', { flatWidth: 100 })).value, false)+ assert.deepEqual((await call('set-prefs', { flatWidth: 40 })).error, { code: 'bot/invalid', message: 'Flat text width must be a whole percent from 50 to 100', details: {} })// A refusal from the team code keeps its message for the user.assert.deepEqual((await call('delete-bot', { id: 'nobody' })).error, { code: 'bot/refused', message: 'Unknown Bot', details: {} })// Off the Desktop profile there are no Bot browsers.diff --git a/ds-bot/test/message-layout.test.js b/ds-bot/test/message-layout.test.jsindex e504e775..ebcae6d3 100644--- a/ds-bot/test/message-layout.test.js+++ b/ds-bot/test/message-layout.test.js@@ -1,7 +1,7 @@import assert from 'node:assert/strict'import { readFileSync } from 'node:fs'import { test } from 'node:test'-import { widthOf } from '../src/client/themes.js'+import { flatWidthOf, layoutOf, widthOf } from '../src/client/themes.js'const bundle = readFileSync(new URL('../client.js', import.meta.url), 'utf8')// The declarations of the rule whose whole selector is `selector`.@@ -12,19 +12,28 @@ const ruleOf = (selector) => {return bundle.slice(open + 1, bundle.indexOf('}', open))}-test('a width the plugin does not know reads as the default', () => {+test('a layout or width the plugin does not know reads as the default', () => {+ assert.equal(layoutOf(undefined), 'bubble')+ assert.equal(layoutOf({ layout: 'grid' }), 'bubble')+ assert.equal(layoutOf({ layout: 'flat' }), 'flat')assert.equal(widthOf({}), 80)assert.deepEqual([40, 101, 72.5, 'wide'].map(width => widthOf({ width })), [80, 80, 80, 80])assert.deepEqual([50, 95, 100].map(width => widthOf({ width })), [50, 95, 100])+ assert.equal(flatWidthOf({ width: 60 }), 100)+ assert.deepEqual([70, 101].map(flatWidth => flatWidthOf({ flatWidth })), [70, 100])})-test('every bubble takes the share of the column that the width setting gives', () => {+test('every message takes the share of the column that the width setting gives', () => {for (const selector of ['.bt-msg', '.bt-astack[data-lead]>.bt-msg', '.bt-ustack', '.bt-ububble', '.bt-think']) {assert.match(ruleOf(selector), /max-width:[^;]*var\(--bt-msg-w\)/, selector)}- assert.match(bundle, /\nbody\{--bt-msg-w:\.8\}/)+ assert.match(bundle, /\nbody\{--bt-msg-w:\.8;--bt-flat-w:1\}/)})-test('a Bot bubble keeps room for the toolbar beside it', () => {+test('a Bot bubble keeps room for the toolbar beside it; flat Bot text takes the flat width', () => {assert.match(ruleOf('.bt-msg'), /calc\(100% - 82px\)/)+ for (const selector of ['body[data-bt-layout=flat] .bt-msg,body[data-bt-layout=flat] .bt-astack[data-lead]>.bt-msg', 'body[data-bt-layout=flat] .bt-think']) {+ assert.match(ruleOf(selector), /max-width:calc\(var\(--bt-flat-w\) \* 100%\)/, selector)+ }+ assert.match(ruleOf('body[data-bt-layout=flat] .bt-bubble'), /background:none/)})diff --git a/ds-bot/test/turn-reasoning.test.js b/ds-bot/test/turn-reasoning.test.jsindex 2f514e08..5c20623f 100644--- a/ds-bot/test/turn-reasoning.test.js+++ b/ds-bot/test/turn-reasoning.test.js@@ -1,6 +1,6 @@import test from 'node:test'import assert from 'node:assert/strict'-import { thinkingStep, turnReasoning } from '../src/client/turn-reasoning.js'+import { opensReply, thinkingStep, turnReasoning } from '../src/client/turn-reasoning.js'const step = (n, blocks, status = 'settled') => ({ turn: 1, step: n, status, blocks })const think = text => ({ kind: 'reasoning', text })@@ -45,3 +45,14 @@ test('a step outside the loaded Turn list shows only its own reasoning', () => {const current = step(1, [think(' A ')])assert.equal(turnReasoning([], current), 'A')})++test('a reply opens on its first text or on its reasoning row, whichever comes first', () => {+ const opener = steps => steps.findIndex(current => opensReply(steps, current))+ // A word before the tools opens the reply, ahead of the reasoning on the last step.+ assert.equal(opener([step(1, [{ kind: 'text', text: 'Looking' }, tool]), step(2, [think('B'), tool]), step(3, [think('C'), { kind: 'text', text: 'Done' }])]), 0)+ // Reasoning that shows before any text opens it.+ assert.equal(opener([step(1, [think('B'), tool]), step(2, [tool]), step(3, [{ kind: 'text', text: 'Done' }])]), 0)+ // Tools alone open nothing; the step that answers does.+ assert.equal(opener([step(1, [tool]), step(2, [tool]), step(3, [{ kind: 'text', text: 'Done' }])]), 2)+ assert.equal(opener([step(1, [tool])]), -1)+})