Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/inlineEdits/vscode-node/parts/inlineEditLogger.ts
13405 views
1
/*---------------------------------------------------------------------------------------------
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 { InlineEditRequestLogContext } from '../../../../platform/inlineEdits/common/inlineEditLogContext';
7
import { IRequestLogger, LoggedRequestKind } from '../../../../platform/requestLogger/common/requestLogger';
8
import { Disposable } from '../../../../util/vs/base/common/lifecycle';
9
10
export class InlineEditLogger extends Disposable {
11
private readonly _requests: InlineEditRequestLogContext[] = [];
12
13
constructor(
14
@IRequestLogger private readonly _requestLogger: IRequestLogger,
15
) {
16
super();
17
}
18
19
/**
20
* Add a live log entry that appears immediately in the tree with dynamic content.
21
* Content and icon are resolved on-demand from the logContext, and the entry
22
* refreshes automatically as the logContext state changes.
23
*/
24
addLive(request: InlineEditRequestLogContext): void {
25
this._requestLogger.addEntry({
26
type: LoggedRequestKind.MarkdownContentRequest,
27
debugName: request.getDebugName(),
28
icon: () => request.getIcon(),
29
startTimeMs: request.time,
30
markdownContent: () => request.toLogDocument(),
31
onDidChange: request.onDidChange,
32
isVisible: () => request.includeInLogTree,
33
});
34
this._pushRequest(request);
35
}
36
37
private _pushRequest(request: InlineEditRequestLogContext): void {
38
this._requests.push(request);
39
if (this._requests.length > 100) {
40
this._requests.shift();
41
}
42
}
43
44
public getRequestById(requestId: number): InlineEditRequestLogContext | undefined {
45
return this._requests.find(request => request.requestId === requestId);
46
}
47
}
48
49