Skip to content

The agent that grows with you

fix(update): the drain hint opens the profile that holds the parked turn

Teknium788f95786dd5
diff --git a/hermes_cli/update_cmd_drain_report.py b/hermes_cli/update_cmd_drain_report.py
index 41d6852216e..24696cca1c5 100644
--- a/hermes_cli/update_cmd_drain_report.py
+++ b/hermes_cli/update_cmd_drain_report.py
@@ -79,6 +79,14 @@ def read_active_work(home: Optional[Path] = None) -> Optional[list]:
return None
+def _tui_command(home: Optional[Path]) -> str:
+ """The TUI command that opens *home*'s profile: a bare ``hermes`` opens the default one."""
+ from hermes_constants import profile_name_for_home
+
+ name = profile_name_for_home(home)
+ return f"hermes -p {name} --tui" if name and name != "default" else "hermes --tui"
+
+
def format_drain_report(work: Optional[list], *, remaining_s: float, home: Optional[Path] = None) -> str:
"""Multi-line progress block: what the gateway is waiting on plus how to stop waiting."""
lines = [f" ⏳ still draining — {max(remaining_s, 0):.0f}s left before the forced restart"]
@@ -93,7 +101,7 @@ def format_drain_report(work: Optional[list], *, remaining_s: float, home: Optio
# The draining gateway stays reachable for this (#139041): a chat turn parked on an
# approval/clarify is answered from a client, not waited out.
lines.append(" a chat turn waiting on an approval or clarify question can be answered now: "
- "open it with `hermes --tui` (resume the session)")
+ f"open it with `{_tui_command(home)}` (resume the session)")
lines.append(" finish or kill the work above to release the drain now; "
"agent.restart_after_turn_timeout in config.yaml caps this wait")
return "\n".join(lines)
diff --git a/tests/gateway/test_restart_wait_prompt_reach.py b/tests/gateway/test_restart_wait_prompt_reach.py
index 73795416995..f30d5d544ba 100644
--- a/tests/gateway/test_restart_wait_prompt_reach.py
+++ b/tests/gateway/test_restart_wait_prompt_reach.py
@@ -220,3 +220,17 @@ async def test_restart_wait_queues_only_interactive_input(tmp_path, monkeypatch)
assert list_session_admissions(db, session_id="s") == []
finally:
db.close()
+
+
+def test_update_drain_hint_names_the_draining_profile(tmp_path, monkeypatch):
+ """The updater's hint opens the profile whose gateway holds the parked turn: a bare
+ ``hermes --tui`` opens the default profile, where that session isn't listed (#139041)."""
+ from hermes_cli.update_cmd_drain_report import format_drain_report
+
+ root = tmp_path / ".hermes"
+ (root / "profiles" / "work").mkdir(parents=True)
+ monkeypatch.setenv("HOME", str(tmp_path))
+ monkeypatch.setenv("HERMES_HOME", str(root))
+ work = [{"kind": "chat", "session": "s1"}]
+ assert "`hermes -p work --tui`" in format_drain_report(work, remaining_s=60, home=root / "profiles" / "work")
+ assert "`hermes --tui`" in format_drain_report(work, remaining_s=60, home=root)