The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): mark truncated group-chat sync payloads
686f6c61d32dacf85564
diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat.test.ts b/apps/desktop/src/plugins/hermes-bots/group-chat.test.tsindex 71feaa6a58b..4bf41b58ec2 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat.test.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-chat.test.ts@@ -502,6 +502,22 @@ describe('gateway mirror', () => {expect(log.length).toBeLessThanOrEqual(16)expect(log.at(-1)?.text).toMatch(/^99:/)expect(log.at(-1)?.text.length).toBeLessThanOrEqual(1200)+ expect(log.at(-1)?.truncated).toBe(true)+ expect(log.at(-1)?.text).toContain('[truncated]')+ expect(log.at(-1)?.text).not.toContain(long)+ })++ it('marks truncated sync text instead of silently slicing it', async () => {+ const { chat } = await loadRoom()+ const long = `plan:${'x'.repeat(2000)}`+ const compacted = chat.compactGroupChatSyncText(long)++ expect(compacted.truncated).toBe(true)+ expect(compacted.text).toContain('[truncated]')+ expect(compacted.text.length).toBeLessThanOrEqual(1200)+ expect(compacted.text.startsWith('plan:')).toBe(true)+ expect(compacted.text).not.toBe(long)+ expect(chat.compactGroupChatSyncText('short').truncated).toBeUndefined()})it('preserves threads and budgets escaped Unicode', async () => {diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat.ts b/apps/desktop/src/plugins/hermes-bots/group-chat.tsindex 8acb8508b87..06053a130f1 100644--- a/apps/desktop/src/plugins/hermes-bots/group-chat.ts+++ b/apps/desktop/src/plugins/hermes-bots/group-chat.ts@@ -52,6 +52,7 @@ const GROUP_CHAT_SYNC_META_KEY = 'hermes-bots-groups'const GROUP_CHAT_SYNC_MAX_BYTES = 48000const GROUP_CHAT_SYNC_MESSAGES = 16const GROUP_CHAT_SYNC_TEXT_CHARS = 1200+const GROUP_CHAT_SYNC_TRUNCATION_MARK = '… [truncated]'const GROUP_CHAT_SYNC_IMAGE_CHARS = 24000let groupChatSyncTimer: ReturnType<typeof setTimeout> | null = null@@ -91,6 +92,25 @@ const groupChatSyncRetryTimers = new Map<string, ReturnType<typeof setTimeout>>(const groupChatSyncRetryCounts = new Map<string, number>()export let groupChatSyncDisposed = false+/** Cut one sync-projection line to the per-message budget and mark the cut.+ * Receivers used to see a silent mid-sentence slice with no signal that the+ * body continued. Keep the mark inside the same char budget so CJK/envelope+ * accounting does not grow. */+export function compactGroupChatSyncText(text: string, limit = GROUP_CHAT_SYNC_TEXT_CHARS) {+ const raw = String(text || '')++ if (raw.length <= limit) {+ return { text: raw }+ }++ const budget = Math.max(0, limit - GROUP_CHAT_SYNC_TRUNCATION_MARK.length)++ return {+ text: `${raw.slice(0, budget)}${GROUP_CHAT_SYNC_TRUNCATION_MARK}`,+ truncated: true as const+ }+}+/** Conservative byte count for the gateway's ensure_ascii JSON encoding.* Python also inserts separator spaces, so reserve one extra byte per JS* structural separator on top of escaped Unicode code-point widths. */@@ -216,29 +236,38 @@ export function groupChatSyncSnapshot(}for (const [name, room] of ranked) {- const log: GroupMessage[] = room.log.slice(-GROUP_CHAT_SYNC_MESSAGES).map(entry => ({- ...(entry?.id- ? {- id: String(entry.id).slice(0, 160)- }- : {}),- from: {- kind: entry?.from?.kind === 'member' ? 'member' : 'user',- name: String(entry?.from?.name || (entry?.from?.kind === 'member' ? 'Bot' : 'You')).slice(0, 128),- ...(entry?.from?.source+ const log: GroupMessage[] = room.log.slice(-GROUP_CHAT_SYNC_MESSAGES).map(entry => {+ const compacted = compactGroupChatSyncText(String(entry?.text || ''))++ return {+ ...(entry?.id? {- source: String(entry.from.source).slice(0, 128)+ id: String(entry.id).slice(0, 160)+ }+ : {}),+ from: {+ kind: entry?.from?.kind === 'member' ? 'member' : 'user',+ name: String(entry?.from?.name || (entry?.from?.kind === 'member' ? 'Bot' : 'You')).slice(0, 128),+ ...(entry?.from?.source+ ? {+ source: String(entry.from.source).slice(0, 128)+ }+ : {})+ },+ text: compacted.text,+ at: Number(entry?.at || 0),+ ...(entry?.thread+ ? {+ thread: String(entry.thread).slice(0, 128)+ }+ : {}),+ ...(compacted.truncated+ ? {+ truncated: true}: {})- },- text: String(entry?.text || '').slice(0, GROUP_CHAT_SYNC_TEXT_CHARS),- at: Number(entry?.at || 0),- ...(entry?.thread- ? {- thread: String(entry.thread).slice(0, 128)- }- : {})- }))+ }+ })const compact: GroupChatSyncRoom = {name: String(name).slice(0, 64),diff --git a/apps/desktop/src/plugins/hermes-bots/types.ts b/apps/desktop/src/plugins/hermes-bots/types.tsindex df397e1cb66..c5eff2606d9 100644--- a/apps/desktop/src/plugins/hermes-bots/types.ts+++ b/apps/desktop/src/plugins/hermes-bots/types.ts@@ -159,6 +159,8 @@ export interface GroupMessage {text: string/** Messages predating threading carry the sentinel thread `'legacy'`. */thread?: string+ /** Set on the ui_meta projection when `text` was cut to the sync budget. */+ truncated?: boolean}export interface GroupHold {