Repository navigation
Closed
Description
English
Problem
A Desktop session keeps the working directory captured in SessionHeader.cwd when the session is created. The composer workspace picker, however, displays and updates the app-wide project root used as the default for new tasks.
Selecting another directory while an existing session is open therefore updates the visible directory, branch context, toast, and next-task default, but it does not change the directory used by that session's tools.
This mismatch can cause real misuse:
- If the original directory still exists, the agent can continue reading, editing, or deleting files in the old project while the UI shows the newly selected project.
- If the original directory has been removed, file tools fail with a
realpath ... ENOENT; pipe-based Bash may misleadingly reportspawn /bin/sh ENOENT; PTY Bash can exit with code 1 and an empty terminal snapshot. - These symptoms can be mistaken for failures in Read, Bash, or PTY even though the actual problem is a stale session working directory.
Reproduction
- Create a session while directory A is selected.
- Keep that session open and select directory B from the composer workspace picker.
- Continue the existing session and ask it to inspect or modify the workspace.
- Observe that the UI shows B while tool execution still uses A.
- Removing A makes subsequent shell and file operations fail despite B being visible.
Expected behavior
- The directory shown for an existing session must match the directory used by its tools.
- Changing the default directory for new tasks must not be presented as changing the active session.
- If a session's directory no longer exists, the failure should identify that condition directly and provide a clear recovery path before the agent attempts tool execution.
- Existing sessions should not be silently rebound to another directory. Explicit rebinding is a separate operation covered by feat(cli): /move — rebind a session to a new working directory #1101.
简体中文
问题
Desktop 会话创建时会把工作目录固定在 SessionHeader.cwd 中,而输入框下方的工作目录选择器显示和修改的却是应用级项目目录。这个应用级目录只会成为新任务的默认目录。
因此,在既有会话中选择另一个目录后,界面显示的目录、分支信息、提示消息以及新任务默认目录都会更新,但该会话的工具仍然在原目录中执行。
这种状态错位会导致真实的误用风险:
- 原目录仍存在时,界面虽然显示新项目,agent 仍可能在旧项目中读取、修改或删除文件。
- 原目录已被删除时,文件工具会报告
realpath ... ENOENT;普通 Bash 可能误导性地报告spawn /bin/sh ENOENT;PTY Bash 可能以退出码 1 结束且终端画面为空。 - 用户和模型容易把这些表现误判为 Read、Bash 或 PTY 本身发生故障,而实际原因是会话工作目录已经失效。
复现步骤
- 选择目录 A 并创建一个会话。
- 保持该会话打开,通过输入框下方的工作目录选择器切换到目录 B。
- 继续在原会话中要求 agent 检查或修改工作区。
- 界面显示目录 B,但工具实际仍在目录 A 中执行。
- 如果删除目录 A,后续 shell 和文件操作会失败,即使界面仍显示目录 B。
预期行为
- 查看既有会话时,界面显示的目录必须与工具实际使用的目录一致。
- 修改新任务默认目录时,不能让用户误以为当前会话也已切换。
- 如果会话目录已经不存在,应在 agent 尝试调用工具前直接说明原因,并提供清晰的恢复路径。
- 不应把既有会话静默重绑定到另一个目录。显式重绑定属于 feat(cli): /move — rebind a session to a new working directory #1101 所讨论的独立操作。
Metadata
Metadata
Assignees
Labels
No labels
Activity