@codingame/monaco-vscode-chat-service-override 15.0.2 → 16.0.0

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.
Files changed (147) hide show
  1. package/index.js +11 -8
  2. package/package.json +29 -20
  3. package/vscode/src/vs/editor/common/diff/documentDiffProvider.d.ts +22 -0
  4. package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +10 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +9 -2
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +80 -55
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +2 -2
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +17 -3
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/{askToSelectPrompt.d.ts → askToSelectPrompt/askToSelectPrompt.d.ts} +9 -1
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/askToSelectPrompt.js +79 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.d.ts +7 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.js +27 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.d.ts +5 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.js +53 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.d.ts +2 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.js +19 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.d.ts +5 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.js +27 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.d.ts +13 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.js +49 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +11 -11
  22. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +6 -1
  23. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +163 -72
  24. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
  25. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +22 -2
  26. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
  27. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +4 -1
  28. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
  29. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +17 -17
  30. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +9 -8
  31. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.d.ts +7 -0
  32. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.js +17 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +15 -15
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +242 -74
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.d.ts +4 -0
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.js +15 -0
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +47 -0
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +688 -0
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +28 -0
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +355 -0
  41. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +11 -11
  42. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +71 -0
  43. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +395 -0
  44. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +98 -0
  45. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +216 -0
  46. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +97 -0
  47. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +831 -0
  48. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +7 -4
  49. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +32 -47
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +110 -0
  51. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +985 -0
  52. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.d.ts +20 -0
  53. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +69 -0
  54. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.d.ts +15 -0
  55. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.js +67 -0
  56. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.d.ts +26 -0
  57. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +147 -0
  58. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +56 -0
  59. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +284 -0
  60. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.d.ts +38 -0
  61. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +578 -0
  62. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.d.ts +45 -0
  63. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +122 -0
  64. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.d.ts +15 -0
  65. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.js +320 -0
  66. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.d.ts +31 -0
  67. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +50 -0
  68. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +5 -3
  69. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +22 -5
  70. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +4 -0
  71. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +166 -62
  72. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
  73. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +6 -104
  74. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +704 -732
  75. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +10 -25
  76. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +329 -236
  77. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.d.ts +19 -0
  78. package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.js +27 -0
  79. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -2
  80. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +14 -6
  81. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +3 -3
  82. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
  83. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
  84. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
  85. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +1 -1
  86. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css +3 -0
  87. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +17 -1
  88. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +217 -18
  89. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css +114 -0
  90. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditorController.css +30 -0
  91. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +56 -0
  92. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css +90 -0
  93. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +65 -19
  94. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +2 -2
  95. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +4 -4
  96. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +2 -2
  97. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +2 -2
  98. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +3 -3
  99. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +14 -12
  100. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
  101. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +5 -3
  102. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -2
  103. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +16 -8
  104. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +175 -57
  105. package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +66 -0
  106. package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +313 -0
  107. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +3 -2
  108. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -2
  109. package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.d.ts +14 -0
  110. package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.js +30 -0
  111. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +2 -3
  112. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +6 -2
  113. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +10 -2
  114. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +18 -3
  115. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.d.ts +9 -0
  116. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.js +117 -0
  117. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +3 -4
  118. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +2 -2
  119. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +2 -2
  120. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +6 -4
  121. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +157 -65
  122. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +2 -1
  123. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +39 -21
  124. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +0 -1
  125. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -3
  126. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
  127. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +11 -10
  128. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
  129. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +10 -0
  130. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +47 -0
  131. package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.d.ts +5 -0
  132. package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.js +26 -0
  133. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +0 -142
  134. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +0 -52
  135. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +0 -331
  136. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +0 -15
  137. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +0 -110
  138. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +0 -6
  139. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +0 -6
  140. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +0 -6
  141. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +0 -6
  142. package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +0 -19
  143. package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +0 -13
  144. package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +0 -31
  145. package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +0 -85
  146. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +0 -11
  147. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +0 -22
