Skip to content

The agent that grows with you

fix(cli): treat profile=current as the request's own profile on fs reads

Austin Pickett671363fa3450
diff --git a/hermes_cli/web_routers/files.py b/hermes_cli/web_routers/files.py
index 7cc7b96127c..8d86c9032f3 100644
--- a/hermes_cli/web_routers/files.py
+++ b/hermes_cli/web_routers/files.py
@@ -910,10 +910,13 @@ async def _fs_download_path(path: str, profile: Optional[str], session_id: Optio
def _fs_profile_home(profile: Optional[str]) -> Optional[Path]:
- """HERMES_HOME of a requested profile (404/400 on an unknown one), None for the active one."""
- if profile is None:
- return None
+ """HERMES_HOME of a requested profile (404/400 on an unknown one), None for the request's
+ own profile (omitted, ``""`` or ``current``, as ``_is_current_profile`` reads them)."""
from hermes_cli.web_server_cron import _cron_profile_home
+ from hermes_cli.web_server_profiles import _is_current_profile
+
+ if _is_current_profile(profile):
+ return None
return _cron_profile_home(profile)[1]
diff --git a/tests/hermes_cli/test_web_server_fs.py b/tests/hermes_cli/test_web_server_fs.py
index b394511b159..5cf693e1d2c 100644
--- a/tests/hermes_cli/test_web_server_fs.py
+++ b/tests/hermes_cli/test_web_server_fs.py
@@ -621,6 +621,19 @@ def test_fs_download_profile_uses_that_profiles_sandbox(client, monkeypatch, tmp
assert default.content == b"DEFAULT"
+def test_fs_reads_accept_profile_current_for_host_files(client, tmp_path):
+ """``profile=current`` means the request's own profile, as elsewhere in the dashboard."""
+ target = tmp_path / "plain.txt"
+ target.write_text("host", encoding="utf-8")
+
+ for selector in ("current", "", "CURRENT"):
+ read = client.get("/api/fs/read-text", params={"path": str(target), "profile": selector})
+ listing = client.get("/api/fs/list", params={"path": str(tmp_path), "profile": selector})
+ assert read.status_code == 200, (selector, read.text)
+ assert read.json()["text"] == "host"
+ assert listing.status_code == 200, (selector, listing.text)
+
+
def test_fs_read_plain_host_path_logs_no_docker_media_warning(client, docker_volumes, tmp_path, caplog):
"""fs routes see ordinary host paths constantly; misses are not MEDIA warnings."""
plain = tmp_path / "plain.txt"