fix(profile): use existing get_active_profile_name() for /profile command

Replace inline Path.home() / '.hermes' / 'profiles' detection in both CLI
and gateway /profile handlers with the existing get_active_profile_name()
from hermes_cli.profiles — which already handles custom-root deployments,
standard profiles, and Docker layouts.

Fixes /profile incorrectly reporting 'default' when HERMES_HOME points to
a custom-root profile path like /opt/data/profiles/coder.

Based on PR #10484 by Xowiek.
This commit is contained in:
Xowiek 2026-04-15 17:38:41 -07:00 committed by Teknium
parent 77435c4f13
commit 21cd3a3fc0
4 changed files with 52 additions and 35 deletions

View file

@ -209,3 +209,28 @@ async def test_status_command_bypasses_active_session_guard():
assert "Agent Running" in sent[0]
assert not interrupt_event.is_set(), "/status incorrectly triggered an agent interrupt"
assert session_key not in adapter._pending_messages, "/status was incorrectly queued"
@pytest.mark.asyncio
async def test_profile_command_reports_custom_root_profile(monkeypatch, tmp_path):
"""Gateway /profile detects custom-root profiles (not under ~/.hermes)."""
from pathlib import Path
session_entry = SessionEntry(
session_key=build_session_key(_make_source()),
session_id="sess-1",
created_at=datetime.now(),
updated_at=datetime.now(),
platform=Platform.TELEGRAM,
chat_type="dm",
)
runner = _make_runner(session_entry)
profile_home = tmp_path / "profiles" / "coder"
monkeypatch.setenv("HERMES_HOME", str(profile_home))
monkeypatch.setattr(Path, "home", lambda: tmp_path / "unrelated-home")
result = await runner._handle_profile_command(_make_event("/profile"))
assert "**Profile:** `coder`" in result
assert f"**Home:** `{profile_home}`" in result