The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp-access): a restart held off by a running chat shows as saved, in plain words
emozillac3e63a101ab8
diff --git a/apps/desktop/src/api/webapp-access.ts b/apps/desktop/src/api/webapp-access.tsindex 5758998f215..a87d35c34a0 100644--- a/apps/desktop/src/api/webapp-access.ts+++ b/apps/desktop/src/api/webapp-access.ts@@ -18,8 +18,10 @@ export interface WebAccessStatus {public_url: string}-/** Start/stop save the config and restart the gateway; a refused restart keeps the config. */+/** Start/stop save the config and restart the gateway; a refused restart keeps the config.+ * `restart_busy`: a running chat refused it. `restart_error` is the CLI's text, for logs only. */export interface WebAccessChange extends WebAccessStatus {+ restart_busy?: booleanrestart_error?: stringrestart_started: boolean}diff --git a/apps/desktop/src/app/settings/web-access-settings.test.tsx b/apps/desktop/src/app/settings/web-access-settings.test.tsxindex 47796554754..325d594e3dc 100644--- a/apps/desktop/src/app/settings/web-access-settings.test.tsx+++ b/apps/desktop/src/app/settings/web-access-settings.test.tsx@@ -24,6 +24,7 @@ import type { WebAccessStatus } from '@/api/webapp-access'import * as hermes from '@/hermes'import { I18nProvider } from '@/i18n'import { queryClient } from '@/lib/query-client'+import { $notifications, clearNotifications } from '@/store/notifications'import { WebAccessSettings } from './web-access-settings'@@ -55,6 +56,7 @@ beforeEach(() => queryClient.clear())afterEach(() => {cleanup()+ clearNotifications()vi.clearAllMocks()})@@ -117,4 +119,29 @@ describe('WebAccessSettings', () => {expect(mocked.startWebAccess).not.toHaveBeenCalled()expect(mocked.stopWebAccess).not.toHaveBeenCalled()})++ it('says plainly that a change was saved when a running chat holds off the restart', async () => {+ const refusal =+ 'Refusing to restart the gateway: 1 live session(s) would be interrupted.\n' ++ ' POST /api/gateway/restart?interrupt=true # interrupts 1 live session(s)'++ mocked.startWebAccess.mockResolvedValue({+ ...OFF,+ enabled: true,+ mode: 'lan',+ restart_busy: true,+ restart_error: refusal,+ restart_started: false+ })+ renderPane(OFF)++ fireEvent.click(await screen.findByRole('button', { name: 'Start' }))++ await waitFor(() => expect($notifications.get()).toHaveLength(1))+ const [toast] = $notifications.get()+ expect(toast.kind).toBe('warning')+ expect(toast.title).toBe('Restart needed')+ expect(toast.message).toMatch(/^Saved\. A chat is running/)+ expect(JSON.stringify(toast)).not.toMatch(/Refusing|interrupt|Couldn't change/)+ })})diff --git a/apps/desktop/src/app/settings/web-access-settings.tsx b/apps/desktop/src/app/settings/web-access-settings.tsxindex 71c89162804..3c6387a772a 100644--- a/apps/desktop/src/app/settings/web-access-settings.tsx+++ b/apps/desktop/src/app/settings/web-access-settings.tsx@@ -20,7 +20,7 @@ import type { WebAccessTranslations } from '@/i18n/types_gateway_host'import { ExternalLink } from '@/lib/external-link'import { Globe, Loader2, Network } from '@/lib/icons'import { isBrowserHostedDesktop } from '@/lib/platform'-import { notifyError } from '@/store/notifications'+import { notify, notifyError } from '@/store/notifications'import { $connection } from '@/store/session'import { CONTROL_TEXT } from './constants'@@ -120,7 +120,10 @@ function WebAccessForm({ queryKey, status, w }: FormProps): ReactElement {apply(result)if (!result.restart_started) {- throw new Error(w.restartRefused(result.restart_error ?? ''))+ // Not a failure: the pane now shows the saved change waiting for the restart.+ notify({ kind: 'warning', message: result.restart_busy ? w.restartBusy : w.restartFailed, title: w.restartNeeded })++ return}if (result.enabled && kind !== 'stop') {diff --git a/apps/desktop/src/i18n/ar_settings.ts b/apps/desktop/src/i18n/ar_settings.tsindex b62f7d837c4..9cb87a1eaac 100644--- a/apps/desktop/src/i18n/ar_settings.ts+++ b/apps/desktop/src/i18n/ar_settings.ts@@ -725,7 +725,8 @@ export const arSettings = {pendingOn: 'تم الحفظ. ستقدّم البوابة تطبيق الويب بعد إعادة تشغيلها.',pendingOff: 'تم الإيقاف، لكن البوابة تواصل تقديم تطبيق الويب حتى إعادة تشغيلها.',unavailableDetail: reason => `تعذّر على البوابة تقديم تطبيق الويب: ${reason}`,- restartRefused: reason => `تم الحفظ. أعد تشغيل البوابة لتطبيقه: ${reason}`,+ restartBusy: 'تم الحفظ. توجد محادثة قيد التشغيل، لذا لم تُعَد تشغيل البوابة. اختر «إعادة تشغيل البوابة» عند انتهائها.',+ restartFailed: 'تم الحفظ، لكن تعذّرت إعادة تشغيل البوابة. اختر «إعادة تشغيل البوابة» للمحاولة مجددًا.',startTimedOut: 'لم تقدّم البوابة تطبيق الويب خلال 90 ثانية.',start: 'تشغيل',stop: 'إيقاف',diff --git a/apps/desktop/src/i18n/de_gateway_host.ts b/apps/desktop/src/i18n/de_gateway_host.tsindex 935b586b938..1a4a70d4fdf 100644--- a/apps/desktop/src/i18n/de_gateway_host.ts+++ b/apps/desktop/src/i18n/de_gateway_host.ts@@ -24,7 +24,8 @@ export const deGatewayHost: GatewayHostTranslations = {pendingOn: 'Gespeichert. Das Gateway stellt die Web-App nach seinem Neustart bereit.',pendingOff: 'Ausgeschaltet, aber das Gateway stellt die Web-App bis zu seinem Neustart weiter bereit.',unavailableDetail: reason => `Das Gateway konnte die Web-App nicht bereitstellen: ${reason}`,- restartRefused: reason => `Gespeichert. Starte das Gateway neu, um es anzuwenden: ${reason}`,+ restartBusy: 'Gespeichert. Ein Chat läuft, deshalb wurde das Gateway nicht neu gestartet. Wähle „Gateway neu starten“, sobald er beendet ist.',+ restartFailed: 'Gespeichert, aber das Gateway konnte nicht neu starten. Wähle „Gateway neu starten“, um es erneut zu versuchen.',startTimedOut: 'Das Gateway hat die Web-App nicht innerhalb von 90 Sekunden bereitgestellt.',start: 'Starten',stop: 'Stoppen',diff --git a/apps/desktop/src/i18n/en_gateway_host.ts b/apps/desktop/src/i18n/en_gateway_host.tsindex ef53604e1c7..c2d43e0e8c5 100644--- a/apps/desktop/src/i18n/en_gateway_host.ts+++ b/apps/desktop/src/i18n/en_gateway_host.ts@@ -24,7 +24,8 @@ export const enGatewayHost: GatewayHostTranslations = {pendingOn: 'Saved. The gateway serves the web app once it restarts.',pendingOff: 'Turned off, but the gateway keeps serving the web app until it restarts.',unavailableDetail: reason => `The gateway couldn't serve the web app: ${reason}`,- restartRefused: reason => `Saved. Restart the gateway to apply it: ${reason}`,+ restartBusy: "Saved. A chat is running, so the gateway didn't restart. Choose Restart gateway once it ends.",+ restartFailed: "Saved, but the gateway couldn't restart. Choose Restart gateway to try again.",startTimedOut: "The gateway didn't serve the web app within 90 seconds.",start: 'Start',stop: 'Stop',diff --git a/apps/desktop/src/i18n/es_gateway_host.ts b/apps/desktop/src/i18n/es_gateway_host.tsindex 07153d530c1..17186b36b1f 100644--- a/apps/desktop/src/i18n/es_gateway_host.ts+++ b/apps/desktop/src/i18n/es_gateway_host.ts@@ -25,7 +25,8 @@ export const esGatewayHost: GatewayHostTranslations = {pendingOn: 'Guardado. El gateway servirá la aplicación web cuando se reinicie.',pendingOff: 'Desactivado, pero el gateway sigue sirviendo la aplicación web hasta que se reinicie.',unavailableDetail: reason => `El gateway no pudo servir la aplicación web: ${reason}`,- restartRefused: reason => `Guardado. Reinicia el gateway para aplicarlo: ${reason}`,+ restartBusy: 'Guardado. Hay un chat en curso, así que el gateway no se reinició. Elige «Reiniciar gateway» cuando termine.',+ restartFailed: 'Guardado, pero el gateway no pudo reiniciarse. Elige «Reiniciar gateway» para volver a intentarlo.',startTimedOut: 'El gateway no sirvió la aplicación web en 90 segundos.',start: 'Iniciar',stop: 'Detener',diff --git a/apps/desktop/src/i18n/fr_gateway_host.ts b/apps/desktop/src/i18n/fr_gateway_host.tsindex d380b532d4c..8348873137a 100644--- a/apps/desktop/src/i18n/fr_gateway_host.ts+++ b/apps/desktop/src/i18n/fr_gateway_host.ts@@ -24,7 +24,8 @@ export const frGatewayHost: GatewayHostTranslations = {pendingOn: "Enregistré. La passerelle servira l'application web après son redémarrage.",pendingOff: "Désactivé, mais la passerelle continue de servir l'application web jusqu'à son redémarrage.",unavailableDetail: reason => `La passerelle n'a pas pu servir l'application web : ${reason}`,- restartRefused: reason => `Enregistré. Redémarrez la passerelle pour l'appliquer : ${reason}`,+ restartBusy: "Enregistré. Une conversation est en cours, la passerelle n'a donc pas redémarré. Choisissez « Redémarrer la passerelle » une fois qu'elle est terminée.",+ restartFailed: "Enregistré, mais la passerelle n'a pas pu redémarrer. Choisissez « Redémarrer la passerelle » pour réessayer.",startTimedOut: "La passerelle n'a pas servi l'application web en 90 secondes.",start: 'Démarrer',stop: 'Arrêter',diff --git a/apps/desktop/src/i18n/ja_gateway_host.ts b/apps/desktop/src/i18n/ja_gateway_host.tsindex e80573e6a68..9d580058ffb 100644--- a/apps/desktop/src/i18n/ja_gateway_host.ts+++ b/apps/desktop/src/i18n/ja_gateway_host.ts@@ -24,7 +24,8 @@ export const jaGatewayHost: GatewayHostTranslations = {pendingOn: '保存しました。ゲートウェイの再起動後に Web アプリが提供されます。',pendingOff: 'オフにしましたが、ゲートウェイは再起動するまで Web アプリを提供し続けます。',unavailableDetail: reason => `ゲートウェイが Web アプリを提供できませんでした: ${reason}`,- restartRefused: reason => `保存しました。適用するにはゲートウェイを再起動してください: ${reason}`,+ restartBusy: '保存しました。チャットが実行中のため、ゲートウェイは再起動しませんでした。終了したら「ゲートウェイを再起動」を選んでください。',+ restartFailed: '保存しましたが、ゲートウェイを再起動できませんでした。「ゲートウェイを再起動」を選んで再試行してください。',startTimedOut: 'ゲートウェイが 90 秒以内に Web アプリを提供しませんでした。',start: '開始',stop: '停止',diff --git a/apps/desktop/src/i18n/ru_gateway_host.ts b/apps/desktop/src/i18n/ru_gateway_host.tsindex 39f354b900e..30f9e71f1a7 100644--- a/apps/desktop/src/i18n/ru_gateway_host.ts+++ b/apps/desktop/src/i18n/ru_gateway_host.ts@@ -24,7 +24,8 @@ export const ruGatewayHost: GatewayHostTranslations = {pendingOn: 'Сохранено. Шлюз откроет веб-приложение после перезапуска.',pendingOff: 'Выключено, но шлюз продолжает открывать веб-приложение до перезапуска.',unavailableDetail: reason => `Шлюзу не удалось открыть веб-приложение: ${reason}`,- restartRefused: reason => `Сохранено. Перезапустите шлюз, чтобы применить: ${reason}`,+ restartBusy: 'Сохранено. Идёт чат, поэтому шлюз не перезапущен. Когда он закончится, нажмите «Перезапустить шлюз».',+ restartFailed: 'Сохранено, но шлюз не удалось перезапустить. Нажмите «Перезапустить шлюз», чтобы попробовать снова.',startTimedOut: 'Шлюз не открыл веб-приложение за 90 секунд.',start: 'Запустить',stop: 'Остановить',diff --git a/apps/desktop/src/i18n/types_gateway_host.ts b/apps/desktop/src/i18n/types_gateway_host.tsindex 6657cc81c5b..85b0b38e88e 100644--- a/apps/desktop/src/i18n/types_gateway_host.ts+++ b/apps/desktop/src/i18n/types_gateway_host.ts@@ -27,7 +27,8 @@ export interface WebAccessTranslations {pendingOn: stringpendingOff: stringunavailableDetail: (reason: string) => string- restartRefused: (reason: string) => string+ restartBusy: string+ restartFailed: stringstartTimedOut: stringstart: stringstop: stringdiff --git a/apps/desktop/src/i18n/zh-hant_settings.ts b/apps/desktop/src/i18n/zh-hant_settings.tsindex 04e0683b22a..14117bcc42d 100644--- a/apps/desktop/src/i18n/zh-hant_settings.ts+++ b/apps/desktop/src/i18n/zh-hant_settings.ts@@ -992,7 +992,8 @@ export const zhHantSettings = {pendingOn: '已儲存。閘道重新啟動後將提供網頁應用程式。',pendingOff: '已關閉,但閘道在重新啟動前仍會繼續提供網頁應用程式。',unavailableDetail: reason => `閘道無法提供網頁應用程式:${reason}`,- restartRefused: reason => `已儲存。重新啟動閘道後生效:${reason}`,+ restartBusy: '已儲存。有對話正在進行,因此閘道沒有重新啟動。對話結束後請選擇「重新啟動閘道」。',+ restartFailed: '已儲存,但閘道無法重新啟動。請選擇「重新啟動閘道」重試。',startTimedOut: '閘道未能在 90 秒內提供網頁應用程式。',start: '啟動',stop: '停止',diff --git a/apps/desktop/src/i18n/zh_gateway_host.ts b/apps/desktop/src/i18n/zh_gateway_host.tsindex 46d64df15e8..e92169229b6 100644--- a/apps/desktop/src/i18n/zh_gateway_host.ts+++ b/apps/desktop/src/i18n/zh_gateway_host.ts@@ -24,7 +24,8 @@ export const zhGatewayHost: GatewayHostTranslations = {pendingOn: '已保存。网关重启后将提供网页应用。',pendingOff: '已关闭,但网关在重启前仍会继续提供网页应用。',unavailableDetail: reason => `网关无法提供网页应用:${reason}`,- restartRefused: reason => `已保存。重启网关后生效:${reason}`,+ restartBusy: '已保存。有对话正在进行,因此网关没有重启。对话结束后请选择“重启网关”。',+ restartFailed: '已保存,但网关无法重启。请选择“重启网关”重试。',startTimedOut: '网关未能在 90 秒内提供网页应用。',start: '启动',stop: '停止',diff --git a/hermes_cli/web_server_gateway.py b/hermes_cli/web_server_gateway.pyindex ec7595dfcaf..716030090e4 100644--- a/hermes_cli/web_server_gateway.py+++ b/hermes_cli/web_server_gateway.py@@ -674,11 +674,12 @@ def live_session_refusal(profile: Optional[str], verb: str) -> Optional[str]:def _restart_gateway_after(profile: Optional[str], *, what: str, label: str) -> dict[str, Any]:"""Best-effort gateway restart after a config change. The save stays authoritative: a failedspawn is reported (``restart_started: False`` + ``restart_error``) so the UI can fall back to- its manual restart banner instead of failing the request. Live sessions refuse it the same way."""+ its manual restart banner instead of failing the request. Live sessions refuse it the same way,+ with ``restart_busy`` set so a UI can say so in its own words."""from hermes_cli.web_server import _spawn_gateway_restartrefusal = live_session_refusal(profile, "restart")if refusal:- return {"restart_started": False, "restart_error": refusal}+ return {"restart_started": False, "restart_error": refusal, "restart_busy": True}try:proc, reused = _spawn_gateway_restart(profile)except Exception as exc:diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.jsonindex c5cae08f8bc..26d31404e8a 100644--- a/locales/_keys.desktop.json+++ b/locales/_keys.desktop.json@@ -3539,9 +3539,10 @@"settings.gateway.webAccess.notRunningDetail","settings.gateway.webAccess.pendingOff","settings.gateway.webAccess.pendingOn",+ "settings.gateway.webAccess.restartBusy",+ "settings.gateway.webAccess.restartFailed","settings.gateway.webAccess.restartGateway","settings.gateway.webAccess.restartNeeded",- "settings.gateway.webAccess.restartRefused","settings.gateway.webAccess.running","settings.gateway.webAccess.runningLan","settings.gateway.webAccess.runningLocal",diff --git a/tests/hermes_cli/test_webapp_access.py b/tests/hermes_cli/test_webapp_access.pyindex e47211e960f..bcafadd285b 100644--- a/tests/hermes_cli/test_webapp_access.py+++ b/tests/hermes_cli/test_webapp_access.py@@ -266,3 +266,19 @@ def test_restart_applies_the_saved_config_and_does_nothing_else(client, restartsassert nous == []assert builds == []assert read_raw_config() == saved+++def test_a_restart_refused_by_a_running_chat_is_reported_as_busy(client, nous, monkeypatch):+ """When a running chat refuses the gateway restart, the change stays saved and the answer says+ so in a field the pane can word plainly (``restart_busy``), beside the CLI's own refusal text."""+ import hermes_cli.web_server_gateway as gw++ refusal = ("Refusing to restart the gateway: 1 live session(s) would be interrupted.\n"+ " POST /api/gateway/restart?interrupt=true # interrupts 1 live session(s)")+ monkeypatch.setattr(gw, "live_session_refusal", lambda _profile, _verb: refusal)++ response = client.post("/api/webapp-access/start", json={"mode": "lan"})+ assert response.status_code == 200, response.text+ assert response.json()["restart_started"] is False+ assert response.json()["restart_busy"] is True+ assert response.json()["enabled"] is True