From fdbfae825e8b5031273bc5e13543d6c097271d80 Mon Sep 17 00:00:00 2001 From: Sahil-SS9 <218421507+Sahil-SS9@users.noreply.github.com> Date: Mon, 29 Jun 2026 01:34:44 +0100 Subject: [PATCH] fix(tui): fall back to config terminal.backend when TERMINAL_ENV is unset in dashboard/TUI process (#54449) --- tui_gateway/server.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tui_gateway/server.py b/tui_gateway/server.py index 4b9e7c190ab..fd33859792f 100644 --- a/tui_gateway/server.py +++ b/tui_gateway/server.py @@ -1542,8 +1542,25 @@ def _terminal_task_cwd(session: dict | None) -> str: point at nonsense. Non-local terminal backends are different: their cwd is inside the target environment, so an SSH path like /home/user/workspace may not exist on the local macOS host but is still the correct execution cwd. + + When ``TERMINAL_ENV`` is unset (dashboard/TUI process) the config's + ``terminal.backend`` is consulted as a fallback so the non-local cwd + resolution path is taken even when the dashboard entrypoint did not call + ``apply_terminal_config_to_env`` on its own ``os.environ``. """ backend = (os.environ.get("TERMINAL_ENV") or "").strip().lower() + if not backend or backend == "local": + # Fall back to config when TERMINAL_ENV is unset (dashboard/TUI process + # never calls apply_terminal_config_to_env on os.environ). + try: + terminal_cfg = _load_cfg().get("terminal", {}) + if isinstance(terminal_cfg, dict): + cfg_backend = str(terminal_cfg.get("backend") or "").strip().lower() + if cfg_backend and cfg_backend != "local": + backend = cfg_backend + except Exception: + pass + if backend and backend != "local": raw = os.environ.get("TERMINAL_CWD", "").strip() if not raw: