Skip to content

Commit cc8cfa8

Browse files
authored
make sure to clear plan mode widget if canceled (#314221)
1 parent 2358983 commit cc8cfa8

3 files changed

Lines changed: 25 additions & 3 deletions

File tree

src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,9 +2928,14 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
29282928
if (review instanceof ChatPlanReviewData) {
29292929
review.completion.complete(undefined);
29302930
}
2931-
if (responseId) {
2932-
widget?.input.clearPlanReview(responseId);
2933-
}
2931+
}
2932+
// Always clear the docked widget once the response is complete —
2933+
// `isUsed` may already be true if the response was cancelled (see
2934+
// `ChatResponseModel.cancel()` → `ChatPlanReviewData.dismiss()`),
2935+
// in which case the branch above is skipped but the widget above
2936+
// the input still needs to go.
2937+
if (responseIsComplete && responseId) {
2938+
widget?.input.clearPlanReview(responseId);
29342939
}
29352940

29362941
// Build the inline progress message. While pending: "Plan review

src/vs/workbench/contrib/chat/common/model/chatModel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import { ChatPerfMark, markChat } from '../chatPerf.js';
3333
import { ChatAgentVoteDirection, ChatRequestQueueKind, ChatResponseClearToPreviousToolInvocationReason, ElicitationState, IChatAgentMarkdownContentWithVulnerability, IChatClearToPreviousToolInvocation, IChatCodeCitation, IChatCommandButton, IChatConfirmation, IChatContentInlineReference, IChatContentReference, IChatDisabledClaudeHooksPart, IChatEditingSessionAction, IChatElicitationRequest, IChatElicitationRequestSerialized, IChatExternalToolInvocationUpdate, IChatExtensionsContent, IChatFollowup, IChatHookPart, IChatLocationData, IChatMarkdownContent, IChatMcpServersStarting, IChatMcpServersStartingSerialized, IChatModelReference, IChatMultiDiffData, IChatMultiDiffDataSerialized, IChatNotebookEdit, IChatProgress, IChatPlanReview, IChatProgressMessage, IChatPullRequestContent, IChatQuestionCarousel, IChatResponseCodeblockUriPart, IChatResponseProgressFileTreeData, IChatSendRequestOptions, IChatService, IChatSessionTiming, IChatTask, IChatTaskSerialized, IChatTextEdit, IChatThinkingPart, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData, IChatUndoStop, IChatUsage, IChatUsedContext, IChatWarningMessage, IChatInfoMessage, IChatWorkspaceEdit, ResponseModelState, ToolConfirmKind, isIUsedContext } from '../chatService/chatService.js';
3434
import { ChatAgentLocation, ChatModeKind, ChatPermissionLevel } from '../constants.js';
3535
import { ChatToolInvocation } from './chatProgressTypes/chatToolInvocation.js';
36+
import { ChatPlanReviewData } from './chatProgressTypes/chatPlanReviewData.js';
37+
import { ChatQuestionCarouselData } from './chatProgressTypes/chatQuestionCarouselData.js';
3638
import { ToolDataSource, IToolData } from '../tools/languageModelToolsService.js';
3739
import { IChatEditingService, IChatEditingSession, ModifiedFileEntryState } from '../editing/chatEditingService.js';
3840
import { ILanguageModelChatMetadata, ILanguageModelChatMetadataAndIdentifier } from '../languageModels.js';
@@ -1447,6 +1449,10 @@ export class ChatResponseModel extends Disposable implements IChatResponseModel
14471449
for (const part of this._response.value) {
14481450
if (part.kind === 'toolInvocation' && part instanceof ChatToolInvocation) {
14491451
part.cancelFromStreaming(ToolConfirmKind.Skipped);
1452+
} else if (part instanceof ChatPlanReviewData) {
1453+
part.dismiss();
1454+
} else if (part instanceof ChatQuestionCarouselData) {
1455+
part.dismiss(undefined);
14501456
}
14511457
}
14521458

src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatPlanReviewData.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ export class ChatPlanReviewData implements IChatPlanReview {
3232
public source?: ToolDataSource,
3333
) { }
3434

35+
36+
dismiss(): void {
37+
if (this.isUsed) {
38+
return;
39+
}
40+
this.isUsed = true;
41+
this.draftFeedback = undefined;
42+
this.draftCollapsed = undefined;
43+
void this.completion.complete(undefined);
44+
}
45+
3546
toJSON(): IChatPlanReview {
3647
return {
3748
kind: this.kind,

0 commit comments

Comments
 (0)