The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): warn when the GUI is older than the backend (reverse contract check)
Hermes Agent7131fe3f03ce
diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 5ca0540d196..f215d79451b 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -247,6 +247,9 @@ export const ar = defineLocale({copyDetailFailed: 'تعذر نسخ تفاصيل الإشعار',backendOutOfDateTitle: 'الخلفية قديمة',backendOutOfDateMessage: 'خلفية Hermes أقدم من إصدار سطح المكتب الحالي وقد لا تعمل كما يجب. حدثهما ليتوافقا.',+ desktopOutOfDateTitle: 'التطبيق قديم',+ desktopOutOfDateMessage: 'تطبيق Hermes أقدم من الخلفية المتصل بها وقد لا يعمل كما يجب. حدّث التطبيق ليتوافقا.',+ updateDesktopApp: 'تحديث التطبيق',updateHermes: 'تحديث Hermes',updateReadyTitle: 'التحديث جاهز',updateReadyMessage: count => `${count} تغيير جديد متاح.`,diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 107184eb8d6..b0fa136c8b6 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -492,6 +492,10 @@ export const deOverrides = {backendOutOfDateTitle: 'Backend veraltet',backendOutOfDateMessage:'Ihr Hermes-Backend ist älter als dieser Desktop-Build und funktioniert möglicherweise nicht richtig. Aktualisieren Sie, um beide abzugleichen.',+ desktopOutOfDateTitle: 'Hermes-App veraltet',+ desktopOutOfDateMessage:+ 'Diese Hermes-App ist älter als das verbundene Backend und funktioniert möglicherweise nicht richtig. Aktualisieren Sie die App, um beide abzugleichen.',+ updateDesktopApp: 'App aktualisieren',installMethodUnsupportedTitle: 'Nicht unterstützte Installationsmethode',updateHermes: 'Hermes aktualisieren',updateReadyTitle: 'Update bereit',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex f6d0690ab80..9de24f0f9d1 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -541,6 +541,10 @@ export const en: Translations = {backendOutOfDateTitle: 'Backend out of date',backendOutOfDateMessage:'Your Hermes backend is older than this desktop build and may not work correctly. Update to align them.',+ desktopOutOfDateTitle: 'Hermes app out of date',+ desktopOutOfDateMessage:+ 'This Hermes app is older than the backend it is connected to and may not work correctly. Update the app to align them.',+ updateDesktopApp: 'Update app',installMethodUnsupportedTitle: 'Unsupported install method',updateHermes: 'Update Hermes',updateReadyTitle: 'Update ready',diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex 357af915fe3..6b337c1107e 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -492,6 +492,10 @@ export const esOverrides = {backendOutOfDateTitle: 'Backend desactualizado',backendOutOfDateMessage:'Tu backend de Hermes es más antiguo que esta compilación de escritorio y puede no funcionar correctamente. Actualízalo para alinearlos.',+ desktopOutOfDateTitle: 'Aplicación de Hermes desactualizada',+ desktopOutOfDateMessage:+ 'Esta aplicación de Hermes es más antigua que el backend al que está conectada y puede no funcionar correctamente. Actualiza la aplicación para alinearlos.',+ updateDesktopApp: 'Actualizar aplicación',installMethodUnsupportedTitle: 'Método de instalación no compatible',updateHermes: 'Actualizar Hermes',updateReadyTitle: 'Actualización lista',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex ab75fb95edc..17d35d83480 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -492,6 +492,10 @@ export const frOverrides = {backendOutOfDateTitle: 'Backend obsolète',backendOutOfDateMessage:'Votre backend Hermes est plus ancien que cette version du desktop et peut ne pas fonctionner correctement. Mettez-le à jour pour les aligner.',+ desktopOutOfDateTitle: 'Application Hermes obsolète',+ desktopOutOfDateMessage:+ "Cette application Hermes est plus ancienne que le backend auquel elle est connectée et peut ne pas fonctionner correctement. Effectuez la mise à jour de l'application pour les aligner.",+ updateDesktopApp: "Mettre à jour l'application",installMethodUnsupportedTitle: "Méthode d'installation non prise en charge",updateHermes: 'Mettre à jour Hermes',updateReadyTitle: 'Mise à jour prête',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex bad46da2fd0..57657c47339 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -244,6 +244,10 @@ export const ja = defineLocale({backendOutOfDateTitle: 'バックエンドが古いです',backendOutOfDateMessage:'Hermes バックエンドがこのデスクトップビルドより古く、正常に動作しない場合があります。更新して揃えてください。',+ desktopOutOfDateTitle: 'アプリが古いです',+ desktopOutOfDateMessage:+ 'この Hermes アプリは接続先のバックエンドより古く、正常に動作しない場合があります。アプリを更新して揃えてください。',+ updateDesktopApp: 'アプリを更新',installMethodUnsupportedTitle: 'サポート対象外のインストール方法',updateHermes: 'Hermes を更新',updateReadyTitle: '更新の準備ができました',diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.tsindex e4aa6913cb3..0403ea42cf8 100644--- a/apps/desktop/src/i18n/ru.ts+++ b/apps/desktop/src/i18n/ru.ts@@ -245,6 +245,10 @@ export const ru = defineLocale({backendOutOfDateTitle: 'Устаревший бэкенд',backendOutOfDateMessage:'Ваш бэкенд Hermes старше этой сборки приложения и может работать некорректно. Обновите их, чтобы они совпали.',+ desktopOutOfDateTitle: 'Устаревшее приложение',+ desktopOutOfDateMessage:+ 'Это приложение Hermes старше подключённого бэкенда и может работать некорректно. Обновите приложение, чтобы они совпали.',+ updateDesktopApp: 'Обновить приложение',installMethodUnsupportedTitle: 'Неподдерживаемый способ установки',updateHermes: 'Обновить Hermes',updateReadyTitle: 'Обновление готово',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 85590e4ca82..dd2bc8f100a 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -563,6 +563,9 @@ export interface Translations {copyDetailFailed: stringbackendOutOfDateTitle: stringbackendOutOfDateMessage: string+ desktopOutOfDateTitle: string+ desktopOutOfDateMessage: string+ updateDesktopApp: stringinstallMethodUnsupportedTitle: stringupdateHermes: stringupdateReadyTitle: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex d3d2dbec36f..f97bf10f1e0 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -237,6 +237,9 @@ export const zhHant = defineLocale({copyDetailFailed: '無法複製通知詳情',backendOutOfDateTitle: '後端版本過舊',backendOutOfDateMessage: '您的 Hermes 後端早於目前的桌面版本,可能無法正常運作。請更新以保持一致。',+ desktopOutOfDateTitle: '應用程式版本過舊',+ desktopOutOfDateMessage: '此 Hermes 應用程式早於所連接的後端,可能無法正常運作。請更新應用程式以保持一致。',+ updateDesktopApp: '更新應用程式',installMethodUnsupportedTitle: '不受支援的安裝方式',updateHermes: '更新 Hermes',updateReadyTitle: '有可用更新',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 1b1e3650b08..10f2f98964b 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -270,6 +270,9 @@ export const zh = defineLocale({copyDetailFailed: '无法复制通知详情',backendOutOfDateTitle: '后端版本过旧',backendOutOfDateMessage: '你的 Hermes 后端早于当前桌面构建,可能无法正常工作。请更新以保持一致。',+ desktopOutOfDateTitle: '应用版本过旧',+ desktopOutOfDateMessage: '此 Hermes 应用早于所连接的后端,可能无法正常工作。请更新应用以保持一致。',+ updateDesktopApp: '更新应用',installMethodUnsupportedTitle: '不受支持的安装方式',updateHermes: '更新 Hermes',updateReadyTitle: '有可用更新',diff --git a/apps/desktop/src/store/updates.test.ts b/apps/desktop/src/store/updates.test.tsindex 43b8c5fadf5..19d89d21862 100644--- a/apps/desktop/src/store/updates.test.ts+++ b/apps/desktop/src/store/updates.test.ts@@ -344,13 +344,49 @@ describe('reportBackendContract', () => {it('clears the snooze once the backend catches up, so a regression warns again', () => {reportBackendContract(1)- lastToast().onDismiss()+ lastToast().onDismiss() // user closes it → cooldown startsnotifySpy.mockClear()reportBackendContract(REQUIRED_BACKEND_CONTRACT) // backend updated → satisfied, snooze clearedreportBackendContract(5) // a later regression must warn immediatelyexpect(notifySpy).toHaveBeenCalledTimes(1)})++ it('warns when the GUI is older than the backend (contract ahead of this build)', () => {+ reportBackendContract(REQUIRED_BACKEND_CONTRACT + 1)+ // The backend-older toast must not fire — this is the reverse direction.+ expect(dismissSpy).toHaveBeenCalledWith('backend-contract-skew')+ expect(notifySpy).toHaveBeenCalledTimes(1)+ expect(notifySpy.mock.calls[0]?.[0]).toMatchObject({ id: 'gui-contract-skew', kind: 'warning' })+ })++ it('gui-skew warning snoozes on close and reminds after the cooldown', () => {+ vi.useFakeTimers()+ vi.setSystemTime(0)++ reportBackendContract(REQUIRED_BACKEND_CONTRACT + 1)+ lastToast().onDismiss() // user closes it → cooldown starts+ notifySpy.mockClear()++ reportBackendContract(REQUIRED_BACKEND_CONTRACT + 1) // another session open within the cooldown+ expect(notifySpy).not.toHaveBeenCalled()++ vi.setSystemTime(25 * 60 * 60 * 1000) // > 24h cooldown+ reportBackendContract(REQUIRED_BACKEND_CONTRACT + 1)+ expect(notifySpy).toHaveBeenCalledTimes(1)+ })++ it('clears the gui-skew toast + snooze once versions align, so a later skew warns again', () => {+ reportBackendContract(REQUIRED_BACKEND_CONTRACT + 1)+ lastToast().onDismiss()+ notifySpy.mockClear()++ reportBackendContract(REQUIRED_BACKEND_CONTRACT) // GUI updated (or backend rolled back) → aligned+ expect(dismissSpy).toHaveBeenCalledWith('gui-contract-skew')++ reportBackendContract(REQUIRED_BACKEND_CONTRACT + 1) // a later skew must warn immediately+ expect(notifySpy).toHaveBeenCalledTimes(1)+ })})describe('checkBackendUpdates', () => {diff --git a/apps/desktop/src/store/updates.ts b/apps/desktop/src/store/updates.tsindex 36b64f8011d..514d478ce25 100644--- a/apps/desktop/src/store/updates.ts+++ b/apps/desktop/src/store/updates.ts@@ -99,7 +99,11 @@ function isUpdateToastSnoozed(): boolean {// Must match tui_gateway's DESKTOP_BACKEND_CONTRACT that this build was written// against. The backend reports its own value in session runtime info; a lower-// value (or none — a pre-GUI checkout) means GUI<->backend skew.+// value (or none — a pre-GUI checkout) means the backend is older than this+// GUI, a higher value means this GUI is older than the backend. Both+// directions are GUI<->backend skew and both warn — an old GUI silently+// driving a newer backend is just as broken as the reverse, it only fails+// further from the cause.// v2: requires the file.attach RPC (remote-gateway non-image file upload).// v3: requires approvals.mode config RPCs and session.info reconciliation.// v4: requires explicit Fast-off session creation and session-scoped Fast edits.@@ -111,12 +115,14 @@ function isUpdateToastSnoozed(): boolean {// `<kind>.request` notifications would never render a card.export const REQUIRED_BACKEND_CONTRACT = 8const SKEW_TOAST_ID = 'backend-contract-skew'+const GUI_SKEW_TOAST_ID = 'gui-contract-skew'// The contract check runs on every session.resume (applyRuntimeInfo), so// without a snooze the warning re-popped on every thread the user opened, even// right after they closed it. Mirror the update toast: persist a cooldown when-// the user dismisses it. It still reminds again after the window if the backend-// is still behind, and clears immediately once the backend catches up.+// the user dismisses it. It still reminds again after the window if the skew+// persists, and clears immediately once the two sides align.const SKEW_TOAST_SNOOZE_KEY = 'hermes:backend-skew-toast-snooze-until'+const GUI_SKEW_TOAST_SNOOZE_KEY = 'hermes:gui-skew-toast-snooze-until'const SKEW_TOAST_COOLDOWN_MS = 24 * 60 * 60 * 1000function snoozeSkewToast(): void {@@ -129,6 +135,16 @@ function isSkewToastSnoozed(): boolean {return Number.isFinite(until) && Date.now() < until}+function snoozeGuiSkewToast(): void {+ persistString(GUI_SKEW_TOAST_SNOOZE_KEY, String(Date.now() + SKEW_TOAST_COOLDOWN_MS))+}++function isGuiSkewToastSnoozed(): boolean {+ const until = Number(storedString(GUI_SKEW_TOAST_SNOOZE_KEY) || 0)++ return Number.isFinite(until) && Date.now() < until+}+const INSTALL_METHOD_TOAST_ID = 'install-method-not-supported'// Same time-based snooze pattern as the update/skew toasts: the warning is// re-derived from every session.info (session.create/resume/activate all@@ -148,43 +164,80 @@ function isInstallMethodToastSnoozed(): boolean {}/**- * Guard against a desktop GUI talking to a backend that predates its contract- * (e.g. a bb/gui-built app pointed at a `main` checkout). Rather than failing- * cryptically downstream, surface a warning with a one-click align that runs- * the normal update flow (which self-heals to the right branch).+ * Guard against GUI<->backend contract skew in either direction. A backend+ * that predates this GUI's contract (e.g. a bb/gui-built app pointed at a+ * `main` checkout) gets a "backend out of date" warning with a one-click+ * align that runs the normal backend update flow. A backend *ahead* of this+ * GUI's contract (typically a long-running app that survived a backend+ * update without relaunching) gets the reverse "app out of date" warning+ * pointing at the client update flow. Without the reverse check an old GUI+ * silently drives a newer backend and fails cryptically downstream.*- * Runs on every session open; closing the toast snoozes it for a cooldown so it+ * Runs on every session open; closing a toast snoozes it for a cooldown so it* doesn't nag on every thread switch.*/export function reportBackendContract(contract: number | undefined): void {- if ((contract ?? 0) >= REQUIRED_BACKEND_CONTRACT) {+ const reported = contract ?? 0++ if (reported >= REQUIRED_BACKEND_CONTRACT) {dismissNotification(SKEW_TOAST_ID)// Backend caught up — forget any prior snooze so a future regression warns// immediately rather than staying silent for the rest of the window.persistString(SKEW_TOAST_SNOOZE_KEY, null)+ }- return+ if (reported <= REQUIRED_BACKEND_CONTRACT) {+ dismissNotification(GUI_SKEW_TOAST_ID)+ // GUI caught up (or the backend rolled back) — same reset for the reverse+ // direction.+ persistString(GUI_SKEW_TOAST_SNOOZE_KEY, null)}- if (isSkewToastSnoozed()) {+ if (reported < REQUIRED_BACKEND_CONTRACT) {+ if (isSkewToastSnoozed()) {+ return+ }++ notify({+ action: {+ label: translateNow('notifications.updateHermes'),+ onClick: () => {+ snoozeSkewToast()+ void applyBackendUpdate()+ }+ },+ durationMs: 0,+ id: SKEW_TOAST_ID,+ kind: 'warning',+ message: translateNow('notifications.backendOutOfDateMessage'),+ onDismiss: () => snoozeSkewToast(),+ title: translateNow('notifications.backendOutOfDateTitle')+ })+return}- notify({- action: {- label: translateNow('notifications.updateHermes'),- onClick: () => {- snoozeSkewToast()- void applyBackendUpdate()- }- },- durationMs: 0,- id: SKEW_TOAST_ID,- kind: 'warning',- message: translateNow('notifications.backendOutOfDateMessage'),- onDismiss: () => snoozeSkewToast(),- title: translateNow('notifications.backendOutOfDateTitle')- })+ if (reported > REQUIRED_BACKEND_CONTRACT) {+ if (isGuiSkewToastSnoozed()) {+ return+ }++ notify({+ action: {+ label: translateNow('notifications.updateDesktopApp'),+ onClick: () => {+ snoozeGuiSkewToast()+ openUpdateOverlayFor('client')+ }+ },+ durationMs: 0,+ id: GUI_SKEW_TOAST_ID,+ kind: 'warning',+ message: translateNow('notifications.desktopOutOfDateMessage'),+ onDismiss: () => snoozeGuiSkewToast(),+ title: translateNow('notifications.desktopOutOfDateTitle')+ })+ }}export function reportInstallMethodWarning(message: string | undefined): void {diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 23ddda90295..d49b1dc29c0 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -2114,8 +2114,10 @@ def _current_profile_name() -> str:# Monotonic GUI<->backend contract version: the desktop refuses a backend reporting less (or none) with a-# one-click "update to align" prompt; bump whenever the desktop's backend contract changes. v2 file.attach;-# v3 approvals.mode RPCs + session.info reconciliation; v4 session.create fast=false = explicit normal tier;+# one-click "update to align" prompt. The desktop also warns in the reverse direction: a backend reporting+# MORE than the GUI's required value means the GUI build predates this backend (e.g. a long-running app+# across a backend update) and should be updated. Bump whenever the desktop's backend contract changes.+# v2 file.attach; v3 approvals.mode RPCs + session.info reconciliation; v4 session.create fast=false = explicit normal tier;# v5 ws_max_size >16 MiB file.attach frames; v6 plugins.manage rows carry the canonical registry key;# v7 blocking prompts are JSON-RPC server->client requests (`srq-<n>` frames, `open_requests` replay) — a v6# backend still emits `<kind>.request` notifications the renderer no longer listens for.