The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): /title collision prints main's "already in use by session <id>" copy
Teknium061a9bdb7435
diff --git a/hermes_cli/gateway_session_store.py b/hermes_cli/gateway_session_store.pyindex e628ab89cdd..2b280c9a79d 100644--- a/hermes_cli/gateway_session_store.py+++ b/hermes_cli/gateway_session_store.py@@ -148,11 +148,27 @@ class GatewaySessionStore:expected_revision=self._revision(session_id), operation=operation, payload=payload)def set_session_title(self, session_id, title):- self._mutate(session_id, "rename", {"title": title})+ try:+ self._mutate(session_id, "rename", {"title": title})+ except GatewayClientError as exc:+ # The owner's SessionDB ValueError text never crosses the wire (bounded reason codes):+ # print main's "already in use" copy from the reader when another row holds the title.+ holder = self._title_holder(session_id, title)+ if holder:+ raise ValueError(f"Title '{title}' is already in use by session {holder}") from exc+ raiseif session_id in self.snapshots:self.connection.state(session_id).title = titlereturn True+ def _title_holder(self, session_id, title):+ db = self._db()+ if db is None or not title:+ return None+ with db._read_ctx() as conn:+ row = conn.execute("SELECT id FROM sessions WHERE title = ? AND id != ?", (title, session_id)).fetchone()+ return row[0] if row else None+def delete_session(self, session_id, sessions_dir=None):self.snapshots.pop(session_id, None)self._mutate(session_id, "delete", {})diff --git a/tests/hermes_cli/test_gateway_session_store.py b/tests/hermes_cli/test_gateway_session_store.pyindex cb4d812a277..a163becced3 100644--- a/tests/hermes_cli/test_gateway_session_store.py+++ b/tests/hermes_cli/test_gateway_session_store.py@@ -181,3 +181,30 @@ def test_cli_startup_notices_render_from_the_snapshot(store, monkeypatch):printed.clear()CLIInfoMixin.show_banner(banner)assert "[yellow]⚠ terminal off[/]" in printed and "LOCAL-WARN" not in printed+++def test_rename_refusal_prints_mains_title_in_use_text(store, tmp_path, monkeypatch):+ """The owner's ValueError text never crosses the wire (bounded reason codes); the rename copy+ main prints comes from the read-only reader."""+ db, client = store+ monkeypatch.setattr("hermes_constants.get_hermes_home", lambda: tmp_path)+ from hermes_state import SessionDB+ writer = SessionDB(db_path=tmp_path / "state.db")+ writer.create_session("local-other", source="local")+ writer.set_session_title("local-other", "Alpha Title")+ writer.create_session("local-old", source="local")+ writer.close()+ db.open_session(cli("local-old", resumed=True))++ async def refuse(method, *, _timeout=None, **params):+ client.calls.append((method, params))+ if method == "session.mutate":+ raise GatewayClientError("request_failed")+ return snapshot(params.get("session_id", "local-old"))+ client.rpc = refuse+ with pytest.raises(ValueError) as err:+ db.set_session_title("local-old", "Alpha Title")+ assert str(err.value) == "Title 'Alpha Title' is already in use by session local-other"+ with pytest.raises(ValueError) as err:+ db.set_session_title("local-old", "Free Title")+ assert str(err.value) == "request_failed"