Skip to content

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

Preview what a running Bot is doing in the sidebar

Fei24119e97bb70f724
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 5fed48a5..1e00fbf0 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -6046,6 +6046,7 @@ var useGroupWork = (useWork, pick2) => useWork ? useWork((work) => JSON.stringif
var workKeys = (text) => JSON.parse(text);
var doingOf = ({ tool, said, note, target, switching }) => ({ tool, said, note, target, switching });
var workLine = (lead, doing, more) => (0, import_react11.createElement)(Shimmer, null, `${lead} · ${workPhrase(doing)}…${more > 0 ? ` +${more}` : ""}`);
+var doingLine = (doing) => (0, import_react11.createElement)(Shimmer, null, `${workPhrase(doing)}…`);
var waitingFor = (roster, waits) => {
const names = [...(waits?.bots ?? []).map((id) => roster.byId[id]?.name), ...(waits?.rooms ?? []).map((id) => roster.roomsById[id]?.name)].filter(Boolean);
return names.length === 0 ? "" : t("Waiting for {names}", { names: names.join(t(" and ")) });
@@ -6066,7 +6067,7 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
const groups = workKeys(useGroupWork(useWork, (rooms) => Object.entries(rooms).flatMap(([roomId, entries2]) => entries2.filter((entry) => entry.botId === id).map((entry) => ({ id: roomId, ...doingOf(entry) })))));
const away = !running && groups.length > 0;
const state = botState(running || away, doing, alert);
- const runningLine = running && doing ? workLine(bot.name, doing, 0) : null;
+ const runningLine = running && doing ? doingLine(doing) : null;
const awayLine = away ? workLine(roster.roomsById[groups[0].id]?.name ?? t("a group chat"), groups[0], groups.length - 1) : null;
const waits = workKeys(useWork ? useWork((work) => JSON.stringify(work.waiting?.[id] ?? null)) : "null");
const waitsFor = state === "waiting" ? waitingFor(roster, waits) : "";
diff --git a/ds-bot/src/client/sidebar.js b/ds-bot/src/client/sidebar.js
index 5b0e1933..8f6c95b6 100644
--- a/ds-bot/src/client/sidebar.js
+++ b/ds-bot/src/client/sidebar.js
@@ -35,6 +35,8 @@ const useGroupWork = (useWork, pick) => (useWork ? useWork(work => JSON.stringif
const workKeys = text => JSON.parse(text)
const doingOf = ({ tool, said, note, target, switching }) => ({ tool, said, note, target, switching })
const workLine = (lead, doing, more) => h(Shimmer, null, `${lead} · ${workPhrase(doing)}…${more > 0 ? ` +${more}` : ''}`)
+// The row already names the Bot; its own-chat preview is just what it is doing.
+const doingLine = doing => h(Shimmer, null, `${workPhrase(doing)}…`)
// The Bots and groups a Bot waits for (handoffs.js), by the names they have now.
const waitingFor = (roster, waits) => {
const names = [...(waits?.bots ?? []).map(id => roster.byId[id]?.name), ...(waits?.rooms ?? []).map(id => roster.roomsById[id]?.name)].filter(Boolean)
@@ -58,6 +60,8 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
const groups = workKeys(useGroupWork(useWork, rooms => Object.entries(rooms).flatMap(([roomId, entries]) => entries.filter(entry => entry.botId === id).map(entry => ({ id: roomId, ...doingOf(entry) })))))
const away = !running && groups.length > 0
const state = botState(running || away, doing, alert)
+ // A Bot running in its own chat previews what it is doing, like a group's row.
+ const runningLine = running && doing ? doingLine(doing) : null
const awayLine = away ? workLine(roster.roomsById[groups[0].id]?.name ?? t('a group chat'), groups[0], groups.length - 1) : null
const waits = workKeys(useWork ? useWork(work => JSON.stringify(work.waiting?.[id] ?? null)) : 'null')
const waitsFor = state === 'waiting' ? waitingFor(roster, waits) : ''
@@ -85,9 +89,10 @@ function BotRow({ bot, roster, actions, useSessions, useSessionStatus, useSessio
pinned && !wide ? h(PinMark) : null,
wide ? h('span', { className: 'bt-row-body' },
h('span', { className: 'bt-row-name' }, h('span', { className: 'bt-row-title' }, bot.name), pinned ? h(PinMark) : null),
- awayLine ? h('span', { className: 'bt-row-preview' }, awayLine)
- : waitsFor ? h('span', { className: 'bt-row-preview' }, waitsFor)
- : preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,
+ runningLine ? h('span', { className: 'bt-row-preview' }, runningLine)
+ : awayLine ? h('span', { className: 'bt-row-preview' }, awayLine)
+ : waitsFor ? h('span', { className: 'bt-row-preview' }, waitsFor)
+ : preview ? h('span', { className: 'bt-row-preview' }, preview) : null) : null,
wide && unread && !active ? h('span', { className: 'bt-unread', 'aria-hidden': true }) : null)
}
diff --git a/ds-bot/test/sidebar-switch.test.js b/ds-bot/test/sidebar-switch.test.js
index 2c16f037..af4a499e 100644
--- a/ds-bot/test/sidebar-switch.test.js
+++ b/ds-bot/test/sidebar-switch.test.js
@@ -164,6 +164,98 @@ test('the navigation guard resets across a full collapse and expansion cycle', (
assert.equal(side.collapsed, true)
})
+// A Bot working in its own chat previews what it is doing, the way a group row does
+// for members at work; an idle Bot keeps the last message preview.
+test('a running Bot\'s sidebar row shows what it is doing', () => {
+ viewport.innerWidth = 1280
+ const bot = { id: 'writer', name: 'Writer', createdAt: 1 }
+ const roster = { bots: [bot], rooms: [], agents: [], byId: { writer: bot }, ready: true, exchangeTurns: {} }
+ const rows = []
+ const walk = (node) => {
+ if (Array.isArray(node)) { node.forEach(walk); return }
+ if (!node || typeof node !== 'object') return
+ if (node.type?.name === 'BotRow') rows.push(node)
+ walk(node.props?.children)
+ }
+ const tree = TeamSidebar({
+ wide: true,
+ actions: Object.fromEntries(['openSession', 'openAgent', 'openAgentSession', 'newAgentSession', 'openMenu', 'openPalette', 'openNewChat', 'toggleSidebar', 'clearUnread'].map(name => [name, () => {}])),
+ useRoster: pick => pick(roster), useUi: pick => pick({ unread: {} }), useRegistry: pick => pick({}),
+ useSessions: pick => pick({ ids: [], byId: {} }), useUpdate: () => ({}),
+ useSessionStatus: pick => pick(new Map([['writer', { running: true }]])),
+ useSessionRetainInfo: () => null,
+ useActivity: pick => pick({ writer: 'working' }),
+ useWork: pick => pick({ waiting: {}, rooms: {}, approvals: [] }),
+ })
+ walk(tree)
+ assert.equal(rows.length, 1)
+ // BotRow renders as a function component: run it, then flatten Shimmer and the
+ // other function children to read the preview line's text.
+ const expand = (node) => {
+ if (Array.isArray(node)) return node.map(expand)
+ if (!node || typeof node !== 'object') return node
+ if (typeof node.type === 'function') return expand(node.type(node.props))
+ return { ...node, props: { ...node.props, children: expand(node.props.children) } }
+ }
+ const previews = []
+ const collect = (node) => {
+ if (Array.isArray(node)) { node.forEach(collect); return }
+ if (!node || typeof node !== 'object') return
+ if (node.props?.className === 'bt-row-preview') previews.push(node)
+ collect(node.props?.children)
+ }
+ const textOf = (node) => {
+ if (node === null || node === undefined || typeof node === 'boolean') return ''
+ if (typeof node === 'string' || typeof node === 'number') return String(node)
+ if (Array.isArray(node)) return node.map(textOf).join('')
+ return textOf(node.props?.children)
+ }
+ collect(expand(rows[0].type(rows[0].props)))
+ assert.equal(previews.length, 1)
+ // The row already says Writer, so the preview is the doing phrase alone.
+ assert.match(textOf(previews[0]), /^.+…$/)
+ assert.doesNotMatch(textOf(previews[0]), /^Writer ·/)
+})
+
+test('an idle Bot\'s sidebar row keeps the message preview', () => {
+ viewport.innerWidth = 1280
+ const bot = { id: 'writer', name: 'Writer', createdAt: 1 }
+ const roster = { bots: [bot], rooms: [], agents: [], byId: { writer: bot }, ready: true, exchangeTurns: {} }
+ const rows = []
+ const walk = (node) => {
+ if (Array.isArray(node)) { node.forEach(walk); return }
+ if (!node || typeof node !== 'object') return
+ if (node.type?.name === 'BotRow') rows.push(node)
+ walk(node.props?.children)
+ }
+ const tree = TeamSidebar({
+ wide: true,
+ actions: Object.fromEntries(['openSession', 'openAgent', 'openAgentSession', 'newAgentSession', 'openMenu', 'openPalette', 'openNewChat', 'toggleSidebar', 'clearUnread'].map(name => [name, () => {}])),
+ useRoster: pick => pick(roster), useUi: pick => pick({ unread: {} }), useRegistry: pick => pick({}),
+ useSessions: pick => pick({ ids: [], byId: {} }), useUpdate: () => ({}),
+ useSessionStatus: pick => pick(new Map()),
+ useSessionRetainInfo: () => null,
+ useActivity: pick => pick({}),
+ useWork: pick => pick({ waiting: {}, rooms: {}, approvals: [] }),
+ })
+ walk(tree)
+ const expand = (node) => {
+ if (Array.isArray(node)) return node.map(expand)
+ if (!node || typeof node !== 'object') return node
+ if (typeof node.type === 'function') return expand(node.type(node.props))
+ return { ...node, props: { ...node.props, children: expand(node.props.children) } }
+ }
+ const previews = []
+ const collect = (node) => {
+ if (Array.isArray(node)) { node.forEach(collect); return }
+ if (!node || typeof node !== 'object') return
+ if (node.props?.className === 'bt-row-preview') previews.push(node)
+ collect(node.props?.children)
+ }
+ collect(expand(rows[0].type(rows[0].props)))
+ assert.equal(previews.length, 0)
+})
+
test('preparing sidebar navigation leaves actions elsewhere unchanged', () => {
viewport.innerWidth = 390
const { actions, calls } = navigationSidebar(true)