Skip to content

The agent that grows with you

fix(onboarding): the first-task handoff follows a renamed owner profile

alt-glitch3531ae5e9307
diff --git a/hermes_cli/setup_profile.py b/hermes_cli/setup_profile.py
index a9e6e167059..3622c90f638 100644
--- a/hermes_cli/setup_profile.py
+++ b/hermes_cli/setup_profile.py
@@ -125,7 +125,17 @@ def _user_home(launch_home: Path) -> Path:
return home
found = find_setup_profile()
owner = _read_state(found[1]).get(_OWNER) if found else None
- return profiles_mod.get_profile_dir(owner or "default")
+ return profiles_mod.get_profile_dir(_live_owner(owner or "default"))
+
+
+def _live_owner(owner: str) -> str:
+ """The saved owner's current name: a renamed profile keeps its old name in ``previous_names``."""
+ if owner == "default" or profiles_mod.get_profile_dir(owner).is_dir():
+ return owner
+ for info in profiles_mod.list_profiles(lazy_skill_count=True):
+ if owner in info.previous_names:
+ return info.name
+ return "default"
def onboarding_eligible() -> bool:
diff --git a/tests/hermes_cli/test_setup_profile_owner.py b/tests/hermes_cli/test_setup_profile_owner.py
index 0b1f57e171c..b7840ddba6a 100644
--- a/tests/hermes_cli/test_setup_profile_owner.py
+++ b/tests/hermes_cli/test_setup_profile_owner.py
@@ -37,3 +37,12 @@ def test_reset_from_the_setup_backend_keeps_the_handoff_owner(root, monkeypatch)
assert setup_profile.primary_profile(setup) == "work"
assert "owner_profile" not in setup_profile.read_state()
+
+
+def test_handoff_follows_a_renamed_owner_profile(root, monkeypatch):
+ setup = _setup_from(monkeypatch, "work")
+ monkeypatch.setenv("HERMES_HOME", str(setup))
+
+ profiles.rename_profile("work", "personal")
+
+ assert setup_profile.primary_profile(setup) == "personal"