A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
fix(client): coalesce group chain scans and break chains across inline cards
Fei2411920851357e06
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 69884b13..b9bd0a1a 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -4404,7 +4404,7 @@ var HANDOFF_CSS = `.bt-handoff .bt-q-foot{flex-wrap:wrap}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/ui.js+// node_modules/deep-view/src/react/ui.jsvar import_react8 = require("react");var FallbackMarkdown = ({ text }) => (0, import_react8.createElement)("span", null, String(text ?? ""));var ViewUi = (0, import_react8.createContext)({ t: (key) => key, Markdown: FallbackMarkdown });@@ -4471,7 +4471,7 @@ function useOptionKeys2(count, onPick, ownRef) {return count > 0 && listening <= 1;}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/formula.js+// node_modules/deep-view/src/core/formula.jsvar FUNCTIONS = {min: { args: [1, Infinity], run: (...values) => Math.min(...values.map(num)) },max: { args: [1, Infinity], run: (...values) => Math.max(...values.map(num)) },@@ -4752,7 +4752,7 @@ function evaluate(tree, lookup) {}}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/views.js+// node_modules/deep-view/src/core/views.jsvar LAYOUT = ["stack", "row"];var DISPLAY = ["text", "metric", "table", "chart", "progress", "callout", "sources", "html"];var INPUT_TYPES = ["slider", "choice", "toggle", "number"];@@ -5372,7 +5372,7 @@ function validateForm(node, values) {return { fields };}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/chart.js+// node_modules/deep-view/src/react/chart.jsvar import_react9 = require("react");var PALETTE = ["var(--dv-accent)", "var(--dv-ink-tangerine)", "var(--dv-ink-green)", "var(--dv-ink-violet)", "var(--dv-ink-sky)", "var(--dv-ink-rose)", "var(--dv-ink-yellow)", "var(--dv-ink-cyan)", "var(--dv-ink-magenta)"];var colorAt = (index) => PALETTE[index % PALETTE.length];@@ -5811,7 +5811,7 @@ var CHART_CSS = `@media (prefers-reduced-motion:reduce){.dv-chart-mark,.dv-chart-dot{transition:none}.dv-chart-tip{animation:none}}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/frame.js+// node_modules/deep-view/src/react/frame.jsvar import_react10 = require("react");var THEME_VARS = [["--view-ink", "--bt-ink", "--dv-ink"],@@ -5893,7 +5893,7 @@ var HTML_CSS = `.dv-view-frame-stopped{margin:0;font-size:13px;line-height:18px;color:var(--dv-ink-2)}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/card.js+// node_modules/deep-view/src/react/card.jsvar import_react11 = require("react");var mdLabels = (ui2) => ({ code: { copyLabel: ui2.t("Copy"), copiedLabel: ui2.t("Copied") }, footnotes: ui2.t("Footnotes") });var TONES2 = ["good", "warn", "bad"];@@ -6562,7 +6562,7 @@ ${CHART_CSS}${HTML_CSS}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/styles.js+// node_modules/deep-view/src/react/styles.jsvar THEME_CSS = `body{--dv-ink:var(--dsw-alias-label-primary);@@ -6659,10 +6659,10 @@ button.dv-q-opt:active{background:var(--dv-active)}@media (prefers-reduced-motion:reduce){.dv-q,.dv-view-bare,.dv-q-submit,.dv-menu,.dv-q-check{animation:none}}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/index.js+// node_modules/deep-view/src/react/index.jsvar DEEP_VIEW_CSS = THEME_CSS + QUESTION_CSS + WIDGET_CSS;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/reply.js+// node_modules/deep-view/src/core/reply.jsvar REPLY_KIND = "user-question-reply";function viewCardText(args) {let card = args;@@ -8174,7 +8174,7 @@ function SpeakerHead({ bot, time }) {Number.isFinite(time) ? (0, import_react17.createElement)("span", { className: "bt-group-time", title: clockLabel(time) }, messageClock(time)) : null);}-var CHAIN_BREAK_SEL = ".bt-group-msg, .bt-umsg, .bt-urow, .bt-event, .bt-time-sep, .bt-new-sep, .bt-part-line, .bt-btw-card, .bt-learn-card";+var CHAIN_BREAK_SEL = ".bt-group-msg, .bt-umsg, .bt-urow, [data-chat-flow-kind=user], [data-chat-flow-kind=command-input], .bt-q-inline, .bt-event, .bt-time-sep, .bt-new-sep, .bt-part-line, .bt-btw-card, .bt-learn-card";function syncGroupChains(flow) {const items = [...flow.querySelectorAll(CHAIN_BREAK_SEL)];for (let i = 0; i < items.length; i += 1) {@@ -8198,6 +8198,15 @@ function syncGroupChains(flow) {}}}+var pendingFlows = /* @__PURE__ */ new WeakSet();+function scheduleGroupChains(flow) {+ if (!flow || pendingFlows.has(flow)) return;+ pendingFlows.add(flow);+ queueMicrotask(() => {+ pendingFlows.delete(flow);+ if (flow.isConnected !== false) syncGroupChains(flow);+ });+}function GroupMessage({ bot, text, texts: texts2 = [text], room: room2, roster, actions, msgKey, useUi, whole, time, duration }) {const ref = (0, import_react17.useRef)(null);(0, import_react17.useLayoutEffect)(() => {@@ -8205,9 +8214,9 @@ function GroupMessage({ bot, text, texts: texts2 = [text], room: room2, roster,if (!el?.closest) return void 0;const flow = el.closest("[data-chat-flow]");if (!flow) return void 0;- syncGroupChains(flow);- return () => syncGroupChains(flow);- });+ scheduleGroupChains(flow);+ return () => scheduleGroupChains(flow);+ }, [bot.id]);const lead = (0, import_react17.createElement)("button",{ type: "button", className: "bt-lead", "aria-label": t("Open {name}'s chat", { name: bot.name }), onClick: () => actions.openSession(bot.id) },diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.jsindex c00d2ddc..0127ff05 100644--- a/ds-bot/src/client/cells.js+++ b/ds-bot/src/client/cells.js@@ -320,8 +320,8 @@ function SpeakerHead({ bot, time }) {Number.isFinite(time) ? h('span', { className: 'bt-group-time', title: clockLabel(time) }, messageClock(time)) : null)}-const CHAIN_BREAK_SEL = '.bt-group-msg, .bt-umsg, .bt-urow, .bt-event, .bt-time-sep, .bt-new-sep, .bt-part-line, .bt-btw-card, .bt-learn-card'-function syncGroupChains(flow) {+const CHAIN_BREAK_SEL = '.bt-group-msg, .bt-umsg, .bt-urow, [data-chat-flow-kind=user], [data-chat-flow-kind=command-input], .bt-q-inline, .bt-event, .bt-time-sep, .bt-new-sep, .bt-part-line, .bt-btw-card, .bt-learn-card'+export function syncGroupChains(flow) {const items = [...flow.querySelectorAll(CHAIN_BREAK_SEL)]for (let i = 0; i < items.length; i += 1) {const curr = items[i]@@ -341,6 +341,16 @@ function syncGroupChains(flow) {}}+const pendingFlows = new WeakSet()+function scheduleGroupChains(flow) {+ if (!flow || pendingFlows.has(flow)) return+ pendingFlows.add(flow)+ queueMicrotask(() => {+ pendingFlows.delete(flow)+ if (flow.isConnected !== false) syncGroupChains(flow)+ })+}+// One Bot message inside a group chat: avatar, name (with its group role), when it ran// 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.@@ -351,9 +361,9 @@ function GroupMessage({ bot, text, texts = [text], room, roster, actions, msgKeyif (!el?.closest) return undefinedconst flow = el.closest('[data-chat-flow]')if (!flow) return undefined- syncGroupChains(flow)- return () => syncGroupChains(flow)- })+ scheduleGroupChains(flow)+ return () => scheduleGroupChains(flow)+ }, [bot.id])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'diff --git a/ds-bot/test/chat-rows.test.js b/ds-bot/test/chat-rows.test.jsindex 06d2ba2a..eada2a21 100644--- a/ds-bot/test/chat-rows.test.js+++ b/ds-bot/test/chat-rows.test.js@@ -25,8 +25,9 @@ runInNewContext(bundle.outputFiles[0].text, {if (!(name in platform)) throw new Error(`no platform module ${name}`)return platform[name]},+ queueMicrotask,})-const { ChatRows, ThinkingRow } = module.exports+const { ChatRows, ThinkingRow, syncGroupChains } = module.exportsconst roster = { byId: { b: { id: 'b', name: 'Writer' } }, roomsById: {} }const MINUTE = 60_000@@ -104,3 +105,28 @@ test('a settled reasoning row shows the turn’s thinking time when known', () =const untimed = ThinkingRow({ text: 'one\ntwo' })assert.equal(untimed.children[0].children.join(''), 'Thought it through')})++test('consecutive group messages from the same Bot chain together, and cards or user rows break the chain', () => {+ const node = (classes, botId, turn = {}) => ({+ dataset: botId ? { botId } : {},+ classList: { contains: name => classes.includes(name) },+ closest: sel => (sel === '[data-chat-group-key]' ? turn : null),+ })+ const t1 = { dataset: {} }, t2 = { dataset: {} }, t3 = { dataset: {} }, t4 = { dataset: {} }+ const m1 = node(['bt-group-msg'], 'a', t1)+ const m2 = node(['bt-group-msg'], 'a', t2)+ const card = node(['bt-q-inline'])+ const m3 = node(['bt-group-msg'], 'a', t3)+ const hostUser = node([], undefined)+ const m4 = node(['bt-group-msg'], 'a', t4)+ syncGroupChains({ querySelectorAll: () => [m1, m2, card, m3, hostUser, m4] })+ assert.equal(m1.dataset.chainPrev, undefined)+ assert.equal(m1.dataset.chainNext, '')+ assert.equal(t1.dataset.btChainNext, '')+ assert.equal(m2.dataset.chainPrev, '')+ assert.equal(m2.dataset.chainNext, undefined)+ assert.equal(t2.dataset.btChainPrev, '')+ assert.equal(m3.dataset.chainPrev, undefined)+ assert.equal(m3.dataset.chainNext, undefined)+ assert.equal(m4.dataset.chainPrev, undefined)+})