✨ feat(vscode): 多人协作二期:状态分层/写校验/签名/团队视图
- 本机状态(会话id/worktree/profile/prDiffFile)迁 workspaceState, 共享 state JSON 只留团队字段;读侧本地记录叠加,旧数据兜底 - mergeStateJsonComment 写后读回校验,并发覆盖时在最新状态上重放一次 - webhook 支持 Gitea secret,校验 X-Gitea-Signature(HMAC-SHA256), 不匹配 401;设置面板新增 Webhook Secret 字段 - 看板新增 我的/全部 范围切换(团队视图),按工作区持久化
This commit is contained in:
@@ -133,11 +133,17 @@ describe('state JSON 尾部普通评论不丢状态', () => {
|
||||
worktreePath: '.claude/worktrees/be3beabc',
|
||||
implementStatus: 'running',
|
||||
}
|
||||
listIssueComments.mockResolvedValue([
|
||||
// merge 现在 post 后会读回校验(乐观并发检测),mock 必须有状态:
|
||||
// postIssueComment 之后列表要包含新评论,否则校验误判丢失导致重放。
|
||||
const comments = [
|
||||
{ body: JSON.stringify(fullState) },
|
||||
{ body: '这是一条普通评论,不是 state JSON' },
|
||||
{ body: JSON.stringify({ note: '像 JSON 但没有任何已知 state 字段' }) },
|
||||
])
|
||||
]
|
||||
listIssueComments.mockImplementation(async () => [...comments])
|
||||
postIssueComment.mockImplementation(async (opts: { body: string }) => {
|
||||
comments.push({ body: opts.body })
|
||||
})
|
||||
|
||||
await mergeStateJsonComment({
|
||||
host: 'https://gitea.example',
|
||||
@@ -156,6 +162,40 @@ describe('state JSON 尾部普通评论不丢状态', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('post 后读回发现字段被并发覆盖时,在最新状态上重放一次', async () => {
|
||||
const { mergeStateJsonComment } = await import('../../src/gitea/stateJson.js')
|
||||
const comments: Array<{ body: string }> = [
|
||||
{ body: JSON.stringify({ column: 'in-progress' }) },
|
||||
]
|
||||
listIssueComments.mockImplementation(async () => [...comments])
|
||||
let postCount = 0
|
||||
postIssueComment.mockImplementation(async (opts: { body: string }) => {
|
||||
postCount++
|
||||
if (postCount === 1) {
|
||||
// 模拟并发写者在我们 post 之后又盖了一条:我们的字段丢失。
|
||||
comments.push({ body: JSON.stringify({ column: 'review' }) })
|
||||
return
|
||||
}
|
||||
comments.push({ body: opts.body })
|
||||
})
|
||||
|
||||
await mergeStateJsonComment({
|
||||
host: 'https://gitea.example',
|
||||
owner: 'owner',
|
||||
repo: 'repo',
|
||||
token: 'token',
|
||||
issueNumber: 7,
|
||||
extra: { pr: '99' },
|
||||
})
|
||||
|
||||
expect(postIssueComment).toHaveBeenCalledTimes(2)
|
||||
// 重放基于并发写者的最新状态,两边的字段都保留。
|
||||
expect(JSON.parse(postIssueComment.mock.calls[1][0].body)).toEqual({
|
||||
column: 'review',
|
||||
pr: '99',
|
||||
})
|
||||
})
|
||||
|
||||
it('read 时跳过尾部普通评论返回最近一条 state JSON', async () => {
|
||||
const { readStateJsonComment } = await import('../../src/gitea/stateJson.js')
|
||||
listIssueComments.mockResolvedValue([
|
||||
|
||||
Reference in New Issue
Block a user