feat(cli,gateway): /new accepts optional session name argument

Allow users to start a fresh session and immediately set its title by
passing a name to /new (or /reset):

    /new Refactor auth module

Changes:
- hermes_cli/commands.py: add args_hint='[name]' to /new command
- cli.py: parse title argument in process_command(), pass to new_session()
- cli.py: new_session() accepts title=None, sets title via SessionDB
- gateway/run.py: _handle_reset_command() parses title, sets on new entry
- gateway/session.py: reset_session() accepts optional display_name
- tests: add test_new_session_with_title, test_reset_command_with_title,
  test_new_command_in_help_output

All 36 affected tests pass.
This commit is contained in:
Exx
2026-05-04 06:20:19 +00:00
committed by Teknium
parent 055fde40e0
commit f720751d79
6 changed files with 138 additions and 9 deletions

View File

@@ -6896,6 +6896,17 @@ class GatewayRunner:
new_entry = self.session_store.get_or_create_session(source, force_new=True)
header = "✨ New session started!"
# Set session title if provided with /new <title>
_title_arg = event.get_command_args().strip()
if _title_arg and self._session_db and new_entry:
try:
from hermes_state import SessionDB
sanitized = SessionDB.sanitize_title(_title_arg)
if sanitized:
self._session_db.set_session_title(new_entry.session_id, sanitized)
except Exception:
pass
# Fire plugin on_session_reset hook (new session guaranteed to exist)
try:
from hermes_cli.plugins import invoke_hook as _invoke_hook

View File

@@ -1121,7 +1121,7 @@ class SessionStore:
self._save()
return count
def reset_session(self, session_key: str) -> Optional[SessionEntry]:
def reset_session(self, session_key: str, display_name: Optional[str] = None) -> Optional[SessionEntry]:
"""Force reset a session, creating a new session ID."""
db_end_session_id = None
db_create_kwargs = None
@@ -1145,7 +1145,7 @@ class SessionStore:
created_at=now,
updated_at=now,
origin=old_entry.origin,
display_name=old_entry.display_name,
display_name=display_name if display_name is not None else old_entry.display_name,
platform=old_entry.platform,
chat_type=old_entry.chat_type,
is_fresh_reset=True,