From 370f5619b9fc80ad7d7c07b56b00dd34f5df6b7b Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Wed, 2 Oct 2024 00:50:08 -0700 Subject: [PATCH] fix: use chat edit state for chat file list decorations (#230284) * fix: use chat edit state for chat file list decorations * Add theme defaults --- build/lib/stylelint/vscode-known-variables.json | 3 ++- .../theme-defaults/themes/dark_modern.json | 1 + .../theme-defaults/themes/light_modern.json | 1 + .../chatReferencesContentPart.ts | 17 +++++++++++------ .../contrib/chat/browser/chatEditingActions.ts | 6 +++--- .../contrib/chat/browser/chatEditingService.ts | 10 +++++----- .../contrib/chat/browser/chatInputPart.ts | 6 +++--- .../contrib/chat/browser/chatListRenderer.ts | 2 +- .../contrib/chat/browser/media/chat.css | 6 ++++++ .../workbench/contrib/chat/common/chatColors.ts | 11 +++++++++++ .../contrib/chat/common/chatEditingService.ts | 2 +- 11 files changed, 45 insertions(+), 20 deletions(-) diff --git a/build/lib/stylelint/vscode-known-variables.json b/build/lib/stylelint/vscode-known-variables.json index 3f82544faa26f..3d1330415fdf1 100644 --- a/build/lib/stylelint/vscode-known-variables.json +++ b/build/lib/stylelint/vscode-known-variables.json @@ -53,6 +53,7 @@ "--vscode-chat-requestBorder", "--vscode-chat-slashCommandBackground", "--vscode-chat-slashCommandForeground", + "--vscode-chat-editedFileForeground", "--vscode-checkbox-background", "--vscode-checkbox-border", "--vscode-checkbox-foreground", @@ -888,4 +889,4 @@ "--widget-color", "--text-link-decoration" ] -} \ No newline at end of file +} diff --git a/extensions/theme-defaults/themes/dark_modern.json b/extensions/theme-defaults/themes/dark_modern.json index 57578ca969250..384310738fc44 100644 --- a/extensions/theme-defaults/themes/dark_modern.json +++ b/extensions/theme-defaults/themes/dark_modern.json @@ -21,6 +21,7 @@ "button.secondaryHoverBackground": "#3C3C3C", "chat.slashCommandBackground": "#34414B", "chat.slashCommandForeground": "#40A6FF", + "chat.editedFileForeground": "#E2C08D", "checkbox.background": "#313131", "checkbox.border": "#3C3C3C", "debugToolBar.background": "#181818", diff --git a/extensions/theme-defaults/themes/light_modern.json b/extensions/theme-defaults/themes/light_modern.json index bd7e647afb334..9b4d627fcd146 100644 --- a/extensions/theme-defaults/themes/light_modern.json +++ b/extensions/theme-defaults/themes/light_modern.json @@ -21,6 +21,7 @@ "button.secondaryHoverBackground": "#CCCCCC", "chat.slashCommandBackground": "#D2ECFF", "chat.slashCommandForeground": "#306CA2", + "chat.editedFileForeground": "#895503", "checkbox.background": "#F8F8F8", "checkbox.border": "#CECECE", "descriptionForeground": "#3B3B3B", diff --git a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatReferencesContentPart.ts b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatReferencesContentPart.ts index 085fadf8f892b..f2ff487b5a8af 100644 --- a/src/vs/workbench/contrib/chat/browser/chatContentParts/chatReferencesContentPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatContentParts/chatReferencesContentPart.ts @@ -188,7 +188,6 @@ export class CollapsibleListPool extends Disposable { constructor( private _onDidChangeVisibility: Event, private readonly menuId: MenuId | undefined, - private readonly options: { enableFileDecorations?: boolean } | undefined, @IInstantiationService private readonly instantiationService: IInstantiationService, @IThemeService private readonly themeService: IThemeService, @ILabelService private readonly labelService: ILabelService, @@ -208,7 +207,7 @@ export class CollapsibleListPool extends Disposable { 'ChatListRenderer', container, new CollapsibleListDelegate(), - [this.instantiationService.createInstance(CollapsibleListRenderer, resourceLabels, this.menuId, this.options)], + [this.instantiationService.createInstance(CollapsibleListRenderer, resourceLabels, this.menuId)], { alwaysConsumeMouseWheel: false, accessibilityProvider: { @@ -299,7 +298,6 @@ class CollapsibleListRenderer implements IListRenderer entry.state.read(reader) !== WorkingSetEntryState.Edited); + const decidedEntries = entries.filter(entry => entry.state.read(reader) !== WorkingSetEntryState.Modified); return decidedEntries.map(entry => entry.entryId); })); this._register(this._chatService.onDidDisposeSession((e) => { @@ -609,7 +609,7 @@ class ModifiedFileEntry extends Disposable implements IModifiedFileEntry { return this.doc.uri; } - private readonly _stateObs = observableValue(this, WorkingSetEntryState.Edited); + private readonly _stateObs = observableValue(this, WorkingSetEntryState.Modified); public get state(): IObservable { return this._stateObs; } @@ -637,11 +637,11 @@ class ModifiedFileEntry extends Disposable implements IModifiedFileEntry { applyEdits(textEdits: TextEdit[]): void { this.doc.applyEdits(textEdits); - this._stateObs.set(WorkingSetEntryState.Edited, undefined); + this._stateObs.set(WorkingSetEntryState.Modified, undefined); } async accept(transaction: ITransaction | undefined): Promise { - if (this._stateObs.get() !== WorkingSetEntryState.Edited) { + if (this._stateObs.get() !== WorkingSetEntryState.Modified) { // already accepted or rejected return; } @@ -651,7 +651,7 @@ class ModifiedFileEntry extends Disposable implements IModifiedFileEntry { } async reject(transaction: ITransaction | undefined): Promise { - if (this._stateObs.get() !== WorkingSetEntryState.Edited) { + if (this._stateObs.get() !== WorkingSetEntryState.Modified) { // already accepted or rejected return; } diff --git a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts index bb1c658ab28b4..3410cddf8ab01 100644 --- a/src/vs/workbench/contrib/chat/browser/chatInputPart.ts +++ b/src/vs/workbench/contrib/chat/browser/chatInputPart.ts @@ -255,7 +255,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge } })); - this._chatEditsListPool = this._register(this.instantiationService.createInstance(CollapsibleListPool, this._onDidChangeVisibility.event, MenuId.ChatEditingSessionWidgetToolbar, { enableFileDecorations: true })); + this._chatEditsListPool = this._register(this.instantiationService.createInstance(CollapsibleListPool, this._onDidChangeVisibility.event, MenuId.ChatEditingSessionWidgetToolbar)); } private setCurrentLanguageModelToDefault() { @@ -950,7 +950,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge if (e.element?.kind === 'reference' && URI.isUri(e.element.reference)) { const modifiedFileUri = e.element.reference; const editedFile = chatEditingSession.entries.get().find((e) => e.modifiedURI.toString() === modifiedFileUri.toString()); - if (editedFile?.state.get() === WorkingSetEntryState.Edited) { + if (editedFile?.state.get() === WorkingSetEntryState.Modified) { void this.editorService.openEditor({ original: { resource: URI.from(editedFile.originalURI, true) }, modified: { resource: URI.from(editedFile.modifiedURI, true) }, @@ -977,7 +977,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge dom.clearNode(actionsContainer); const actionsContainerRight = actionsContainer.querySelector('.chat-editing-session-actions-group') as HTMLElement ?? $('.chat-editing-session-actions-group'); - if (chatEditingSession.entries.get().find((e) => e.state.get() === WorkingSetEntryState.Edited)) { + if (chatEditingSession.entries.get().find((e) => e.state.get() === WorkingSetEntryState.Modified)) { // Don't show Accept All / Discard All actions if user already selected Accept All / Discard All const actions = []; actions.push( diff --git a/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts b/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts index 505b25d91a343..8bbf1a56dffb9 100644 --- a/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts +++ b/src/vs/workbench/contrib/chat/browser/chatListRenderer.ts @@ -156,7 +156,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer