🐛 fix(vscode): 修复评论全量接口被误分页导致审查反馈卡住
This commit is contained in:
1 parent
8d70ee1659
commit
3134201243
7 files changed
+71
-122
No files matched your search
@@ -21,7 +21,7 @@ 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 { deleteWebhook, getIssue, getPullRequest } from '../gitea/api'
|
||||
import { cleanCommentSummary, systemCommentText } from '../gitea/issueComment'
|
||||
import { loadIssues, loadSingleIssue } from '../gitea/issueLoader'
|
||||
import { hasReviewMarker, parseClosingIssueNumber, stripReviewMarker } from '../gitea/markers'
|
||||
@@ -1444,10 +1444,6 @@ class WebhookCoordinator {
|
||||
* Comments without the `<!-- spx:review=1 -->` marker are ignored. Edited /
|
||||
* deleted comments are also ignored (the dispatcher only routes 'created').
|
||||
*
|
||||
* `isFirstReview` is derived by counting the marker across the issue's
|
||||
* existing comments — when this is the only one (count <= 1), it's the
|
||||
* first review and `injectIntoImplTerminal` appends the merge-to-main
|
||||
* suffix.
|
||||
*/
|
||||
/** 申请移交时给负责人发系统通知。看板关着也发。 */
|
||||
private async notifyHandoffRequest(event: IssueCommentWebhookEvent): Promise<void> {
|
||||
@@ -1636,39 +1632,12 @@ class WebhookCoordinator {
|
||||
|
||||
if (await this.resolveOwnership(realIssueNumber, ctx) === 'observe') {
|
||||
// 审查反馈只注入责任人机器的实施终端;其他机器上本来也找不到
|
||||
// 该终端,提前拦截省掉后面的评论计数 API 往返。
|
||||
// 该终端,不执行本地注入。
|
||||
return
|
||||
}
|
||||
|
||||
// Count marker comments to determine isFirstReview. This call also
|
||||
// includes the just-posted comment, so a first review yields count=1.
|
||||
let reviewCount = 1
|
||||
try {
|
||||
// 审查评论 post 在 PR 上,不是工单 issue 上。如果当前 comment 来自 PR
|
||||
// (event.prNumber !== undefined),就去 PR 评论流数;否则才走工单号。
|
||||
const commentsIndex = event.prNumber ?? realIssueNumber
|
||||
const comments = await listIssueComments({
|
||||
host: ctx.host,
|
||||
token: ctx.token,
|
||||
owner: ctx.owner,
|
||||
repo: ctx.repo,
|
||||
index: commentsIndex,
|
||||
})
|
||||
reviewCount = comments.filter(c => hasReviewMarker(c.body ?? '')).length
|
||||
}
|
||||
catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
logger.add({
|
||||
level: 'warn',
|
||||
source: 'webhook',
|
||||
message: `统计审查评论数失败 #${realIssueNumber}(按首次处理)`,
|
||||
details: message,
|
||||
})
|
||||
}
|
||||
const isFirstReview = reviewCount <= 1
|
||||
|
||||
const injected = this.activePanel
|
||||
? this.activePanel.injectIntoImplTerminal(realIssueNumber, text, isFirstReview)
|
||||
? this.activePanel.injectIntoImplTerminal(realIssueNumber, text)
|
||||
: false
|
||||
if (!injected) {
|
||||
logger.add({
|
||||
@@ -1682,7 +1651,7 @@ class WebhookCoordinator {
|
||||
logger.add({
|
||||
level: 'info',
|
||||
source: 'webhook',
|
||||
message: `审查反馈已注入实施终端 #${realIssueNumber} isFirstReview=${isFirstReview} length=${text.length}`,
|
||||
message: `审查反馈已注入实施或测试终端 #${realIssueNumber} length=${text.length}`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user