A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Let chat bubbles follow the column, with a bubble width setting
chimneyaab7516f60ed
diff --git a/docs/plans/2026-10-22-message-layout.md b/docs/plans/2026-10-22-message-layout.mdnew file mode 100644index 00000000..b1e1ea49--- /dev/null+++ b/docs/plans/2026-10-22-message-layout.md@@ -0,0 +1,34 @@+# 消息宽度++- 日期:2026-10-22+- 相关:#380++## 为什么++Bot 回复的气泡最宽写死在 560px。宽屏下正文列是 960px,Bot 气泡只占 58%,比用户气泡(列宽的 70.2%,674px)还窄。长回答、代码块和表格因此被挤成一窄条,频繁换行。#380 希望能调宽度。++取舍:++- 气泡跟着正文列按比例走,不再有像素上限,Bot 和用户的气泡用同一个比例,默认 80%。+- 宽度用滑块按百分比调,不填像素:换窗口大小、打开右侧面板时仍然成比例。几档预设太粗,滑块能调到每个人顺手的宽度。+- 和主题、强调色、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)。拿到团队状态之前,先用本机缓存的上一次设置,避免先闪一下默认样式。++## 不做什么++- 不提供像素宽度。+- 拖动时不实时改聊天区的样式;松手后保存,再跟着团队状态变化。+- 不改正文列宽,也不恢复 DSH 的拖动把手(#28)。+- 不按设备分开保存。++## 已知限制++- Bot 气泡最宽到整列宽减 82px:960px 的列大约在 91% 封顶,再往右拖只有用户气泡还在变宽。手机这类窄屏上更早封顶。diff --git a/docs/plans/README.md b/docs/plans/README.mdindex aa9670ae..0bad3dbe 100644--- a/docs/plans/README.md+++ b/docs/plans/README.md@@ -46,3 +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 |diff --git a/ds-bot/client.js b/ds-bot/client.jsindex cc565215..27136a19 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -416,6 +416,7 @@ var ZH = {"Unread marks, badges, and the brand mark.": "未读标记、徽标和品牌标志。","Theme accent": "主题强调色","Custom accent": "自定义强调色",+ "Bubble 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…",@@ -1690,6 +1691,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 widthOf = (prefs) => percent(prefs?.width, 80);// src/shared/mentions.jsvar ALL_WORDS = ["all", "everyone", "所有人", "全体"];@@ -2356,8 +2360,10 @@ 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}.bt-astack{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin:0}-.bt-bubble{max-width:min(80%,560px,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-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}.bt-msg:not(:last-child)>.bt-msg-line>.bt-bubble{border-end-start-radius:6px}.bt-bubble [class*="_markdown"]>*+*{margin-top:10px}@@ -2749,13 +2755,15 @@ ${SKIN_FOOT}>div:has(> [data-slot="sidebar.settings"]){order:-1!important;flex:n@keyframes bt-fade{from{opacity:0}to{opacity:1}}@keyframes bt-blur-in{from{opacity:0;filter:blur(2px)}to{opacity:1;filter:blur(0)}}@media (prefers-reduced-motion:reduce){.bt-voice-pane,.bt-voice-caption,.bt-voice-ring{animation:none!important}}-.bt-msg{display:flex;flex-direction:column;align-items:flex-start;max-width:min(80%,560px,calc(100% - 82px))}+/* A bubble takes the set share of the column, as the user's does; 82px stays free for+ the hover toolbar beside it: a 6px margin and three 24px tools 2px apart. */+.bt-msg{display:flex;flex-direction:column;align-items:flex-start;max-width:min(calc(var(--bt-msg-w) * 100%),calc(100% - 82px))}/* The bubble's row: reactions hang below it, so the hover toolbar (and a groupsender's avatar) line up with the bubble alone. */.bt-msg-line{position:relative;display:flex;align-items:flex-end;gap:8px;max-width:100%}.bt-msg-line>.bt-bubble{max-width:none;min-width:0}-/* The same bubble width as beside an avatar column: 80% of (100% - 30px), plus the 30px. */-.bt-astack[data-lead]>.bt-msg{max-width:min(calc(80% + 6px),590px,calc(100% - 52px))}+/* The same bubble width as beside an avatar column: the share of (100% - 30px), plus the 30px. */+.bt-astack[data-lead]>.bt-msg{max-width:min(calc(var(--bt-msg-w) * (100% - 30px) + 30px),calc(100% - 52px))}.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}@@ -2873,6 +2881,16 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}.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}+/* 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}+.bt-range input::-webkit-slider-runnable-track{height:4px;border-radius:999px;background:linear-gradient(to right,var(--bt-accent) var(--bt-fill),var(--bt-active) var(--bt-fill))}+.bt-range input::-moz-range-track{height:4px;border-radius:999px;background:linear-gradient(to right,var(--bt-accent) var(--bt-fill),var(--bt-active) var(--bt-fill))}+.bt-range input::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;margin-top:-6px;border:0;border-radius:50%;corner-shape:round;background:var(--bt-card);box-shadow:inset 0 0 0 .5px var(--bt-line-2),0 1px 3px rgba(0,0,0,.08);transition:${spring(SPRING_TAP, "scale")}}+.bt-range input::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var(--bt-card);box-shadow:inset 0 0 0 .5px var(--bt-line-2),0 1px 3px rgba(0,0,0,.08)}+.bt-range input:active::-webkit-slider-thumb{scale:1.15}+.bt-range input:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:999px}+.bt-range output{flex:none;width:38px;text-align:right;font-size:13px;color:var(--bt-ink-2);font-variant-numeric:tabular-nums}.bt-seg button{position:relative;z-index:1;flex:1;height:30px;border:0;border-radius:8px;background:none;font:inherit;font-size:13px;color:var(--bt-ink-2);cursor:pointer;transition:background-color .15s ease,color .15s ease,box-shadow .15s ease,${spring(SPRING_TAP, "scale")}}.bt-seg button[aria-pressed=true]{background:var(--bt-card);color:var(--bt-ink);box-shadow:0 1px 3px rgba(0,0,0,.08)}.bt-seg button:disabled{opacity:.4;cursor:default}@@ -3024,7 +3042,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:min(560px,78%)}+.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%)}.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}@@ -3231,7 +3249,7 @@ div:has(> nav [class*="_marks"]){display:none!important}.bt-earlier-top{display:flex;justify-content:center;align-items:center;height:34px;flex:none}.bt-earlier-top .bt-soft{height:28px;font-size:12px;padding:0 12px}.bt-urow{display:flex;justify-content:flex-end}-.bt-ububble{max-width:min(560px,78%);background:var(--bt-user);color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:14px;line-height:20px;box-sizing:border-box;overflow-wrap:anywhere}+.bt-ububble{max-width:calc(var(--bt-msg-w) * 100%);background:var(--bt-user);color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:14px;line-height:20px;box-sizing:border-box;overflow-wrap:anywhere}.bt-ububble [class*="_markdown"],.bt-ububble a{color:inherit!important}.bt-ububble p{margin:0;line-height:22px}.bt-uimages{display:block;font-size:12px;opacity:.7}@@ -4312,19 +4330,19 @@ function WidgetTable({ node }) {);}function WidgetProgress({ node }) {- const percent2 = Math.max(0, Math.min(100, Number(node.percent) || 0));+ const percent3 = Math.max(0, Math.min(100, Number(node.percent) || 0));return (0, import_react6.createElement)("div",{ className: "bt-widget-progress" },- (0, import_react6.createElement)("span", { className: "bt-widget-progress-label" }, (0, import_react6.createElement)("span", null, node.label), (0, import_react6.createElement)("span", null, `${Math.round(percent2)}%`)),+ (0, import_react6.createElement)("span", { className: "bt-widget-progress-label" }, (0, import_react6.createElement)("span", null, node.label), (0, import_react6.createElement)("span", null, `${Math.round(percent3)}%`)),(0, import_react6.createElement)("div", {className: "bt-widget-progress-track",role: "progressbar",- "aria-valuenow": percent2,+ "aria-valuenow": percent3,"aria-valuemin": 0,"aria-valuemax": 100,"aria-label": node.label ?? t("Progress")- }, (0, import_react6.createElement)("div", { className: "bt-widget-progress-fill", style: { width: `${percent2}%` } }))+ }, (0, import_react6.createElement)("div", { className: "bt-widget-progress-fill", style: { width: `${percent3}%` } })));}function WidgetNode({ node, ctx }) {@@ -11123,7 +11141,7 @@ function compact(count) {}return String(Math.round(count));}-function percent(part, whole) {+function percent2(part, whole) {if (!(whole > 0) || !(part > 0)) return "0";const value = part / whole * 100;return value < 1 ? "<1" : String(Math.round(value));@@ -11145,7 +11163,7 @@ var soften = (paint, strength = 1) => {return paint.startsWith("linear-gradient(") ? paint.replace(/#[0-9a-f]{6}/gi, mix) : mix(paint);};var full = (count) => new Intl.NumberFormat(dateLocale()).format(Math.round(count));-var hitRate = (sum) => percent(sum.cacheRead, sum.input + sum.cacheRead);+var hitRate = (sum) => percent2(sum.cacheRead, sum.input + sum.cacheRead);var dates = (options) => new Intl.DateTimeFormat(dateLocale(), { timeZone: "UTC", ...options });var hourText = (ms) => `${String(new Date(ms).getUTCHours()).padStart(2, "0")}:00`;var yearOf = (ms) => new Date(ms).getUTCFullYear();@@ -11388,7 +11406,7 @@ function Row2({ kind, glyph, name, sub, sum, whole, fill: fill2, index, onClick),(0, import_react28.createElement)("span", { className: "bt-us-track" }, (0, import_react28.createElement)("span", { style: { width: `${width}%`, background: fill2 } }))),- (0, import_react28.createElement)("span", { className: "bt-us-row-num" }, (0, import_react28.createElement)("b", null, compact(sum.total)), (0, import_react28.createElement)("small", null, `${percent(sum.total, whole)}%`))+ (0, import_react28.createElement)("span", { className: "bt-us-row-num" }, (0, import_react28.createElement)("b", null, compact(sum.total)), (0, import_react28.createElement)("small", null, `${percent2(sum.total, whole)}%`)));}function ListCard({ title, count, index, children }) {@@ -11425,7 +11443,7 @@ function Profile({ face, share, range }) {{ className: "bt-us-profile-copy" },(0, import_react28.createElement)("h3", null, face.name),face.sub ? (0, import_react28.createElement)("span", { className: "bt-us-profile-sub" }, face.sub) : null,- (0, import_react28.createElement)("span", { className: "bt-us-profile-share" }, range.from ? t("{share}% of all usage from {span}", { share: percent(share, 1), span: spanText(range.from, range.to) }) : t("{share}% of all usage in the last {range}", { share: percent(share, 1), range: rangeLabel(range.id) }))+ (0, import_react28.createElement)("span", { className: "bt-us-profile-share" }, range.from ? t("{share}% of all usage from {span}", { share: percent2(share, 1), span: spanText(range.from, range.to) }) : t("{share}% of all usage in the last {range}", { share: percent2(share, 1), range: rangeLabel(range.id) }))));}@@ -12723,6 +12741,38 @@ function SetRow({ label, hint, children }) {children ? (0, import_react33.createElement)("div", { className: "bt-set-control" }, children) : null);}+function WidthSlider({ label, value, save }) {+ const [width, setWidth] = (0, import_react33.useState)(value);+ const pending = (0, import_react33.useRef)(null);+ const timer = (0, import_react33.useRef)(0);+ const saveRef = (0, import_react33.useRef)(save);+ saveRef.current = save;+ (0, import_react33.useEffect)(() => {+ if (pending.current === null) setWidth(value);+ }, [value]);+ const flush = () => {+ const next = pending.current;+ pending.current = null;+ if (next !== null) saveRef.current(next);+ };+ (0, import_react33.useEffect)(() => () => {+ clearTimeout(timer.current);+ flush();+ }, []);+ const pick2 = (next) => {+ setWidth(next);+ pending.current = next;+ clearTimeout(timer.current);+ timer.current = setTimeout(flush, 350);+ };+ const { min, max, step } = MESSAGE_WIDTH;+ return (0, import_react33.createElement)(+ "div",+ { className: "bt-range", style: { "--bt-fill": `${(width - min) / (max - min) * 100}%` } },+ (0, import_react33.createElement)("input", { type: "range", min, max, step, value: width, "aria-label": label, "aria-valuetext": `${width}%`, onChange: (event) => pick2(Number(event.target.value)) }),+ (0, import_react33.createElement)("output", null, `${width}%`)+ );+}function GeneralPage({ roster, actions, run }) {const prefs = roster.prefs ?? {};const themes = allThemes();@@ -12771,7 +12821,8 @@ function GeneralPage({ roster, actions, run }) {(0, import_react33.createElement)("input", { type: "color", value: custom, "aria-label": t("Custom accent"), onChange: (event) => pickCustom(event.target.value) })))- )+ ),+ (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)(SetSection,@@ -15374,7 +15425,7 @@ function UserMessageCell({ node, sessionId, useRoster, actions, renderMessageIma}var USER_MESSAGE_CSS = `.bt-umsg{display:flex;flex-direction:row-reverse;align-items:center;justify-content:flex-start;gap:4px}-.bt-ustack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702),82%);display:flex;flex-direction:column;align-items:flex-end;gap:8px}+.bt-ustack{min-width:0;max-width:calc(var(--bt-msg-w) * 100%);display:flex;flex-direction:column;align-items:flex-end;gap:8px}.bt-ubody{max-width:100%;box-sizing:border-box;background:var(--bt-user);color:var(--bt-user-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);white-space:pre-wrap;word-break:break-word}.bt-ubody a{color:inherit}.bt-umention{display:inline-flex;align-items:center;gap:3px;vertical-align:-3px;max-width:100%;padding:0 1px;border:0;background:none;color:inherit;font:inherit;font-weight:600;line-height:inherit;cursor:pointer;border-radius:6px;white-space:nowrap}@@ -15709,8 +15760,10 @@ 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 width = widthOf(prefs);document.body.dataset.btMotion = motion;- const next = `${id}|${accent ?? ""}|${motion}|${registry.getSnapshot()}`;+ document.body.style.setProperty("--bt-msg-w", String(width / 100));+ const next = `${id}|${accent ?? ""}|${motion}|${width}|${registry.getSnapshot()}`;if (next === key) return;key = next;style.textContent = themeCss(themes[id], accent);@@ -15719,7 +15772,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 }));+ localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, width: prefs.width }));} catch {}}@@ -15734,6 +15787,7 @@ function apply(ctx) {if (typeof releaseTokens === "function") releaseTokens();} finally {delete document.body.dataset.btMotion;+ document.body.style.removeProperty("--bt-msg-w");style.remove();}};diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex 16c0a6a3..54afcf64 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -354,6 +354,7 @@ const ZH = {'Unread marks, badges, and the brand mark.': '未读标记、徽标和品牌标志。','Theme accent': '主题强调色','Custom accent': '自定义强调色',+ 'Bubble 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 535019ff..8bf39d77 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 } from './themes.js'+import { themeCss, shellTokens, registry, registerShape, registerTheme, allThemes, widthOf } 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,8 +293,10 @@ 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 width = widthOf(prefs)document.body.dataset.btMotion = motion- const next = `${id}|${accent ?? ''}|${motion}|${registry.getSnapshot()}`+ document.body.style.setProperty('--bt-msg-w', String(width / 100))+ const next = `${id}|${accent ?? ''}|${motion}|${width}|${registry.getSnapshot()}`if (next === key) returnkey = nextstyle.textContent = themeCss(themes[id], accent)@@ -302,7 +304,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 })) } catch { /* storage unavailable */ }+ try { localStorage.setItem(PREFS_KEY, JSON.stringify({ theme: prefs.theme, accent: prefs.accent, motion: prefs.motion, width: prefs.width })) } catch { /* storage unavailable */ }}}render()@@ -315,6 +317,7 @@ export function apply(ctx) {if (typeof releaseTokens === 'function') releaseTokens()} finally {delete document.body.dataset.btMotion+ document.body.style.removeProperty('--bt-msg-w')style.remove()}}diff --git a/ds-bot/src/client/settings.js b/ds-bot/src/client/settings.jsindex 4ccd8589..0552a17f 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 { allThemes } from './themes.js'+import { MESSAGE_WIDTH, allThemes, 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,33 @@ function SetRow({ label, hint, children }) {children ? h('div', { className: 'bt-set-control' }, children) : null)}+// 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 }) {+ const [width, setWidth] = useState(value)+ const pending = useRef(null)+ const timer = useRef(0)+ const saveRef = useRef(save)+ saveRef.current = save+ useEffect(() => { if (pending.current === null) setWidth(value) }, [value])+ const flush = () => {+ const next = pending.current+ pending.current = null+ if (next !== null) saveRef.current(next)+ }+ useEffect(() => () => { clearTimeout(timer.current); flush() }, [])+ const pick = (next) => {+ setWidth(next)+ pending.current = next+ clearTimeout(timer.current)+ timer.current = setTimeout(flush, 350)+ }+ const { min, max, step } = MESSAGE_WIDTH+ return h('div', { className: 'bt-range', style: { '--bt-fill': `${((width - min) / (max - min)) * 100}%` } },+ h('input', { type: 'range', min, max, step, value: width, 'aria-label': label, 'aria-valuetext': `${width}%`, onChange: event => pick(Number(event.target.value)) }),+ h('output', null, `${width}%`))+}+function GeneralPage({ roster, actions, run }) {const prefs = roster.prefs ?? {}const themes = allThemes()@@ -62,7 +89,8 @@ function GeneralPage({ roster, actions, run }) {style: { background: INKS[ink][0] }, onClick: () => run(actions.setPrefs({ accent: INKS[ink][0] })),})),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('input', { type: 'color', value: custom, 'aria-label': t('Custom accent'), onChange: event => pickCustom(event.target.value) })))),+ 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') },h('button', { type: 'button', className: 'bt-soft bt-soft-sm', onClick: () => actions.setSurface('agent') }, t('Switch')))) : null,diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex 42c06d86..7d33aaca 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -178,8 +178,10 @@ 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}.bt-astack{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin:0}-.bt-bubble{max-width:min(80%,560px,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-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}.bt-msg:not(:last-child)>.bt-msg-line>.bt-bubble{border-end-start-radius:6px}.bt-bubble [class*="_markdown"]>*+*{margin-top:10px}@@ -571,13 +573,15 @@ ${SKIN_FOOT}>div:has(> [data-slot="sidebar.settings"]){order:-1!important;flex:n@keyframes bt-fade{from{opacity:0}to{opacity:1}}@keyframes bt-blur-in{from{opacity:0;filter:blur(2px)}to{opacity:1;filter:blur(0)}}@media (prefers-reduced-motion:reduce){.bt-voice-pane,.bt-voice-caption,.bt-voice-ring{animation:none!important}}-.bt-msg{display:flex;flex-direction:column;align-items:flex-start;max-width:min(80%,560px,calc(100% - 82px))}+/* A bubble takes the set share of the column, as the user's does; 82px stays free for+ the hover toolbar beside it: a 6px margin and three 24px tools 2px apart. */+.bt-msg{display:flex;flex-direction:column;align-items:flex-start;max-width:min(calc(var(--bt-msg-w) * 100%),calc(100% - 82px))}/* The bubble's row: reactions hang below it, so the hover toolbar (and a groupsender's avatar) line up with the bubble alone. */.bt-msg-line{position:relative;display:flex;align-items:flex-end;gap:8px;max-width:100%}.bt-msg-line>.bt-bubble{max-width:none;min-width:0}-/* The same bubble width as beside an avatar column: 80% of (100% - 30px), plus the 30px. */-.bt-astack[data-lead]>.bt-msg{max-width:min(calc(80% + 6px),590px,calc(100% - 52px))}+/* The same bubble width as beside an avatar column: the share of (100% - 30px), plus the 30px. */+.bt-astack[data-lead]>.bt-msg{max-width:min(calc(var(--bt-msg-w) * (100% - 30px) + 30px),calc(100% - 52px))}.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}@@ -695,6 +699,16 @@ body[data-ds-dark-theme] .bt-theme-chip i{background:var(--da)}.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}+/* 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}+.bt-range input::-webkit-slider-runnable-track{height:4px;border-radius:999px;background:linear-gradient(to right,var(--bt-accent) var(--bt-fill),var(--bt-active) var(--bt-fill))}+.bt-range input::-moz-range-track{height:4px;border-radius:999px;background:linear-gradient(to right,var(--bt-accent) var(--bt-fill),var(--bt-active) var(--bt-fill))}+.bt-range input::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;margin-top:-6px;border:0;border-radius:50%;corner-shape:round;background:var(--bt-card);box-shadow:inset 0 0 0 .5px var(--bt-line-2),0 1px 3px rgba(0,0,0,.08);transition:${spring(SPRING_TAP, 'scale')}}+.bt-range input::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var(--bt-card);box-shadow:inset 0 0 0 .5px var(--bt-line-2),0 1px 3px rgba(0,0,0,.08)}+.bt-range input:active::-webkit-slider-thumb{scale:1.15}+.bt-range input:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:999px}+.bt-range output{flex:none;width:38px;text-align:right;font-size:13px;color:var(--bt-ink-2);font-variant-numeric:tabular-nums}.bt-seg button{position:relative;z-index:1;flex:1;height:30px;border:0;border-radius:8px;background:none;font:inherit;font-size:13px;color:var(--bt-ink-2);cursor:pointer;transition:background-color .15s ease,color .15s ease,box-shadow .15s ease,${spring(SPRING_TAP, 'scale')}}.bt-seg button[aria-pressed=true]{background:var(--bt-card);color:var(--bt-ink);box-shadow:0 1px 3px rgba(0,0,0,.08)}.bt-seg button:disabled{opacity:.4;cursor:default}@@ -847,7 +861,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:min(560px,78%)}+.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%)}.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}@@ -1054,7 +1068,7 @@ div:has(> nav [class*="_marks"]){display:none!important}.bt-earlier-top{display:flex;justify-content:center;align-items:center;height:34px;flex:none}.bt-earlier-top .bt-soft{height:28px;font-size:12px;padding:0 12px}.bt-urow{display:flex;justify-content:flex-end}-.bt-ububble{max-width:min(560px,78%);background:var(--bt-user);color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:14px;line-height:20px;box-sizing:border-box;overflow-wrap:anywhere}+.bt-ububble{max-width:calc(var(--bt-msg-w) * 100%);background:var(--bt-user);color:var(--bt-user-ink);border-radius:18px;padding:7px 12px;font-size:14px;line-height:20px;box-sizing:border-box;overflow-wrap:anywhere}.bt-ububble [class*="_markdown"],.bt-ububble a{color:inherit!important}.bt-ububble p{margin:0;line-height:22px}.bt-uimages{display:block;font-size:12px;opacity:.7}diff --git a/ds-bot/src/client/themes.js b/ds-bot/src/client/themes.jsindex f4153e82..b1d4da9a 100644--- a/ds-bot/src/client/themes.js+++ b/ds-bot/src/client/themes.js@@ -116,3 +116,9 @@ 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.+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 widthOf = prefs => percent(prefs?.width, 80)diff --git a/ds-bot/src/client/user-message.js b/ds-bot/src/client/user-message.jsindex ecf0cc88..81a951cc 100644--- a/ds-bot/src/client/user-message.js+++ b/ds-bot/src/client/user-message.js@@ -121,7 +121,7 @@ export function UserMessageCell({ node, sessionId, useRoster, actions, renderMesexport const USER_MESSAGE_CSS = `.bt-umsg{display:flex;flex-direction:row-reverse;align-items:center;justify-content:flex-start;gap:4px}-.bt-ustack{min-width:0;max-width:min(calc(var(--dsh-chat-content-width,748px) * .702),82%);display:flex;flex-direction:column;align-items:flex-end;gap:8px}+.bt-ustack{min-width:0;max-width:calc(var(--bt-msg-w) * 100%);display:flex;flex-direction:column;align-items:flex-end;gap:8px}.bt-ubody{max-width:100%;box-sizing:border-box;background:var(--bt-user);color:var(--bt-user-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);white-space:pre-wrap;word-break:break-word}.bt-ubody a{color:inherit}.bt-umention{display:inline-flex;align-items:center;gap:3px;vertical-align:-3px;max-width:100%;padding:0 1px;border:0;background:none;color:inherit;font:inherit;font-weight:600;line-height:inherit;cursor:pointer;border-radius:6px;white-space:nowrap}diff --git a/ds-bot/src/host/channel.js b/ds-bot/src/host/channel.jsindex 9451b1f5..66c81dfb 100644--- a/ds-bot/src/host/channel.js+++ b/ds-bot/src/host/channel.js@@ -102,6 +102,11 @@ 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.width !== undefined) {+ if (body.width === null || body.width === 80) delete state.prefs.width+ else if (Number.isInteger(body.width) && body.width >= 50 && body.width <= 100) state.prefs.width = body.width+ else throw invalid('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 f4af2708..7ab8f844 100644--- a/ds-bot/test/install.test.js+++ b/ds-bot/test/install.test.js@@ -152,6 +152,12 @@ 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.+ 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))+ }// 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.jsnew file mode 100644index 00000000..e504e775--- /dev/null+++ b/ds-bot/test/message-layout.test.js@@ -0,0 +1,30 @@+import assert from 'node:assert/strict'+import { readFileSync } from 'node:fs'+import { test } from 'node:test'+import { 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`.+const ruleOf = (selector) => {+ const start = bundle.search(new RegExp(`(^|[\\n}\`])${selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\{`))+ assert.notEqual(start, -1, `no rule for ${selector}`)+ const open = bundle.indexOf('{', start + 1)+ return bundle.slice(open + 1, bundle.indexOf('}', open))+}++test('a width the plugin does not know reads as the default', () => {+ 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])+})++test('every bubble 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\}/)+})++test('a Bot bubble keeps room for the toolbar beside it', () => {+ assert.match(ruleOf('.bt-msg'), /calc\(100% - 82px\)/)+})