A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Keep Stop in a group's details while a member waits for approval
Fei24113a82002ee54f
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 484938ff..120178f8 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -11702,7 +11702,7 @@ function MemberState({ entry, bot, room: room2, roster }) {}function StopMemberWork({ entry, bot, room: room2, actions }) {const [stopping, setStopping] = (0, import_react32.useState)(false);- if (entry?.state !== "work" || !entry.here) return null;+ if (!entry?.here || entry.state !== "work" && entry.state !== "ask") return null;const stop = () => {setStopping(true);void Promise.resolve(actions.stopMemberWork(room2.id, bot.id)).catch((error) => actions.reportError(error, "stop")).finally(() => setStopping(false));diff --git a/ds-bot/src/client/member-status.js b/ds-bot/src/client/member-status.jsindex b7d199c9..c3d74e9a 100644--- a/ds-bot/src/client/member-status.js+++ b/ds-bot/src/client/member-status.js@@ -160,10 +160,10 @@ export function MemberState({ entry, bot, room, roster }) {}// Work in this group can be stopped from its details, since the user cannot reach the-// member's group Session otherwise.+// member's group Session otherwise; a turn waiting for an approval still holds its work.export function StopMemberWork({ entry, bot, room, actions }) {const [stopping, setStopping] = useState(false)- if (entry?.state !== 'work' || !entry.here) return null+ if (!entry?.here || (entry.state !== 'work' && entry.state !== 'ask')) return nullconst stop = () => {setStopping(true)void Promise.resolve(actions.stopMemberWork(room.id, bot.id))diff --git a/ds-bot/test/member-status.test.js b/ds-bot/test/member-status.test.jsindex ca5e6854..67f3dcee 100644--- a/ds-bot/test/member-status.test.js+++ b/ds-bot/test/member-status.test.js@@ -22,7 +22,7 @@ runInNewContext(bundle.outputFiles[0].text, {return platform[name]},})-const { busyMembers, summaryText, MemberDock, MemberState } = module.exports+const { busyMembers, summaryText, MemberDock, MemberState, StopMemberWork } = module.exports// Values from the bundle's realm compare by content only.const plain = value => JSON.parse(JSON.stringify(value))// The dock's capsule in an element tree.@@ -57,6 +57,42 @@ const team = {byId: Object.fromEntries(Object.entries(names).map(([id, name]) => [id, { id, name }])),roomsById: { r1: { id: 'r1', name: 'Ops', members: ['a', 'b', 'c', 'd'] }, r2: { id: 'r2', name: 'Docs', members: ['a', 'b'] } },}++// #156: a member waiting for an approval keeps its work here, so Stop stays.+test('a member waiting for approval in this group can still be stopped', async () => {+ const stopped = []+ const room = team.roomsById.r1+ const entry = busyMembers(room, { rooms: { r1: [{ botId: 'a', since: 1 }] }, approvals: [{ botId: 'a', roomId: 'r1', at: 1 }] }, team)[0]+ assert.equal(entry.state, 'ask')+ const node = StopMemberWork({ entry, bot: team.byId.a, room, actions: { stopMemberWork: (...args) => stopped.push(args) } })+ assert.ok(node, 'waiting for approval must not hide Stop')+ node.props.onClick()+ await Promise.resolve()+ assert.deepEqual(stopped, [['r1', 'a']])+})++test('an approval for work elsewhere never offers to stop work in this group', () => {+ const room = team.roomsById.r1+ const entry = busyMembers(room, { rooms: { r2: [{ botId: 'a', since: 1 }] }, approvals: [{ botId: 'a', roomId: 'r2', at: 1 }] }, team)[0]+ assert.equal(StopMemberWork({ entry, bot: team.byId.a, room, actions: {} }), null)+ // Work here stays stoppable while it runs.+ const working = busyMembers(room, { rooms: { r1: [{ botId: 'a', since: 1 }] }, approvals: [] }, team)[0]+ assert.ok(StopMemberWork({ entry: working, bot: team.byId.a, room, actions: {} }))+})++test('a failed stop is reported and never answers the approval', async () => {+ const reported = []+ const room = team.roomsById.r1+ const entry = busyMembers(room, { rooms: { r1: [{ botId: 'a', since: 1 }] }, approvals: [{ botId: 'a', roomId: 'r1', at: 1 }] }, team)[0]+ const node = StopMemberWork({ entry, bot: team.byId.a, room, actions: {+ stopMemberWork: () => Promise.reject(new Error('connection lost')),+ reportError: (error, action) => reported.push([error.message, action]),+ } })+ assert.ok(node)+ node.props.onClick()+ await new Promise(resolve => setImmediate(resolve))+ assert.deepEqual(reported, [['connection lost', 'stop']])+})// The capsule's label and what a click on it asks for.const dock = (sessionId, work) => {const calls = []