The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(sessions): tell the user when a delete is refused for a live turn
kshitijk4poor173770144fdd
diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.pyindex 76fe1e8cb24..f42381067bc 100644--- a/gateway/platforms/api_server.py+++ b/gateway/platforms/api_server.py@@ -156,9 +156,9 @@ from gateway.browser_control_broker import (browser_control_protocol_supported, filter_browser_control_capabilities, get_browser_control_broker)from gateway.platforms._shared import coerce_port as _coerce_port-from hermes_state_errors import SessionActiveWriteGuardErrorfrom gateway.platforms._shared import get_scoped_secret as _get_scoped_secretfrom gateway.platforms.tcp_site import start_tcp_site+from hermes_state_errors import SessionActiveWriteGuardErrorlogger = logging.getLogger(__name__)diff --git a/hermes_cli/sessions_cmd_browse.py b/hermes_cli/sessions_cmd_browse.pyindex 1508abdac48..2e095a0a63f 100644--- a/hermes_cli/sessions_cmd_browse.py+++ b/hermes_cli/sessions_cmd_browse.py@@ -4,6 +4,7 @@ delete-with-confirmation; numbered-list fallback when curses is unavailable (Winfrom typing import Optionalfrom hermes_cli.timefmt import relative_time as _relative_time+from hermes_state_errors import SessionActiveWriteGuardErrordef _session_status_tag(status: Optional[str]) -> str:@@ -152,7 +153,12 @@ class _CursesBrowser:target, self.confirm_delete = self.confirm_delete, Noneif key not in {ord("y"), ord("Y")}:return False- if not self.delete_fn(target["id"]):+ try:+ ok = self.delete_fn(target["id"])+ except SessionActiveWriteGuardError:+ self.flash = "Session is active (a live turn owns it); try again when it finishes."+ return False+ if not ok:self.flash = "Delete failed."return Falseself.sessions[:] = [s for s in self.sessions if s["id"] != target["id"]]@@ -255,6 +261,8 @@ def _session_browse_picker(sessions: list, session_db=None) -> Optional[str]:sessions_dir = Nonetry:return bool(session_db.delete_session(session_id, sessions_dir=sessions_dir, exclude_active_write_guards=True))+ except SessionActiveWriteGuardError:+ raise # the browser tells the user the session is busy instead of a generic failureexcept Exception:return Falsetry: # curses first; any failure (no curses module, odd terminal) falls backdiff --git a/web/src/i18n/en.ts b/web/src/i18n/en.tsindex 6e70c305b06..31517e86273 100644--- a/web/src/i18n/en.ts+++ b/web/src/i18n/en.ts@@ -193,6 +193,8 @@ export const en: Translations = {deleteSelectedConfirmMessage:"This permanently removes {count} selected sessions and all their messages. This cannot be undone.",selectedSessionsDeleted: "{count} sessions deleted",+ selectedSessionsSkippedActive:+ "{count} sessions kept: a live turn is still running in them",failedToDeleteSelected: "Failed to delete selected sessions",resumeInChat: "Resume in Chat",newChat: "New chat",diff --git a/web/src/i18n/types.ts b/web/src/i18n/types.tsindex bddad31aca3..f7fd2bd983b 100644--- a/web/src/i18n/types.ts+++ b/web/src/i18n/types.ts@@ -207,6 +207,7 @@ export interface Translations {deleteSelectedConfirmTitle: string;deleteSelectedConfirmMessage: string;selectedSessionsDeleted: string;+ selectedSessionsSkippedActive: string;failedToDeleteSelected: string;resumeInChat: string;newChat: string;diff --git a/web/src/pages/SessionsPage.tsx b/web/src/pages/SessionsPage.tsxindex 3bdec148fdc..93834ca7d1b 100644--- a/web/src/pages/SessionsPage.tsx+++ b/web/src/pages/SessionsPage.tsx@@ -1403,6 +1403,16 @@ export default function SessionsPage() {),"success",);+ if (resp.skipped_active?.length) {+ // Rows a live turn owns were refused server-side; say so instead of implying all went.+ showToast(+ t.sessions.selectedSessionsSkippedActive.replace(+ "{count}",+ String(resp.skipped_active.length),+ ),+ "error",+ );+ }setDeleteSelectedOpen(false);// Drop deleted rows out of the visible list immediately rather// than waiting for the reload. The reload still runs so total /