The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: disband tombstones no longer hold the group name or leak into storage
Tekniumd1ea11d58981
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.jsindex 33d2c3f921b..a37f66893a4 100644--- a/apps/desktop/src/plugins/hermes-bots/plugin.js+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js@@ -3817,6 +3817,10 @@ function groupChatNames(metaByName, rooms) {const names = new Set(knownGroups(metaByName))for (const [name, room] of Object.entries(rooms || {})) {+ if (room?.tombstone) {+ continue+ }+if ((Array.isArray(room?.members) && room.members.length) || (Array.isArray(room?.log) && room.log.length)) {names.add(name)}@@ -3825,6 +3829,15 @@ function groupChatNames(metaByName, rooms) {return [...names]}+/** Names of REAL rooms in the atom — disband tombstones excluded. Feeds the+ * create/rename collision sets so a just-disbanded name is immediately+ * reusable even while an in-flight drive's tombstone still holds its key. */+function liveGroupChatNames() {+ return Object.entries($groupChats.get())+ .filter(([, room]) => !room?.tombstone)+ .map(([name]) => name)+}+/** Millisecond timestamp of a room's newest log entry (0 for a silent room) —* the group's recency key, competing in the same ordering as bot rows. */function groupLastActivity(room) {@@ -4126,6 +4139,14 @@ function updateGroupChat(group, mutate) {const durable = {}for (const [name, room] of Object.entries(all)) {+ // Disband tombstones are runtime-only coordination state (they hold the+ // epoch bump for an in-flight drive). Persisting one would resurrect+ // the room as an empty record on the next load AND keep its name+ // "taken" for same-name recreates.+ if (room.tombstone) {+ continue+ }+durable[name] = {log: room.log,watermarks: room.watermarks,@@ -4166,9 +4187,12 @@ async function disbandGroupChat(group, members) {delete all[group]// Keep a runtime-only tombstone while a drive may still be mid-turn; it- // carries no log and is never persisted, so it can't rehydrate.+ // carries no log and is flagged so persistence and name-dedup skip it —+ // updateGroupChat writes the WHOLE atom map, so an unflagged tombstone+ // would be persisted by the next unrelated room write and its name would+ // count as taken, suffixing a same-name recreate to "<name> 2" forever.if (prior.running) {- all[group] = { log: [], watermarks: {}, sessions: {}, epoch: (prior.epoch || 0) + 1, running: false }+ all[group] = { log: [], watermarks: {}, sessions: {}, epoch: (prior.epoch || 0) + 1, running: false, tombstone: true }}$groupChats.set(all)@@ -4254,8 +4278,9 @@ async function renameGroupChat(oldName, newName, members) {}// Renames are explicit user intent: reject a collision honestly instead of- // silently suffixing like creation does.- const taken = new Set(Object.keys($groupChats.get()))+ // silently suffixing like creation does. Disband tombstones don't hold+ // their name — the room is gone, only its epoch survives briefly.+ const taken = new Set(liveGroupChatNames())for (const meta of Object.values($botMeta.get() || {})) {for (const existing of botGroups(meta)) {@@ -8626,7 +8651,7 @@ function CreateGroupChatDialog({ open, roster, onClose, onCreated }) {// roomId: member sessions are titled by that roomId, so a// disbanded-and-recreated group with the SAME display name still gets// new sessions instead of resuming the old room's by title.- const taken = new Set(Object.keys($groupChats.get()))+ const taken = new Set(liveGroupChatNames())for (const meta of Object.values($botMeta.get() || {})) {for (const existing of botGroups(meta)) {diff --git a/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjsindex fdaa360212c..129c2a29484 100644--- a/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs+++ b/apps/desktop/src/plugins/hermes-bots/tests/group-chat.test.mjs@@ -124,7 +124,7 @@ function load(turnScript, { busyUntilResumeCall, clarifyUntilResumeCall, approva.replace(/^import .* from 'react\/jsx-runtime'\r?\n/m, '').replace('export default {', 'globalThis.plugin = {').concat(- '\nglobalThis.__gc = { sendToGroupChat, runGroupChatRounds, harvestStrandedGroupReply, resolveGroupResponders, parseGroupChatMentions, rotateGroupSpeakers, isGroupPassText, formatGroupChatLine, buildGroupChatTurnPrompt, trimGroupChatLog, disbandGroupChat, updateGroupChat, ensureGroupChatSession, uniqueGroupChatName, openGroupChat, closeGroupChatMainTab, shouldRenderGroupChatInPane, syncGroupClarify, clearGroupClarify, answerGroupClarify, $groupClarify, $groupChats, $groupNeedsYou, $groupChatWorkspace, $groupMainTabsRev, $botMeta, GROUP_CHAT_MAX_ROUNDS, GROUP_CHAT_MAX_MESSAGES };\n'+ '\nglobalThis.__gc = { sendToGroupChat, runGroupChatRounds, harvestStrandedGroupReply, resolveGroupResponders, parseGroupChatMentions, rotateGroupSpeakers, isGroupPassText, formatGroupChatLine, buildGroupChatTurnPrompt, trimGroupChatLog, disbandGroupChat, updateGroupChat, ensureGroupChatSession, uniqueGroupChatName, liveGroupChatNames, openGroupChat, closeGroupChatMainTab, shouldRenderGroupChatInPane, syncGroupClarify, clearGroupClarify, answerGroupClarify, $groupClarify, $groupChats, $groupNeedsYou, $groupChatWorkspace, $groupMainTabsRev, $botMeta, GROUP_CHAT_MAX_ROUNDS, GROUP_CHAT_MAX_MESSAGES };\n')vm.runInNewContext(source, context, { filename: 'plugin.js' })const storageWrites = new Map()@@ -635,8 +635,23 @@ test('disband: a running room leaves an epoch-bumped empty tombstone so in-flighassert.equal(tomb.log.length, 0)assert.equal(tomb.running, false)assert.equal(tomb.epoch, 4, 'epoch bumped so the loop bails at its member boundary')+ assert.equal(tomb.tombstone, true, 'flagged so persistence and name-dedup skip it')const durable = gc.storageWrites.get('group-chats')assert.ok(!durable || !('Live' in (durable || {})), 'tombstone is never persisted')++ // Regression (#90028 live E2E): updateGroupChat persists the WHOLE atom+ // map — an unrelated room write while the tombstone lingers must not+ // smuggle the tombstone into durable storage, and the disbanded name must+ // be immediately reusable (uniqueGroupChatName would suffix it otherwise).+ gc.updateGroupChat('Other', room => {+ room.log.push({ at: Date.now(), from: { kind: 'user' }, text: 'x', thread: 't' })+ return room+ })+ const durable2 = gc.storageWrites.get('group-chats')+ assert.ok(durable2 && 'Other' in durable2, 'real room persists')+ assert.ok(!('Live' in durable2), 'tombstone excluded from later whole-map writes')+ assert.equal(gc.uniqueGroupChatName('Live', new Set(gc.liveGroupChatNames())), 'Live',+ 'disbanded name is immediately reusable — tombstone does not hold it')})test('source contract: workspace header offers disband behind a ConfirmDialog', () => {@@ -848,7 +863,7 @@ test('source contract: the working line names the member on turn', () => {})test('source contract: creating a group with a taken name mints a fresh room, never reopens the old log', () => {- assert.match(pluginSource, /const taken = new Set\(Object\.keys\(\$groupChats\.get\(\)\)\)/)+ assert.match(pluginSource, /const taken = new Set\(liveGroupChatNames\(\)\)/)assert.match(pluginSource, /const groupName = uniqueGroupChatName\(base, taken\)/)assert.match(pluginSource, /const roomId = mintGroupRoomId\(\)/)assert.match(pluginSource, /room\.roomId = roomId/)