The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-mode): stabilize sync entry identity across gateway round-trips
Teknium5d75a4664586
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.jsindex 2f614655cb1..a697972d471 100644--- a/apps/desktop/src/plugins/hermes-bots/plugin.js+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js@@ -423,7 +423,14 @@ function groupChatSyncEntryKey(entry) {String(entry?.from?.kind || ''),String(entry?.from?.name || ''),String(entry?.from?.source || ''),- String(entry?.thread || ''),+ // Threadless entries (pre-thread rooms, older Desktop builds) get+ // SYNTHETIC `legacy-N` ids from assignLegacyThreads. Those ids are+ // position-derived — not stable across a gateway round-trip (the+ // projection copy may be threadless or numbered differently). Collapse+ // the whole synthetic family to one bucket, or the merge duplicates+ // every id-less entry — shifting watermarks and manufacturing phantom+ // member turns that re-submit into busy sessions.+ String(entry?.thread || 'legacy').replace(/^legacy-\d+$/, 'legacy'),String(entry?.text || '')])}@@ -549,7 +556,14 @@ function mergeRemoteGroupChatSnapshotIntoRooms()for (const entry of projected.log) {- entries.set(groupChatSyncEntryKey(entry), entry)+ const key = groupChatSyncEntryKey(entry)+ // The projection is COMPACT (truncated text, no images). When the same+ // entry exists locally, the local rich copy is authoritative — merging+ // the compact twin over it would strip attachments and retrigger+ // watermark deltas for members that already saw it (phantom rounds).+ if (!entries.has(key)) {+ entries.set(key, entry)+ }}if (!preserved.has(name)) {if (remoteRevision > localRevision) {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 04d7ed03aae..372ec426ddc 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@@ -11,7 +11,12 @@ const pluginSource = readFileSync(new URL('../plugin.js', import.meta.url), 'utffunction load(turnScript, { busyUntilResumeCall, clarifyUntilResumeCall, approvalUntilResumeCall, conflictOnce = false, deferredTimers = false } = {}) {const values = new Map()const atom = initial => {- const slot = { get: () => values.get(slot), set: value => values.set(slot, value) }+ const slot = { get: () => values.get(slot), set: value => {+ if (process.env.TRACE_ATOM && value && typeof value === 'object' && value.Grind) {+ console.error('ATOM SET Grind stranded=', JSON.stringify(value.Grind.stranded), new Error().stack.split('\n').slice(2,5).join(' | '))+ }+ values.set(slot, value)+ } }values.set(slot, initial)return slot}