fix(desktop): treat profile=default as this process's own home
_is_other_profile only allowed empty/current, so a ?profile=default save skipped the session.info broadcast on the process whose config it just wrote. Compare the resolved target to the process HERMES_HOME.
This commit is contained in:
@@ -7067,7 +7067,13 @@ async def update_config(body: ConfigUpdate, profile: Optional[str] = None):
|
||||
def _is_other_profile(profile: Optional[str]) -> bool:
|
||||
"""True when ``profile`` names a profile other than this process's own."""
|
||||
requested = (profile or "").strip()
|
||||
return bool(requested) and requested.lower() != "current"
|
||||
if not requested or requested.lower() == "current":
|
||||
return False
|
||||
try:
|
||||
target = _resolve_profile_dir(requested)
|
||||
except HTTPException:
|
||||
return True
|
||||
return target.resolve() != get_process_hermes_home().resolve()
|
||||
|
||||
|
||||
def _approval_mode_of(config: Dict[str, Any]) -> str:
|
||||
|
||||
@@ -99,6 +99,19 @@ class TestApprovalsSaveBroadcast:
|
||||
"re-emit session.info"
|
||||
)
|
||||
|
||||
def test_own_profile_named_default_broadcasts(self, client, broadcast_calls):
|
||||
"""Dashboard/desktop often send ?profile=default for this process's
|
||||
own home. That is not an other-profile save and must still emit."""
|
||||
resp = client.put(
|
||||
"/api/config?profile=default",
|
||||
json={"config": {"approvals": {"mode": "off"}}},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert broadcast_calls, (
|
||||
"?profile=default is this process's own HERMES_HOME; skipping "
|
||||
"the broadcast leaves live sessions painting stale YOLO state"
|
||||
)
|
||||
|
||||
def test_other_profile_save_does_not_broadcast(self, client, broadcast_calls, monkeypatch, tmp_path):
|
||||
from hermes_cli import web_server
|
||||
|
||||
|
||||
Reference in New Issue
Block a user