Skip to content

Commit 91070de

Browse files
authored
Chat codeblock improvements (microsoft#183173)
1 parent 7bbede2 commit 91070de

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

src/vs/workbench/contrib/chat/browser/chatListRenderer.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
418418
}));
419419

420420
if (isResponseVM(element)) {
421-
const info = {
421+
const info: IChatCodeBlockInfo = {
422422
codeBlockIndex: data.codeBlockIndex,
423423
element,
424424
focus() {
@@ -584,8 +584,8 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
584584
@IContextKeyService contextKeyService: IContextKeyService,
585585
@ILanguageService private readonly languageService: ILanguageService,
586586
@IModelService private readonly modelService: IModelService,
587-
@IConfigurationService private readonly _configurationService: IConfigurationService,
588-
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
587+
@IConfigurationService private readonly configurationService: IConfigurationService,
588+
@IAccessibilityService private readonly accessibilityService: IAccessibilityService
589589
) {
590590
super();
591591
this.element = $('.interactive-result-editor-wrapper');
@@ -598,8 +598,8 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
598598
}));
599599

600600
this._configureForScreenReader();
601-
this._register(this._accessibilityService.onDidChangeScreenReaderOptimized(() => this._configureForScreenReader()));
602-
this._register(this._configurationService.onDidChangeConfiguration((e) => {
601+
this._register(this.accessibilityService.onDidChangeScreenReaderOptimized(() => this._configureForScreenReader()));
602+
this._register(this.configurationService.onDidChangeConfiguration((e) => {
603603
if (e.affectedKeys.has(AccessibilityVerbositySettingId.Chat)) {
604604
this._configureForScreenReader();
605605
}
@@ -648,9 +648,11 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
648648
}
649649
}));
650650
this._register(this.editor.onDidBlurEditorWidget(() => {
651+
this.element.classList.remove('focused');
651652
WordHighlighterContribution.get(this.editor)?.stopHighlighting();
652653
}));
653654
this._register(this.editor.onDidFocusEditorWidget(() => {
655+
this.element.classList.add('focused');
654656
WordHighlighterContribution.get(this.editor)?.restoreViewState(true);
655657
}));
656658

@@ -675,9 +677,9 @@ class CodeBlockPart extends Disposable implements IChatResultCodeBlockPart {
675677

676678
private _configureForScreenReader(): void {
677679
const toolbarElt = this.toolbar.getElement();
678-
if (this._accessibilityService.isScreenReaderOptimized()) {
680+
if (this.accessibilityService.isScreenReaderOptimized()) {
679681
toolbarElt.style.display = 'block';
680-
toolbarElt.ariaLabel = this._configurationService.getValue(AccessibilityVerbositySettingId.Chat) ? localize('chat.codeBlock.toolbarVerbose', 'Toolbar for code block which can be reached via tab') : localize('chat.codeBlock.toolbar', 'Code block toolbar');
682+
toolbarElt.ariaLabel = this.configurationService.getValue(AccessibilityVerbositySettingId.Chat) ? localize('chat.codeBlock.toolbarVerbose', 'Toolbar for code block which can be reached via tab') : localize('chat.codeBlock.toolbar', 'Code block toolbar');
681683
} else {
682684
toolbarElt.style.display = '';
683685
}

src/vs/workbench/contrib/chat/browser/media/chat.css

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,14 @@
6565
color: var(--vscode-badge-foreground) !important;
6666
}
6767

68-
.interactive-item-container .header .monaco-toolbar,
69-
.interactive-item-container .header .monaco-toolbar .action-label {
68+
.interactive-item-container:not(.interactive-response:hover) .header .monaco-toolbar,
69+
.interactive-item-container:not(.interactive-response:hover) .header .monaco-toolbar .action-label {
7070
/* Also apply this rule to the .action-label directly to work around a strange issue- when the
7171
toolbar is hidden without that second rule, tabbing from the list container into a list item doesn't work
7272
and the tab key doesn't do anything. */
7373
display: none;
7474
}
7575

76-
.interactive-item-container.interactive-response:hover .header .monaco-toolbar,
77-
.interactive-item-container.interactive-response:hover .header .monaco-toolbar .action-label {
78-
display: initial;
79-
}
80-
8176
.interactive-item-container .header .monaco-toolbar .action-label {
8277
border: 1px solid transparent;
8378
padding: 2px;
@@ -167,7 +162,7 @@
167162
line-height: 1.6em;
168163
}
169164

170-
.interactive-item-container li {
165+
.interactive-item-container .value li {
171166
line-height: 1.5rem;
172167
}
173168

@@ -240,22 +235,27 @@
240235
margin: 1px;
241236
}
242237

243-
.interactive-item-container .interactive-result-editor-wrapper:hover .monaco-toolbar {
238+
.interactive-item-container .interactive-result-editor-wrapper:hover .monaco-toolbar,
239+
.interactive-item-container .interactive-result-editor-wrapper.focused .monaco-toolbar {
244240
display: initial;
245241
border-radius: 2px;
246242
}
247243

248-
.interactive-item-container .interactive-result-editor-wrapper .interactive-result-editor {
249-
border: 1px solid var(--vscode-input-border, transparent);
244+
.interactive-item-container .interactive-result-editor-wrapper {
245+
margin: 16px 0;
250246
}
251247

252248
.interactive-response .monaco-editor .margin,
253249
.interactive-response .monaco-editor .monaco-editor-background {
254250
background-color: var(--vscode-interactive-result-editor-background-color);
255251
}
256252

257-
.interactive-item-container .interactive-result-editor-wrapper {
258-
margin: 16px 0;
253+
.interactive-item-container .interactive-result-editor-wrapper .interactive-result-editor .monaco-editor {
254+
border: 1px solid var(--vscode-input-border, transparent);
255+
}
256+
257+
.interactive-item-container .interactive-result-editor-wrapper .interactive-result-editor .monaco-editor.focused {
258+
border-color: var(--vscode-focusBorder, transparent);
259259
}
260260

261261
.interactive-item-container .interactive-result-editor-wrapper,

0 commit comments

Comments
 (0)