The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): read only the backend and mount flag when registering a Desktop cwd
kshitijk4poor3a481782eb57
diff --git a/tests/tui_gateway/test_unmounted_docker_cwd.py b/tests/tui_gateway/test_unmounted_docker_cwd.pyindex 20003f4e54a..5dce3ef371e 100644--- a/tests/tui_gateway/test_unmounted_docker_cwd.py+++ b/tests/tui_gateway/test_unmounted_docker_cwd.py@@ -100,3 +100,23 @@ def test_unmounted_registration_preserves_configured_container_cwd(tmp_path):finally:terminal_tool.clear_task_env_overrides("configured-cwd")reset_terminal_scope(token)+++def test_a_bad_unrelated_terminal_setting_does_not_drop_the_registration(tmp_path):+ """Only the backend and the mount flag decide; an unparsable ``TERMINAL_TIMEOUT`` (which the+ full terminal config would raise on, inside the caller's blanket suppress) changes nothing."""+ from tools import terminal_tool+ from tools.terminal_scope import reset_terminal_scope, set_terminal_scope+ from tui_gateway import server++ token = set_terminal_scope({+ "TERMINAL_ENV": "docker",+ "TERMINAL_DOCKER_MOUNT_CWD_TO_WORKSPACE": "false",+ "TERMINAL_TIMEOUT": "5m",+ })+ try:+ server._register_session_cwd({"session_key": "bad-timeout", "cwd": str(tmp_path), "explicit_cwd": True})+ assert terminal_tool.resolve_task_overrides("bad-timeout") == {"cwd": "", "cwd_source": "process"}+ finally:+ terminal_tool.clear_task_env_overrides("bad-timeout")+ reset_terminal_scope(token)diff --git a/tui_gateway/session_workdir.py b/tui_gateway/session_workdir.pyindex 1d28622520f..534386f3643 100644--- a/tui_gateway/session_workdir.py+++ b/tui_gateway/session_workdir.py@@ -510,7 +510,8 @@ def _register_session_cwd(session: dict | None) -> None:if hints is not None and hasattr(hints, "rebind_working_dir"):hints.rebind_working_dir(str(session.get("cwd")))with contextlib.suppress(Exception):- from tools.terminal_tool import _get_env_config, register_task_env_overrides+ from tools.terminal_tool import _ensure_terminal_env_bridged, register_task_env_overrides+ from tools.terminal_tool_config import _tenv, _tenv_boolcwd, cwd_source = _terminal_task_cwd_with_source(session)# The cwd/override record is keyed by the ROUTED home (#123989). session.create is a plain# @method, so bind the session's own profile home here or the record lands under the raw key@@ -524,8 +525,9 @@ def _register_session_cwd(session: dict | None) -> None:if profile_home and hc.hermes_home_key(hc.get_hermes_home()) != hc.hermes_home_key(profile_home):stack.callback(hc.reset_hermes_home_override, hc.set_hermes_home_override(str(profile_home)))stack.enter_context(install_and_reset_profile_terminal_scope(profile_home))- terminal = _get_env_config()- if terminal["env_type"] == "docker" and not terminal["docker_mount_cwd_to_workspace"]:+ _ensure_terminal_env_bridged()+ unmounted = not _tenv_bool("TERMINAL_DOCKER_MOUNT_CWD_TO_WORKSPACE", "false")+ if _tenv("TERMINAL_ENV", "local") == "docker" and unmounted:# The Desktop workspace is host context, not a directory in this sandbox.# An empty override leaves its configured cwd and subsequent in-container cd intact.cwd, cwd_source = "", "process"