Skip to content

The agent that grows with you

fix(tui): ssh resume keeps a picked remote "/"; the launch-dir filter is sandbox-only

Teknium256e9f32f88c
diff --git a/tests/tui_gateway/test_remote_backend_launch_cwd.py b/tests/tui_gateway/test_remote_backend_launch_cwd.py
index 8a0ea753ce0..9c0bcfadfc5 100644
--- a/tests/tui_gateway/test_remote_backend_launch_cwd.py
+++ b/tests/tui_gateway/test_remote_backend_launch_cwd.py
@@ -174,9 +174,11 @@ def test_docker_keeps_the_host_dir(launch_dir, monkeypatch, mount):
def test_sandbox_resume_drops_a_stored_hermes_home_cwd(launch_dir, monkeypatch):
"""A row persisted before the fix with a launch dir (the Hermes home, its subprocess home) as cwd is not
- re-adopted as the sandbox workspace."""
+ re-adopted as the sandbox workspace. ssh keeps its own rule: a remote ``/`` someone picked survives."""
hermes_home = server.get_hermes_home()
(hermes_home / "home").mkdir(exist_ok=True)
+ monkeypatch.setenv("TERMINAL_ENV", "ssh")
+ assert server._resumable_stored_cwd("/", None) == "/"
_backend(monkeypatch, "modal")
for launch in (str(hermes_home), str(hermes_home / "home")):
assert server._resumable_stored_cwd(launch, None) == ""
diff --git a/tui_gateway/session_workdir.py b/tui_gateway/session_workdir.py
index 8271fd86e6f..c0cf3d46e87 100644
--- a/tui_gateway/session_workdir.py
+++ b/tui_gateway/session_workdir.py
@@ -374,7 +374,8 @@ def _resumable_stored_cwd(cwd, profile_home) -> str:
cwd = str(cwd or "")
if cwd and _cwd_is_remote(profile_home) and _is_hermes_owned_cwd(cwd, profile_home):
return ""
- if cwd and not _host_cwd_is_terminal_cwd(profile_home) and _is_launch_dir(cwd, profile_home):
+ if cwd and not _cwd_is_remote(profile_home) and not _host_cwd_is_terminal_cwd(profile_home) \
+ and _is_launch_dir(cwd, profile_home):
return ""
if cwd and _is_other_profiles_cwd(cwd, profile_home):
return ""