🐛 fix(vscode): issue opened 广播按看板 scope 门禁,mine 不再凭空上别人的卡

This commit is contained in:
2026-08-19 20:41:11 +08:00
parent ea4c4e4658
commit fea7b2e604
5 changed files with 136 additions and 5 deletions
+27
View File
@@ -11,6 +11,7 @@
import type { ExtensionContext } from 'vscode'
import type { KanbanWebviewPanel } from '../panel/KanbanPanel'
import type { KanbanScope } from '../panel/kanbanScope'
import type { IssueCommentWebhookEvent, IssueWebhookEvent, PrWebhookEvent, WebhookEvent } from './server'
import { promises as fsp } from 'node:fs'
import { env, Uri, window, workspace } from 'vscode'
@@ -24,9 +25,11 @@ import { mergeStateJsonComment, mergeStateJsonCommentGuarded, readStateJsonComme
import { getLocalIssueState, mergeLocalIssueState, overlayLocalIssueState } from '../issues/localState'
import { logger } from '../logging/logger'
import { hasLiveIssueSessionTerminal } from '../panel/handlers/terminals'
import { KANBAN_SCOPE_KEY } from '../panel/kanbanScope'
import { annotateReviewSessionFileExists } from '../sessions/codexSessions'
import { getSettings } from '../settings/store'
import { decideEventOwnership } from './eventOwnership'
import { decideIssueAppend } from './issueAppend'
import { WebhookServer } from './server'
/**
@@ -600,6 +603,30 @@ class WebhookCoordinator {
}
if (this.activePanel) {
// 看板 'mine' 范围的批量加载只拉"我创建/指派给我"的工单,而 webhook
// 广播到所有机器 → append 前按同一套可见性规则过门禁,否则别人的卡
// 会凭空上屏、刷新后又消失。身份/payload 只在 'mine' 且非本机创建时
// 才解析,省一次身份请求。
const scope = this.ctx.workspaceState.get<KanbanScope>(KANBAN_SCOPE_KEY) ?? 'mine'
const pendingCreatedLocally = pending !== undefined
let poster: string | undefined
let assignees: string[] = []
let me: string | undefined
if (!pendingCreatedLocally && scope === 'mine') {
const raw = event.raw as { issue?: { user?: { login?: string } | null, assignees?: Array<{ login?: string } | null> | null } | null } | null
poster = raw?.issue?.user?.login
assignees = (raw?.issue?.assignees ?? []).flatMap(a => (a?.login ? [a.login] : []))
me = await loginForToken(remote.host, token)
}
if (!decideIssueAppend({ scope, pendingCreatedLocally, poster, assignees, me })) {
logger.add({
level: 'info',
source: 'webhook',
message: `issue #${event.issueNumber} 与我无关,scope=mine 过滤跳过 append`,
details: `poster=${poster ?? '<未知>'} assignees=[${assignees.join(',')}] me=${me ?? '<未知>'}`,
})
return
}
try {
const loaded = await loadSingleIssue({
host: remote.host,