🐛 fix(vscode): 恢复实施会话改按显式角色命名,worktree 清理后不再误标为规划
Claude-Session: https://claude.ai/code/session_012YFEAU7RsuCdinUNMS9tzv
This commit is contained in:
1 parent
1fee0f2630
commit
e8963ac2a2
11 files changed
+116
-61
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { planResumeCwd, resumeTerminalName } from './resumeTarget'
|
||||
|
||||
const ROOT = '/repo'
|
||||
const WT = '/repo-worktrees/feature-x'
|
||||
|
||||
describe('resumeTerminalName', () => {
|
||||
it('实施会话 → issue-N-实施', () => {
|
||||
expect(resumeTerminalName('implement', 'abcdef1234', 398)).toBe('issue-398-实施')
|
||||
})
|
||||
it('规划会话 → issue-N-规划', () => {
|
||||
expect(resumeTerminalName('brainstorm', 'abcdef1234', 398)).toBe('issue-398-规划')
|
||||
})
|
||||
it('没有工单号 → 按会话 id 前 8 位命名', () => {
|
||||
expect(resumeTerminalName('implement', 'abcdef1234', undefined)).toBe('Claude · abcdef12')
|
||||
})
|
||||
})
|
||||
|
||||
describe('planResumeCwd', () => {
|
||||
it('规划会话永远在工作区根目录', () => {
|
||||
expect(planResumeCwd({ kind: 'brainstorm', workspaceRoot: ROOT, worktreeAbs: WT, worktreeExists: true }))
|
||||
.toEqual({ cwd: ROOT, worktreeMissing: false })
|
||||
})
|
||||
it('实施会话 worktree 在 → cwd 用 worktree', () => {
|
||||
expect(planResumeCwd({ kind: 'implement', workspaceRoot: ROOT, worktreeAbs: WT, worktreeExists: true }))
|
||||
.toEqual({ cwd: WT, worktreeMissing: false })
|
||||
})
|
||||
it('实施会话 worktree 记了但磁盘上没了 → 退回根目录并标记缺失', () => {
|
||||
expect(planResumeCwd({ kind: 'implement', workspaceRoot: ROOT, worktreeAbs: WT, worktreeExists: false }))
|
||||
.toEqual({ cwd: ROOT, worktreeMissing: true })
|
||||
})
|
||||
it('实施会话工单里没记 worktreePath(PR 合并后清掉)→ 同样标记缺失,角色不变', () => {
|
||||
expect(planResumeCwd({ kind: 'implement', workspaceRoot: ROOT, worktreeAbs: undefined, worktreeExists: false }))
|
||||
.toEqual({ cwd: ROOT, worktreeMissing: true })
|
||||
expect(resumeTerminalName('implement', 'abcdef1234', 398)).toBe('issue-398-实施')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user