✨ feat(vscode): 申请移交时给负责人发系统通知

This commit is contained in:
cruldra committed 2026-10-04 10:01:41 +08:00
1 parent 5bcbb87152
commit a1fac829f8
3 files changed
+108 -1

No files matched your search

@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { canAnswerHandoffRequest, canAskHandoff, canCancelHandoffRequest, handoffRequestNotices } from './handoffRequest'
import { canAnswerHandoffRequest, canAskHandoff, canCancelHandoffRequest, handoffRequestNotices, handoffRequestSystemNotice } from './handoffRequest'
const review = {
source: 'gitea' as const,
@@ -37,6 +37,34 @@ describe('移交申请', () => {
.toEqual(['#435 没交出来:会话太大'])
})
it('系统通知只打给负责人,同一条申请不重复', () => {
expect(handoffRequestSystemNotice({
issueNumber: 435,
me: 'chw',
assignees: ['chw'],
from: 'cruldra',
})).toBe('cruldra 想要 #435')
expect(handoffRequestSystemNotice({
issueNumber: 435,
me: 'chw',
assignees: ['chw'],
from: 'cruldra',
seenFrom: 'cruldra',
})).toBeUndefined()
expect(handoffRequestSystemNotice({
issueNumber: 435,
me: 'cruldra',
assignees: ['chw'],
from: 'cruldra',
})).toBeUndefined()
expect(handoffRequestSystemNotice({
issueNumber: 435,
me: 'other',
assignees: ['chw'],
from: 'cruldra',
})).toBeUndefined()
})
it('只有负责人能同意或拒绝', () => {
const pending = { ...review, handoffRequestFrom: 'cruldra' }
expect(canAnswerHandoffRequest(pending, 'chw')).toBe(true)
@@ -50,6 +50,22 @@ export function handoffRequestNotices(before: HandoffRequestFacts & { number: nu
return notices
}
/** 负责人没开着看板也能看到的那一句。同一申请人不重复。 */
export function handoffRequestSystemNotice(opts: {
issueNumber: number
me?: string
assignees: string[]
from?: string
seenFrom?: string
}): string | undefined {
const from = opts.from?.trim()
if (!from || !opts.me || from === opts.me || from === opts.seenFrom)
return
if (!opts.assignees.includes(opts.me))
return
return `${from} 想要 #${opts.issueNumber}`
}
export function canAnswerHandoffRequest(issue: HandoffRequestFacts, me: string | undefined): boolean {
return !!me
&& openReview(issue)