Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCheckpointTimeline.ts
4780 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 { VSBuffer } from '../../../../../base/common/buffer.js';
7
import { IDisposable } from '../../../../../base/common/lifecycle.js';
8
import { IObservable, IReader, ITransaction } from '../../../../../base/common/observable.js';
9
import { URI } from '../../../../../base/common/uri.js';
10
import { IEditSessionDiffStats, IEditSessionEntryDiff } from '../../common/editing/chatEditingService.js';
11
import { IChatRequestDisablement } from '../../common/model/chatModel.js';
12
import { FileOperation, IChatEditingTimelineState, IFileBaseline } from './chatEditingOperations.js';
13
14
/**
15
* Interface for the new checkpoint-based timeline system
16
*/
17
export interface IChatEditingCheckpointTimeline {
18
readonly requestDisablement: IObservable<IChatRequestDisablement[]>;
19
readonly canUndo: IObservable<boolean>;
20
readonly canRedo: IObservable<boolean>;
21
22
// Checkpoint management
23
createCheckpoint(requestId: string | undefined, undoStopId: string | undefined, label: string, description?: string): void;
24
navigateToCheckpoint(checkpointId: string): Promise<void>;
25
undoToLastCheckpoint(): Promise<void>;
26
redoToNextCheckpoint(): Promise<void>;
27
getCheckpointIdForRequest(requestId: string, undoStopId?: string): string | undefined;
28
29
// Operation tracking
30
recordFileOperation(operation: FileOperation): void;
31
incrementEpoch(): number;
32
33
// File baselines
34
recordFileBaseline(baseline: IFileBaseline): void;
35
hasFileBaseline(uri: URI, requestId: string): boolean;
36
37
// State reconstruction
38
getContentURIAtStop(requestId: string, fileURI: URI, stopId: string | undefined): URI;
39
getContentAtStop(requestId: string, contentURI: URI, stopId: string | undefined): Promise<string | VSBuffer | undefined>;
40
onDidChangeContentsAtStop(requestId: string, contentURI: URI, stopId: string | undefined, callback: (data: string) => void): IDisposable;
41
42
// Persistence
43
getStateForPersistence(): IChatEditingTimelineState;
44
restoreFromState(state: IChatEditingTimelineState, tx: ITransaction): void;
45
46
// Diffing
47
getEntryDiffBetweenStops(uri: URI, requestId: string | undefined, stopId: string | undefined): IObservable<IEditSessionEntryDiff | undefined> | undefined;
48
getEntryDiffBetweenRequests(uri: URI, startRequestId: string, stopRequestId: string): IObservable<IEditSessionEntryDiff | undefined>;
49
getDiffsForFilesInRequest(requestId: string): IObservable<readonly IEditSessionEntryDiff[]>;
50
getDiffsForFilesInSession(): IObservable<readonly IEditSessionEntryDiff[]>;
51
getDiffForSession(): IObservable<IEditSessionDiffStats>;
52
hasEditsInRequest(requestId: string, reader?: IReader): boolean;
53
}
54
55