The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): preview a staged text file from this host for an SSH profile
unsupportedpastels70f45a81370b
diff --git a/hermes_cli/web_routers/files.py b/hermes_cli/web_routers/files.pyindex 24ee1c50d08..7b1d9b16543 100644--- a/hermes_cli/web_routers/files.py+++ b/hermes_cli/web_routers/files.py@@ -980,7 +980,8 @@ async def fs_list(path: str, request: Request, profile: Optional[str] = None):@router.get("/api/fs/read-text")async def fs_read_text(path: str, request: Request = None, profile: Optional[str] = None):- backend = await asyncio.to_thread(_fs_backend, profile)+ # A staged paste or pick previews from this host, as read-data-url reads it back to send.+ backend = await asyncio.to_thread(_remote_fs_backend, path, profile)if backend is not None:try:data, size, target = await asyncio.to_thread(diff --git a/tests/hermes_cli/test_web_server_fs.py b/tests/hermes_cli/test_web_server_fs.pyindex 5455e204fa5..b2cf641a183 100644--- a/tests/hermes_cli/test_web_server_fs.py+++ b/tests/hermes_cli/test_web_server_fs.py@@ -758,6 +758,32 @@ def test_a_picked_image_reads_back_from_the_host_for_an_ssh_profile(client, monkassert workspace.asked == [path for path in not_host_owned for _route in range(2)]+def test_a_staged_text_preview_reads_back_from_the_host_for_an_ssh_profile(client, monkeypatch, tmp_path):+ """A long paste or a picked text file is staged in the profile's uploads folder on this host,+ even when its workspace is an SSH machine. Its chip previews it through /api/fs/read-text, so+ that one host-owned file is read here, as /api/fs/read-data-url reads a staged image. A file in+ the uploads folder the upload route did not name is still the SSH machine's to answer."""+ _profile, workspace = _ssh_profiles(tmp_path, monkeypatch)+ monkeypatch.setattr(web_server.app.state, "ui_surface", "webapp", raising=False)+ remote_dev = {"profile": "remote-dev"}++ staged = client.post("/api/chat/file-upload", params=remote_dev,+ files={"file": ("pasted.txt", b"pasted words", "text/plain")})+ assert staged.status_code == 200, staged.text+ staged_path = Path(staged.json()["path"])+ unnamed = staged_path.parent / "pasted.txt"+ unnamed.write_bytes(b"not staged")++ preview = client.get("/api/fs/read-text", params={"path": str(staged_path), **remote_dev})+ assert preview.status_code == 200, preview.text+ assert preview.json()["text"] == "pasted words"+ assert workspace.asked == []++ not_host_owned = client.get("/api/fs/read-text", params={"path": str(unnamed), **remote_dev})+ assert not_host_owned.status_code == 404, not_host_owned.text+ assert workspace.asked == [str(unnamed)]++@pytest.mark.platforms("posix")def test_a_link_staged_in_the_uploads_folder_is_not_read_from_the_host(client, monkeypatch, tmp_path):"""A staged name that links to another host file resolves outside the uploads folder, so an