fix(chat): 侧栏点选跨工作空间会话时同步切换工作空间与右侧文件树 - #817
Open
AlphaCatMeow wants to merge 2 commits into
Open
AlphaCatMeow wants to merge 2 commits into
AlphaCatMeow wants to merge 2 commits into
Conversation
普通点选会话只走 openController.open,没有把会话所属工作空间置为当前, 右侧 dock 的文件树/终端/Git 仍停在上一个工作空间。从搜索路径抽出 activateConversationWorkspace,Desktop 与 WebUI 的普通点选分支在打开前 按会话 cwd 激活对应工作空间;同工作空间或无 cwd 时不动。 Refs Stack-Cairn#787
点选前先激活工作空间会让侧栏作用域先行刷新,旧的当前会话从列表消失 触发兜底新建草稿,把这次打开顶掉——表现为要点两次。改为会话提交后 (afterCommit)再激活其工作空间;Desktop 的 cache-hit 分支补调 afterCommit, 热路径同样生效。cwd 优先取运行时/历史响应的权威 workdir。 Refs Stack-Cairn#787
StackCairn
marked this pull request as draft
September 16, 2026 17:37
Contributor
|
PR governance checks passed. Awaiting human review. |
AlphaCatMeow
marked this pull request as ready for review
September 16, 2026 23:37
StackCairn
marked this pull request as draft
September 16, 2026 23:37
AlphaCatMeow
marked this pull request as ready for review
September 16, 2026 23:38
StackCairn
marked this pull request as draft
September 16, 2026 23:38
AlphaCatMeow
marked this pull request as ready for review
September 16, 2026 23:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #787
问题
侧栏改成跨工作空间的会话树(#770)之后,点另一个工作空间下的会话,会话内容切过去了,右侧 dock(文件树、终端、Git 面板)还停在上一个工作空间。
原因:dock 的
cwd/projectPathKey一直取自activeWorkspaceProjectPath,这个值只在点项目行、Workbench 聚焦 Pane、或从搜索弹窗打开会话(#752 加的beforeCommit)时更新。普通点选会话走openController.open(id)直开,中间没有任何一步把会话所属的工作空间置为当前。Desktop 和 WebUI 都有这个问题。改法
activateSearchConversationWorkspace抽出activateConversationWorkspace(cwd):按 cwd 找到对应项目(找不到就按 history 类型临时建一个)并activateWorkspaceProject(project, { preserveMissing: true })。同工作空间或无 cwd 时直接返回,不写 settings。搜索路径改为复用它,行为不变。handleSelectConversation和 WebUIhandleSidebarSelectConversation的普通点选分支,把这个激活挂在openController.open的afterCommit上:会话先提交,提交后再切工作空间。只在 agent 模式生效。openInitial的 cache-hit 分支补调了request?.afterCommit?.()。缓存命中同样是一次真实提交,之前只有冷路径会调,不补的话热路径下工作空间不会跟。搜索路径不走这个分支,不受影响。为什么必须等 afterCommit
第一版实现是点选时先切工作空间再打开会话,实测要点两次才能进会话。链条是:先切工作空间 →
sidebarScope先行刷新 → 旧的当前会话从新作用域的列表里消失 → ChatPage 里"当前会话从历史列表消失则新建草稿"的兜底 effect 触发startNewConversation→cancelConversationLoad把正在进行的这次打开顶掉,用户落在空白草稿上。挂到afterCommit之后,提交时当前会话已经是目标会话,在新作用域列表里存在,兜底 effect 不会误判。文件树面板关着的时候也一样生效:
RightDockPanel的cwd/projectPathKey是常驻 props,激活后内部状态已指向新工作空间,下次展开就是对的目录,不会主动弹开面板。验证
tsc --noEmit通过pnpm test:webui721/721,含新增 3 个用例(点选立即打开、提交时才激活、text 模式不动工作空间)pnpm test:gui3087/3095,8 个失败在基线 main @ 4eb6a4a 上复测结果相同,与本次改动无关截屏
不改的东西
activateWorkspaceProject本身、搜索路径和 Workbench 路径的语义都没动。有一个副作用是有意保留的:当前是空白草稿时点别的工作空间的会话,草稿的 workdir 会跟过去,和点项目行、搜索打开的既有行为一致。