Skip to content

[Bug] ~ 不被当作绝对路径:平台内部三种口径,resolveWorkspacePath 会把它拼到 cwd 之后 #475

Description

@greyoak111

从本机实测得到,已附可复现代码与实测输出。

症状

~ 形式的路径不被当作绝对路径,而是被拼到某个基准目录之后,得到不存在的路径。
用户看到的是「文件不存在」。

最小复现(@deepseek-ai/dsh-client-ui-chat)

function resolveWorkspacePath(cwd, path) {
  if (path.startsWith("/") || isWindowsStylePath(path)) return path;
  if (cwd === void 0 || cwd === "") return path;
  return `${cwd.replace(/[/\\]+$/, "")}/${path.replace(/^[/\\]+/, "")}`;
}
  • ~/deepseek/foo.md ⇒ <cwd>/~/deepseek/foo.md
  • 实测:open /Users/<user>/proj/~/deepseek/foo.md
    ⇒ The file /Users/<user>/proj/~/deepseek/foo.md does not exist.

根因:平台内部对 ~ 有三种口径

组件 对 ~ 的态度
dsh-client-ui-deliverables 的 localPathReference 明确接受(正则 ^~[\\/] 直接放行)
dsh-client-ui-tool 的 abbreviateHomePath 明确产出(把 /Users/x/… 显示成 ~/…)
dsh-client-ui-chat 的 resolveWorkspacePath 不展开 ⇒ 拼错

平台自己一边生产 ~/… 形式、一边有一个组件接受它、另一边不认它。

期望

统一口径:要么都展开(用 os.homedir() 或宿主 facts),要么都不接受。
不要在同一个平台内部三种态度。

影响面

任何「点击文本里的文件路径去打开」的交互。用户与 Agent 都习惯写 ~/…。

补充

同一个病根在第三方插件 dsh-better-sidebar 里也有一份(已单独报给该仓库)——
这说明它不是某一个组件的笔误,而是平台缺少统一的路径规范化约定。


被测版本:DSH Desktop 0.9.0(内核 @deepseek-ai/* = 0.1.5-rc.2) · macOS / Apple Silicon (arm64)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions