hermes_cli/main_tui_launch.py::_print_tui_exit_summary printed `hermes --tui --resume ID` / `hermes --tui -c "TITLE"` without the `-p <profile>` suffix that the classic CLI sibling (cli_session_mixin.py::_print_exit_summary) already appends, so a hint copied from a named profile's TUI resolved against the default profile and failed with "No session found". Trimmed from #125079: no try/except fallback (get_active_profile_name does not raise), tests folded into the existing tests/hermes_cli/test_exit_summary_resume_hint.py. red-on-base: tests/hermes_cli/test_exit_summary_resume_hint.py::TestTuiExitSummaryResumeHint:: test_tui_hints_include_profile_flag_for_named_profile fails on origin/main with `assert 'hermes --tui --resume 20260524_000001_abc123 -p dev' in '...hermes --tui --resume 20260524_000001_abc123\n hermes --tui -c "My TUI Session"...'`; green-on-head: 7 passed.
This commit is contained in:
@@ -59,9 +59,13 @@ def _print_tui_exit_summary(session_id: Optional[str], active_session_file: Opti
|
||||
if db is not None:
|
||||
db.close()
|
||||
|
||||
print(f"\nResume this session with:\n hermes --tui --resume {target}")
|
||||
# Sessions live under the profile's HERMES_HOME — mirror cli_session_mixin::_print_exit_summary.
|
||||
from hermes_cli.profiles import get_active_profile_name
|
||||
active_profile = get_active_profile_name()
|
||||
profile_flag = "" if active_profile in ("default", "custom") else f" -p {active_profile}"
|
||||
print(f"\nResume this session with:\n hermes --tui --resume {target}{profile_flag}")
|
||||
if title:
|
||||
print(f' hermes --tui -c "{title}"')
|
||||
print(f' hermes --tui -c "{title}"{profile_flag}')
|
||||
print(f"\nSession: {target}")
|
||||
if title:
|
||||
print(f"Title: {title}")
|
||||
|
||||
@@ -4,6 +4,9 @@ from datetime import datetime
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from cli import HermesCLI
|
||||
from hermes_cli.main_tui_launch import _print_tui_exit_summary
|
||||
|
||||
import hermes_cli.main # noqa: F401 — _print_tui_exit_summary imports it lazily; load it at collection time
|
||||
|
||||
|
||||
def _make_cli(session_id="20260524_000001_abc123"):
|
||||
@@ -81,3 +84,33 @@ class TestExitSummaryResumeHint:
|
||||
# Resume hint still printed without -p.
|
||||
assert "hermes --resume 20260524_000001_abc123" in out
|
||||
assert " -p " not in out
|
||||
|
||||
|
||||
def _tui_session_db(*_args, **_kwargs):
|
||||
db = MagicMock()
|
||||
db.get_session.return_value = {"message_count": 3}
|
||||
db.get_session_title.return_value = "My TUI Session"
|
||||
return db
|
||||
|
||||
|
||||
class TestTuiExitSummaryResumeHint:
|
||||
"""``_print_tui_exit_summary`` (hermes_cli/main_tui_launch.py) is a separate entry
|
||||
point from the classic CLI summary above and must carry the same ``-p`` flag (#125078)."""
|
||||
|
||||
def test_tui_hints_include_profile_flag_for_named_profile(self, capsys):
|
||||
with patch("hermes_state.SessionDB", _tui_session_db), patch(
|
||||
"hermes_cli.profiles.get_active_profile_name", return_value="dev"
|
||||
):
|
||||
_print_tui_exit_summary("20260524_000001_abc123")
|
||||
out = capsys.readouterr().out
|
||||
assert "hermes --tui --resume 20260524_000001_abc123 -p dev" in out
|
||||
assert 'hermes --tui -c "My TUI Session" -p dev' in out
|
||||
|
||||
def test_tui_hints_no_profile_flag_on_default(self, capsys):
|
||||
with patch("hermes_state.SessionDB", _tui_session_db), patch(
|
||||
"hermes_cli.profiles.get_active_profile_name", return_value="default"
|
||||
):
|
||||
_print_tui_exit_summary("20260524_000001_abc123")
|
||||
out = capsys.readouterr().out
|
||||
assert "hermes --tui --resume 20260524_000001_abc123" in out
|
||||
assert " -p " not in out
|
||||
|
||||
Reference in New Issue
Block a user