The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a restore or edit above a compaction boundary says the message was summarized
Tekniumfb8d3409ac56
diff --git a/apps/desktop/src/i18n/ar_boot.ts b/apps/desktop/src/i18n/ar_boot.tsindex 7827be66ed7..7f99bc4c927 100644--- a/apps/desktop/src/i18n/ar_boot.ts+++ b/apps/desktop/src/i18n/ar_boot.ts@@ -81,6 +81,7 @@ export const arBoot = {'هذه المحادثة مشغولة: يُطبَّق تغيير MCP بعد انتهاء دورها وإعادة تحميل MCP مجددًا، أو عند إعادة فتح المحادثة',mcpReloadNotInChat: server => `${server} غير مفعّل في هذه المحادثة`,mcpReloadUnavailable: servers => `تعذّر الاتصال: ${servers}`,+ compactedTurnUnavailable: 'تم تلخيص هذه الرسالة عند ضغط المحادثة، لذا لم يعد بالإمكان استعادتها أو تحريرها.',sessionCommands: arSessionCommands},updates: {diff --git a/apps/desktop/src/i18n/de_notices.ts b/apps/desktop/src/i18n/de_notices.tsindex b9f77a80ea9..0dfa82d2de5 100644--- a/apps/desktop/src/i18n/de_notices.ts+++ b/apps/desktop/src/i18n/de_notices.ts@@ -24,6 +24,8 @@ export const deNotices = {'Dieser Chat ist beschäftigt: Die MCP-Änderung gilt, sobald sein Durchlauf endet und MCP erneut geladen wird, oder wenn du den Chat wieder öffnest',mcpReloadNotInChat: server => `${server} ist in diesem Chat nicht aktiviert`,mcpReloadUnavailable: servers => `Keine Verbindung: ${servers}`,+ compactedTurnUnavailable:+ 'Diese Nachricht wurde beim Komprimieren des Chats zusammengefasst und kann nicht mehr wiederhergestellt oder bearbeitet werden.',sessionCommands: deSessionCommands},keepAwakeOffer: {diff --git a/apps/desktop/src/i18n/en_notices.ts b/apps/desktop/src/i18n/en_notices.tsindex cbad0c6a8cd..9cd8e0504a7 100644--- a/apps/desktop/src/i18n/en_notices.ts+++ b/apps/desktop/src/i18n/en_notices.ts@@ -24,6 +24,8 @@ export const enNotices = {'This chat is busy: the MCP change applies once its turn finishes and MCP reloads again, or when you reopen the chat',mcpReloadNotInChat: server => `${server} is not enabled in this chat`,mcpReloadUnavailable: servers => `Did not connect: ${servers}`,+ compactedTurnUnavailable:+ "That message was summarized when the chat was compressed, so it can't be restored or edited anymore.",sessionCommands: enSessionCommands},keepAwakeOffer: {diff --git a/apps/desktop/src/i18n/es_notices.ts b/apps/desktop/src/i18n/es_notices.tsindex e0b9911392f..c014e4880fe 100644--- a/apps/desktop/src/i18n/es_notices.ts+++ b/apps/desktop/src/i18n/es_notices.ts@@ -24,6 +24,8 @@ export const esNotices = {'Este chat está ocupado: el cambio de MCP se aplica cuando termine su turno y MCP se recargue de nuevo, o al volver a abrir el chat',mcpReloadNotInChat: server => `${server} no está activado en este chat`,mcpReloadUnavailable: servers => `No se conectó: ${servers}`,+ compactedTurnUnavailable:+ 'Ese mensaje se resumió al comprimir el chat, así que ya no se puede restaurar ni editar.',sessionCommands: esSessionCommands},keepAwakeOffer: {diff --git a/apps/desktop/src/i18n/fr_notices.ts b/apps/desktop/src/i18n/fr_notices.tsindex 1bcddc6f491..65ebf03c516 100644--- a/apps/desktop/src/i18n/fr_notices.ts+++ b/apps/desktop/src/i18n/fr_notices.ts@@ -24,6 +24,8 @@ export const frNotices = {'Cette discussion est occupée : la modification MCP s’applique à la fin de son tour et au prochain rechargement MCP, ou à la réouverture de la discussion',mcpReloadNotInChat: server => `${server} n’est pas activé dans cette discussion`,mcpReloadUnavailable: servers => `Connexion impossible : ${servers}`,+ compactedTurnUnavailable:+ 'Ce message a été résumé lors de la compression de la conversation : il ne peut plus être restauré ni modifié.',sessionCommands: frSessionCommands},keepAwakeOffer: {diff --git a/apps/desktop/src/i18n/ja_notices.ts b/apps/desktop/src/i18n/ja_notices.tsindex 61b95abbe53..6e135d23743 100644--- a/apps/desktop/src/i18n/ja_notices.ts+++ b/apps/desktop/src/i18n/ja_notices.ts@@ -24,6 +24,7 @@ export const jaNotices = {'このチャットは処理中です。MCP の変更は現在のターンが終わって MCP を再読み込みしたとき、またはチャットを開き直したときに反映されます',mcpReloadNotInChat: server => `${server} はこのチャットでは有効になっていません`,mcpReloadUnavailable: servers => `接続できませんでした: ${servers}`,+ compactedTurnUnavailable: 'このメッセージはチャットの圧縮時に要約されたため、復元や編集はできなくなりました。',sessionCommands: jaSessionCommands},keepAwakeOffer: {diff --git a/apps/desktop/src/i18n/ru_notices.ts b/apps/desktop/src/i18n/ru_notices.tsindex 857327584cc..97a4a1e0cbd 100644--- a/apps/desktop/src/i18n/ru_notices.ts+++ b/apps/desktop/src/i18n/ru_notices.ts@@ -24,6 +24,8 @@ export const ruNotices = {'Чат занят: изменение MCP применится, когда завершится текущий ход и MCP будет перезагружен снова, или при повторном открытии чата',mcpReloadNotInChat: server => `${server} не включён в этом чате`,mcpReloadUnavailable: servers => `Не удалось подключиться: ${servers}`,+ compactedTurnUnavailable:+ 'Это сообщение было сжато в краткое изложение при сжатии чата, поэтому его больше нельзя восстановить или изменить.',sessionCommands: ruSessionCommands},keepAwakeOffer: {diff --git a/apps/desktop/src/i18n/types_notices.ts b/apps/desktop/src/i18n/types_notices.tsindex 1e5e1bea001..a011619b8f0 100644--- a/apps/desktop/src/i18n/types_notices.ts+++ b/apps/desktop/src/i18n/types_notices.ts@@ -19,6 +19,8 @@ export interface NoticeTranslations {mcpReloadNotInChat: (server: string) => string/** Configured MCP servers that did not connect on reload. */mcpReloadUnavailable: (servers: string) => string+ /** An edit/restore/regenerate whose target compaction archived: the owner refused the rewind. */+ compactedTurnUnavailable: string/** Typed /undo /retry /steer /queue lines (the Ink TUI's wording on the same gateway). */sessionCommands: SessionCommandNotices}diff --git a/apps/desktop/src/i18n/zh-hant_boot.ts b/apps/desktop/src/i18n/zh-hant_boot.tsindex 79ad7cd94e1..2080b18c046 100644--- a/apps/desktop/src/i18n/zh-hant_boot.ts+++ b/apps/desktop/src/i18n/zh-hant_boot.ts@@ -82,6 +82,7 @@ export const zhHantBoot = {mcpReloadDeferred: '此對話正忙:MCP 變更會在目前輪次結束並再次重新載入 MCP 後生效,或在重新開啟對話時生效',mcpReloadNotInChat: server => `此對話未啟用 ${server}`,mcpReloadUnavailable: servers => `未能連線:${servers}`,+ compactedTurnUnavailable: '這則訊息在壓縮對話時已被摘要,無法再還原或編輯。',sessionCommands: zhHantSessionCommands},diff --git a/apps/desktop/src/i18n/zh_notices.ts b/apps/desktop/src/i18n/zh_notices.tsindex eaedcd41ad3..98265b53e08 100644--- a/apps/desktop/src/i18n/zh_notices.ts+++ b/apps/desktop/src/i18n/zh_notices.ts@@ -21,6 +21,7 @@ export const zhNotices = {mcpReloadDeferred: '此对话正忙:MCP 更改将在当前轮次结束并再次重新加载 MCP 后生效,或在重新打开对话时生效',mcpReloadNotInChat: server => `此对话未启用 ${server}`,mcpReloadUnavailable: servers => `未能连接:${servers}`,+ compactedTurnUnavailable: '这条消息在压缩对话时已被概括,无法再恢复或编辑。',sessionCommands: zhSessionCommands},keepAwakeOffer: {diff --git a/apps/desktop/src/store/notifications.test.ts b/apps/desktop/src/store/notifications.test.tsindex 2ff772b4771..21d04a708c7 100644--- a/apps/desktop/src/store/notifications.test.ts+++ b/apps/desktop/src/store/notifications.test.ts@@ -1,3 +1,4 @@+import { JsonRpcGatewayError } from '@hermes/shared'import { beforeEach, expect, test, vi } from 'vitest'import { en } from '@/i18n/en'@@ -141,3 +142,39 @@ test('code-skew 503 unwraps to a restart-required summary, not raw IPC JSON', ()$notifications.get()[0]?.action?.onClick()expect($backendRestartRequest.get()).toBe(before + 1)})++// RT-39: an edit/restore aimed above a compaction boundary is refused by the owner with+// invalid_params on target_message_id. The toast says so in plain words, not the bare code.+test('a rewind refused for a compacted target says the message was summarized', () => {+ const refused = new JsonRpcGatewayError('invalid_params', {+ code: 4001,+ data: {+ reason: 'invalid_params',+ field: 'target_message_id',+ detail: 'target user message is no longer in session history'+ }+ })++ notifyError(refused, 'Restore failed')++ const toast = $notifications.get()[0]+ expect(toast?.title).toBe('Restore failed')+ expect(toast?.message).toBe(en.promptNotices.compactedTurnUnavailable)+ expect(toast?.message).not.toMatch(/invalid_params/)+ expect(toast?.detail).toBeUndefined()+})++test('an unrelated invalid_params keeps the generic toast', () => {+ notifyError(+ new JsonRpcGatewayError('invalid_params', { code: 4001, data: { reason: 'invalid_params', field: 'title' } }),+ 'Restore failed'+ )+ expect(lastMessage()).toBe('invalid_params')++ clearNotifications()+ notifyError(+ new JsonRpcGatewayError('invalid_params', { code: 4001, data: { reason: 'invalid_params' } }),+ 'Edit failed'+ )+ expect(lastMessage()).toBe('invalid_params')+})diff --git a/apps/desktop/src/store/notifications.ts b/apps/desktop/src/store/notifications.tsindex 7548a6465a8..5483b317e90 100644--- a/apps/desktop/src/store/notifications.ts+++ b/apps/desktop/src/store/notifications.ts@@ -228,12 +228,31 @@ function summarizeErrorMessage(message: string, fallback: string) {}}+// The owner's rewind refusal for a row compaction archived (hermes_state_mutations._rewind): an+// edit, restore or regenerate aimed above the compaction boundary. Matched on the structured+// reason + field, so every other invalid_params keeps the generic toast.+function isCompactedRewindRefusal(error: unknown): boolean {+ const data = error && typeof error === 'object' ? (error as { data?: unknown }).data : undefined++ if (!data || typeof data !== 'object') {+ return false+ }++ const { field, reason } = data as { field?: unknown; reason?: unknown }++ return reason === 'invalid_params' && field === 'target_message_id'+}+// Exported so flows that surface errors inline (e.g. ConfirmDialog's onConfirm// rethrow) can reuse the same IPC-unwrapping + summarizing as notifyError.export function readableError(error: unknown,fallback: string): { message: string; detail?: string; action?: NotificationAction; category: ErrorToastCategory } {+ if (isCompactedRewindRefusal(error)) {+ return { message: translateNow('promptNotices.compactedTurnUnavailable'), category: 'other' }+ }+const raw = error instanceof Error ? error.message : typeof error === 'string' ? error : fallbackconst unwrapped = raw.match(/Error invoking remote method '[^']+': Error: (.+)$/)?.[1] ?? rawconst cleaned = cleanErrorText(unwrapped)diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.jsonindex 187718f7adb..bd66aa6196a 100644--- a/locales/_keys.desktop.json+++ b/locales/_keys.desktop.json@@ -2431,6 +2431,7 @@"profiles.switchToProfile","profiles.title","profiles.unsavedChanges",+ "promptNotices.compactedTurnUnavailable","promptNotices.legacySendUnconfirmed","promptNotices.mcpReloadDeferred","promptNotices.mcpReloadNotInChat",