Skip to content

fix(chat): open worktree references from the branch copy - #1780

Merged
vastsa merged 2 commits into
vastsa:mainfrom
zszz3:fix/1747-worktree-ref-rebase
Oct 21, 2026
Merged

vastsa merged 2 commits into
vastsa:mainfrom
zszz3:fix/1747-worktree-ref-rebase

Conversation

@zszz3

@zszz3 zszz3 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

修复 #1747。

隔离会话的文件在 worktree 里,但聊天引用可能仍带主 checkout 的路径(项目指令、MCP 工具,或在隔离前生成的引用)。解析器会把它判为根外路径;即使解析成功,渲染层还会把主根命中转成相对路径交给文件视图,插件再按主 checkout 解析,于是点击失败或打开主干版本。

改动

  • fsResolveRef:绝对引用落在父 checkout 内、且 worktree 有同名文件时,映射到 worktree 的同相对路径;只在父 checkout 存在的文件仍然返回 outside-allowed-roots。
  • 渲染层:孤立会话保留 worktree 绝对路径,文件管理器打开分支副本。
  • 补充单元测试和中英文 IPC 规范说明。

验证

  • 真实应用 + 真实 host-core + 真实 worktree 会话:点击指向主 checkout 的链接,文件管理器收到 worktree 绝对路径并显示分支内容(修复前显示主干内容)。
  • desktop 全量测试 4141 通过 / 3 跳过,typecheck、lint、docs check 通过。

fixes #1747

zszz3 and others added 2 commits October 20, 2026 16:55
An isolated session's files live in its worktree, but chat references can
still carry a path from the parent checkout: project instructions, MCP tools,
or a reference captured before isolation. The resolver rejected that path as
outside its roots, and the renderer then handed the file view a relative path
that it resolved against the parent checkout, so the click either failed or
opened the main-branch copy.

Rebase an absolute parent-checkout reference onto the same relative path in
the worktree when that file exists, and keep the worktree's absolute path in
the renderer so the file view opens the branch copy. Paths that exist only in
the parent still report outside-allowed-roots.

fixes vastsa#1747
Current main adds a second search handler in the same workspace IPC module. Keep that handler and the contributor's worktree reference mapping together in the integration candidate.
@vastsa
vastsa merged commit bcce2fa into vastsa:main Oct 21, 2026
4 of 6 checks passed
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.

[Bug] git分支往本地版本开发后分支内容无法直接点开

2 participants