🐛 fix(vscode): 移除侵入式弹窗并过滤 PR 评论,仅对工单讨论发送简洁系统通知

This commit is contained in:
cruldra committed 2026-09-29 10:49:28 +08:00
1 parent 8ea5361f3d
commit 6a2ab7eaf4
5 files changed
+172 -24

No files matched your search

+9 -17
View File
@@ -10,18 +10,19 @@
*/
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 { execFile } from 'node:child_process'
import { promises as fsp } from 'node:fs'
import { env, Uri, ViewColumn, window, workspace } from 'vscode'
import { env, Uri, window, workspace } from 'vscode'
import { loginForToken } from '../auth/identity'
import { getToken } from '../auth/secrets'
import { renderReviewPrompt } from '../cc/prompts'
import { isMailboxIssue } from '../cc/sessionHandoff'
import { detectRepo } from '../git/remote'
import { deleteWebhook, getIssue, getPullRequest, listIssueComments } from '../gitea/api'
import { systemCommentText } from '../gitea/issueComment'
import { cleanCommentSummary, systemCommentText } from '../gitea/issueComment'
import { loadIssues, loadSingleIssue } from '../gitea/issueLoader'
import { hasReviewMarker, parseClosingIssueNumber, stripReviewMarker } from '../gitea/markers'
import { hasStateColumn, mergeStateJsonComment, mergeStateJsonCommentGuarded, readStateJsonComment } from '../gitea/stateJson'
@@ -29,7 +30,6 @@ import { getLocalIssueState, mergeLocalIssueState, overlayLocalIssueState } from
import { logger } from '../logging/logger'
import * as issueChat from '../panel/handlers/issueChat'
import { hasLiveIssueSessionTerminal } from '../panel/handlers/terminals'
import { KanbanWebviewPanel } from '../panel/KanbanPanel'
import { DEFAULT_KANBAN_SCOPE, KANBAN_SCOPE_KEY } from '../panel/kanbanScope'
import { annotateMissingSessionIds } from '../sessions/sessionFiles'
import { getSettings } from '../settings/store'
@@ -1498,17 +1498,20 @@ class WebhookCoordinator {
return
}
// 判定发言人:如果发言人不是当前用户(不是 me),且不是插件状态机自动评论(systemCommentText(body) 为空,即真人评论):
// 判定发言人:只有纯工单(event.prNumber === undefined)上的真人评论才提醒;
// PR 评论(代码审查、PR 讨论、Review 机器人等)绝对不发通知。
const isPureIssueComment = event.prNumber === undefined
const author = event.commentAuthor
const me = await loginForToken(ctx.host, ctx.token)
const isSystemComment = !!systemCommentText(body)
const isMine = !!(me && author === me)
if (author && !isMine && !isSystemComment) {
if (isPureIssueComment && author && !isMine && !isSystemComment) {
const summary = cleanCommentSummary(body)
// 触发 macOS 系统原生右上角横幅通知
execFile('osascript', [
'-e',
`display notification ${JSON.stringify(body)} with title ${JSON.stringify(`工单 #${realIssueNumber} 新讨论`)} subtitle ${JSON.stringify(author)}`,
`display notification ${JSON.stringify(summary)} with title ${JSON.stringify(`工单 #${realIssueNumber} 新讨论`)} subtitle ${JSON.stringify(author)}`,
], (err) => {
if (err) {
logger.add({
@@ -1519,17 +1522,6 @@ class WebhookCoordinator {
})
}
})
// 同时在 VS Code 内部弹出信息框
void window.showInformationMessage(`[#${realIssueNumber}] ${author}: ${body}`, '查看').then((action) => {
if (action === '查看') {
const panel = this.activePanel ?? (this.ctx ? KanbanWebviewPanel.createOrShow(this.ctx) : undefined)
if (panel) {
panel.reveal(ViewColumn.Active)
panel.selectIssueAndTab(realIssueNumber, 'chat')
}
}
})
}
if (!hasReviewMarker(body)) {