Skip to content

fix(acp): preserve UNC cwd for Windows batch launchers - #638

Merged
xintaofei merged 2 commits into
xintaofei:mainfrom
damiandelmas:fix/windows-unc-agent-cwd
Sep 3, 2026
Merged

fix(acp): preserve UNC cwd for Windows batch launchers#638
xintaofei merged 2 commits into
xintaofei:mainfrom
damiandelmas:fix/windows-unc-agent-cwd

Conversation

@damiandelmas

Copy link
Copy Markdown
Contributor

Summary

  • detect Windows UNC workspaces when the resolved ACP agent is a .cmd or .bat launcher
  • launch that narrow case through the system cmd.exe and pushd, avoiding cmd's fallback to C:\Windows
  • preserve the existing direct-spawn behavior for local paths, native executables, and non-Windows hosts
  • defensively encode batch arguments using Rust stdlib-compatible rules; disable AutoRun and delayed expansion

Why

A native Windows Codeg session can open a WSL workspace such as \\wsl.localhost\Ubuntu\home\user\repo. Codeg correctly passes that project path as the ACP process cwd. For npm-backed agents such as Hermes, however, the resolved launcher is a Windows .cmd file. cmd.exe rejects a UNC process cwd and silently falls back to the Windows directory, so the ACP session reports the project while the agent process derives its terminal cwd from C:\Windows.

pushd maps the UNC share to a temporary drive for the lifetime of the command processor, retaining the intended workspace without changing agent installation or execution namespaces.

Validation

  • cargo test --manifest-path vendor/sacp-tokio/Cargo.toml --lib — 16 passed
  • cargo check --manifest-path vendor/sacp-tokio/Cargo.toml --lib --target x86_64-pc-windows-gnu — passed
  • git diff --check — passed

A live UNC integration run still requires a Windows host with an accessible UNC fixture; the existing CI Windows matrix will compile the Windows-specific path.

damiandelmas and others added 2 commits September 2, 2026 12:10
Three defects in the batch-launcher detour, all of which fire on exactly
the setup it was written for — a Windows session on a UNC workspace:

- `\\?\UNC\...` was detected as a UNC workspace but emitted verbatim, and
  cmd.exe resolves no extended-length path at all. `pushd` would fail and
  `&&` would take the whole agent launch down with it. It is now folded
  back to the plain `\\server\share\...` spelling.
- A trailing separator on the cwd was doubled into `\\` by
  `append_windows_batch_arg`. That is right for an argument a batch file
  re-parses and wrong for a cmd built-in, which never unescapes its own
  command line, so the pair reached `pushd` verbatim. Trimmed.
- A relative launcher was handed straight to cmd.exe, whose search order
  starts at the current directory — which `pushd` has just pointed at the
  workspace. Rust resolves a bare program name against PATH and never
  against the child's cwd, so this let an `agent.cmd` committed to a repo
  shadow the trusted one. The detour now requires an absolute launcher
  and anything else keeps the direct spawn.

The "is this launch taking the detour?" predicate was also evaluated in
two places that had to agree; it is now one `windows_pushd_cwd`, read by
both the command line and the `current_dir` call.
@xintaofei

Copy link
Copy Markdown
Owner

codeg work task 145 is done — #638 (1 file, +201/-13).

@xintaofei
xintaofei merged commit 20c1191 into xintaofei:main Sep 3, 2026
7 checks passed
xintaofei added a commit that referenced this pull request Sep 3, 2026
Conversation forks are now more reliable, staying on the reply and session you chose while carrying their settings into the next prompt.
Pi questions, MCP settings, and Windows network-share launches are more dependable too.

## New

- **DeepSeek can now fork a conversation at the exact reply you picked** (deepseek-acp 0.8.0), instead of falling back to the end of the session.

## Improved

- **“Fork from here” is now the single, clearer way to branch a conversation** — the redundant composer shortcut is gone, and the reply action stays visible with an explanation while a response is still running.

## Fixed

- **Conversation forks now reliably open on the intended new session and are ready for the very next prompt**, preserving the selected turn plus supported model, effort, and mode settings without jumping back, hanging, or losing a fast follow-up.
- **Pi’s multiple-choice prompts now use the same interactive question card as other agents**, and the choice you make remains visible in the transcript. (#644)
- **One unreadable agent config no longer takes down the MCP settings page** — healthy configs still load, empty files are handled normally, and codeg identifies the problem and pauses writes until every existing setting can be preserved safely. (#646, @dawNotPoi)
- **Windows agents launched from UNC workspaces now start in the correct project directory**, including `.cmd` and `.bat` launchers used by npm-installed agents in WSL or network-share projects. (#638, @damiandelmas)

Thanks to @dawNotPoi and @damiandelmas for contributing to this release.

-----------------------------

# 发布版本 0.30.2

会话分叉现在更可靠了:它会稳稳留在你选中的回复和新会话上,并带着原有设置继续接收下一条消息。
Pi 问答、MCP 设置,以及 Windows 网络路径下的智能体启动也变得更加稳定。

## 新增

- **DeepSeek 现在能从你选中的那条回复精确分叉**(随 deepseek-acp 0.8.0 到位),不再悄悄退回到会话末尾。

## 改进

- **「从这里分叉」成为统一而清楚的会话分叉入口**——输入框旁重复的快捷入口已移除,回复生成期间按钮也会留在原位并说明暂时不可用,不再忽隐忽现。

## 修复

- **会话分叉现在会可靠地打开并留在预期的新会话中,紧接着发出的下一条消息也能正常发送**,选中的分叉点和原会话支持的模型、思考强度及模式都会保留,不再跳回旧会话、卡住或让快速跟进的回复消失。
- **Pi 发起的多选提问现在会显示为统一的可交互问答卡片**,选项可以直接点击,回答结果也会保留在会话记录中。(#644)
- **某个智能体的配置文件不可读时,MCP 设置页不再整页失效**——其余配置仍会正常显示,空白配置文件也能正常处理,同时 codeg 会指出问题来源,并在无法安全保留全部设置时暂停写入。(#646@dawNotPoi)
- **Windows 现在能从 UNC 工作区的正确项目目录启动智能体**,包括 WSL 或网络共享项目中由 npm 安装的 `.cmd`、`.bat` 启动器。(#638@damiandelmas)

感谢 @dawNotPoi@damiandelmas 为本次发布做出的贡献。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants