Skip to content

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

Let remount reconcile the dependent conversation group

Fei2411ae7574f1d14c
diff --git a/ds-bot/client.js b/ds-bot/client.js
index c71b66a9..67f496c6 100644
--- a/ds-bot/client.js
+++ b/ds-bot/client.js
@@ -10095,7 +10095,7 @@ function surfaceGroups(install, { onError } = {}) {
return false;
}
};
- return {
+ const api = {
reconcile(wanted) {
for (const group of [...GROUPS].reverse()) if (!wanted[group]) withdraw(group);
for (const group of GROUPS) {
@@ -10105,17 +10105,22 @@ function surfaceGroups(install, { onError } = {}) {
},
// A step can go on with nothing actually contributed — a slot inject whose
// callback threw inside the host still returns its disposer. remount takes
- // the group off and puts it back, so a caller that notices the contribution
- // is missing can retry instead of trusting `mounted`.
- remount(group) {
+ // the group off and lets the reconcile put it back, so a caller that
+ // notices the contribution is missing can retry instead of trusting
+ // `mounted`. Groups that lean on it (the conversation on the shell's
+ // styles) come off first and go back only through the reconcile — a
+ // failed remount never leaves one stranded.
+ remount(group, wanted = {}) {
if (!GROUPS.includes(group)) return;
+ for (const later of GROUPS.slice(GROUPS.indexOf(group) + 1)) withdraw(later);
withdraw(group);
- mount(group);
+ api.reconcile(wanted);
},
dispose() {
for (const group of [...GROUPS].reverse()) withdraw(group);
}
};
+ return api;
}
function freePriority(entries2, { priority, key, id }) {
if (priority === void 0) return void 0;
@@ -19596,7 +19601,7 @@ function apply(ctx) {
if (verifyAttempts >= 3) return;
verifyAttempts += 1;
console.warn("[ds-bot] sidebar entry missing after shell mount; remounting");
- groups.remount("shell");
+ groups.remount("shell", groupsFor(surface.getSnapshot()));
verifyTimer = setTimeout(verifySidebar, 250);
};
const reconcile = () => {
diff --git a/ds-bot/src/client/index.js b/ds-bot/src/client/index.js
index 13b31576..4e8897b1 100644
--- a/ds-bot/src/client/index.js
+++ b/ds-bot/src/client/index.js
@@ -948,7 +948,7 @@ export function apply(ctx) {
if (verifyAttempts >= 3) return
verifyAttempts += 1
console.warn('[ds-bot] sidebar entry missing after shell mount; remounting')
- groups.remount('shell')
+ groups.remount('shell', groupsFor(surface.getSnapshot()))
verifyTimer = setTimeout(verifySidebar, 250)
}
const reconcile = () => {
diff --git a/ds-bot/src/client/surface.js b/ds-bot/src/client/surface.js
index 262e5832..6e175ced 100644
--- a/ds-bot/src/client/surface.js
+++ b/ds-bot/src/client/surface.js
@@ -46,7 +46,7 @@ export function surfaceGroups(install, { onError } = {}) {
return false
}
}
- return {
+ const api = {
reconcile(wanted) {
for (const group of [...GROUPS].reverse()) if (!wanted[group]) withdraw(group)
for (const group of GROUPS) {
@@ -56,15 +56,20 @@ export function surfaceGroups(install, { onError } = {}) {
},
// A step can go on with nothing actually contributed — a slot inject whose
// callback threw inside the host still returns its disposer. remount takes
- // the group off and puts it back, so a caller that notices the contribution
- // is missing can retry instead of trusting `mounted`.
- remount(group) {
+ // the group off and lets the reconcile put it back, so a caller that
+ // notices the contribution is missing can retry instead of trusting
+ // `mounted`. Groups that lean on it (the conversation on the shell's
+ // styles) come off first and go back only through the reconcile — a
+ // failed remount never leaves one stranded.
+ remount(group, wanted = {}) {
if (!GROUPS.includes(group)) return
+ for (const later of GROUPS.slice(GROUPS.indexOf(group) + 1)) withdraw(later)
withdraw(group)
- mount(group)
+ api.reconcile(wanted)
},
dispose() { for (const group of [...GROUPS].reverse()) withdraw(group) },
}
+ return api
}
// The priority that puts an entry below every other entry of its cell (lowest
diff --git a/ds-bot/test/surface.test.js b/ds-bot/test/surface.test.js
index 1c57804a..0119e96e 100644
--- a/ds-bot/test/surface.test.js
+++ b/ds-bot/test/surface.test.js
@@ -129,14 +129,27 @@ test('remount takes a mounted group off and installs it again', (t) => {
const groups = recordingGroups(log)
groups.reconcile(groupsFor({ mode: 'bot' }))
log.length = 0
- groups.remount('shell')
- assert.deepEqual(log, ['shell theme', 'shell styles', 'install shell'])
+ groups.remount('shell', groupsFor({ mode: 'bot' }))
+ assert.deepEqual(log, ['conversation cells', 'conversation tokens', 'conversation styles', 'shell theme', 'shell styles', 'install shell', 'install conversation'])
log.length = 0
- // A group that is not mounted installs without a withdraw pass.
+ // A group the surface does not want stays off — remount only retries mounts.
groups.reconcile(groupsFor({ mode: 'agent' }))
log.length = 0
- groups.remount('shell')
- assert.deepEqual(log, ['install shell'])
+ groups.remount('shell', groupsFor({ mode: 'agent' }))
+ assert.deepEqual(log, [])
+ groups.dispose()
+})
+
+// A withdraw that throws on the way down does not strand the conversation
+// group: the remount still takes the shell off and puts both back.
+test('a failed shell withdraw does not strand the conversation group', (t) => {
+ t.mock.method(console, 'warn', () => {})
+ const log = []
+ const groups = recordingGroups(log, { failing: 'shell theme' })
+ groups.reconcile(groupsFor({ mode: 'bot' }))
+ log.length = 0
+ groups.remount('shell', groupsFor({ mode: 'bot' }))
+ assert.deepEqual(log, ['conversation cells', 'conversation tokens', 'conversation styles', 'shell theme', 'shell styles', 'install shell', 'install conversation'])
groups.dispose()
})