fix(cli,gateway): surface title errors from /new <name>

The contributor's PR silently swallowed ValueError from
SessionDB.set_session_title() with bare except Exception: pass.
Users typing /new <title> with an already-in-use title got an
untitled session and no feedback.

Changes:
- cli.py: catch ValueError from both sanitize_title() and
  set_session_title(); print the error and mark the session
  untitled in the banner (never echo the rejected title back).
- gateway/run.py: append a warning note to the reset reply on
  title rejection; reflect the accepted title in the header.
- Add regression tests for the duplicate-title path in CLI and
  gateway.

Also map exx@example.com -> @exxmen in scripts/release.py.
This commit is contained in:
Teknium 2026-05-04 02:38:24 -07:00
parent f720751d79
commit 5b6d413476
5 changed files with 136 additions and 8 deletions

View file

@ -6898,14 +6898,26 @@ class GatewayRunner:
# Set session title if provided with /new <title>
_title_arg = event.get_command_args().strip()
_title_note = ""
if _title_arg and self._session_db and new_entry:
from hermes_state import SessionDB
try:
from hermes_state import SessionDB
sanitized = SessionDB.sanitize_title(_title_arg)
if sanitized:
except ValueError as e:
sanitized = None
_title_note = f"\n⚠️ Title rejected: {e}"
if sanitized:
try:
self._session_db.set_session_title(new_entry.session_id, sanitized)
except Exception:
pass
header = f"✨ New session started: {sanitized}"
except ValueError as e:
_title_note = f"\n⚠️ {e} — session started untitled."
except Exception:
pass
elif not _title_note:
# sanitize_title returned empty (whitespace-only / unprintable)
_title_note = "\n⚠️ Title is empty after cleanup — session started untitled."
header = header + _title_note
# Fire plugin on_session_reset hook (new session guaranteed to exist)
try: