Skip to content

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

Keep the activity row when a streamed turn starts a tool

Fei2411ee29f4027a53
diff --git a/ds-bot/client.js b/ds-bot/client.js
index 899861be..5fed48a5 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -5855,6 +5855,7 @@ var import_react10 = require("react");
var import_react_dom2 = require("react-dom");
var PHRASE_HOLD_MS = 800;
var drawPhrase = (pool) => t(pool[Math.min(pool.length - 1, Math.floor(Math.random() * pool.length))]);
+var rowVisible = ({ running, streaming, tools, relaying, bot, room: room2 }) => running && (!streaming || tools.length > 0) && !relaying && (bot !== void 0 || room2 !== void 0);
var mountMissed = false;
function findHost() {
const node = document.querySelector("[data-chat-flow] [data-chat-running]") ?? document.querySelector("[data-chat-flow]");
@@ -5953,7 +5954,7 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
const streaming = entries2.some((entry) => entry.text);
const tools = entries2.filter((entry) => !entry.text).sort((a, b) => a.at - b.at);
const relaying = tools.some((entry) => entry.relay);
- const visible = running && !streaming && !relaying && (bot !== void 0 || room2 !== void 0);
+ const visible = rowVisible({ running, streaming, tools, relaying, bot, room: room2 });
const tool = tools.at(-1);
const inputRef = (0, import_react10.useRef)(0);
const inputAt = Math.max(inputRef.current, pendingInput);
diff --git a/ds-bot/src/client/activity-row.js b/ds-bot/src/client/activity-row.js
index f146863b..ccfc6e11 100644
--- a/ds-bot/src/client/activity-row.js
+++ b/ds-bot/src/client/activity-row.js
@@ -15,6 +15,11 @@ const PHRASE_HOLD_MS = 800
const drawPhrase = pool => t(pool[Math.min(pool.length - 1, Math.floor(Math.random() * pool.length))])
export { reducedMotion }
+// A turn that streams text first and runs a tool after keeps its row once the
+// tool starts: streaming alone hides it, but running work must not.
+export const rowVisible = ({ running, streaming, tools, relaying, bot, room }) =>
+ running && (!streaming || tools.length > 0) && !relaying && (bot !== undefined || room !== undefined)
+
// The shell's running slot can sit under wrappers it adds around the flow, so the
// search is a descendant one; without the slot the row mounts at the flow's tail.
// No flow at all is a mount failure, noted once per page — the observer keeps
@@ -114,7 +119,7 @@ export function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useL
const tools = entries.filter(entry => !entry.text).sort((a, b) => a.at - b.at)
// Group chats show who is typing on their own while members speak.
const relaying = tools.some(entry => entry.relay)
- const visible = running && !streaming && !relaying && (bot !== undefined || room !== undefined)
+ const visible = rowVisible({ running, streaming, tools, relaying, bot, room })
const tool = tools.at(-1)
const inputRef = useRef(0)
// A steer keeps the run going, so nothing else resets the row: fresh input is
diff --git a/ds-bot/test/activity-row.test.js b/ds-bot/test/activity-row.test.js
index 295f82d8..ba280329 100644
--- a/ds-bot/test/activity-row.test.js
+++ b/ds-bot/test/activity-row.test.js
@@ -15,7 +15,7 @@ const { JSDOM } = createRequire(join(process.env.DSH_HARNESS ?? join(PLUGIN, '..
const { outputFiles } = await build({
stdin: {
contents: [
- "export { findHost } from './src/client/activity-row.js'",
+ "export { findHost, rowVisible } from './src/client/activity-row.js'",
"export { clientErrors } from './src/client/diagnostics.js'",
].join('\n'),
resolveDir: PLUGIN,
@@ -39,7 +39,7 @@ runInNewContext(outputFiles[0].text, {
cancelAnimationFrame: id => clearTimeout(id),
require: name => (name === 'react' ? react : name === 'react-dom' ? { createPortal: node => node } : {}),
})
-const { findHost, clientErrors } = module.exports
+const { findHost, rowVisible, clientErrors } = module.exports
test('the activity row mounts at the running slot even under an extra wrapper', () => {
dom.window.document.body.innerHTML = '<div data-chat-flow><div class="wrap"><div data-chat-running id="slot"></div></div></div>'
@@ -62,3 +62,21 @@ test('a missing chat flow is reported once per page, not on every retry', () =>
assert.equal(entries.length, before + 1)
assert.match(entries.at(-1).text, /activity row:/)
})
+
+// The row hides while a reply streams — but a turn that streams first and runs a
+// tool after keeps the row once the tool starts.
+test('the row shows while a turn runs, also when text streamed before a tool', () => {
+ const bot = {}
+ const cases = [
+ [{ running: true, streaming: false, tools: [], relaying: false, bot }, true],
+ [{ running: true, streaming: true, tools: [], relaying: false, bot }, false],
+ [{ running: true, streaming: true, tools: [{ label: 'x' }], relaying: false, bot }, true],
+ [{ running: true, streaming: false, tools: [{ label: 'x' }], relaying: false, bot }, true],
+ [{ running: false, streaming: false, tools: [{ label: 'x' }], relaying: false, bot }, false],
+ [{ running: true, streaming: true, tools: [{ relay: true }], relaying: true, bot }, false],
+ [{ running: true, streaming: false, tools: [{ relay: true }], relaying: true, bot }, false],
+ [{ running: true, streaming: false, tools: [], relaying: false }, false],
+ [{ running: true, streaming: false, tools: [], relaying: false, room: {} }, true],
+ ]
+ for (const [input, expected] of cases) assert.equal(rowVisible(input), expected, JSON.stringify(input))
+})