A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Scope a member's group folder pick to that group and point the group's own Session at the group folder
Fei2411597cbab07b56
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex 57d20937..255db8d8 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -4332,7 +4332,7 @@ var HANDOFF_CSS = `.bt-handoff .bt-q-foot{flex-wrap:wrap}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/ui.js+// node_modules/deep-view/src/react/ui.jsvar import_react7 = require("react");var FallbackMarkdown = ({ text }) => (0, import_react7.createElement)("span", null, String(text ?? ""));var ViewUi = (0, import_react7.createContext)({ t: (key) => key, Markdown: FallbackMarkdown });@@ -4399,7 +4399,7 @@ function useOptionKeys2(count, onPick, ownRef) {return count > 0 && listening <= 1;}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/formula.js+// node_modules/deep-view/src/core/formula.jsvar FUNCTIONS = {min: { args: [1, Infinity], run: (...values) => Math.min(...values.map(num)) },max: { args: [1, Infinity], run: (...values) => Math.max(...values.map(num)) },@@ -4680,7 +4680,7 @@ function evaluate(tree, lookup) {}}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/views.js+// node_modules/deep-view/src/core/views.jsvar LAYOUT = ["stack", "row"];var DISPLAY = ["text", "metric", "table", "chart", "progress", "callout", "sources", "html"];var INPUT_TYPES = ["slider", "choice", "toggle", "number"];@@ -5300,7 +5300,7 @@ function validateForm(node, values) {return { fields };}-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/chart.js+// node_modules/deep-view/src/react/chart.jsvar import_react8 = require("react");var PALETTE = ["var(--dv-accent)", "var(--dv-ink-tangerine)", "var(--dv-ink-green)", "var(--dv-ink-violet)", "var(--dv-ink-sky)", "var(--dv-ink-rose)", "var(--dv-ink-yellow)", "var(--dv-ink-cyan)", "var(--dv-ink-magenta)"];var colorAt = (index) => PALETTE[index % PALETTE.length];@@ -5739,7 +5739,7 @@ var CHART_CSS = `@media (prefers-reduced-motion:reduce){.dv-chart-mark,.dv-chart-dot{transition:none}.dv-chart-tip{animation:none}}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/frame.js+// node_modules/deep-view/src/react/frame.jsvar import_react9 = require("react");var THEME_VARS = [["--view-ink", "--bt-ink", "--dv-ink"],@@ -5821,7 +5821,7 @@ var HTML_CSS = `.dv-view-frame-stopped{margin:0;font-size:13px;line-height:18px;color:var(--dv-ink-2)}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/card.js+// node_modules/deep-view/src/react/card.jsvar import_react10 = require("react");var mdLabels = (ui2) => ({ code: { copyLabel: ui2.t("Copy"), copiedLabel: ui2.t("Copied") }, footnotes: ui2.t("Footnotes") });var TONES2 = ["good", "warn", "bad"];@@ -6490,7 +6490,7 @@ ${CHART_CSS}${HTML_CSS}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/styles.js+// node_modules/deep-view/src/react/styles.jsvar THEME_CSS = `body{--dv-ink:var(--dsw-alias-label-primary);@@ -6587,10 +6587,10 @@ button.dv-q-opt:active{background:var(--dv-active)}@media (prefers-reduced-motion:reduce){.dv-q,.dv-view-bare,.dv-q-submit,.dv-menu,.dv-q-check{animation:none}}`;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/react/index.js+// node_modules/deep-view/src/react/index.jsvar DEEP_VIEW_CSS = THEME_CSS + QUESTION_CSS + WIDGET_CSS;-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/deep-view/src/core/reply.js+// node_modules/deep-view/src/core/reply.jsvar REPLY_KIND = "user-question-reply";function viewCardText(args) {let card = args;diff --git a/ds-bot/office.js b/ds-bot/office.jsindex a4aab41b..ada743e1 100644--- a/ds-bot/office.js+++ b/ds-bot/office.js@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__gemod));-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/conventions.js+// node_modules/@xmldom/xmldom/lib/conventions.jsvar require_conventions = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/conventions.js"(exports) {"use strict";function find(list, predicate, ac) {if (ac === void 0) {@@ -243,9 +243,9 @@ var require_conventions = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/errors.js+// node_modules/@xmldom/xmldom/lib/errors.jsvar require_errors = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/errors.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/errors.js"(exports) {"use strict";var conventions = require_conventions();function extendError(constructor, writableName) {@@ -402,9 +402,9 @@ var require_errors = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/grammar.js+// node_modules/@xmldom/xmldom/lib/grammar.jsvar require_grammar = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/grammar.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/grammar.js"(exports) {"use strict";function detectUnicodeSupport(RegExpImpl) {try {@@ -609,9 +609,9 @@ var require_grammar = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom.js+// node_modules/@xmldom/xmldom/lib/dom.jsvar require_dom = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/dom.js"(exports) {"use strict";var conventions = require_conventions();var find = conventions.find;@@ -3276,9 +3276,9 @@ var require_dom = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/entities.js+// node_modules/@xmldom/xmldom/lib/entities.jsvar require_entities = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/entities.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/entities.js"(exports) {"use strict";var freeze = require_conventions().freeze;exports.XML_ENTITIES = freeze({@@ -5419,9 +5419,9 @@ var require_entities = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/sax.js+// node_modules/@xmldom/xmldom/lib/sax.jsvar require_sax = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/sax.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/sax.js"(exports) {"use strict";var conventions = require_conventions();var g = require_grammar();@@ -6201,9 +6201,9 @@ var require_sax = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom-parser.js+// node_modules/@xmldom/xmldom/lib/dom-parser.jsvar require_dom_parser = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/dom-parser.js"(exports) {"use strict";var conventions = require_conventions();var dom = require_dom();@@ -6469,9 +6469,9 @@ var require_dom_parser = __commonJS({}});-// ../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/index.js+// node_modules/@xmldom/xmldom/lib/index.jsvar require_lib = __commonJS({- "../../../DS Bot/DeepSeek-Bot/ds-bot/node_modules/@xmldom/xmldom/lib/index.js"(exports) {+ "node_modules/@xmldom/xmldom/lib/index.js"(exports) {"use strict";var conventions = require_conventions();exports.assign = conventions.assign;diff --git a/ds-bot/src/host/folders.js b/ds-bot/src/host/folders.jsindex f6130805..9caad66b 100644--- a/ds-bot/src/host/folders.js+++ b/ds-bot/src/host/folders.js@@ -23,7 +23,15 @@ export function install(rt) {const teamFolder = () => ctx.workspaceRegistry.get?.(state.workspaceId)?.path// The desktop app names the folder the user chose for the Bots' files.const defaultTeamFolder = () => rt.config.workspace ?? (process.env.DS_BOT_WORKSPACE?.trim() || join(rt.home, 'workspace'))- const workDirOf = ({ botId, roomId } = {}) => rt.roomOf(roomId)?.workDir ?? rt.botOf(botId)?.workDir+ // A member's own pick inside one group, made with working_directory there: a path,+ // or null for the team workspace, which a missing entry would read as the Bot's+ // folder. A group's folder outranks it; without one the Bot's folder is the default.+ const workDirOf = ({ botId, roomId } = {}) => {+ const room = rt.roomOf(roomId)+ if (room?.workDir !== undefined) return room.workDir+ if (room !== undefined && botId !== undefined && Object.hasOwn(room.memberDirs ?? {}, botId)) return room.memberDirs[botId] ?? undefined+ return rt.botOf(botId)?.workDir+ }const isFolder = path => stat(path).then(info => info.isDirectory(), () => false)const real = path => realpath(path).catch(() => resolve(path))// The real path of the deepest part that exists, with the rest after it.diff --git a/ds-bot/src/host/roster.js b/ds-bot/src/host/roster.jsindex a7b33e4e..6ff56232 100644--- a/ds-bot/src/host/roster.js+++ b/ds-bot/src/host/roster.js@@ -425,10 +425,60 @@ export function install(rt) {return holdName('room', custom, () => buildRoom({ members, custom, notice, mode, adminId, createdBy }))}+ // A group's own Session already exists, so a folder change cannot make it again.+ // The header is frozen and keys the log, so only the live header moves. `still`+ // is false when a later change already picked another folder.+ async function pointSession(sessionId, cwd, still) {+ try {+ const agent = await rt.resolveAgent(sessionId)+ if (still !== undefined && !still()) return+ const session = agent?.session+ const header = session?.header+ if (header === undefined || header.cwd === cwd) return+ try {+ header.cwd = cwd+ } catch {+ try {+ session.header = { ...header, cwd }+ } catch (error) {+ rt.warn('ds-bot: group chat Session %s stays where it was; it could not move to %s: %s', sessionId, cwd, error)+ }+ }+ } catch (error) {+ rt.warn('ds-bot: group chat Session %s stays where it was; it could not move to %s: %s', sessionId, cwd, error)+ }+ }++ // The file tree reads this Session's cwd. The relay does not write there: its step+ // is a synthesized group_relay, and a long line is stored under the team data.+ // Members keep their own Sessions and move on to the folder at their next turn.+ async function pointRoom(room) {+ const dir = room.workDir+ const usable = dir !== undefined && await rt.isFolder(dir)+ if (room.workDir !== dir) return+ const cwd = usable ? dir : await rt.keepTeamFolder()+ if (room.workDir !== dir || cwd === undefined) return+ await pointSession(room.id, cwd, () => room.workDir === dir)+ }++ // Once per process, after the team is loaded: a restart reads the stored header.+ let roomsPointed = null+ function pointSavedRooms() {+ roomsPointed ??= (async () => {+ for (const room of Object.values(state.rooms)) {+ if (room.workDir !== undefined) await pointRoom(room)+ }+ })().catch(error => {+ roomsPointed = null+ rt.warn('ds-bot: group chats could not be pointed at their folders: %s', error)+ })+ return roomsPointed+ }+async function buildRoom({ members, custom, notice, mode, adminId, createdBy }) {const title = custom || autoRoomName(members)- // The group's own Session only relays, so it stays in the team workspace; the- // group's folder is for its members' Sessions.+ // A new group has no folder yet, so its own Session starts in the team workspace.+ // pointRoom moves that same Session when a folder is set.const id = await createSession(title)try {// A member deleted while the Session was made stays out, and the group is checked@@ -539,6 +589,9 @@ export function install(rt) {if (moving && workDir !== room.workDir) {if (workDir === undefined) delete room.workDirelse room.workDir = workDir+ // A member's own pick for this group gives way to the group's folder, and a+ // cleared one does not bring it back.+ delete room.memberDirschanges.push(workDir ? `every member now works in ${workDir} here` : 'every member works in its own folder again')}const before = room.name@@ -560,6 +613,8 @@ export function install(rt) {await retitleRoom(room)}await rt.save()+ // After the folder is saved. A failure here leaves the setting in place.+ if (moving) await pointRoom(room)return { room, changes }}@@ -684,6 +739,8 @@ export function install(rt) {async function bootstrap() {await rt.load()void rt.syncModels()+ // Opening the group Sessions must not hold up the team view.+ void pointSavedRooms()if (state.mainBotIds.some(id => rt.botOf(id))) return// Only the team's first Main Bot is stored as the DeepSeek whale; other Bots get a// look from their id, and a Bot made Main Bot later keeps its own.diff --git a/ds-bot/src/host/store.js b/ds-bot/src/host/store.jsindex 44ab52da..102e1e83 100644--- a/ds-bot/src/host/store.js+++ b/ds-bot/src/host/store.js@@ -386,6 +386,7 @@ export function install(rt) {const isBotSession = id => chatOwners.has(id) || groupOwners.has(id)const groupSessionsOf = botId => Object.values(state.rooms).map(room => room.sessions?.[botId]).filter(Boolean)const dropGroupSession = (room, botId) => {+ if (room.memberDirs !== undefined) delete room.memberDirs[botId]const sessionId = room.sessions?.[botId]if (sessionId === undefined) returndelete room.sessions[botId]diff --git a/ds-bot/src/host/tools.js b/ds-bot/src/host/tools.jsindex c8a3a7e9..2f83c537 100644--- a/ds-bot/src/host/tools.js+++ b/ds-bot/src/host/tools.js@@ -380,7 +380,9 @@ export function install(rt) {// DSH's working_directory changes a Session's folder in place, and the next part starts in// the Bot's working folder again. A Bot that changes to a folder outside its working folder// sets its working folder instead, with update_bot's checks, and goes on in a fresh part- // there; a folder inside it only moves this Session there.+ // there; a folder inside it only moves this Session there. In a group without a folder of+ // its own the change holds only for that conversation: the Bot's folder, its other groups+ // and its own chat keep theirs (folders.js memberDirs).ctx.on('tools/execute', async (exec, next) => {// Resolved as DSH gets it, untrimmed, so that both mean the same folder.const cd = exec.name === WORKING_DIRECTORY_TOOL && typeof exec.arguments?.cd === 'string' ? exec.arguments.cd : ''@@ -399,6 +401,18 @@ export function install(rt) {// Saved folders are trimmed like typed ones, so such a name would save another folder.if (unquote(target) !== target) throw new Error(`${JSON.stringify(target)} cannot be a working folder: its name starts or ends with a space or a quote mark.`)const workDir = await rt.workFolder(target)+ if (room !== undefined) {+ // The folder holds only for this group conversation, so only this Session's+ // writes widen; the private-Bot check is the one updateBot would run.+ await rt.checkPrivacyChange(bot, { moving: true, workDir })+ await rt.approveFolder(exec, { path: workDir, sessions: [exec.agent.id], who: { en: bot.name, zh: ` ${bot.name} ` } })+ const result = await next()+ if (result?.isError !== true) {+ ;(room.memberDirs ??= {})[bot.id] = workDir ?? null+ await rt.save()+ }+ return result+ }await rt.approveFolder(exec, { path: workDir, sessions: rt.sessionsOfBot(bot.id), who: { en: bot.name, zh: ` ${bot.name} ` } })const result = await next()if (result?.isError !== true) await rt.updateBot(bot.id, { workDir: workDir ?? '' }, rt.selfOf(exec.agent?.id))diff --git a/ds-bot/test/work-dir.test.js b/ds-bot/test/work-dir.test.jsindex b4360a88..dcf998b7 100644--- a/ds-bot/test/work-dir.test.js+++ b/ds-bot/test/work-dir.test.js@@ -777,7 +777,8 @@ test('in a group with a folder of its own a member stays inside it; without oneassert.equal((await call('update-room', { id: 'r1', workDir: '' })).ok, true)const own = await changeDirectory(ctx, service, agentOf('gb'), project)assert.equal(own.ran, true)- assert.equal(state().bots.b.workDir, project)+ assert.equal(state().rooms.r1.memberDirs.b, project)+ assert.equal(state().bots.b.workDir, undefined)assert.equal(state().rooms.r1.workDir, undefined)})@@ -838,3 +839,160 @@ test('a Bot changes back to the team workspace when the team workspace is knownassert.equal(state().bots.b.workDir, undefined)assert.equal(requests.length, 0)})++// A folder a member picks inside a group is kept on the room, per member: it holds+// for that conversation's next parts, and nowhere else.+const TWO_ROOMS = {+ ...TEAM.rooms,+ r2: { id: 'r2', name: 'Cuda', members: ['a', 'b'], mode: 'admin', admin: 'a', named: true, sessions: { b: 'gb2' } },+}++test('a folder a member picks in one group holds only there, not in its other groups or its own chat', async (t) => {+ const { service } = folderService()+ const { requests, services } = approvalServices('allowed-once')+ const { ctx, call, agentOf, created, root, state, preStep, stop } = await start({ services: { ...services, workingDirectory: service }, team: { ...TEAM, rooms: TWO_ROOMS } })+ t.after(stop)+ const own = join(root, 'cuda')+ const ascend = join(root, 'ascend')+ mkdirSync(own)+ mkdirSync(ascend)+ assert.equal((await call('update-bot', { id: 'b', workDir: own })).ok, true)+ await until(() => state().bots.b.sessionId === 's1')+ // The member's group Sessions were made in its own folder.+ agentOf('gb').session.header.cwd = own+ agentOf('gb2').session.header.cwd = own++ const moved = await changeDirectory(ctx, service, agentOf('gb'), ascend)+ assert.equal(moved.ran, true)+ assert.equal(requests.length, 1)+ assert.equal(requests[0].toolName, 'working_directory')+ assert.equal(state().rooms.r1.memberDirs.b, ascend)+ // Neither the Bot's folder, its conversation in the other group, nor its own chat moved.+ assert.equal(state().bots.b.workDir, own)+ assert.equal(state().rooms.r1.workDir, undefined)+ assert.equal(await preStep('gb2'), 'next')+ assert.equal(await preStep('s1'), 'next')+ assert.deepEqual(created.map(options => options.cwd).filter(Boolean), [own])++ // Its conversation in this group moves on to a fresh part in the new folder.+ assert.deepEqual(await preStep('gb'), { kind: 'reject' })+ await until(() => state().rooms.r1.sessions.b === 's2')+ assert.deepEqual(created.at(-1), { cwd: ascend })+ assert.equal(state().rooms.r2.sessions.b, 'gb2')+ assert.equal(state().bots.b.sessionId, 's1')+})++test('a member that changes to the team workspace in a group stays there, not back in its own folder', async (t) => {+ const { service } = folderService()+ const { services } = approvalServices('allowed-once')+ const { ctx, call, agentOf, created, root, team, state, preStep, stop } = await start({ services: { ...services, workingDirectory: service } })+ t.after(stop)+ const own = join(root, 'cuda')+ mkdirSync(own)+ assert.equal((await call('update-bot', { id: 'b', workDir: own })).ok, true)+ await until(() => state().bots.b.sessionId === 's1')+ agentOf('gb').session.header.cwd = own++ const moved = await changeDirectory(ctx, service, agentOf('gb'), team)+ assert.equal(moved.ran, true)+ assert.equal(state().rooms.r1.memberDirs.b, null)+ assert.equal(state().bots.b.workDir, own)+ assert.deepEqual(await preStep('gb'), { kind: 'reject' })+ await until(() => state().rooms.r1.sessions.b === 's2')+ assert.deepEqual(created.at(-1), { workspaceId: 'w1' })+})++test('a member\'s folder pick in a group goes with the group\'s folder setting or the member', async (t) => {+ const { service } = folderService()+ const { services } = approvalServices('allowed-once')+ const three = {+ ...TEAM,+ bots: { ...TEAM.bots, c: { id: 'c', name: 'Tester', role: 'Test', sessionId: 'c', createdAt: 3 } },+ rooms: { r1: { ...TEAM.rooms.r1, members: ['a', 'b', 'c'] } },+ }+ const { ctx, call, agentOf, project, state, stop } = await start({ services: { ...services, workingDirectory: service }, team: three })+ t.after(stop)+ assert.equal((await changeDirectory(ctx, service, agentOf('gb'), project)).ran, true)+ assert.equal(state().rooms.r1.memberDirs.b, project)+ // Setting the group's folder overrides every pick, and clearing it does not bring one back.+ assert.equal((await call('update-room', { id: 'r1', workDir: project })).ok, true)+ assert.equal(state().rooms.r1.memberDirs, undefined)+ assert.equal((await call('update-room', { id: 'r1', workDir: '' })).ok, true)+ assert.equal((await changeDirectory(ctx, service, agentOf('gb'), project)).ran, true)+ assert.equal(state().rooms.r1.memberDirs.b, project)+ assert.equal((await call('update-room', { id: 'r1', remove: ['b'] })).ok, true)+ assert.equal(state().rooms.r1.memberDirs?.b, undefined)+})++test('setting a group folder points that group\'s own Session, and clearing it points back', async (t) => {+ const { call, created, agentOf, preStep, project, team, state, stop } = await start()+ t.after(stop)+ assert.equal((await call('update-room', { id: 'r1', workDir: project })).ok, true)+ assert.equal(state().rooms.r1.id, 'r1')+ assert.equal(agentOf('r1').session.header.cwd, project)+ assert.equal(state().rooms.r1.sessions.b, 'gb')+ assert.deepEqual(created, [])++ assert.deepEqual(await preStep('gb'), { kind: 'reject' })+ await until(() => state().rooms.r1.sessions.b === 's1')+ assert.deepEqual(created, [{ cwd: project }])+ assert.equal(state().rooms.r1.id, 'r1')+ assert.equal(agentOf('r1').session.header.cwd, project)++ assert.equal((await call('update-room', { id: 'r1', workDir: '' })).ok, true)+ assert.equal(state().rooms.r1.workDir, undefined)+ assert.equal(state().rooms.r1.id, 'r1')+ assert.equal(agentOf('r1').session.header.cwd, team)+ assert.equal(state().rooms.r1.sessions.b, 's1')+})++test('a frozen group Session header is replaced in memory', async (t) => {+ const { call, agentOf, project, team, state, created, stop } = await start()+ t.after(stop)+ const session = agentOf('r1').session+ const previous = session.header+ Object.freeze(previous)+ assert.equal((await call('update-room', { id: 'r1', workDir: project })).ok, true)+ assert.equal(previous.cwd, team)+ assert.equal(session.header.cwd, project)+ assert.notEqual(session.header, previous)+ assert.equal(state().rooms.r1.id, 'r1')+ assert.deepEqual(created, [])+})++test('pointing a saved group folder does not hold up the team view', async (t) => {+ const env = await start()+ t.after(env.stop)+ assert.equal((await env.call('update-room', { id: 'r1', workDir: env.project })).ok, true)+ assert.equal(env.agentOf('r1').session.header.cwd, env.project)+ env.agentOf('r1').session.header.cwd = env.team+ let release+ const gate = new Promise(resolve => { release = resolve })+ const resolveAgent = env.ctx.sessionController.resolveAgent+ env.ctx.sessionController.resolveAgent = async (id) => {+ if (id === 'r1') await gate+ return resolveAgent(id)+ }+ const view = await Promise.race([+ env.call('state', {}),+ new Promise((_, reject) => setTimeout(() => reject(new Error('state waited for the group Session')), 300)),+ ])+ assert.equal(view.ok, true)+ assert.equal(env.agentOf('r1').session.header.cwd, env.team)+ release()+ await until(() => env.agentOf('r1').session.header.cwd === env.project)+ env.agentOf('r1').session.header.cwd = env.team+ assert.equal((await env.call('state', {})).ok, true)+ await settle()+ assert.equal(env.agentOf('r1').session.header.cwd, env.team)+})++test('a group Session that cannot be opened still saves the folder', async (t) => {+ const env = await start()+ t.after(env.stop)+ env.ctx.sessionController.resolveAgent = async () => { throw new Error('down') }+ assert.equal((await env.call('update-room', { id: 'r1', workDir: env.project })).ok, true)+ assert.equal(env.state().rooms.r1.workDir, env.project)+ assert.equal(env.state().rooms.r1.id, 'r1')+ assert.equal((await env.call('state', {})).ok, true)+})