🐛 fix(vscode): 接管工单不再用同事机器上的模型配置盖掉本机的,移交出去也不清自己选的配置

This commit is contained in:
cruldra committed 2026-10-17 16:31:32 +11:00
1 parent 7ca2a8db34
commit 1f161c7012
9 files changed
+90 -93

No files matched your search

+7 -9
View File
@@ -51,16 +51,14 @@ codex/YYYY/MM/DD/rollout-*.jsonl 审查会话(存在才有)
"sessions": {
"sessionId": "…", "implementSessionId": "…", "testSessionId": "…", "reviewSessionId": "…"
},
"profiles": {
"profilePath": "/Users/chw/.claude/profiles/x.json",
"brainstormProfilePath": "…", "testProfilePath": "…"
},
"claude": [ { "id": "<sid>", "kind": "brainstorm" | "implement" | "test" } ],
"codex": [ { "id": "<uuid>", "relPath": "2026/08/26/rollout-….jsonl" } ]
}
```
`sessions` / `profiles` 只放存在的键;`claude` / `codex` 只列实际打进包里的文件。profile 路径原样带发送方绝对路径,接管方沿用现有 `resolveProfilePath` 按文件名重映射。
`sessions` 只放存在的键;`claude` / `codex` 只列实际打进包里的文件。
profile(`profilePath` / `brainstormProfilePath` / `testProfilePath` / `prototypeProfilePath`,各类会话用哪份模型配置)是每台机器自己的选择,不进会话包:发送方不打包,接管方不写入,旧包里残留的 `profiles` 解析时直接忽略。接管方的工单没选过 profile 就用自己设置里的默认值。
## 共享 state JSON 新字段
@@ -89,15 +87,15 @@ codex/YYYY/MM/DD/rollout-*.jsonl 审查会话(存在才有)
扩展端 `handleHandoffStart(panel, issueNumber, to)` 顺序:
1. 前置:移交存储已配置;workspaceRoot / `detectRepo` / token / `loginForToken` 得 `me`。读 `readIssueState`,取本机字段(四个 sid、三个 profile、`worktreePath`)与共享 `branch`。
1. 前置:移交存储已配置;workspaceRoot / `detectRepo` / token / `loginForToken` 得 `me`。读 `readIssueState`,取本机的会话 id、`worktreePath` 与共享 `branch`(profile 不取)。
2. **worktree 守卫**(有 `worktreePath` 且目录存在时):`git status --porcelain` 必须为空;`git fetch origin <branch>` 后 `HEAD` 必须等于 `origin/<branch>`。否则 toast「有未提交/未推送改动」并终止,什么都不改。
3. 关闭该工单全部终端(`terminalOrigin` 同 issueNumber + 名称匹配 `issue-N-冲突解决`),等 600ms 让 jsonl 刷盘。
4. 在 scratch 临时目录收集会话包:同一卷上用硬链接收文件,跨卷才复制。每个 sid 在 `~/.claude/projects/*/` 里找 `<sid>.jsonl`(多份取最新 mtime),连同 `<sid>/` 一起拷入 `claude/`(跳过 `subagents/`,子代理对话不移交);`reviewSessionId` 在 `~/.codex/sessions` 里按文件名尾部 uuid 找到 rollout 拷入 `codex/<relPath>`。找不到的会话不进清单,只 log。写 `handoff.json`,`tar --options xz:compression-level=1 -cJf`。
5. 用阿里云官方 SDK `ali-oss` 的分片上传传到 OSS,带 `x-oss-object-acl: private`;中途失败把已传的分片清掉(abort)。
6. `mergeIssueState(issueNumber, { handoffBundleKey, handoffFrom: me })`。
7. `updateIssueAssignees(… [to])`。
8. 本机清理(失败只 warn,不回滚——远端移交已生效):`pre-remove` 钩子 → `killProcessesUsingWorktree` → `removeWorktreeDir`;`cleanupFeatureBranch` **不传 remote/token**(只删本地分支,远端分支必须保留给接管方);本机字段全部写 `''` 墓碑。发送方磁盘上的会话文件保留。
9. `issue/patch { handoffBundleKey, handoffFrom, worktreePath: null, worktreeExists: false, …sid: null }` + 成功 toast。
8. 本机清理(失败只 warn,不回滚——远端移交已生效):`pre-remove` 钩子 → `killProcessesUsingWorktree` → `removeWorktreeDir`;`cleanupFeatureBranch` **不传 remote/token**(只删本地分支,远端分支必须保留给接管方);本机的会话 id、`worktreePath`、`prDiffFile` 写 `''` 墓碑(worktree 没删掉时保留 `worktreePath`),四个 profile 字段不动,工单以后接回来还是自己原来选的模型配置。发送方磁盘上的会话文件保留。
9. `issue/patch { handoffBundleKey, handoffFrom, worktreePath: null, worktreeExists: false, …sid: null }` + 成功 toast;patch 里没有 profile 字段。
进度 toast 从核对分支开始,同一条提示随步骤改文案(核对分支、关闭终端、收集会话、`打包 x MB`、`上传 x MB / y MB`、写入状态、指派、清理本机)。打包时按包文件已写出的大小报,上传时每传完一片报一次。移交结束前不自动消失。
@@ -115,7 +113,7 @@ codex/YYYY/MM/DD/rollout-*.jsonl 审查会话(存在才有)
2. 从 OSS 边下边写到 scratch 临时目录(文件名固定,不拿 key 拼本机路径;连续 60 秒收不到数据就放弃),`tar -xJf`,解析并校验 `handoff.json`(`version === 1`、`issue === issueNumber`)。
3. **重建 worktree**(`manifest.branch ?? state.branch` 存在时):`ensureWorktreeFromRemote({ workspaceRoot, worktreePath, branch })`——`git fetch origin <branch>`;该分支已有 live worktree → 直接用;模板路径被垃圾目录占着 → kill + 删;`git worktree add -B <branch> <path> origin/<branch>`。模板路径用设置 `worktreeDirectory`,slug = `branch` 去掉 `feature/` 前缀。之后跑 `post-create` 钩子。分支不存在于远端 → toast 终止(会话包保留,可重试)。
4. **安装会话**:`brainstorm` 会话装到 `projectsDirFor(workspaceRoot)`,`implement` / `test` 装到 `projectsDirFor(worktreeAbs)`(无 worktree 时也装到 workspaceRoot)。安装前先删本机所有 `~/.claude/projects/*/<sid>.jsonl` 与 `<sid>/`(避免重复 sid),再拷 jsonl + 目录。codex 文件按 `relPath` 拷到 `~/.codex/sessions/` 下。
5. 写本机字段:清单里的四个 sid、三个 profile 路径、`worktreePath`。
5. 写本机字段:清单里的会话 id、`worktreePath`。profile 不写,本机原有的选择和设置里的默认值照旧生效。
6. `mergeIssueState(issueNumber, { handoffBundleKey: '', handoffFrom: '' })`;删 OSS 对象(失败只 warn)。
7. `issue/patch`(sid、worktreePath、worktreeExists、两个 handoff 字段置 null)+ 成功 toast。