1
>
/*---------------------------------------------------------------------------------------------
mockChatModel.ts
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 { Emitter, Event } from '../../../../../../base/common/event.js';
7
>
import { Disposable } from '../../../../../../base/common/lifecycle.js';
8
>
import { IObservable, observableValue } from '../../../../../../base/common/observable.js';
9
>
import { URI } from '../../../../../../base/common/uri.js';
10
>
import { IChatEditingSession } from '../../../common/editing/chatEditingService.js';
11
>
import { IChatChangeEvent, IChatModel, IChatPendingRequest, IChatRequestModel, IChatRequestNeedsInputInfo, IExportableChatData, IExportableRepoData, IInputModel, ISerializableChatData } from '../../../common/model/chatModel.js';
12
>
import { ChatAgentLocation } from '../../../common/constants.js';
13
>
import { IChatSessionContext, IChatSessionTiming } from '../../../common/chatService/chatService.js';
14
>
15
>
export class MockChatModel extends Disposable implements IChatModel {
16
>
readonly onDidDispose = this._register(new Emitter<void>()).event;
17
>
readonly onDidChange = this._register(new Emitter<IChatChangeEvent>()).event;
18
>
sessionId = '';
19
>
readonly timestamp = 0;
20
>
readonly timing: IChatSessionTiming = { created: Date.now(), lastRequestStarted: undefined, lastRequestEnded: undefined };
21
>
readonly initialLocation = ChatAgentLocation.Chat;
22
>
readonly title = '';
23
>
readonly hasCustomTitle = false;
24
>
customTitle: string | undefined;
25
>
lastMessageDate = Date.now();
26
>
creationDate = Date.now();
27
>
requests: IChatRequestModel[] = [];
28
>
readonly requestInProgress = observableValue('requestInProgress', false);
29
>
readonly hasActiveRequest = observableValue('hasActiveRequest', false);
30
>
readonly requestNeedsInput = observableValue<IChatRequestNeedsInputInfo | undefined>('requestNeedsInput', undefined);
31
>
readonly isReadOnly = observableValue(this, false);
32
>
readonly inputPlaceholder = undefined;
33
>
readonly editingSession = undefined;
34
>
readonly checkpoint = undefined;
35
>
readonly willKeepAlive = true;
36
>
readonly responderUsername: string = 'agent';
37
>
readonly inputModel: IInputModel = {
38
>
state: observableValue('inputModelState', undefined),
39
>
setState: () => { },
40
>
clearState: () => { },
41
>
toJSON: () => undefined
42
>
};
43
>
readonly contributedChatSession = undefined;
44
>
repoData: IExportableRepoData | undefined = undefined;
45
>
isDisposed = false;
46
>
lastRequestObs: IObservable<IChatRequestModel | undefined>;
47
>
48
>
constructor(readonly sessionResource: URI) {
49
super();
50
this.lastRequest = undefined;
51
this.lastRequestObs = observableValue('lastRequest', undefined);
52
}
54
>
setContributedChatSession(session: IChatSessionContext | undefined): void {
55
throw new Error('Method not implemented.');
56
}
58
>
readonly hasRequests = false;
59
>
readonly lastRequest: IChatRequestModel | undefined;
60
>
readonly sessionCost: number = 0;
61
>
62
>
override dispose() {
63
this.isDisposed = true;
64
super.dispose();
65
}
67
>
startEditingSession(isGlobalEditingSession?: boolean, transferFromSession?: IChatEditingSession): void { }
68
>
getRequests(): IChatRequestModel[] { return []; }
69
>
setCheckpoint(requestId: string | undefined): void { }
70
>
setRepoData(data: IExportableRepoData | undefined): void { this.repoData = data; }
71
>
workingDirectory: URI | undefined = undefined;
72
>
setWorkingDirectory(uri: URI | undefined): void { this.workingDirectory = uri; }
73
>
readonly onDidChangePendingRequests: Event<void> = this._register(new Emitter<void>()).event;
74
>
getPendingRequests(): readonly IChatPendingRequest[] { return []; }
75
>
toExport(): IExportableChatData {
76
return {
77
initialLocation: this.initialLocation,