Skip to content

Commit 37ccf90

Browse files
authored
fix(codeReview): handle task abortion by resetting state and prevent duplicate completion (#783)
1 parent 7cde2e8 commit 37ccf90

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/core/costrict/code-review/codeReviewService.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,13 @@ export class CodeReviewService {
350350
isCompleted: true,
351351
})
352352
})
353+
task.on(RooCodeEventName.TaskAborted, () => {
354+
if (completionHandled) return
355+
this.updateTaskState({
356+
error: new Error(t("common:review.tip.task_cancelled")),
357+
isCompleted: true,
358+
})
359+
})
353360

354361
// 把 postMessageToWebview 移到事件注册之后
355362
provider.postMessageToWebview({
@@ -420,8 +427,6 @@ export class CodeReviewService {
420427
// Reset state
421428
this.currentTask = null
422429
this.currentActiveIssueId = null
423-
424-
// Note: No longer sending taskAborted message as per requirements
425430
}
426431

427432
/**

src/i18n/costrict-i18n/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
"service_unavailable": "Service unavailable, please try again later.",
174174
"api_provider_not_support": "The current API provider does not support the Code Review function, please switch to the CoStrict API provider.",
175175
"task_timeout": "Task execution timed out, has been automatically canceled",
176+
"task_cancelled": "Task has been cancelled, please create a new task for Code Review",
176177
"get_review_result_failed": "Unable to obtain review results, please try again",
177178
"no_changed_files": "No changed files, please ensure that the current workspace is a git repository and has changed files.",
178179
"new_commit_notification": "You committed: {{commitMessage}}, whether to perform review?"

src/i18n/costrict-i18n/locales/zh-CN/common.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/i18n/costrict-i18n/locales/zh-TW/common.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)