The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): path completion ignores the launch dir the TUI echoes back for a sandbox session
Tekniuma867ffb35a07
diff --git a/tests/tui_gateway/test_remote_backend_launch_cwd.py b/tests/tui_gateway/test_remote_backend_launch_cwd.pyindex 754b2c131f6..8a0ea753ce0 100644--- a/tests/tui_gateway/test_remote_backend_launch_cwd.py+++ b/tests/tui_gateway/test_remote_backend_launch_cwd.py@@ -326,3 +326,10 @@ def test_sandbox_path_completion_lists_the_backend_cwd(launch_dir, monkeypatch):assert seen["dir"] == "."assert [i["text"] for i in resp["result"]["items"]] == ["notes.md"]++ # The TUI echoes session.info's cwd (the host launch dir nobody picked) back as params.cwd.+ session = _fresh_session("complete-echo")+ monkeypatch.setitem(server._sessions, "s-echo", session)+ server.handle_request({"id": "2", "method": "complete.path",+ "params": {"word": "no", "session_id": "s-echo", "cwd": session["cwd"]}})+ assert seen["dir"] == "."diff --git a/tui_gateway/methods_complete.py b/tui_gateway/methods_complete.pyindex ec944b782b7..ea2b069c6ee 100644--- a/tui_gateway/methods_complete.py+++ b/tui_gateway/methods_complete.py@@ -235,8 +235,12 @@ def _(rid, params: dict) -> dict:session = _sessions.get(params.get("session_id", ""))local = _effective_terminal_backend() == "local"# A non-local backend's cwd lives inside the target; the host cannot validate it, so take the composer's- # session cwd (Desktop sends it) or the session's terminal cwd as-is ("." = the backend's own cwd).- root = _completion_cwd(params) if local else (params.get("cwd") or _terminal_task_cwd(session) or ".")+ # session cwd (Desktop sends it) or the session's terminal cwd as-is (".": the backend's own cwd). The TUI+ # echoes session.info's cwd back; for a sandbox session nobody gave a workspace that is the host launch dir.+ client_cwd = params.get("cwd")+ if session and client_cwd == session.get("cwd") and _is_remote_launch_cwd(session):+ client_cwd = None+ root = _completion_cwd(params) if local else (client_cwd or _terminal_task_cwd(session) or ".")session_key = session.get("session_key") if session else Nonereturn _ok(rid, {"items": _path_completion_items(word, root, session_key, local)})