Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Stack a group member's messages in a row under its name

Fei241137a9cd478ffc
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 3dec7061..698b158c 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -3978,7 +3978,7 @@ function EventLine({ prefix, bots, joiner = t("and"), onOpen, whole = false }) {
});
return (0, import_react6.createElement)("div", { className: "bt-event" }, parts);
}
-function GroupMessage({ bot, text, room: room2, roster, actions, msgKey, useUi }) {
+function GroupMessage({ bot, text, texts: texts2 = [text], room: room2, roster, actions, msgKey, useUi }) {
const lead = (0, import_react6.createElement)(
"button",
{ type: "button", className: "bt-lead", "aria-label": t("Open {name}'s chat", { name: bot.name }), onClick: () => actions.openSession(bot.id) },
@@ -3993,9 +3993,18 @@ function GroupMessage({ bot, text, room: room2, roster, actions, msgKey, useUi }
bot.name,
room2?.admin === bot.id ? (0, import_react6.createElement)("span", { className: "bt-group-role" }, t("Admin")) : null
),
- (0, import_react6.createElement)(Bubbles, { texts: [text], roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead })
+ (0, import_react6.createElement)(Bubbles, { texts: texts2, roster, selfId: bot.id, actions, sessionId: room2?.id, msgKey, useUi, lead })
);
}
+function stackReplies(replies) {
+ const items = [];
+ replies.forEach((reply, index) => {
+ const last = items.at(-1);
+ if (reply.kind === void 0 && last?.reply.kind === void 0 && last?.reply.botId === reply.botId) last.texts.push(reply.text);
+ else items.push({ reply, index, texts: reply.kind === void 0 ? [reply.text] : [] });
+ });
+ return items;
+}
function GroupEvent({ prefix, room: room2, name, roster, actions }) {
return (0, import_react6.createElement)(
"div",
@@ -4382,7 +4391,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
return (0, import_react6.createElement)(
"div",
{ className: "bt-group-replies" },
- replies.map((reply, index) => {
+ stackReplies(replies).map(({ reply, index, texts: texts2 }) => {
const bot = roster.byId[reply.botId] ?? { id: reply.botId, name: reply.name, color: reply.color ?? "gray" };
if (reply.kind === "user") {
return (0, import_react6.createElement)("div", { key: `user-${index}`, className: "bt-urow" }, (0, import_react6.createElement)(
@@ -4429,7 +4438,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
if (reply.kind === "stopped") {
return (0, import_react6.createElement)("div", { key: `${reply.botId}-${index}`, className: "bt-event" }, t("You stopped {name}'s work", { name: bot.name }));
}
- return (0, import_react6.createElement)(GroupMessage, { key: `${reply.botId}-${index}`, bot, text: reply.text, room: room2, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : void 0, useUi });
+ return (0, import_react6.createElement)(GroupMessage, { key: `${reply.botId}-${index}`, bot, texts: texts2, room: room2, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : void 0, useUi });
}),
pending.map((id) => {
const bot = roster.byId[id];
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index 0d404884..4656057f 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -171,13 +171,25 @@ function EventLine({ prefix, bots, joiner = t('and'), onOpen, whole = false }) {
}
// One Bot message inside a group chat: avatar, name (with its group role), bubble.
-function GroupMessage({ bot, text, room, roster, actions, msgKey, useUi }) {
+function GroupMessage({ bot, text, texts = [text], room, roster, actions, msgKey, useUi }) {
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 }))
return h('div', { className: 'bt-group-msg' },
h('span', { className: 'bt-group-name', style: { color: inkText(colorOf(bot)) } }, bot.name,
room?.admin === bot.id ? h('span', { className: 'bt-group-role' }, t('Admin')) : null),
- h(Bubbles, { texts: [text], roster, selfId: bot.id, actions, sessionId: room?.id, msgKey, useUi, lead }))
+ h(Bubbles, { texts, roster, selfId: bot.id, actions, sessionId: room?.id, msgKey, useUi, lead }))
+}
+
+// A member's messages in a row, as one block under its name: what it says while it
+// works comes one message at a time.
+export function stackReplies(replies) {
+ const items = []
+ replies.forEach((reply, index) => {
+ const last = items.at(-1)
+ if (reply.kind === undefined && last?.reply.kind === undefined && last?.reply.botId === reply.botId) last.texts.push(reply.text)
+ else items.push({ reply, index, texts: reply.kind === undefined ? [reply.text] : [] })
+ })
+ return items
}
// A centered event line that names a group chat and opens it.
@@ -575,7 +587,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
if (replies.length === 0 && pending.length === 0) return null
const room = roster.roomsById[sessionId]
return h('div', { className: 'bt-group-replies' },
- replies.map((reply, index) => {
+ stackReplies(replies).map(({ reply, index, texts }) => {
const bot = roster.byId[reply.botId] ?? { id: reply.botId, name: reply.name, color: reply.color ?? 'gray' }
if (reply.kind === 'user') {
return h('div', { key: `user-${index}`, className: 'bt-urow' }, h('div', { className: 'bt-ububble' },
@@ -606,7 +618,7 @@ function GroupReplies({ sessionId, callId, done, content, roster, actions, useUi
if (reply.kind === 'stopped') {
return h('div', { key: `${reply.botId}-${index}`, className: 'bt-event' }, t("You stopped {name}'s work", { name: bot.name }))
}
- return h(GroupMessage, { key: `${reply.botId}-${index}`, bot, text: reply.text, room, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : undefined, useUi })
+ return h(GroupMessage, { key: `${reply.botId}-${index}`, bot, texts, room, roster, actions, msgKey: callId ? `${sessionId}:${callId}:${index}` : undefined, useUi })
}),
pending.map((id) => {
const bot = roster.byId[id]
diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.js
index 417c6221..ec43fb05 100644
--- a/ds-bot/test/tool-cells.test.js
+++ b/ds-bot/test/tool-cells.test.js
@@ -9,7 +9,7 @@ import { build } from 'esbuild'
const { outputFiles } = await build({
stdin: {
contents: [
- "export { ToolCell, TriggerCell, callTree } from './src/client/cells.js'",
+ "export { ToolCell, TriggerCell, callTree, stackReplies } from './src/client/cells.js'",
"export { QuestionDock } from './src/client/questions.js'",
"export { SecretDock } from './src/client/secret-card.js'",
"export { countCards } from './src/client/sources.js'",
@@ -44,7 +44,7 @@ runInNewContext(outputFiles[0].text, {
throw new Error(`Unexpected platform module ${name}`)
},
})
-const { ToolCell, TriggerCell, callTree, QuestionDock, SecretDock, countCards } = module.exports
+const { ToolCell, TriggerCell, callTree, stackReplies, QuestionDock, SecretDock, countCards } = module.exports
// Runs the effects collected since the last render; returns the cleanups.
const mount = () => {
@@ -87,6 +87,14 @@ const call = (name, callId, { args = {}, content = '', subCalls = [], running =
: { kind: 'tool-result', name, callId, call: { name, argsRaw: JSON.stringify(args) }, content: text$(content), isError, subCalls })
const program = (subCalls, over = {}) => call('run_code', 'program', { subCalls, ...over })
+test('a member\'s messages in a row stack under its name, and an event line starts a new block', () => {
+ const replies = [
+ { botId: 'writer', text: 'a' }, { botId: 'writer', text: 'b' }, { kind: 'working', botId: 'writer' },
+ { botId: 'writer', text: 'c' }, { botId: 'chief', text: 'd' }, { botId: 'writer', text: 'e' },
+ ]
+ assert.deepEqual(JSON.parse(JSON.stringify(stackReplies(replies).map(item => [item.index, item.texts]))), [[0, ['a', 'b']], [2, []], [3, ['c']], [4, ['d']], [5, ['e']]])
+})
+
const props = (root, { sessionId = chief.id, roster = team(), actions = {}, turn = 1 } = {}) => ({
node: { key: 'node', data: { root }, location: { turn: { turn } } }, sessionId,
useRoster: select => select(roster), useUi: select => select({ reactions: {}, visits: {} }), actions,