2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { DeferredPromise } from '../../../../../../base/common/async.js';
7
>
import { IMarkdownString } from '../../../../../../base/common/htmlContent.js';
8
>
import { IChatQuestion, IChatQuestionAnswers, IChatQuestionCarousel } from '../../chatService/chatService.js';
9
>
import { ToolDataSource } from '../../tools/languageModelToolsService.js';
10
>
11
>
/**
12
>
* Runtime representation of a question carousel with a {@link DeferredPromise}
13
>
* that is resolved when the user submits answers. {@link toJSON} strips the
14
>
* completion so only serialisable data is persisted.
15
>
*/
16
>
export class ChatQuestionCarouselData implements IChatQuestionCarousel {
17
>
public readonly kind = 'questionCarousel' as const;
18
>
public readonly completion = new DeferredPromise<{ answers: IChatQuestionAnswers | undefined }>();
19
>
public draftAnswers: IChatQuestionAnswers | undefined;
20
>
public draftCurrentIndex: number | undefined;
21
>
public draftCollapsed: boolean | undefined;
22
>
/**
23
>
* Set to `true` when the carousel was dismissed because the user typed
24
>
* directly in the associated terminal instead of using the carousel UI.
25
>
*/
26
>
public dismissedByTerminalInput?: boolean;
27
>
28
>
/**
29
>
* True when the input was accepted/answered outside the carousel UI (e.g.
30
>
* via voice) without structured answers, so the summary reads "Answered".
31
>
*/
32
>
public answeredExternally?: boolean;
33
>
34
>
/**
35
>
* Marks the carousel as dismissed with the given answers and clears draft
36
>
* state. Safe to call multiple times — subsequent calls are no-ops.
37
>
*/
38
>
dismiss(answers: IChatQuestionAnswers | undefined): void {
39
>
if (this.isUsed) {
40
return;
41
}
43
>
this.isUsed = true;
44
>
this.draftAnswers = undefined;
45
>
this.draftCurrentIndex = undefined;
46
>
this.draftCollapsed = undefined;
47
>
void this.completion.complete({ answers });
48
>
}
49
>
50
>
constructor(
51
public questions: IChatQuestion[],
52
public allowSkip: boolean,