@@ -18,18 +18,20 @@ class ChatToolInvocation {
18
18
  get resultDetails() {
19
19
  return this._resultDetails;
20
20
  }
21
- constructor(preparedInvocation, toolData) {
21
+ constructor(preparedInvocation, toolData, toolCallId) {
22
+ this.toolCallId = toolCallId;
22
23
  this.kind = 'toolInvocation';
23
24
  this._isComplete = false;
24
25
  this._isCompleteDeferred = ( new DeferredPromise());
25
26
  this._confirmDeferred = ( new DeferredPromise());
26
- const defaultMessage = ( localize(4856, "Using {0}", `"${toolData.displayName}"`));
27
+ const defaultMessage = ( localize(4983, "Using {0}", `"${toolData.displayName}"`));
27
28
  const invocationMessage = preparedInvocation?.invocationMessage ?? defaultMessage;
28
29
  this.invocationMessage = invocationMessage;
29
30
  this.pastTenseMessage = preparedInvocation?.pastTenseMessage;
30
31
  this._confirmationMessages = preparedInvocation?.confirmationMessages;
31
32
  this.presentation = preparedInvocation?.presentation;
32
33
  this.toolSpecificData = preparedInvocation?.toolSpecificData;
34
+ this.toolId = toolData.id;
33
35
  if (!this._confirmationMessages) {
34
36
  this._isConfirmed = true;
35
37
  this._confirmDeferred.complete(true);
@@ -62,6 +64,7 @@ class ChatToolInvocation {
62
64
  isComplete: this._isComplete,
63
65
  resultDetails: this._resultDetails,
64
66
  toolSpecificData: this.toolSpecificData,
67
+ toolCallId: this.toolCallId,
65
68
  };
66
69
  }
67
70
  }
@@ -10,7 +10,6 @@ import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platfo
10
10
  import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
11
11
  import { IWorkbenchAssignmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service";
12
12
  import { IExtensionService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service";
13
- import { ChatAgentLocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents";
14
13
  import { IChatAgentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service";
15
14
  import { ChatModel, IChatModel, IChatRequestModel, IChatRequestVariableData, IExportableChatData, ISerializableChatData } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel";
16
15
  import { IParsedChatRequest } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParserTypes";
@@ -18,6 +17,7 @@ import { IChatCompleteResponse, IChatDetail, IChatSendRequestData, IChatSendRequ
18
17
  import { IChatService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service";
19
18
  import { IChatSlashCommandService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service";
20
19
  import { IChatVariablesService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariables.service";
20
+ import { ChatAgentLocation } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants";
21
21
  export declare class ChatService extends Disposable implements IChatService {
22
22
  private readonly storageService;
23
23
  private readonly logService;
@@ -50,24 +50,29 @@ export declare class ChatService extends Disposable implements IChatService {
50
50
  }>;
51
51
  private readonly _sessionFollowupCancelTokens;
52
52
  private readonly _chatServiceTelemetry;
53
+ private readonly _chatSessionStore;
54
+ get unifiedViewEnabled(): boolean;
55
+ private get useFileStorage();
56
+ private get isEmptyWindow();
53
57
  constructor(storageService: IStorageService, logService: ILogService, extensionService: IExtensionService, instantiationService: IInstantiationService, telemetryService: ITelemetryService, workspaceContextService: IWorkspaceContextService, chatSlashCommandService: IChatSlashCommandService, chatVariablesService: IChatVariablesService, chatAgentService: IChatAgentService, configurationService: IConfigurationService, experimentService: IWorkbenchAssignmentService);
54
58
  isEnabled(location: ChatAgentLocation): boolean;
55
59
  private saveState;
56
60
  private syncEmptyWindowChats;
57
61
  notifyUserAction(action: IChatUserActionEvent): void;
58
- setChatSessionTitle(sessionId: string, title: string): void;
62
+ setChatSessionTitle(sessionId: string, title: string): Promise<void>;
59
63
  private trace;
60
64
  private error;
61
65
  private deserializeChats;
62
66
  private getTransferredSessionData;
63
- getHistory(): IChatDetail[];
64
- removeHistoryEntry(sessionId: string): void;
65
- clearAllHistoryEntries(): void;
66
- startSession(location: ChatAgentLocation, token: CancellationToken): ChatModel;
67
+ getHistory(): Promise<IChatDetail[]>;
68
+ removeHistoryEntry(sessionId: string): Promise<void>;
69
+ clearAllHistoryEntries(): Promise<void>;
70
+ startSession(location: ChatAgentLocation, token: CancellationToken, isGlobalEditingSession?: boolean): ChatModel;
67
71
  private _startSession;
68
72
  private initializeSession;
69
73
  getSession(sessionId: string): IChatModel | undefined;
70
- getOrRestoreSession(sessionId: string): ChatModel | undefined;
74
+ getOrRestoreSession(sessionId: string): Promise<ChatModel | undefined>;
75
+ isPersistedSessionEmpty(sessionId: string): boolean;
71
76
  loadSessionFromContent(data: IExportableChatData | ISerializableChatData): IChatModel | undefined;
72
77
  resendRequest(request: IChatRequestModel, options?: IChatSendRequestOptions): Promise<void>;
73
78
  sendRequest(sessionId: string, request: string, options?: IChatSendRequestOptions): Promise<IChatSendRequestData | undefined>;
@@ -81,7 +86,10 @@ export declare class ChatService extends Disposable implements IChatService {
81
86
  adoptRequest(sessionId: string, request: IChatRequestModel): Promise<void>;
82
87
  addCompleteRequest(sessionId: string, message: IParsedChatRequest | string, variableData: IChatRequestVariableData | undefined, attempt: number | undefined, response: IChatCompleteResponse): Promise<void>;
83
88
  cancelCurrentRequestForSession(sessionId: string): void;
84
- clearSession(sessionId: string): void;
89
+ clearSession(sessionId: string): Promise<void>;
85
90
  hasSessions(): boolean;
86
91
  transferChatSession(transferredSessionData: IChatTransferredSessionData, toWorkspace: URI): void;
92
+ isEditingLocation(location: ChatAgentLocation): boolean;
93
+ getChatStorageFolder(): URI;
94
+ logChatIndex(): void;
87
95
  }
@@ -2,6 +2,7 @@
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
3
  import { DeferredPromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
4
4
  import { CancellationToken, CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
5
+ import { memoize } from '@codingame/monaco-vscode-api/vscode/vs/base/common/decorators';
5
6
  import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
6
7
  import { ErrorNoTelemetry } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
7
8
  import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
@@ -23,14 +24,15 @@ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platfo
23
24
  import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
24
25
  import { IWorkbenchAssignmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service';
25
26
  import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
26
- import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents';
27
27
  import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
28
28
  import { normalizeSerializableChatData, ChatModel, ChatRequestRemovalReason, updateRanges, toChatHistoryContent, ChatRequestModel } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel';
29
29
  import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, chatSubcommandLeader, chatAgentLeader, ChatRequestSlashCommandPart, getPromptText } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
30
30
  import { ChatRequestParser } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
31
31
  import { ChatServiceTelemetry } from './chatServiceTelemetry.js';
32
+ import { ChatSessionStore } from './chatSessionStore.js';
32
33
  import { IChatSlashCommandService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
33
34
  import { IChatVariablesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
35
+ import { ChatConfiguration, ChatAgentLocation, ChatMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
34
36
  import { ChatMessageRole } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
35
37
  import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
36
38
 
@@ -61,6 +63,16 @@ let ChatService = class ChatService extends Disposable {
61
63
  get transferredSessionData() {
62
64
  return this._transferredSessionData;
63
65
  }
66
+ get unifiedViewEnabled() {
67
+ return !!this.configurationService.getValue(ChatConfiguration.UnifiedChatView);
68
+ }
69
+ get useFileStorage() {
70
+ return this.configurationService.getValue(ChatConfiguration.UseFileStorage);
71
+ }
72
+ get isEmptyWindow() {
73
+ const workspace = this.workspaceContextService.getWorkspace();
74
+ return !workspace.configuration && workspace.folders.length === 0;
75
+ }
64
76
  constructor(storageService, logService, extensionService, instantiationService, telemetryService, workspaceContextService, chatSlashCommandService, chatVariablesService, chatAgentService, configurationService, experimentService) {
65
77
  super();
66
78
  this.storageService = storageService;
@@ -85,8 +97,7 @@ let ChatService = class ChatService extends Disposable {
85
97
  this.onDidDisposeSession = this._onDidDisposeSession.event;
86
98
  this._sessionFollowupCancelTokens = this._register(( new DisposableMap()));
87
99
  this._chatServiceTelemetry = this.instantiationService.createInstance(ChatServiceTelemetry);
88
- const isEmptyWindow = !workspaceContextService.getWorkspace().folders.length;
89
- const sessionData = storageService.get(serializedChatKey, isEmptyWindow ? StorageScope.APPLICATION : StorageScope.WORKSPACE, '');
100
+ const sessionData = storageService.get(serializedChatKey, this.isEmptyWindow ? StorageScope.APPLICATION : StorageScope.WORKSPACE, '');
90
101
  if (sessionData) {
91
102
  this._persistedSessions = this.deserializeChats(sessionData);
92
103
  const countsForLog = ( Object.keys(this._persistedSessions)).length;
@@ -106,9 +117,13 @@ let ChatService = class ChatService extends Disposable {
106
117
  sessionId: transferredChat.sessionId,
107
118
  inputValue: transferredData.inputValue,
108
119
  location: transferredData.location,
109
- toolsAgentModeEnabled: transferredData.toolsAgentModeEnabled,
120
+ mode: transferredData.mode,
110
121
  };
111
122
  }
123
+ this._chatSessionStore = this._register(this.instantiationService.createInstance(ChatSessionStore));
124
+ if (this.useFileStorage) {
125
+ this._chatSessionStore.migrateDataIfNeeded(() => this._persistedSessions);
126
+ }
112
127
  this._register(storageService.onWillSaveState(() => this.saveState()));
113
128
  }
114
129
  isEnabled(location) {
@@ -116,27 +131,43 @@ let ChatService = class ChatService extends Disposable {
116
131
  }
117
132
  saveState() {
118
133
  const liveChats = Array.from(( this._sessionModels.values()))
119
- .filter(session => session.initialLocation === ChatAgentLocation.Panel || session.initialLocation === ChatAgentLocation.EditingSession)
120
- .filter(session => session.getRequests().length > 0);
121
- const isEmptyWindow = !this.workspaceContextService.getWorkspace().folders.length;
122
- if (isEmptyWindow) {
123
- this.syncEmptyWindowChats(liveChats);
134
+ .filter(session => session.initialLocation === ChatAgentLocation.Panel || session.initialLocation === ChatAgentLocation.EditingSession);
135
+ if (this.useFileStorage) {
136
+ this._chatSessionStore.storeSessions(liveChats);
124
137
  }
125
138
  else {
126
- let allSessions = liveChats;
127
- allSessions = allSessions.concat(( Object.values(this._persistedSessions))
128
- .filter(session => !( this._sessionModels.has(session.sessionId)))
129
- .filter(session => session.requests.length));
130
- allSessions.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
131
- allSessions = allSessions.slice(0, maxPersistedSessions);
132
- if (allSessions.length) {
133
- this.trace('onWillSaveState', `Persisting ${allSessions.length} sessions`);
139
+ if (this.isEmptyWindow) {
140
+ this.syncEmptyWindowChats(liveChats);
134
141
  }
135
- const serialized = JSON.stringify(allSessions);
136
- if (allSessions.length) {
137
- this.trace('onWillSaveState', `Persisting ${serialized.length} chars`);
142
+ else {
143
+ let allSessions = liveChats;
144
+ allSessions = allSessions.concat(( Object.values(this._persistedSessions))
145
+ .filter(session => !( this._sessionModels.has(session.sessionId)))
146
+ .filter(session => session.requests.length));
147
+ allSessions.sort((a, b) => (b.creationDate ?? 0) - (a.creationDate ?? 0));
148
+ let hasPersistedEditSession = false;
149
+ allSessions = allSessions.filter(s => {
150
+ if (s.initialLocation === ChatAgentLocation.EditingSession) {
151
+ if (hasPersistedEditSession) {
152
+ return false;
153
+ }
154
+ else {
155
+ hasPersistedEditSession = true;
156
+ return true;
157
+ }
158
+ }
159
+ return true;
160
+ });
161
+ allSessions = allSessions.slice(0, maxPersistedSessions);
162
+ if (allSessions.length) {
163
+ this.trace('onWillSaveState', `Persisting ${allSessions.length} sessions`);
164
+ }
165
+ const serialized = JSON.stringify(allSessions);
166
+ if (allSessions.length) {
167
+ this.trace('onWillSaveState', `Persisting ${serialized.length} chars`);
168
+ }
169
+ this.storageService.store(serializedChatKey, serialized, StorageScope.WORKSPACE, StorageTarget.MACHINE);
138
170
  }
139
- this.storageService.store(serializedChatKey, serialized, StorageScope.WORKSPACE, StorageTarget.MACHINE);
140
171
  }
141
172
  this._deletedChatIds.clear();
142
173
  }
@@ -180,12 +211,16 @@ let ChatService = class ChatService extends Disposable {
180
211
  this._chatServiceTelemetry.notifyUserAction(action);
181
212
  this._onDidPerformUserAction.fire(action);
182
213
  }
183
- setChatSessionTitle(sessionId, title) {
214
+ async setChatSessionTitle(sessionId, title) {
184
215
  const model = this._sessionModels.get(sessionId);
185
216
  if (model) {
186
217
  model.setCustomTitle(title);
187
218
  return;
188
219
  }
220
+ if (this.useFileStorage) {
221
+ await this._chatSessionStore.setSessionTitle(sessionId, title);
222
+ return;
223
+ }
189
224
  const session = this._persistedSessions[sessionId];
190
225
  if (session) {
191
226
  session.customTitle = title;
@@ -245,7 +280,28 @@ let ChatService = class ChatService extends Disposable {
245
280
  this.storageService.store(globalChatKey, JSON.stringify(filtered), StorageScope.PROFILE, StorageTarget.MACHINE);
246
281
  return transferred;
247
282
  }
248
- getHistory() {
283
+ async getHistory() {
284
+ if (this.useFileStorage) {
285
+ const liveSessionItems = ( Array.from(( this._sessionModels.values()))
286
+ .filter(session => !session.isImported && (session.initialLocation !== ChatAgentLocation.EditingSession || this.unifiedViewEnabled))
287
+ .map(session => {
288
+ const title = session.title || ( localize(4984, "New Chat"));
289
+ return {
290
+ sessionId: session.sessionId,
291
+ title,
292
+ lastMessageDate: session.lastMessageDate,
293
+ isActive: true,
294
+ };
295
+ }));
296
+ const index = await this._chatSessionStore.getIndex();
297
+ const entries = ( ( Object.values(index))
298
+ .filter(entry => !( this._sessionModels.has(entry.sessionId)) && !entry.isImported && !entry.isEmpty)
299
+ .map((entry) => ({
300
+ ...entry,
301
+ isActive: ( this._sessionModels.has(entry.sessionId)),
302
+ })));
303
+ return [...liveSessionItems, ...entries];
304
+ }
249
305
  const persistedSessions = ( Object.values(this._persistedSessions))
250
306
  .filter(session => session.requests.length > 0)
251
307
  .filter(session => !( this._sessionModels.has(session.sessionId)));
@@ -263,7 +319,7 @@ let ChatService = class ChatService extends Disposable {
263
319
  const liveSessionItems = ( Array.from(( this._sessionModels.values()))
264
320
  .filter(session => !session.isImported && session.initialLocation !== ChatAgentLocation.EditingSession)
265
321
  .map(session => {
266
- const title = session.title || ( localize(4857, "New Chat"));
322
+ const title = session.title || ( localize(4984, "New Chat"));
267
323
  return {
268
324
  sessionId: session.sessionId,
269
325
  title,
@@ -273,24 +329,35 @@ let ChatService = class ChatService extends Disposable {
273
329
  }));
274
330
  return [...liveSessionItems, ...persistedSessionItems];
275
331
  }
276
- removeHistoryEntry(sessionId) {
332
+ async removeHistoryEntry(sessionId) {
333
+ if (this.useFileStorage) {
334
+ await this._chatSessionStore.deleteSession(sessionId);
335
+ return;
336
+ }
277
337
  if (this._persistedSessions[sessionId]) {
278
338
  this._deletedChatIds.add(sessionId);
279
339
  delete this._persistedSessions[sessionId];
280
340
  this.saveState();
281
341
  }
282
342
  }
283
- clearAllHistoryEntries() {
343
+ async clearAllHistoryEntries() {
344
+ if (this.useFileStorage) {
345
+ await this._chatSessionStore.clearAllSessions();
346
+ return;
347
+ }
284
348
  ( Object.values(this._persistedSessions)).forEach(session => this._deletedChatIds.add(session.sessionId));
285
349
  this._persistedSessions = {};
286
350
  this.saveState();
287
351
  }
288
- startSession(location, token) {
352
+ startSession(location, token, isGlobalEditingSession = true) {
289
353
  this.trace('startSession');
290
- return this._startSession(undefined, location, token);
354
+ return this._startSession(undefined, location, isGlobalEditingSession, token);
291
355
  }
292
- _startSession(someSessionHistory, location, token) {
356
+ _startSession(someSessionHistory, location, isGlobalEditingSession, token) {
293
357
  const model = this.instantiationService.createInstance(ChatModel, someSessionHistory, location);
358
+ if (location === ChatAgentLocation.EditingSession || (this.unifiedViewEnabled && location === ChatAgentLocation.Panel)) {
359
+ model.startEditingSession(isGlobalEditingSession);
360
+ }
294
361
  this._sessionModels.set(model.sessionId, model);
295
362
  this.initializeSession(model, token);
296
363
  return model;
@@ -304,14 +371,17 @@ let ChatService = class ChatService extends Disposable {
304
371
  if (!defaultAgentData) {
305
372
  throw ( new ErrorNoTelemetry('No default agent contributed'));
306
373
  }
307
- await this.extensionService.activateByEvent(`onChatParticipant:${defaultAgentData.id}`);
308
- const defaultAgent = this.chatAgentService.getActivatedAgents().find(agent => agent.id === defaultAgentData.id);
309
- if (!defaultAgent) {
310
- throw ( new ErrorNoTelemetry('No default agent registered'));
374
+ if (this.configurationService.getValue('chat.setupFromDialog')) {
375
+ this.extensionService.activateByEvent(`onChatParticipant:${defaultAgentData.id}`);
376
+ }
377
+ else {
378
+ await this.extensionService.activateByEvent(`onChatParticipant:${defaultAgentData.id}`);
379
+ const defaultAgent = this.chatAgentService.getActivatedAgents().find(agent => agent.id === defaultAgentData.id);
380
+ if (!defaultAgent) {
381
+ throw ( new ErrorNoTelemetry('No default agent registered'));
382
+ }
311
383
  }
312
- const welcomeMessage = (await defaultAgent.provideWelcomeMessage?.(token)) ?? undefined;
313
- const sampleQuestions = (await defaultAgent.provideSampleQuestions?.(model.initialLocation, token)) ?? undefined;
314
- model.initialize(welcomeMessage, sampleQuestions);
384
+ model.initialize();
315
385
  }
316
386
  catch (err) {
317
387
  this.trace('startSession', `initializeSession failed: ${err}`);
@@ -323,26 +393,38 @@ let ChatService = class ChatService extends Disposable {
323
393
  getSession(sessionId) {
324
394
  return this._sessionModels.get(sessionId);
325
395
  }
326
- getOrRestoreSession(sessionId) {
396
+ async getOrRestoreSession(sessionId) {
327
397
  this.trace('getOrRestoreSession', `sessionId: ${sessionId}`);
328
398
  const model = this._sessionModels.get(sessionId);
329
399
  if (model) {
330
400
  return model;
331
401
  }
332
- const sessionData = revive(this._persistedSessions[sessionId]);
402
+ let sessionData;
403
+ if (this.useFileStorage) {
404
+ sessionData = revive(await this._chatSessionStore.readSession(sessionId));
405
+ }
406
+ else {
407
+ sessionData = revive(this._persistedSessions[sessionId]);
408
+ }
333
409
  if (!sessionData) {
334
410
  return undefined;
335
411
  }
336
- const session = this._startSession(sessionData, sessionData.initialLocation ?? ChatAgentLocation.Panel, CancellationToken.None);
412
+ const session = this._startSession(sessionData, sessionData.initialLocation ?? ChatAgentLocation.Panel, true, CancellationToken.None);
337
413
  const isTransferred = this.transferredSessionData?.sessionId === sessionId;
338
414
  if (isTransferred) {
339
- this.chatAgentService.toggleToolsAgentMode(this.transferredSessionData.toolsAgentModeEnabled);
340
415
  this._transferredSessionData = undefined;
341
416
  }
342
417
  return session;
343
418
  }
419
+ isPersistedSessionEmpty(sessionId) {
420
+ const session = this._persistedSessions[sessionId];
421
+ if (session) {
422
+ return session.requests.length === 0;
423
+ }
424
+ return this._chatSessionStore.isSessionEmpty(sessionId);
425
+ }
344
426
  loadSessionFromContent(data) {
345
- return this._startSession(data, data.initialLocation ?? ChatAgentLocation.Panel, CancellationToken.None);
427
+ return this._startSession(data, data.initialLocation ?? ChatAgentLocation.Panel, true, CancellationToken.None);
346
428
  }
347
429
  async resendRequest(request, options) {
348
430
  const model = this._sessionModels.get(request.session.sessionId);
@@ -358,7 +440,7 @@ let ChatService = class ChatService extends Disposable {
358
440
  const location = options?.location ?? model.initialLocation;
359
441
  const attempt = options?.attempt ?? 0;
360
442
  const enableCommandDetection = !options?.noCommandDetection;
361
- const defaultAgent = this.chatAgentService.getDefaultAgent(location);
443
+ const defaultAgent = this.chatAgentService.getDefaultAgent(location, options?.mode);
362
444
  model.removeRequest(request.id, ChatRequestRemovalReason.Resend);
363
445
  const resendOptions = {
364
446
  ...options,
@@ -400,7 +482,7 @@ let ChatService = class ChatService extends Disposable {
400
482
  }
401
483
  const location = options?.location ?? model.initialLocation;
402
484
  const attempt = options?.attempt ?? 0;
403
- const defaultAgent = this.chatAgentService.getDefaultAgent(location);
485
+ const defaultAgent = this.chatAgentService.getDefaultAgent(location, options?.mode);
404
486
  const parsedRequest = this.parseChatRequest(sessionId, request, location, options);
405
487
  const agent = parsedRequest.parts.find((r) => r instanceof ChatRequestAgentPart)?.agent ?? defaultAgent;
406
488
  const agentSlashCommandPart = parsedRequest.parts.find((r) => r instanceof ChatRequestAgentSubcommandPart);
@@ -417,7 +499,7 @@ let ChatService = class ChatService extends Disposable {
417
499
  if (!agent) {
418
500
  throw ( new Error(`Unknown agent: ${options.agentId}`));
419
501
  }
420
- parserContext = { selectedAgent: agent };
502
+ parserContext = { selectedAgent: agent, mode: options.mode };
421
503
  const commandPart = options.slashCommand ? ` ${chatSubcommandLeader}${options.slashCommand}` : '';
422
504
  request = `${chatAgentLeader}${agent.name}${commandPart} ${request}`;
423
505
  }
@@ -494,7 +576,7 @@ let ChatService = class ChatService extends Disposable {
494
576
  if (agentPart || (defaultAgent && !commandPart)) {
495
577
  const prepareChatAgentRequest = async (agent, command, enableCommandDetection, chatRequest, isParticipantDetected) => {
496
578
  const initVariableData = { variables: [] };
497
- request = chatRequest ?? model.addRequest(parsedRequest, initVariableData, attempt, agent, command, options?.confirmation, options?.locationData, options?.attachedContext);
579
+ request = chatRequest ?? model.addRequest(parsedRequest, initVariableData, attempt, agent, command, options?.confirmation, options?.locationData, options?.attachedContext, undefined, options?.userSelectedModelId);
498
580
  let variableData;
499
581
  let message;
500
582
  if (chatRequest) {
@@ -522,10 +604,11 @@ let ChatService = class ChatService extends Disposable {
522
604
  locationData: request.locationData,
523
605
  acceptedConfirmationData: options?.acceptedConfirmationData,
524
606
  rejectedConfirmationData: options?.rejectedConfirmationData,
525
- userSelectedModelId: options?.userSelectedModelId
607
+ userSelectedModelId: options?.userSelectedModelId,
608
+ userSelectedTools: options?.userSelectedTools
526
609
  };
527
610
  };
528
- if (this.configurationService.getValue('chat.detectParticipant.enabled') !== false && this.chatAgentService.hasChatParticipantDetectionProviders() && !agentPart && !commandPart && !agentSlashCommandPart && enableCommandDetection) {
611
+ if (this.configurationService.getValue('chat.detectParticipant.enabled') !== false && this.chatAgentService.hasChatParticipantDetectionProviders() && !agentPart && !commandPart && !agentSlashCommandPart && enableCommandDetection && options?.mode !== ChatMode.Agent && options?.mode !== ChatMode.Edit) {
529
612
  const defaultAgentHistory = this.getHistoryEntriesFromModel(requests, model.sessionId, location, defaultAgent.id);
530
613
  const chatAgentRequest = await prepareChatAgentRequest(defaultAgent, undefined, enableCommandDetection, undefined, false);
531
614
  const result = await this.chatAgentService.detectAgentOrCommand(chatAgentRequest, defaultAgentHistory, { location }, token);
@@ -578,7 +661,7 @@ let ChatService = class ChatService extends Disposable {
578
661
  else {
579
662
  if (!rawResult) {
580
663
  this.trace('sendRequest', `Provider returned no response for session ${model.sessionId}`);
581
- rawResult = { errorDetails: { message: ( localize(4858, "Provider returned null response")) } };
664
+ rawResult = { errorDetails: { message: ( localize(4985, "Provider returned null response")) } };
582
665
  }
583
666
  const result = rawResult.errorDetails?.responseIsFiltered ? 'filtered' :
584
667
  rawResult.errorDetails && gotProgress ? 'errorWithOutput' :
@@ -710,12 +793,12 @@ let ChatService = class ChatService extends Disposable {
710
793
  }
711
794
  getHistoryEntriesFromModel(requests, sessionId, location, forAgentId) {
712
795
  const history = [];
796
+ const agent = this.chatAgentService.getAgent(forAgentId);
713
797
  for (const request of requests) {
714
798
  if (!request.response) {
715
799
  continue;
716
800
  }
717
- const defaultAgentId = this.chatAgentService.getDefaultAgent(location)?.id;
718
- if (forAgentId !== request.response.agent?.id && forAgentId !== defaultAgentId) {
801
+ if (forAgentId !== request.response.agent?.id && !agent?.isDefault) {
719
802
  continue;
720
803
  }
721
804
  const promptTextResult = getPromptText(request.message);
@@ -774,7 +857,7 @@ let ChatService = class ChatService extends Disposable {
774
857
  const parsedRequest = typeof message === 'string' ?
775
858
  this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(sessionId, message) :
776
859
  message;
777
- const request = model.addRequest(parsedRequest, variableData || { variables: [] }, attempt ?? 0, undefined, undefined, undefined, undefined, undefined, undefined, true);
860
+ const request = model.addRequest(parsedRequest, variableData || { variables: [] }, attempt ?? 0, undefined, undefined, undefined, undefined, undefined, true);
778
861
  if (typeof response.message === 'string') {
779
862
  model.acceptResponseProgress(request, { content: ( new MarkdownString(response.message)), kind: 'markdownContent' });
780
863
  }
@@ -794,16 +877,31 @@ let ChatService = class ChatService extends Disposable {
794
877
  this._pendingRequests.get(sessionId)?.cancel();
795
878
  this._pendingRequests.deleteAndDispose(sessionId);
796
879
  }
797
- clearSession(sessionId) {
880
+ async clearSession(sessionId) {
798
881
  this.trace('clearSession', `sessionId: ${sessionId}`);
799
882
  const model = this._sessionModels.get(sessionId);
800
883
  if (!model) {
801
884
  throw ( new Error(`Unknown session: ${sessionId}`));
802
885
  }
803
886
  if (model.initialLocation === ChatAgentLocation.Panel) {
804
- const sessionData = JSON.parse(JSON.stringify(model));
805
- sessionData.isNew = true;
806
- this._persistedSessions[sessionId] = sessionData;
887
+ if (this.useFileStorage) {
888
+ if (model.getRequests().length === 0) {
889
+ await this._chatSessionStore.deleteSession(sessionId);
890
+ }
891
+ else {
892
+ await this._chatSessionStore.storeSessions([model]);
893
+ }
894
+ }
895
+ else {
896
+ if (model.getRequests().length === 0) {
897
+ delete this._persistedSessions[sessionId];
898
+ }
899
+ else {
900
+ const sessionData = JSON.parse(JSON.stringify(model));
901
+ sessionData.isNew = true;
902
+ this._persistedSessions[sessionId] = sessionData;
903
+ }
904
+ }
807
905
  }
808
906
  this._sessionModels.deleteAndDispose(sessionId);
809
907
  this._pendingRequests.get(sessionId)?.cancel();
@@ -811,7 +909,12 @@ let ChatService = class ChatService extends Disposable {
811
909
  this._onDidDisposeSession.fire({ sessionId, reason: 'cleared' });
812
910
  }
813
911
  hasSessions() {
814
- return ( Object.values(this._persistedSessions)).length > 0;
912
+ if (this.useFileStorage) {
913
+ return this._chatSessionStore.hasSessions();
914
+ }
915
+ else {
916
+ return ( Object.values(this._persistedSessions)).length > 0;
917
+ }
815
918
  }
816
919
  transferChatSession(transferredSessionData, toWorkspace) {
817
920
  const model = Iterable.find(( this._sessionModels.values()), model => model.sessionId === transferredSessionData.sessionId);
@@ -827,12 +930,27 @@ let ChatService = class ChatService extends Disposable {
827
930
  toWorkspace: toWorkspace,
828
931
  inputValue: transferredSessionData.inputValue,
829
932
  location: transferredSessionData.location,
830
- toolsAgentModeEnabled: transferredSessionData.toolsAgentModeEnabled,
933
+ mode: transferredSessionData.mode,
831
934
  });
832
935
  this.storageService.store(globalChatKey, JSON.stringify(existingRaw), StorageScope.PROFILE, StorageTarget.MACHINE);
833
936
  this.trace('transferChatSession', `Transferred session ${model.sessionId} to workspace ${( toWorkspace.toString())}`);
834
937
  }
938
+ isEditingLocation(location) {
939
+ return location === ChatAgentLocation.EditingSession || this.unifiedViewEnabled;
940
+ }
941
+ getChatStorageFolder() {
942
+ return this._chatSessionStore.getChatStorageFolder();
943
+ }
944
+ logChatIndex() {
945
+ this._chatSessionStore.logIndex();
946
+ }
835
947
  };
948
+ ChatService.__decorator = ( __decorate([
949
+ memoize
950
+ ], ChatService.prototype, "unifiedViewEnabled", null));
951
+ ChatService.__decorator = ( __decorate([
952
+ memoize
953
+ ], ChatService.prototype, "useFileStorage", null));
836
954
  ChatService = ( __decorate([
837
955
  ( __param(0, IStorageService)),
838
956
  ( __param(1, ILogService)),
@@ -0,0 +1,66 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
3
+ import { IEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/platform/environment/common/environment.service";
4
+ import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
5
+ import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
6
+ import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
7
+ import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
8
+ import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
9
+ import { ILifecycleService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service";
10
+ import { ChatModel, ISerializableChatData, ISerializableChatsData } from "@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatModel";
11
+ import { ChatAgentLocation, ChatMode } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants";
12
+ export declare class ChatSessionStore extends Disposable {
13
+ private readonly fileService;
14
+ private readonly environmentService;
15
+ private readonly logService;
16
+ private readonly workspaceContextService;
17
+ private readonly telemetryService;
18
+ private readonly storageService;
19
+ private readonly lifecycleService;
20
+ private readonly storageRoot;
21
+ private readonly storeQueue;
22
+ private storeTask;
23
+ private shuttingDown;
24
+ constructor(fileService: IFileService, environmentService: IEnvironmentService, logService: ILogService, workspaceContextService: IWorkspaceContextService, telemetryService: ITelemetryService, storageService: IStorageService, lifecycleService: ILifecycleService);
25
+ storeSessions(sessions: ChatModel[]): Promise<void>;
26
+ private writeSession;
27
+ private flushIndex;
28
+ private getIndexStorageScope;
29
+ private trimEntries;
30
+ private internalDeleteSession;
31
+ hasSessions(): boolean;
32
+ isSessionEmpty(sessionId: string): boolean;
33
+ deleteSession(sessionId: string): Promise<void>;
34
+ clearAllSessions(): Promise<void>;
35
+ setSessionTitle(sessionId: string, title: string): Promise<void>;
36
+ private reportError;
37
+ private indexCache;
38
+ private internalGetIndex;
39
+ getIndex(): Promise<IChatSessionIndex>;
40
+ logIndex(): void;
41
+ migrateDataIfNeeded(getInitialData: () => ISerializableChatsData | undefined): Promise<void>;
42
+ private migrate;
43
+ readSession(sessionId: string): Promise<ISerializableChatData | undefined>;
44
+ private getStorageLocation;
45
+ getChatStorageFolder(): URI;
46
+ }
47
+ interface IChatSessionEntryMetadata {
48
+ sessionId: string;
49
+ title: string;
50
+ lastMessageDate: number;
51
+ isImported?: boolean;
52
+ initialLocation?: ChatAgentLocation;
53
+ isEmpty?: boolean;
54
+ }
55
+ export type IChatSessionIndex = Record<string, IChatSessionEntryMetadata>;
56
+ export interface IChatTransfer {
57
+ toWorkspace: URI;
58
+ timestampInMilliseconds: number;
59
+ inputValue: string;
60
+ location: ChatAgentLocation;
61
+ mode: ChatMode;
62
+ }
63
+ export interface IChatTransfer2 extends IChatTransfer {
64
+ chat: ISerializableChatData;
65
+ }
66
+ export {};