Skip to content

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

Name a folder-triggered part switch while it runs

Fei24118d0db5217719
diff --git a/docs/plans/2026-10-09-context-and-memory.md b/docs/plans/2026-10-09-context-and-memory.md
index 4c474b8c..f467cb68 100644
--- a/docs/plans/2026-10-09-context-and-memory.md
+++ b/docs/plans/2026-10-09-context-and-memory.md
@@ -13,7 +13,7 @@ Bot 是长期的:用户和一个 Bot 聊几周、几个月,上下文一定
所以 DS Bot 的做法是:**一个 Bot 是一个长期不变的身份,它的对话由多段 DSH Session 组成**。快满时由一个轻量的「上下文管家」看最近的消息,判断活是不是告一段落:没做完就原地压缩继续,告一段落就换到新的一段。旧的段整份留着,随时能搜。
-对用户来说这一切**无感**:看到的始终是一条连续的聊天,没有「上下文已用 80%」之类的提示,也没有让 Bot 自己切换的工具。
+对用户来说这一切**无感**:看到的始终是一条连续的聊天,没有「上下文已用 80%」之类的提示,也没有让 Bot 自己切换的工具。唯一的例外是换工作文件夹引起的换段:换段进行中,会话尾部会出现一行「正在切换工作文件夹」,因为聊天会跳到空白的新的一段,不提示就像打字的内容凭空消失。
记忆是另一条线:上下文管的是「这次在做什么」,记忆管的是「跨所有对话都该记住的事」。记忆不能只靠 Bot 想起来调用 `remember`,所以每段对话空闲后还有一次自动的记忆整理。
@@ -141,3 +141,4 @@ Bot 是长期的:用户和一个 Bot 聊几周、几个月,上下文一定
- 2026-10-08:定记忆的格式、存放和「整理不用 git」。
- 2026-10-09:分段从「到线就换段」改为「管家判断压缩还是换段」;所有线改为跟着模型走。
- 2026-10-17:加群记忆(#151)。之前群里学到的东西只能进团队记忆,所有 Bot 都读,群外新建的 Bot 也会带上;现在群聊按群整理,只写群记忆。
+- 2026-10-23:换工作文件夹触发的换段在会话尾部显示一行状态(「正在切换工作文件夹」,#486)。其他原因的换段仍然无感。
diff --git a/ds-bot/client.js b/ds-bot/client.js
index b75e44b1..77634f65 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -568,6 +568,7 @@ var ZH = {
"Taking care of it": "处理中",
"Making headway": "有进展了",
"Moving to a fresh conversation": "整理记忆,换到新对话",
+ "Switching working folder": "正在切换工作文件夹",
"Searching online": "上网搜索",
"Reading a page": "阅读网页",
"Running shell commands": "运行命令",
@@ -7760,8 +7761,8 @@ function toolActivity(name, arg, findBot, self) {
}
}
function workPhrase(doing) {
- const { tool, said, note, target, switching } = typeof doing === "string" ? { tool: doing } : doing ?? {};
- if (switching) return t("Moving to a fresh conversation");
+ const { tool, said, note, target, switching, folder } = typeof doing === "string" ? { tool: doing } : doing ?? {};
+ if (switching) return folder === true ? t("Switching working folder") : t("Moving to a fresh conversation");
const own = (said || note)?.replace(/[\s.。…]+$/u, "");
if (own) return own;
if (!tool) return t("Thinking about it");
@@ -8111,16 +8112,20 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
const pendingInput = useSession((snapshot) => Math.max(0, ...(snapshot?.pendingSubmissions ?? []).filter((sub) => sub.placement !== "queued").map((sub) => sub.time)));
const bot = roster.byId[sessionId];
const room2 = roster.roomsById[sessionId];
+ const moveAt = useWork?.((work) => {
+ const entry = bot === void 0 ? void 0 : work.bots?.[bot.id];
+ return entry?.switching === true && entry.folder === true && entry.roomId === void 0 ? entry.since : 0;
+ }) ?? 0;
const entries2 = (0, import_react13.useMemo)(() => Object.values(JSON.parse(liveKey)), [liveKey]);
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 = rowVisible({ running, streaming, tools, relaying, bot, room: room2 });
+ const visible = moveAt !== 0 || rowVisible({ running, streaming, tools, relaying, bot, room: room2 });
const tool = tools.at(-1);
const inputRef = (0, import_react13.useRef)(0);
const inputAt = Math.max(inputRef.current, pendingInput);
inputRef.current = inputAt;
- const want = !visible ? null : inputAt > (tool?.at ?? 0) ? { key: `input:${inputAt}`, pool: PHRASES.thinking, state: "thinking" } : tool ? { key: tool.label ? `tool:${tool.label}` : "working", label: tool.label, pool: PHRASES.working, state: tool.state ?? "working" } : { key: "thinking", pool: PHRASES.thinking, state: "thinking" };
+ const want = !visible ? null : moveAt !== 0 ? { key: "move", label: t("Switching working folder"), state: "thinking" } : inputAt > (tool?.at ?? 0) ? { key: `input:${inputAt}`, pool: PHRASES.thinking, state: "thinking" } : tool ? { key: tool.label ? `tool:${tool.label}` : "working", label: tool.label, pool: PHRASES.working, state: tool.state ?? "working" } : { key: "thinking", pool: PHRASES.thinking, state: "thinking" };
const [shown, setShown] = (0, import_react13.useState)(null);
const wantKey = want?.key ?? null;
const markState = (0, import_react13.useRef)("thinking");
@@ -8168,7 +8173,7 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
if (!running) actions.clearLive(sessionId);
}, [running, sessionId]);
useRowEntrances(() => leaving.current || Date.now() - endedAt.current < 300);
- const host = useRunningHost(running);
+ const host = useRunningHost(running || moveAt !== 0);
if (!host || phase === null || !shown) return null;
return (0, import_react_dom2.createPortal)((0, import_react13.createElement)(
"div",
@@ -8178,7 +8183,7 @@ function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useLive, us
"span",
{ className: "bt-typing-text" },
(0, import_react13.createElement)("span", { key: `${shown.key}:${shown.at}`, className: "bt-typing-label" }, (0, import_react13.createElement)(Shimmer, null, `${shown.text}…`)),
- (0, import_react13.createElement)(Elapsed, { at: Math.max(turnAt ?? runAt.current, inputAt), className: "bt-typing-time" })
+ (0, import_react13.createElement)(Elapsed, { at: moveAt !== 0 ? moveAt : Math.max(turnAt ?? runAt.current, inputAt), className: "bt-typing-time" })
)
), host);
}
diff --git a/ds-bot/src/client/activity-row.js b/ds-bot/src/client/activity-row.js
index ccfc6e11..cfaf6c9e 100644
--- a/ds-bot/src/client/activity-row.js
+++ b/ds-bot/src/client/activity-row.js
@@ -114,12 +114,18 @@ export function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useL
.filter(sub => sub.placement !== 'queued').map(sub => sub.time)))
const bot = roster.byId[sessionId]
const room = roster.roomsById[sessionId]
+ // The one switch the row names: a working-folder move jumps the chat to a fresh
+ // part while a turn is not running, so without it the conversation just empties.
+ const moveAt = useWork?.((work) => {
+ const entry = bot === undefined ? undefined : work.bots?.[bot.id]
+ return entry?.switching === true && entry.folder === true && entry.roomId === undefined ? entry.since : 0
+ }) ?? 0
const entries = useMemo(() => Object.values(JSON.parse(liveKey)), [liveKey])
const streaming = entries.some(entry => entry.text)
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 = rowVisible({ running, streaming, tools, relaying, bot, room })
+ const visible = moveAt !== 0 || 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
@@ -127,10 +133,11 @@ export function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useL
const inputAt = Math.max(inputRef.current, pendingInput)
inputRef.current = inputAt
const want = !visible ? null
- : inputAt > (tool?.at ?? 0)
- ? { key: `input:${inputAt}`, pool: PHRASES.thinking, state: 'thinking' }
- : tool ? { key: tool.label ? `tool:${tool.label}` : 'working', label: tool.label, pool: PHRASES.working, state: tool.state ?? 'working' }
- : { key: 'thinking', pool: PHRASES.thinking, state: 'thinking' }
+ : moveAt !== 0 ? { key: 'move', label: t('Switching working folder'), state: 'thinking' }
+ : inputAt > (tool?.at ?? 0)
+ ? { key: `input:${inputAt}`, pool: PHRASES.thinking, state: 'thinking' }
+ : tool ? { key: tool.label ? `tool:${tool.label}` : 'working', label: tool.label, pool: PHRASES.working, state: tool.state ?? 'working' }
+ : { key: 'thinking', pool: PHRASES.thinking, state: 'thinking' }
const [shown, setShown] = useState(null)
const wantKey = want?.key ?? null
const markState = useRef('thinking')
@@ -174,11 +181,11 @@ export function ActivityIndicator({ sessionId, useRoster, useSessionStatus, useL
useEffect(() => { if (!running) actions.clearLive(sessionId) }, [running, sessionId])
// Only rows that take the activity row's place grow out of it.
useRowEntrances(() => leaving.current || Date.now() - endedAt.current < 300)
- const host = useRunningHost(running)
+ const host = useRunningHost(running || moveAt !== 0)
if (!host || phase === null || !shown) return null
return createPortal(h('div', { className: 'bt-typing', 'data-exiting': phase === 'out' ? '' : undefined, 'aria-hidden': true },
bot ? h(BotMark, { bot, size: 28, state: markState.current, live: true, pokeable: true }) : h(RoomAvatar, { room, roster, size: 28 }),
h('span', { className: 'bt-typing-text' },
h('span', { key: `${shown.key}:${shown.at}`, className: 'bt-typing-label' }, h(Shimmer, null, `${shown.text}…`)),
- h(Elapsed, { at: Math.max(turnAt ?? runAt.current, inputAt), className: 'bt-typing-time' }))), host)
+ h(Elapsed, { at: moveAt !== 0 ? moveAt : Math.max(turnAt ?? runAt.current, inputAt), className: 'bt-typing-time' }))), host)
}
diff --git a/ds-bot/src/client/cells.js b/ds-bot/src/client/cells.js
index 043857e2..c1c0593f 100644
--- a/ds-bot/src/client/cells.js
+++ b/ds-bot/src/client/cells.js
@@ -741,8 +741,8 @@ function toolActivity(name, arg, findBot, self) {
// call's own description, else the kind of tool and what it works on. `doing` is a work
// entry, or just a tool name.
export function workPhrase(doing) {
- const { tool, said, note, target, switching } = typeof doing === 'string' ? { tool: doing } : doing ?? {}
- if (switching) return t('Moving to a fresh conversation')
+ const { tool, said, note, target, switching, folder } = typeof doing === 'string' ? { tool: doing } : doing ?? {}
+ if (switching) return folder === true ? t('Switching working folder') : t('Moving to a fresh conversation')
const own = (said || note)?.replace(/[\s.。…]+$/u, '')
if (own) return own
if (!tool) return t('Thinking about it')
diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.js
index e04ef55a..03a55aa1 100644
--- a/ds-bot/src/client/i18n.js
+++ b/ds-bot/src/client/i18n.js
@@ -513,6 +513,7 @@ const ZH = {
'Taking care of it': '处理中',
'Making headway': '有进展了',
'Moving to a fresh conversation': '整理记忆,换到新对话',
+ 'Switching working folder': '正在切换工作文件夹',
'Searching online': '上网搜索',
'Reading a page': '阅读网页',
'Running shell commands': '运行命令',
diff --git a/ds-bot/src/host/turns.js b/ds-bot/src/host/turns.js
index a78b9637..de9a5f16 100644
--- a/ds-bot/src/host/turns.js
+++ b/ds-bot/src/host/turns.js
@@ -291,7 +291,8 @@ export function install(rt) {
bots[botId] = { since: entry.since, ...doingOf(entry), ...(owner ? { roomId: owner.roomId } : {}) }
}
for (const job of rt.switchJobs()) {
- const work = { since: job.since, switching: true, ...(job.roomId ? { roomId: job.roomId } : {}) }
+ // `folder` marks the switch the chat must name: the working folder changed.
+ const work = { since: job.since, switching: true, ...(job.folder === true ? { folder: true } : {}), ...(job.roomId ? { roomId: job.roomId } : {}) }
if (job.roomId === undefined) bots[job.botId] = work
else bots[job.botId] ??= work
}
@@ -317,7 +318,7 @@ export function install(rt) {
if (entry.turn !== undefined && owner !== undefined) add(owner.roomId, owner.botId, { since: entry.since, ...doingOf(entry) })
}
for (const job of rt.switchJobs()) {
- if (job.roomId !== undefined) add(job.roomId, job.botId, { since: job.since, switching: true })
+ if (job.roomId !== undefined) add(job.roomId, job.botId, { since: job.since, switching: true, ...(job.folder === true ? { folder: true } : {}) })
}
return rooms
}
diff --git a/ds-bot/test/member-status.test.js b/ds-bot/test/member-status.test.js
index 67f3dcee..e3252422 100644
--- a/ds-bot/test/member-status.test.js
+++ b/ds-bot/test/member-status.test.js
@@ -126,6 +126,7 @@ test('the capsule says what a member does in its call\'s own words, and that it
assert.equal(label({ tool: 'pwsh', note: 'Download Ghidra 12.1.4 and check its hash.' }), 'Anvil · Download Ghidra 12.1.4 and check its hash…')
assert.equal(label({ tool: 'read', target: 'dump.py' }), 'Anvil · Opening a file · dump.py…')
assert.equal(label({ switching: true }), 'Anvil · Moving to a fresh conversation…')
+ assert.equal(label({ switching: true, folder: true }), 'Anvil · Switching working folder…')
assert.equal(label({ tool: 'pwsh', said: '解压 Ghidra,顺便写脚本。', note: 'Expand-Archive' }), 'Anvil · 解压 Ghidra,顺便写脚本…')
})
diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.js
index 9ff2e53c..b4360a88 100644
--- a/ds-bot/test/work-dir.test.js
+++ b/ds-bot/test/work-dir.test.js
@@ -506,6 +506,22 @@ test('a Bot without a model of its own goes on with the earlier part\'s route',
assert.deepEqual(selected.filter(([sessionId]) => sessionId === 's1'), [['s1', 'flash']])
})
+test('a folder-triggered part switch is flagged in the work view while it runs', async (t) => {
+ const env = await start()
+ t.after(env.stop)
+ let seen
+ const archive = env.ctx.workspaceRegistry.archiveSession
+ env.ctx.workspaceRegistry.archiveSession = async (...args) => {
+ if (seen === undefined) seen = (await env.call('state', {})).value.work.bots.b ?? null
+ return archive(...args)
+ }
+ assert.equal((await env.call('update-bot', { id: 'b', workDir: env.project })).ok, true)
+ await until(() => env.state().bots.b.sessionId === 's1')
+ await until(() => handoffOf(env.agentOf('s1')) !== undefined)
+ assert.equal(seen?.switching, true)
+ assert.equal(seen?.folder, true)
+})
+
// #209: DSH 0.2.1 checks a Session's folder as it puts a model request together, before
// agent/pre-step, and fails the turn when the folder and the one the Session was made in
// are gone. Its documented way out is to change the Session's folder first.