Skip to content

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

Fix side chat review findings

Fei241177902903a215
diff --git a/docs/plans/2026-10-21-btw.md b/docs/plans/2026-10-21-btw.md
index a8a3d810..6df44b02 100644
--- a/docs/plans/2026-10-21-btw.md
+++ b/docs/plans/2026-10-21-btw.md
@@ -49,7 +49,7 @@ Bot 之间也有反方向「拉」事实的需求(我需要对方掌握的事
### 旧的 `/btw` 卡片
-- `/btw` 命令移除,输入 `/btw` 按普通文本发出。已有问答卡片保留在原分段的原回合处,只读展示,不提供取消。
+- `/btw` 命令移除,输入 `/btw` 按普通文本发出。已有问答卡片留在原处只读展示:已关闭回合的卡片挂在回合尾,回合还开着或找不到所属回合的卡片挂在输入框上方的泊位;不提供取消。
## 不做什么
diff --git a/ds-bot/client.js b/ds-bot/client.js
index d10d4169..4983c700 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -6939,6 +6939,13 @@ function useTurnFacts(sessionId, actions) {
}, [sessionId, actions]);
return facts;
}
+function BtwDock({ sessionId, useRoster, actions }) {
+ const roster = useRoster((value) => value);
+ const facts = useTurnFacts(sessionId, actions);
+ const cards = dockCards(sessionCards(roster, sessionId), facts);
+ if (cards.length === 0) return null;
+ return (0, import_react11.createElement)("div", { className: "bt-btw-dock" }, cards.map((card) => (0, import_react11.createElement)(BtwCardView, { key: card.id, card, compact: true })));
+}
function BtwTurnTail({ turn, sessionId, useRoster, actions }) {
const roster = useRoster((value) => value);
const facts = useTurnFacts(sessionId, actions);
@@ -9646,6 +9653,7 @@ function SideEntry({ chatId, entry, actions }) {
function SideChatView({ subject, chat, actions }) {
const scroll = (0, import_react17.useRef)(null);
const [draft, setDraft] = (0, import_react17.useState)("");
+ const [fail2, setFail] = (0, import_react17.useState)(null);
const entries2 = Array.isArray(chat?.entries) ? chat.entries : [];
const busy = entries2.some((entry) => entry?.status === "answering");
const last = entries2.at(-1);
@@ -9658,7 +9666,10 @@ function SideChatView({ subject, chat, actions }) {
const text = draft.trim();
if (text === "" || busy || typeof actions?.askSide !== "function") return;
setDraft("");
- Promise.resolve(actions.askSide(subject, chat.id, text)).catch(() => {
+ setFail(null);
+ Promise.resolve(actions.askSide(subject, chat.id, text)).catch((error) => {
+ setDraft((value) => value === "" ? text : value);
+ setFail(hostText(error?.message ?? ""));
});
};
return (0, import_react17.createElement)(
@@ -9680,13 +9691,17 @@ function SideChatView({ subject, chat, actions }) {
disabled: busy,
placeholder: t("Ask about the work so far"),
"aria-label": t("Ask about the work so far"),
- onChange: (event) => setDraft(event.target.value),
+ onChange: (event) => {
+ setDraft(event.target.value);
+ if (fail2 !== null) setFail(null);
+ },
onKeyDown: (event) => {
if (event.key !== "Enter" || event.shiftKey || event.nativeEvent?.isComposing) return;
event.preventDefault();
ask();
}
- })
+ }),
+ fail2 !== null ? (0, import_react17.createElement)("p", { className: "bt-side-fail" }, fail2) : null
)
);
}
@@ -16225,17 +16240,20 @@ function PanelMenu({ items, className, "aria-label": label }) {
);
}
function menuItemFor(key, actions, subject) {
+ const report = (run2) => () => {
+ void Promise.resolve(run2()).catch((error) => actions.reportError(error, "panel-menu"));
+ };
switch (key) {
case "browser":
- return { key, icon: GlobeIcon, label: t("Browser"), onPick: () => actions.openBrowser(subject) };
+ return { key, icon: GlobeIcon, label: t("Browser"), onPick: report(() => actions.openBrowser(subject)) };
case "new-tab":
- return { key, icon: PlusTabIcon, label: t("New browser tab"), onPick: () => actions.browserNewTab(subject) };
+ return { key, icon: PlusTabIcon, label: t("New browser tab"), onPick: report(() => actions.browserNewTab(subject)) };
case "side":
- return { key, icon: SideIcon, label: t("Side chat"), onPick: () => actions.newSideChat(subject) };
+ return { key, icon: SideIcon, label: t("Side chat"), onPick: report(() => actions.newSideChat(subject)) };
case "terminal":
- return { key, icon: TerminalIcon, label: t("Terminal"), onPick: () => actions.newTerminal() };
+ return { key, icon: TerminalIcon, label: t("Terminal"), onPick: report(() => actions.newTerminal()) };
case "files":
- return { key, icon: FolderIcon, label: t("Files"), onPick: () => actions.openFiles() };
+ return { key, icon: FolderIcon, label: t("Files"), onPick: report(() => actions.openFiles()) };
default:
return { sep: true };
}
@@ -18948,7 +18966,8 @@ function apply(ctx) {
() => installCompiledStyles(USER_MESSAGE_CSS, "user-messages"),
() => installCompiledStyles(WIDGET_CSS, "widgets"),
() => installCompiledStyles(SIDE_CSS, "side"),
- browsers ? () => installCompiledStyles(BROWSER_CSS, "browser") : null,
+ // Strip and panel styles also serve the side-chat tabs, which need no bridge.
+ () => installCompiledStyles(BROWSER_CSS, "browser"),
() => installTheme(),
() => shadow("sidebar.workspaces", { priority: BOT_PRIORITY, inject: face }, TeamSidebar),
() => shadow("sidebar.brand.mark", { priority: BOT_PRIORITY }, BrandMark),
@@ -18993,6 +19012,7 @@ function apply(ctx) {
() => shadow("conversation.input.model", { priority: BOT_PRIORITY }, Nothing),
() => shadow("conversation.composer.dock", { id: "activity", order: 0, priority: BOT_PRIORITY }, Nothing),
() => shadow("conversation.composer.dock", { id: "usage", order: 1, priority: BOT_PRIORITY }, Nothing),
+ () => shadow("conversation.composer.dock", { id: "btw", order: 2, priority: BOT_PRIORITY, inject: face }, BtwDock),
() => shadow("conversation.input.left", { id: "bot-plus", order: -100, inject: face }, ComposerPlus),
() => shadow("conversation.input.right", { id: "bot-voice", order: 100, inject: face }, ComposerVoice),
() => shadow("conversation.composer", {
diff --git a/ds-bot/src/client/browser-pane.js b/ds-bot/src/client/browser-pane.js
index a74161cd..09c1b2cc 100644
--- a/ds-bot/src/client/browser-pane.js
+++ b/ds-bot/src/client/browser-pane.js
@@ -155,14 +155,15 @@ export function PanelMenu({ items, className, 'aria-label': label }) {
}
// The menu builders in side-model.js give keys; each maps to an icon, a label
-// and the action it runs.
+// and the action it runs. A rejected action surfaces through reportError.
export function menuItemFor(key, actions, subject) {
+ const report = run => () => { void Promise.resolve(run()).catch(error => actions.reportError(error, 'panel-menu')) }
switch (key) {
- case 'browser': return { key, icon: GlobeIcon, label: t('Browser'), onPick: () => actions.openBrowser(subject) }
- case 'new-tab': return { key, icon: PlusTabIcon, label: t('New browser tab'), onPick: () => actions.browserNewTab(subject) }
- case 'side': return { key, icon: SideIcon, label: t('Side chat'), onPick: () => actions.newSideChat(subject) }
- case 'terminal': return { key, icon: TerminalIcon, label: t('Terminal'), onPick: () => actions.newTerminal() }
- case 'files': return { key, icon: FolderIcon, label: t('Files'), onPick: () => actions.openFiles() }
+ case 'browser': return { key, icon: GlobeIcon, label: t('Browser'), onPick: report(() => actions.openBrowser(subject)) }
+ case 'new-tab': return { key, icon: PlusTabIcon, label: t('New browser tab'), onPick: report(() => actions.browserNewTab(subject)) }
+ case 'side': return { key, icon: SideIcon, label: t('Side chat'), onPick: report(() => actions.newSideChat(subject)) }
+ case 'terminal': return { key, icon: TerminalIcon, label: t('Terminal'), onPick: report(() => actions.newTerminal()) }
+ case 'files': return { key, icon: FolderIcon, label: t('Files'), onPick: report(() => actions.openFiles()) }
default: return { sep: true }
}
}
diff --git a/ds-bot/src/client/btw.js b/ds-bot/src/client/btw.js
index 4769f278..c13b257f 100644
--- a/ds-bot/src/client/btw.js
+++ b/ds-bot/src/client/btw.js
@@ -3,7 +3,7 @@ import { createElement as h, useEffect, useState } from 'react'
import { MarkdownText } from './dsh-primitives.js'
import { hostText, t } from './i18n.js'
import { messageClock } from './text.js'
-import { sessionCards, tailCards } from './btw-model.js'
+import { dockCards, sessionCards, tailCards } from './btw-model.js'
export const mdLabels = () => ({ code: { copyLabel: t('Copy'), copiedLabel: t('Copied') }, footnotes: t('Footnotes') })
@@ -67,6 +67,16 @@ function useTurnFacts(sessionId, actions) {
return facts
}
+// Cards whose turn is still open, or that no closed turn owns, sit in the
+// composer dock. Read-only like the rest: no new cards can arrive.
+export function BtwDock({ sessionId, useRoster, actions }) {
+ const roster = useRoster(value => value)
+ const facts = useTurnFacts(sessionId, actions)
+ const cards = dockCards(sessionCards(roster, sessionId), facts)
+ if (cards.length === 0) return null
+ return h('div', { className: 'bt-btw-dock' }, cards.map(card => h(BtwCardView, { key: card.id, card, compact: true })))
+}
+
export function BtwTurnTail({ turn, sessionId, useRoster, actions }) {
const roster = useRoster(value => value)
const facts = useTurnFacts(sessionId, actions)
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index f8a5c961..49dc509a 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -11,7 +11,7 @@ import { TeamSidebar, ConnectPlugins, YouAvatar, AccountLauncher, FooterAccount,
import { HeaderPill } from './header.js'
import { ComposerPlus, ComposerVoice, menuIcons } from './composer.js'
import { CHATS_SOURCE, atSources } from './at-menu.js'
-import { BtwTurnTail } from './btw.js'
+import { BtwDock, BtwTurnTail } from './btw.js'
import { SIDE_CSS, sideSource } from './side-chat.js'
import { VOICE_BUNDLE } from './speech.js'
import { sameVersion } from './dsh-offer.js'
@@ -771,7 +771,8 @@ export function apply(ctx) {
() => installCompiledStyles(USER_MESSAGE_CSS, 'user-messages'),
() => installCompiledStyles(WIDGET_CSS, 'widgets'),
() => installCompiledStyles(SIDE_CSS, 'side'),
- browsers ? () => installCompiledStyles(BROWSER_CSS, 'browser') : null,
+ // Strip and panel styles also serve the side-chat tabs, which need no bridge.
+ () => installCompiledStyles(BROWSER_CSS, 'browser'),
() => installTheme(),
() => shadow('sidebar.workspaces', { priority: BOT_PRIORITY, inject: face }, TeamSidebar),
() => shadow('sidebar.brand.mark', { priority: BOT_PRIORITY }, BrandMark),
@@ -816,6 +817,7 @@ export function apply(ctx) {
() => shadow('conversation.input.model', { priority: BOT_PRIORITY }, Nothing),
() => shadow('conversation.composer.dock', { id: 'activity', order: 0, priority: BOT_PRIORITY }, Nothing),
() => shadow('conversation.composer.dock', { id: 'usage', order: 1, priority: BOT_PRIORITY }, Nothing),
+ () => shadow('conversation.composer.dock', { id: 'btw', order: 2, priority: BOT_PRIORITY, inject: face }, BtwDock),
() => shadow('conversation.input.left', { id: 'bot-plus', order: -100, inject: face }, ComposerPlus),
() => shadow('conversation.input.right', { id: 'bot-voice', order: 100, inject: face }, ComposerVoice),
() => shadow('conversation.composer', {
diff --git a/ds-bot/src/client/side-chat.js b/ds-bot/src/client/side-chat.js
index 01122148..bf762a75 100644
--- a/ds-bot/src/client/side-chat.js
+++ b/ds-bot/src/client/side-chat.js
@@ -4,7 +4,7 @@
import { createElement as h, useEffect, useRef, useState } from 'react'
import { call } from './api.js'
import { MarkdownText } from './dsh-primitives.js'
-import { t } from './i18n.js'
+import { hostText, t } from './i18n.js'
import { failureText, mdLabels } from './btw.js'
import {
SIDE_SOURCE, SIDE_TOKEN, matchSideClaim, matchSideEnter, matchSideSpace, sideQueryMatches, sideSurface, submitSide,
@@ -37,6 +37,7 @@ function SideEntry({ chatId, entry, actions }) {
export function SideChatView({ subject, chat, actions }) {
const scroll = useRef(null)
const [draft, setDraft] = useState('')
+ const [fail, setFail] = useState(null)
const entries = Array.isArray(chat?.entries) ? chat.entries : []
const busy = entries.some(entry => entry?.status === 'answering')
const last = entries.at(-1)
@@ -49,7 +50,12 @@ export function SideChatView({ subject, chat, actions }) {
const text = draft.trim()
if (text === '' || busy || typeof actions?.askSide !== 'function') return
setDraft('')
- Promise.resolve(actions.askSide(subject, chat.id, text)).catch(() => {})
+ setFail(null)
+ Promise.resolve(actions.askSide(subject, chat.id, text)).catch((error) => {
+ // A refused question keeps what was typed unless a new draft replaced it.
+ setDraft(value => (value === '' ? text : value))
+ setFail(hostText(error?.message ?? ''))
+ })
}
return h('div', { className: 'bt-side' },
h('p', { className: 'bt-side-note' }, t('Answered from progress so far; nothing was run')),
@@ -60,13 +66,14 @@ export function SideChatView({ subject, chat, actions }) {
className: 'bt-side-input', rows: 1, value: draft, disabled: busy,
placeholder: t('Ask about the work so far'),
'aria-label': t('Ask about the work so far'),
- onChange: event => setDraft(event.target.value),
+ onChange: (event) => { setDraft(event.target.value); if (fail !== null) setFail(null) },
onKeyDown: (event) => {
if (event.key !== 'Enter' || event.shiftKey || event.nativeEvent?.isComposing) return
event.preventDefault()
ask()
},
- })))
+ }),
+ fail !== null ? h('p', { className: 'bt-side-fail' }, fail) : null))
}
export function sideSource({ roster, actions }) {
diff --git a/ds-bot/test/btw-client.test.js b/ds-bot/test/btw-client.test.js
index 7eaf1551..dfc4b4ed 100644
--- a/ds-bot/test/btw-client.test.js
+++ b/ds-bot/test/btw-client.test.js
@@ -265,3 +265,59 @@ test('a card whose turn is not loaded stays in the trailing block', () => {
'user:progress', 'bot:working', 'user:next', 'bot:ok', 'user:later', 'bot:more', 'btw:gone',
])
})
+
+// BtwDock, bundled and rendered with a minimal React stand-in: the dock is the
+// composer slot for cards whose turn is still open or matches nothing closed.
+// Old cards are read-only, so the dock shows no Cancel.
+import { fileURLToPath } from 'node:url'
+import { runInNewContext } from 'node:vm'
+import { build } from 'esbuild'
+
+const btwBundle = await build({
+ entryPoints: [fileURLToPath(new URL('../src/client/btw.js', import.meta.url))],
+ bundle: true, format: 'cjs', platform: 'node', write: false,
+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
+})
+const btwModule = { exports: {} }
+runInNewContext(btwBundle.outputFiles[0].text, {
+ module: btwModule, exports: btwModule.exports, URL, URLSearchParams, setTimeout, clearTimeout,
+ window: { addEventListener() {}, removeEventListener() {}, innerWidth: 1280 },
+ require: (name) => {
+ const platform = {
+ react: {
+ createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
+ useState: init => [typeof init === 'function' ? init() : init, () => {}],
+ useEffect: () => {}, useRef: () => ({ current: null }),
+ useLayoutEffect: () => {}, useMemo: make => make(), useCallback: fn => fn,
+ useSyncExternalStore: (_subscribe, get) => get(), Fragment: 'fragment',
+ },
+ 'react-dom': { createPortal: node => node },
+ '@deepseek-ai/dsh-client-ui-primitives': { MarkdownText: () => null },
+ }
+ if (!(name in platform)) throw new Error(`no platform module ${name}`)
+ return platform[name]
+ },
+})
+const { BtwDock } = btwModule.exports
+
+const findIn = (node, match, out = []) => {
+ if (Array.isArray(node)) node.forEach(child => findIn(child, match, out))
+ else if (node !== null && typeof node === 'object') {
+ if (match(node)) out.push(node)
+ for (const child of node.children ?? []) findIn(child, match, out)
+ }
+ return out
+}
+
+test('an open-turn card renders in the dock without a Cancel button', () => {
+ const card = { id: 'c1', partId: 's', status: 'done', question: 'q?', answer: 'a.', atSeq: null, createdAt: 1, finishedAt: 2 }
+ const roster = { ready: true, btwCards: { bot: [card] }, byId: { s: { id: 'bot', sessionId: 's' } }, roomsById: {} }
+ const actions = { turnFacts: () => ({ turns: new Map(), openTurn: { seq: 1 } }), watchTurns: () => () => {} }
+ const tree = BtwDock({ sessionId: 's', useRoster: select => select(roster), actions })
+ assert.equal(findIn(tree, node => node.props?.className === 'bt-btw-dock').length, 1)
+ // The card component sits in the tree as a vnode; render it to see the card.
+ const [cardNode] = findIn(tree, node => typeof node.type === 'function' && node.props?.card?.id === 'c1')
+ const view = cardNode.type(cardNode.props)
+ assert.equal(view.props.className, 'bt-btw bt-btw-compact')
+ assert.equal(findIn(view, node => node.props?.className === 'bt-btw-cancel').length, 0)
+})
diff --git a/ds-bot/test/side-panel.test.js b/ds-bot/test/side-panel.test.js
index 3f20571f..d4dda64e 100644
--- a/ds-bot/test/side-panel.test.js
+++ b/ds-bot/test/side-panel.test.js
@@ -85,3 +85,81 @@ test('the `···` button opens the menu with an item per entry', () => {
test('an empty list renders no button', () => {
assert.equal(PanelMenu({ items: [], className: 'bt-round', 'aria-label': 'More' }), null)
})
+
+test('a rejecting menu action reports through reportError', async () => {
+ const calls = []
+ const actions = {
+ newSideChat: () => Promise.reject(new Error('no model yet')),
+ reportError: (error, area) => calls.push([area, error.message]),
+ }
+ menuItemFor('side', actions, 's').onPick()
+ await new Promise(resolve => setTimeout(resolve, 0))
+ assert.deepEqual(calls, [['panel-menu', 'no model yet']])
+})
+
+// side-chat.js, bundled the same way; useState returns queued pairs so a test
+// controls draft/fail and records what the setters get.
+const sideBundle = await build({
+ entryPoints: [fileURLToPath(new URL('../src/client/side-chat.js', import.meta.url))],
+ bundle: true, format: 'cjs', platform: 'node', write: false,
+ external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
+})
+const sideExports = (states) => {
+ const sideModule = { exports: {} }
+ let hook = 0
+ runInNewContext(sideBundle.outputFiles[0].text, {
+ module: sideModule, exports: sideModule.exports, URL, URLSearchParams, setTimeout, clearTimeout,
+ window: { addEventListener() {}, removeEventListener() {}, innerWidth: 1280 },
+ require: (name) => {
+ const platform = {
+ react: {
+ createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }),
+ useState: init => states[hook++] ?? [init, () => {}],
+ useEffect: () => {}, useRef: () => ({ current: null }),
+ useLayoutEffect: () => {}, useMemo: make => make(), useCallback: fn => fn,
+ useSyncExternalStore: (_subscribe, get) => get(), Fragment: 'fragment',
+ },
+ 'react-dom': { createPortal: node => node },
+ '@deepseek-ai/dsh-client-ui-primitives': { MarkdownText: () => null },
+ }
+ if (!(name in platform)) throw new Error(`no platform module ${name}`)
+ return platform[name]
+ },
+ })
+ return sideModule.exports
+}
+
+const chat = { id: 'c1', entries: [{ id: 'e1', status: 'done', question: 'q?', answer: 'a.', createdAt: 1, finishedAt: 2 }] }
+
+test('a refused question puts the text back and shows the error', async () => {
+ const calls = { draft: [], fail: [] }
+ const actions = { askSide: () => Promise.reject(new Error('refused by host')) }
+ const { SideChatView } = sideExports([
+ ['question?', (...args) => calls.draft.push(args)],
+ [null, (...args) => calls.fail.push(args)],
+ ])
+ const tree = SideChatView({ subject: 's', chat, actions })
+ const [input] = find(tree, node => node.props?.className === 'bt-side-input')
+ input.props.onKeyDown({ key: 'Enter', preventDefault() {}, nativeEvent: {} })
+ await new Promise(resolve => setTimeout(resolve, 0))
+ assert.deepEqual(calls.draft[0], [''])
+ const restore = calls.draft.at(-1)[0]
+ assert.equal(restore(''), 'question?')
+ assert.equal(restore('newer'), 'newer')
+ assert.deepEqual(calls.fail, [[null], ['refused by host']])
+})
+
+test('a stored failure renders under the input and typing clears it', () => {
+ const calls = { draft: [], fail: [] }
+ const { SideChatView } = sideExports([
+ ['', (...args) => calls.draft.push(args)],
+ ['the error', (...args) => calls.fail.push(args)],
+ ])
+ const tree = SideChatView({ subject: 's', chat, actions: {} })
+ const [failLine] = find(tree, node => node.props?.className === 'bt-side-fail')
+ assert.equal(failLine.children[0], 'the error')
+ const [input] = find(tree, node => node.props?.className === 'bt-side-input')
+ input.props.onChange({ target: { value: 'next' } })
+ assert.deepEqual(calls.draft, [['next']])
+ assert.deepEqual(calls.fail, [[null]])
+})