@codingame/monaco-vscode-chat-cloud-service-override 0.0.0-stage → 38.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common.d.ts +2 -0
- package/common.js +29 -0
- package/index.d.ts +3 -0
- package/index.js +9 -0
- package/package.json +52 -3
- package/session.d.ts +3 -0
- package/session.js +11 -0
- package/vscode/src/vs/sessions/contrib/chat/browser/newSession.d.ts +9 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.d.ts +67 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudAutomationStore.js +695 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.d.ts +4 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/cloudSandboxSessionConfig.js +39 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.d.ts +1 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessions.contribution.js +59 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.d.ts +1 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsActions.js +83 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.d.ts +87 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsChangesets.js +176 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.d.ts +422 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.js +2444 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.d.ts +91 -0
- package/vscode/src/vs/sessions/contrib/providers/copilotChatSessions/browser/githubCloudAutomationStore.js +620 -0
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.d.ts +1 -0
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHost.contribution.js +5 -0
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.d.ts +46 -0
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.js +321 -0
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.d.ts +104 -0
- package/vscode/src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.js +345 -0
- package/README.md +0 -3
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ResolveSessionConfigResult } from "@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/state/protocol/commands";
|
|
2
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
3
|
+
/** Cloud draft vocabulary until the provisioned host supplies its authoritative schema. */
|
|
4
|
+
export declare function createCloudSandboxSessionConfig(configurationService: IConfigurationService): ResolveSessionConfigResult;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
3
|
+
import { isAutoApprovePolicyRestricted } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/agentHostConfigPolicy';
|
|
4
|
+
import { ChatConfiguration, ChatDefaultPermissionLevel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
5
|
+
|
|
6
|
+
function createCloudSandboxSessionConfig(configurationService) {
|
|
7
|
+
const restricted = isAutoApprovePolicyRestricted(configurationService);
|
|
8
|
+
const modes = ["interactive", "plan", "autopilot"];
|
|
9
|
+
const approvals = restricted ? ["manual"] : ["manual", "assisted", "allow-all"];
|
|
10
|
+
const defaults = configurationService.getValue(ChatConfiguration.DefaultConfiguration);
|
|
11
|
+
const approval = defaults?.approvals === ChatDefaultPermissionLevel.AllowAll ? "allow-all" : defaults?.approvals;
|
|
12
|
+
return {
|
|
13
|
+
schema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
mode: {
|
|
17
|
+
type: "string",
|
|
18
|
+
title: ( localize(5049, "Agent Mode")),
|
|
19
|
+
enum: modes,
|
|
20
|
+
enumLabels: [( localize(5050, "Interactive")), ( localize(5051, "Plan")), ( localize(5052, "Autopilot"))],
|
|
21
|
+
enumDescriptions: [( localize(5053, "Works with you and asks for input when needed.")), ( localize(5054, "Plans the task before making changes.")), ( localize(5055, "Continues working until the task is done."))],
|
|
22
|
+
default: "interactive"
|
|
23
|
+
},
|
|
24
|
+
approvalMode: {
|
|
25
|
+
type: "string",
|
|
26
|
+
title: ( localize(5056, "Approvals")),
|
|
27
|
+
enum: approvals,
|
|
28
|
+
default: restricted ? "manual" : "assisted"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
values: {
|
|
33
|
+
mode: defaults?.mode && modes.includes(defaults.mode) ? defaults.mode : "interactive",
|
|
34
|
+
approvalMode: approval && approvals.includes(approval) ? approval : restricted ? "manual" : "assisted"
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { createCloudSandboxSessionConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
4
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
|
+
import { Disposable, MutableDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
7
|
+
import { CopilotChatSessionsProvider } from './copilotChatSessionsProvider.js';
|
|
8
|
+
import './copilotChatSessionsActions.js';
|
|
9
|
+
import { ISessionsProvidersService } from '@codingame/monaco-vscode-api/vscode/vs/sessions/services/sessions/browser/sessionsProvidersService.service';
|
|
10
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
11
|
+
import { isCloudSandboxEnabled, CloudSandboxEnabledSettingId } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/cloudSandboxAgentHost';
|
|
12
|
+
import { RemoteAgentHostsEnabledSettingId } from '@codingame/monaco-vscode-api/vscode/vs/platform/agentHost/common/remoteAgentHostService';
|
|
13
|
+
import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service';
|
|
14
|
+
|
|
15
|
+
let DefaultSessionsProviderContribution = class DefaultSessionsProviderContribution extends Disposable {
|
|
16
|
+
static {
|
|
17
|
+
this.ID = "sessions.defaultSessionsProvider";
|
|
18
|
+
}
|
|
19
|
+
constructor(
|
|
20
|
+
instantiationService,
|
|
21
|
+
sessionsProvidersService,
|
|
22
|
+
configurationService,
|
|
23
|
+
chatEntitlementService
|
|
24
|
+
) {
|
|
25
|
+
super();
|
|
26
|
+
const provider = this._register(
|
|
27
|
+
instantiationService.createInstance(CopilotChatSessionsProvider, "default")
|
|
28
|
+
);
|
|
29
|
+
this._register(sessionsProvidersService.registerProvider(provider));
|
|
30
|
+
if (isWeb) {
|
|
31
|
+
const sandboxRegistration = this._register(( new MutableDisposable()));
|
|
32
|
+
const updateSandboxRegistration = () => {
|
|
33
|
+
if (!isCloudSandboxEnabled(configurationService) || chatEntitlementService.sentiment.hidden) {
|
|
34
|
+
sandboxRegistration.clear();
|
|
35
|
+
} else if (!sandboxRegistration.value) {
|
|
36
|
+
const store = ( new DisposableStore());
|
|
37
|
+
sandboxRegistration.value = store;
|
|
38
|
+
const sandboxProvider = store.add(
|
|
39
|
+
instantiationService.createInstance(CopilotChatSessionsProvider, "sandbox")
|
|
40
|
+
);
|
|
41
|
+
store.add(sessionsProvidersService.registerProvider(sandboxProvider));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
this._register(configurationService.onDidChangeConfiguration(event => {
|
|
45
|
+
if (event.affectsConfiguration(CloudSandboxEnabledSettingId) || event.affectsConfiguration(RemoteAgentHostsEnabledSettingId)) {
|
|
46
|
+
updateSandboxRegistration();
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
this._register(chatEntitlementService.onDidChangeSentiment(updateSandboxRegistration));
|
|
50
|
+
updateSandboxRegistration();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
DefaultSessionsProviderContribution = ( __decorate([( __param(0, IInstantiationService)), ( __param(1, ISessionsProvidersService)), ( __param(2, IConfigurationService)), ( __param(3, IChatEntitlementService))], DefaultSessionsProviderContribution));
|
|
55
|
+
registerWorkbenchContribution2(
|
|
56
|
+
DefaultSessionsProviderContribution.ID,
|
|
57
|
+
DefaultSessionsProviderContribution,
|
|
58
|
+
WorkbenchPhase.AfterRestored
|
|
59
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
5
|
+
import { IActionViewItemService } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/actionViewItemService.service';
|
|
6
|
+
import { registerAction2, Action2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
7
|
+
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
8
|
+
import { registerWorkbenchContribution2, WorkbenchPhase } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions';
|
|
9
|
+
import { Menus } from '@codingame/monaco-vscode-api/vscode/vs/sessions/browser/menus';
|
|
10
|
+
import { SessionProviderIdContext, IsNewChatSessionContext } from '@codingame/monaco-vscode-api/vscode/vs/sessions/common/contextkeys';
|
|
11
|
+
import { COPILOT_PROVIDER_ID } from './copilotChatSessionsProvider.js';
|
|
12
|
+
import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/actions/chatContextKeys';
|
|
13
|
+
import { ISessionContext } from '@codingame/monaco-vscode-api/vscode/vs/sessions/services/sessions/browser/sessionContext.service';
|
|
14
|
+
import { CLOUD_SANDBOX_CREATION_PROVIDER_ID } from '../../remoteAgentHost/browser/cloudSandboxAgentHostContribution.js';
|
|
15
|
+
import { AgentHostModePicker } from '@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/providers/agentHost/browser/agentHostModePicker';
|
|
16
|
+
import { AgentHostPermissionPickerDelegate } from '@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/providers/agentHost/browser/agentHostPermissionPickerDelegate';
|
|
17
|
+
import { PickerActionViewItem } from '@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/providers/agentHost/browser/agentHostSessionConfigPicker';
|
|
18
|
+
import { MobilePermissionPicker } from '@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/providers/copilotChatSessions/browser/mobilePermissionPicker';
|
|
19
|
+
import { MobileAgentHostModePicker } from '@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/providers/agentHost/browser/mobile/mobileAgentHostModePicker';
|
|
20
|
+
import { isPhoneLayout } from '@codingame/monaco-vscode-api/vscode/vs/sessions/browser/parts/mobile/mobileLayout';
|
|
21
|
+
import { IWorkbenchLayoutService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/layout/browser/layoutService.service';
|
|
22
|
+
|
|
23
|
+
const IsActiveCopilotChatSessionProvider = ( ContextKeyExpr.equals(SessionProviderIdContext.key, COPILOT_PROVIDER_ID));
|
|
24
|
+
const IsNewCloudSession = ( ContextKeyExpr.and(IsNewChatSessionContext, ChatContextKeys.enabled, ( ContextKeyExpr.or(IsActiveCopilotChatSessionProvider, ( SessionProviderIdContext.isEqualTo(CLOUD_SANDBOX_CREATION_PROVIDER_ID))))));
|
|
25
|
+
for (const [id, title, order] of [["sessions.sandbox.modePicker", ( localize2(5057, "Agent Mode")), 0], ["sessions.sandbox.approvalPicker", ( localize2(5058, "Approvals")), 1]]) {
|
|
26
|
+
registerAction2(class extends Action2 {
|
|
27
|
+
constructor() {
|
|
28
|
+
super({
|
|
29
|
+
id,
|
|
30
|
+
title,
|
|
31
|
+
menu: [{
|
|
32
|
+
id: Menus.NewSessionControl,
|
|
33
|
+
group: "navigation",
|
|
34
|
+
order,
|
|
35
|
+
when: IsNewCloudSession
|
|
36
|
+
}]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
run() {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
let CopilotPickerActionViewItemContribution = class CopilotPickerActionViewItemContribution extends Disposable {
|
|
43
|
+
static {
|
|
44
|
+
this.ID = "workbench.contrib.copilotPickerActionViewItems";
|
|
45
|
+
}
|
|
46
|
+
constructor(actionViewItemService, layoutService) {
|
|
47
|
+
super();
|
|
48
|
+
this._register(actionViewItemService.register(
|
|
49
|
+
Menus.NewSessionControl,
|
|
50
|
+
"sessions.sandbox.modePicker",
|
|
51
|
+
(_action, _options, scopedInstantiationService) => {
|
|
52
|
+
const {
|
|
53
|
+
session
|
|
54
|
+
} = scopedInstantiationService.invokeFunction(accessor => accessor.get(ISessionContext));
|
|
55
|
+
return ( new PickerActionViewItem(scopedInstantiationService.createInstance(
|
|
56
|
+
isPhoneLayout(layoutService) ? MobileAgentHostModePicker : AgentHostModePicker,
|
|
57
|
+
session
|
|
58
|
+
)));
|
|
59
|
+
}
|
|
60
|
+
));
|
|
61
|
+
this._register(actionViewItemService.register(
|
|
62
|
+
Menus.NewSessionControl,
|
|
63
|
+
"sessions.sandbox.approvalPicker",
|
|
64
|
+
(_action, _options, scopedInstantiationService) => {
|
|
65
|
+
const {
|
|
66
|
+
session
|
|
67
|
+
} = scopedInstantiationService.invokeFunction(accessor => accessor.get(ISessionContext));
|
|
68
|
+
const delegate = scopedInstantiationService.createInstance(AgentHostPermissionPickerDelegate, session);
|
|
69
|
+
return ( new PickerActionViewItem(
|
|
70
|
+
scopedInstantiationService.createInstance(MobilePermissionPicker, delegate),
|
|
71
|
+
delegate,
|
|
72
|
+
true
|
|
73
|
+
));
|
|
74
|
+
}
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
CopilotPickerActionViewItemContribution = ( __decorate([( __param(0, IActionViewItemService)), ( __param(1, IWorkbenchLayoutService))], CopilotPickerActionViewItemContribution));
|
|
79
|
+
registerWorkbenchContribution2(
|
|
80
|
+
CopilotPickerActionViewItemContribution.ID,
|
|
81
|
+
CopilotPickerActionViewItemContribution,
|
|
82
|
+
WorkbenchPhase.AfterRestored
|
|
83
|
+
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { IObservable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/observable";
|
|
2
|
+
import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
|
|
3
|
+
import { IChatSessionFileChange2 } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService";
|
|
4
|
+
import { IChat, ISessionChangeset, ISessionChangesetOperation, ISessionChangesetOperationTarget, ISessionFileChange, ISessionWorkspace } from "@codingame/monaco-vscode-api/vscode/vs/sessions/services/sessions/common/session";
|
|
5
|
+
type IChangesetChat = Pick<IChat, "changes" | "checkpoints" | "isArchived">;
|
|
6
|
+
interface IChangesetResolver {
|
|
7
|
+
resolve(firstCheckpointRef: string, lastCheckpointRef: string): Promise<IChatSessionFileChange2[] | undefined>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createChangesets(workspaceObs: IObservable<ISessionWorkspace | undefined>, chatsObs: IObservable<readonly IChangesetChat[]>, instantiationService: IInstantiationService): IObservable<readonly ISessionChangeset[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Common base for {@link ISessionChangeset} implementations.
|
|
12
|
+
*
|
|
13
|
+
* Changesets operate at the session level and derive everything they need
|
|
14
|
+
* from the session's chats list (checkpoints, archived state, last-turn
|
|
15
|
+
* end time). Subclasses that need session-level metadata not carried on
|
|
16
|
+
* `IChat` (e.g. workspace / git repository info) take those as additional
|
|
17
|
+
* constructor parameters.
|
|
18
|
+
*/
|
|
19
|
+
declare abstract class AbstractChangeset implements ISessionChangeset {
|
|
20
|
+
protected readonly _chats: IObservable<readonly IChangesetChat[]>;
|
|
21
|
+
abstract readonly id: string;
|
|
22
|
+
abstract readonly label: string;
|
|
23
|
+
abstract readonly description?: string;
|
|
24
|
+
abstract readonly isEnabled: IObservable<boolean>;
|
|
25
|
+
abstract readonly isDefault: IObservable<boolean>;
|
|
26
|
+
abstract readonly isLoadingChanges: IObservable<boolean>;
|
|
27
|
+
abstract readonly changes: IObservable<readonly ISessionFileChange[]>;
|
|
28
|
+
abstract readonly originalCheckpointRef: IObservable<string | undefined>;
|
|
29
|
+
abstract readonly modifiedCheckpointRef: IObservable<string | undefined>;
|
|
30
|
+
readonly operations: IObservable<readonly ISessionChangesetOperation[]>;
|
|
31
|
+
constructor(_chats: IObservable<readonly IChangesetChat[]>);
|
|
32
|
+
invokeOperation(_operationId: string, _target?: ISessionChangesetOperationTarget): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Diff between a branch and its base (e.g. `main...feature`). Used for
|
|
36
|
+
* PR-style review and "what changed on this branch" views. Expected to be
|
|
37
|
+
* semi-static — refresh on new commits to either ref.
|
|
38
|
+
*/
|
|
39
|
+
export declare class BranchChangesChangeset extends AbstractChangeset {
|
|
40
|
+
static readonly ID = "branch";
|
|
41
|
+
readonly id = "branch";
|
|
42
|
+
readonly label: string;
|
|
43
|
+
readonly description: string | undefined;
|
|
44
|
+
readonly category: string;
|
|
45
|
+
readonly isEnabled: IObservable<boolean>;
|
|
46
|
+
readonly isDefault: IObservable<boolean>;
|
|
47
|
+
readonly isLoadingChanges: IObservable<boolean>;
|
|
48
|
+
readonly changes: IObservable<readonly ISessionFileChange[]>;
|
|
49
|
+
readonly originalCheckpointRef: IObservable<string | undefined>;
|
|
50
|
+
readonly modifiedCheckpointRef: IObservable<string | undefined>;
|
|
51
|
+
constructor(workspaceObs: IObservable<ISessionWorkspace | undefined>, chatsObs: IObservable<readonly IChangesetChat[]>);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Aggregate of every file the session has touched.
|
|
55
|
+
*/
|
|
56
|
+
export declare class AllChangesChangeset extends AbstractChangeset {
|
|
57
|
+
static readonly ID = "allChanges";
|
|
58
|
+
readonly id = "allChanges";
|
|
59
|
+
readonly label: string;
|
|
60
|
+
readonly description: string;
|
|
61
|
+
readonly category: string;
|
|
62
|
+
readonly isEnabled: IObservable<boolean>;
|
|
63
|
+
readonly isDefault: IObservable<boolean>;
|
|
64
|
+
readonly isLoadingChanges: IObservable<boolean>;
|
|
65
|
+
readonly changes: IObservable<readonly ISessionFileChange[]>;
|
|
66
|
+
readonly originalCheckpointRef: IObservable<string | undefined>;
|
|
67
|
+
readonly modifiedCheckpointRef: IObservable<string | undefined>;
|
|
68
|
+
constructor(chatsObs: IObservable<readonly IChangesetChat[]>, changesetResolver: IChangesetResolver);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Files touched by the most recent agent turn.
|
|
72
|
+
*/
|
|
73
|
+
export declare class LastTurnChangesChangeset extends AbstractChangeset {
|
|
74
|
+
static readonly ID = "lastTurnChanges";
|
|
75
|
+
readonly id = "lastTurnChanges";
|
|
76
|
+
readonly label: string;
|
|
77
|
+
readonly description: string;
|
|
78
|
+
readonly category: string;
|
|
79
|
+
readonly isEnabled: IObservable<boolean>;
|
|
80
|
+
readonly isDefault: IObservable<boolean>;
|
|
81
|
+
readonly isLoadingChanges: IObservable<boolean>;
|
|
82
|
+
readonly changes: IObservable<readonly ISessionFileChange[]>;
|
|
83
|
+
readonly originalCheckpointRef: IObservable<string | undefined>;
|
|
84
|
+
readonly modifiedCheckpointRef: IObservable<string | undefined>;
|
|
85
|
+
constructor(chatsObs: IObservable<readonly IChangesetChat[]>, changesetResolver: IChangesetResolver);
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
4
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
5
|
+
import { gitHubInfoEqual, BRANCH_CHANGES_CHANGESET_ID, sessionFileChangesEqual } from '@codingame/monaco-vscode-api/vscode/vs/sessions/services/sessions/common/session';
|
|
6
|
+
import { IGitHubService } from '@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/github/browser/githubService.service';
|
|
7
|
+
import { toPRContentUri } from '@codingame/monaco-vscode-api/vscode/vs/sessions/contrib/github/common/utils';
|
|
8
|
+
import { constObservable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/constObservable';
|
|
9
|
+
import { derivedOpts, derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
|
|
10
|
+
import { ObservablePromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/promise';
|
|
11
|
+
|
|
12
|
+
let GitHubRepositoryChangesetResolver = class GitHubRepositoryChangesetResolver {
|
|
13
|
+
constructor(workspace, _gitHubService) {
|
|
14
|
+
this._gitHubService = _gitHubService;
|
|
15
|
+
this._gitHubInfoObs = derivedOpts({
|
|
16
|
+
equalsFn: gitHubInfoEqual
|
|
17
|
+
}, reader => {
|
|
18
|
+
const gitRepository = workspace.read(reader)?.folders[0].gitRepository;
|
|
19
|
+
return gitRepository?.gitHubInfo.read(reader);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async resolve(firstCheckpointRef, lastCheckpointRef) {
|
|
23
|
+
const gitHubInfo = this._gitHubInfoObs.get();
|
|
24
|
+
if (!gitHubInfo || !gitHubInfo.pullRequest?.number) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const params = {
|
|
28
|
+
owner: gitHubInfo.owner,
|
|
29
|
+
repo: gitHubInfo.repo,
|
|
30
|
+
prNumber: gitHubInfo.pullRequest.number
|
|
31
|
+
};
|
|
32
|
+
const changes = await this._gitHubService.getChangedFiles(params.owner, params.repo, firstCheckpointRef, lastCheckpointRef);
|
|
33
|
+
return changes.map(change => {
|
|
34
|
+
const uri = toPRContentUri(change.filename, {
|
|
35
|
+
...params,
|
|
36
|
+
commitSha: lastCheckpointRef,
|
|
37
|
+
status: change.status,
|
|
38
|
+
isBase: false
|
|
39
|
+
});
|
|
40
|
+
const originalUri = change.status !== "added" ? toPRContentUri(change.previous_filename || change.filename, {
|
|
41
|
+
...params,
|
|
42
|
+
commitSha: firstCheckpointRef,
|
|
43
|
+
previousFileName: change.previous_filename,
|
|
44
|
+
status: change.status,
|
|
45
|
+
isBase: true
|
|
46
|
+
}) : undefined;
|
|
47
|
+
const modifiedUri = change.status !== "removed" ? uri : undefined;
|
|
48
|
+
return {
|
|
49
|
+
uri,
|
|
50
|
+
originalUri,
|
|
51
|
+
modifiedUri,
|
|
52
|
+
insertions: change.additions,
|
|
53
|
+
deletions: change.deletions
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
GitHubRepositoryChangesetResolver = ( __decorate([( __param(1, IGitHubService))], GitHubRepositoryChangesetResolver));
|
|
59
|
+
function createChangesets(workspaceObs, chatsObs, instantiationService) {
|
|
60
|
+
const changesetResolver = instantiationService.createInstance(GitHubRepositoryChangesetResolver, workspaceObs);
|
|
61
|
+
return constObservable([( new BranchChangesChangeset(workspaceObs, chatsObs)), ( new AllChangesChangeset(chatsObs, changesetResolver)), ( new LastTurnChangesChangeset(chatsObs, changesetResolver))]);
|
|
62
|
+
}
|
|
63
|
+
class AbstractChangeset {
|
|
64
|
+
constructor(_chats) {
|
|
65
|
+
this._chats = _chats;
|
|
66
|
+
this.operations = constObservable([]);
|
|
67
|
+
}
|
|
68
|
+
async invokeOperation(_operationId, _target) {}
|
|
69
|
+
}
|
|
70
|
+
class BranchChangesChangeset extends AbstractChangeset {
|
|
71
|
+
static {
|
|
72
|
+
this.ID = BRANCH_CHANGES_CHANGESET_ID;
|
|
73
|
+
}
|
|
74
|
+
constructor(workspaceObs, chatsObs) {
|
|
75
|
+
super(chatsObs);
|
|
76
|
+
this.id = BranchChangesChangeset.ID;
|
|
77
|
+
this.label = ( localize(5059, "Branch Changes"));
|
|
78
|
+
this.category = ( localize(5060, "Changes"));
|
|
79
|
+
this.isLoadingChanges = constObservable(false);
|
|
80
|
+
this.modifiedCheckpointRef = constObservable(undefined);
|
|
81
|
+
const gitRepository = workspaceObs.get()?.folders[0].gitRepository;
|
|
82
|
+
const branchName = gitRepository?.branchName;
|
|
83
|
+
const baseBranchName = gitRepository?.baseBranchName;
|
|
84
|
+
this.description = branchName && baseBranchName ? `${branchName} → ${baseBranchName}` : branchName;
|
|
85
|
+
this.originalCheckpointRef = derived(reader => {
|
|
86
|
+
return chatsObs.read(reader)[0]?.checkpoints.read(reader)?.firstCheckpointRef;
|
|
87
|
+
});
|
|
88
|
+
const isArchivedObs = derived(reader => chatsObs.read(reader)[0]?.isArchived.read(reader) === true);
|
|
89
|
+
this.isDefault = derived(reader => !isArchivedObs.read(reader));
|
|
90
|
+
this.isEnabled = derived(reader => !isArchivedObs.read(reader));
|
|
91
|
+
this.changes = derived(reader => {
|
|
92
|
+
return chatsObs.read(reader)[0]?.changes.read(reader) ?? [];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
class AllChangesChangeset extends AbstractChangeset {
|
|
97
|
+
static {
|
|
98
|
+
this.ID = "allChanges";
|
|
99
|
+
}
|
|
100
|
+
constructor(chatsObs, changesetResolver) {
|
|
101
|
+
super(chatsObs);
|
|
102
|
+
this.id = AllChangesChangeset.ID;
|
|
103
|
+
this.label = ( localize(5061, "All Changes"));
|
|
104
|
+
this.description = ( localize(5062, "Show all changes made in this session"));
|
|
105
|
+
this.category = ( localize(5063, "Checkpoints"));
|
|
106
|
+
this.originalCheckpointRef = derived(reader => {
|
|
107
|
+
return chatsObs.read(reader)[0]?.checkpoints.read(reader)?.firstCheckpointRef;
|
|
108
|
+
});
|
|
109
|
+
this.modifiedCheckpointRef = derived(reader => {
|
|
110
|
+
return chatsObs.read(reader)[0]?.checkpoints.read(reader)?.lastCheckpointRef;
|
|
111
|
+
});
|
|
112
|
+
const changesPromiseObs = derived(reader => {
|
|
113
|
+
const originalCheckpointRef = this.originalCheckpointRef.read(reader);
|
|
114
|
+
const modifiedCheckpointRef = this.modifiedCheckpointRef.read(reader);
|
|
115
|
+
if (!originalCheckpointRef || !modifiedCheckpointRef) {
|
|
116
|
+
return constObservable([]);
|
|
117
|
+
}
|
|
118
|
+
const diffPromise = changesetResolver.resolve(originalCheckpointRef, modifiedCheckpointRef);
|
|
119
|
+
return ( new ObservablePromise(diffPromise)).resolvedValue;
|
|
120
|
+
});
|
|
121
|
+
this.isLoadingChanges = derived(reader => {
|
|
122
|
+
return changesPromiseObs.read(reader).read(reader) === undefined;
|
|
123
|
+
});
|
|
124
|
+
this.changes = derivedOpts({
|
|
125
|
+
equalsFn: sessionFileChangesEqual
|
|
126
|
+
}, reader => {
|
|
127
|
+
return changesPromiseObs.read(reader).read(reader) ?? [];
|
|
128
|
+
});
|
|
129
|
+
this.isDefault = derived(reader => chatsObs.read(reader)[0]?.isArchived.read(reader) === true);
|
|
130
|
+
this.isEnabled = derived(
|
|
131
|
+
reader => this.originalCheckpointRef.read(reader) !== undefined && this.modifiedCheckpointRef.read(reader) !== undefined
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
class LastTurnChangesChangeset extends AbstractChangeset {
|
|
136
|
+
static {
|
|
137
|
+
this.ID = "lastTurnChanges";
|
|
138
|
+
}
|
|
139
|
+
constructor(chatsObs, changesetResolver) {
|
|
140
|
+
super(chatsObs);
|
|
141
|
+
this.id = LastTurnChangesChangeset.ID;
|
|
142
|
+
this.label = ( localize(5064, "Last Turn Changes"));
|
|
143
|
+
this.description = ( localize(5065, "Show only changes made in the last turn"));
|
|
144
|
+
this.category = ( localize(5063, "Checkpoints"));
|
|
145
|
+
this.isDefault = constObservable(false);
|
|
146
|
+
this.modifiedCheckpointRef = derived(reader => {
|
|
147
|
+
return chatsObs.read(reader)[0]?.checkpoints.read(reader)?.lastCheckpointRef;
|
|
148
|
+
});
|
|
149
|
+
this.originalCheckpointRef = derived(reader => {
|
|
150
|
+
const modifiedCheckpointRef = this.modifiedCheckpointRef.read(reader);
|
|
151
|
+
return modifiedCheckpointRef ? `${modifiedCheckpointRef}^` : undefined;
|
|
152
|
+
});
|
|
153
|
+
const changesPromiseObs = derived(reader => {
|
|
154
|
+
const originalCheckpointRef = this.originalCheckpointRef.read(reader);
|
|
155
|
+
const modifiedCheckpointRef = this.modifiedCheckpointRef.read(reader);
|
|
156
|
+
if (!originalCheckpointRef || !modifiedCheckpointRef) {
|
|
157
|
+
return constObservable([]);
|
|
158
|
+
}
|
|
159
|
+
const diffPromise = changesetResolver.resolve(originalCheckpointRef, modifiedCheckpointRef);
|
|
160
|
+
return ( new ObservablePromise(diffPromise)).resolvedValue;
|
|
161
|
+
});
|
|
162
|
+
this.isLoadingChanges = derived(reader => {
|
|
163
|
+
return changesPromiseObs.read(reader).read(reader) === undefined;
|
|
164
|
+
});
|
|
165
|
+
this.changes = derivedOpts({
|
|
166
|
+
equalsFn: sessionFileChangesEqual
|
|
167
|
+
}, reader => {
|
|
168
|
+
return changesPromiseObs.read(reader).read(reader) ?? [];
|
|
169
|
+
});
|
|
170
|
+
this.isEnabled = derived(
|
|
171
|
+
reader => this.originalCheckpointRef.read(reader) !== undefined && this.modifiedCheckpointRef.read(reader) !== undefined
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { AllChangesChangeset, BranchChangesChangeset, LastTurnChangesChangeset, createChangesets };
|