The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(dashboard): remove session files when deleting empty sessions
Adolanium5a2a300d99a1
diff --git a/hermes_cli/web_routers/sessions.py b/hermes_cli/web_routers/sessions.pyindex 9e63e40dd0f..2db774b886e 100644--- a/hermes_cli/web_routers/sessions.py+++ b/hermes_cli/web_routers/sessions.py@@ -489,9 +489,10 @@ async def delete_empty_sessions_endpoint(profile: Optional[str] = None):Archived sessions are skipped — the user explicitly chose to keep those rows. * Children of deletedparents are orphaned, not cascade-deleted. See #95868."""+ profile = destructive_profile(profile, "DELETE /api/sessions/empty")deleted = await asyncio.to_thread(- _with_db, destructive_profile(profile, "DELETE /api/sessions/empty"),- lambda db: db.delete_empty_sessions(), read_only=False)+ _with_db, profile,+ lambda db: db.delete_empty_sessions(sessions_dir=_session_files_dir(profile)), read_only=False)return {"ok": True, "deleted": deleted}diff --git a/tests/hermes_cli/test_web_routers_destructive_profile_scope.py b/tests/hermes_cli/test_web_routers_destructive_profile_scope.pyindex 2220456ab17..7b11f46e60e 100644--- a/tests/hermes_cli/test_web_routers_destructive_profile_scope.py+++ b/tests/hermes_cli/test_web_routers_destructive_profile_scope.py@@ -96,7 +96,7 @@ class _StubDB:def delete_sessions(self, ids, **_kwargs):return len(ids)- def delete_empty_sessions(self):+ def delete_empty_sessions(self, sessions_dir=None):return 1def count_open_prune_matches(self, **_filters):diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.pyindex 442227d2722..3bb104ea317 100644--- a/tests/hermes_cli/test_web_server.py+++ b/tests/hermes_cli/test_web_server.py@@ -4506,6 +4506,25 @@ class TestDeleteEmptySessionsEndpoint:finally:db.close()+ def test_delete_removes_on_disk_files_of_deleted_sessions_only(self):+ """Deleting an empty session also removes its files in ``sessions/``.+ A kept session's files stay."""+ from hermes_constants import get_hermes_home++ self._seed()+ sessions_dir = get_hermes_home() / "sessions"+ sessions_dir.mkdir(parents=True, exist_ok=True)+ deleted_files = [sessions_dir / "session_empty1.json", sessions_dir / "request_dump_empty2_1.json"]+ kept_file = sessions_dir / "session_hasmsg.json"+ for path in (*deleted_files, kept_file):+ path.write_text("{}", encoding="utf-8")++ resp = self.auth_client.delete("/api/sessions/empty")++ assert resp.json() == {"ok": True, "deleted": 2}+ assert [p for p in deleted_files if p.exists()] == []+ assert kept_file.exists()+class TestPluginAPIAuth:"""Tests that plugin API routes require the session token (issue #19533)."""