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 { CancellationToken } from '../../../base/common/cancellation.js';
7
>
import { basename } from '../../../base/common/resources.js';
8
>
import { URI } from '../../../base/common/uri.js';
9
>
import { localize } from '../../../nls.js';
10
>
import { ChangesetKind, parseChangesetUri } from '../common/changesetUri.js';
11
>
import { type IChangesetOperationHandler } from '../common/agentHostChangesetOperationService.js';
12
>
import { ChangesetOperationTargetKind, type InvokeChangesetOperationParams, type InvokeChangesetOperationResult } from '../common/state/protocol/channels-changeset/commands.js';
13
>
import { AHP_SESSION_NOT_FOUND, JsonRpcErrorCodes, ProtocolError } from '../common/state/sessionProtocol.js';
14
>
import { type SessionState } from '../common/state/sessionState.js';
15
>
import { ILogService } from '../../log/common/log.js';
16
>
import { IAgentHostGitService } from '../common/agentHostGitService.js';
17
>
18
>
export class AgentHostDiscardChangesOperationHandler implements IChangesetOperationHandler {
19
>
20
>
public static readonly OPERATION_DISCARD_CHANGES = 'discard-changes';
21
>
22
>
constructor(
23
private readonly _getSessionState: (sessionKey: string) => SessionState | undefined,
24
@IAgentHostGitService private readonly _agentHostGitService: IAgentHostGitService,
25
@ILogService private readonly _logService: ILogService,
26
) { }
28
>
async invoke(params: InvokeChangesetOperationParams, token: CancellationToken): Promise<InvokeChangesetOperationResult> {
29
const abortController = new AbortController();
30
if (token.isCancellationRequested) {