Skip to content

Commit ad5a40f

Browse files
authored
Inline chat fixes/feature (microsoft#208393)
* only show slash command as detected when not having typed one * use clearer message that hunks need to be accepted or discard, also add hover with more details fixes microsoft#206939
1 parent a00f2e6 commit ad5a40f

File tree

4 files changed

+43
-65
lines changed

4 files changed

+43
-65
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ class BridgeAgent implements IChatAgentImplementation {
9393
// if (data.message) {
9494
// progress({ kind: 'progressMessage', content: new MarkdownString(data.message) });
9595
// }
96-
if (data.slashCommand) {
96+
// TODO@ulugbekna,jrieken should we only send data.slashCommand when having detected one?
97+
if (data.slashCommand && !inlineRequest.prompt.startsWith('/')) {
9798
const command = this._data.slashCommands.find(c => c.name === data.slashCommand);
9899
progress({ kind: 'agentDetection', agentId: this._data.id, command });
99100
}

src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ export class LiveStrategy extends EditModeStrategy {
551551
this._editor.revealPositionInCenterIfOutsideViewport(widgetData.position);
552552

553553
const remainingHunks = this._session.hunkData.pending;
554-
this._updateSummaryMessage(remainingHunks);
554+
this._updateSummaryMessage(remainingHunks, this._session.hunkData.size);
555555

556556

557557
const mode = this._configService.getValue<'on' | 'off' | 'auto'>(InlineChatConfigKeys.AccessibleDiffView);
@@ -587,16 +587,28 @@ export class LiveStrategy extends EditModeStrategy {
587587
return renderHunks()?.position;
588588
}
589589

590-
protected _updateSummaryMessage(hunkCount: number) {
590+
private _updateSummaryMessage(remaining: number, total: number) {
591+
592+
const needsReview = this._configService.getValue<boolean>(InlineChatConfigKeys.AcceptedOrDiscardBeforeSave);
591593
let message: string;
592-
if (hunkCount === 0) {
593-
message = localize('change.0', "Nothing changed");
594-
} else if (hunkCount === 1) {
595-
message = localize('change.1', "1 change");
594+
if (total === 0) {
595+
message = localize('change.0', "Nothing changed.");
596+
} else if (remaining === 1) {
597+
message = needsReview
598+
? localize('review.1', "$(info) Accept or Discard 1 change.")
599+
: localize('change.1', "1 change");
596600
} else {
597-
message = localize('lines.NM', "{0} changes", hunkCount);
601+
message = needsReview
602+
? localize('review.N', "$(info) Accept or Discard {0} changes.", remaining)
603+
: localize('change.N', "{0} changes", total);
604+
}
605+
606+
let title: string | undefined;
607+
if (needsReview) {
608+
title = localize('review', "Review (accept or discard) all changes before continuing.");
598609
}
599-
this._zone.widget.updateStatus(message);
610+
611+
this._zone.widget.updateStatus(message, { title });
600612
}
601613

602614
hasFocus(): boolean {

src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import { ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditor/co
5252
import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2';
5353
import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestController';
5454
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
55+
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
56+
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
5557

5658

5759
export interface InlineChatWidgetViewState {
@@ -281,9 +283,13 @@ export class InlineChatWidget {
281283

282284
this._elements.followUps.tabIndex = 0;
283285
this._elements.followUps.ariaLabel = this._accessibleViewService.getOpenAriaHint(AccessibilityVerbositySettingId.InlineChat);
284-
285286
this._elements.statusLabel.tabIndex = 0;
286287

288+
// this._elements.status
289+
this._store.add(setupCustomHover(getDefaultHoverDelegate('element'), this._elements.statusLabel, () => {
290+
return this._elements.statusLabel.dataset['title'];
291+
}));
292+
287293
this._store.add(this._chatService.onDidPerformUserAction(e => {
288294
if (e.sessionId === this._chatWidget.viewModel?.model.sessionId && e.action.kind === 'vote') {
289295
this.updateStatus('Thank you for your feedback!', { resetAfter: 1250 });
@@ -525,7 +531,7 @@ export class InlineChatWidget {
525531
this._onDidChangeHeight.fire();
526532
}
527533

528-
updateStatus(message: string, ops: { classes?: string[]; resetAfter?: number; keepMessage?: boolean } = {}) {
534+
updateStatus(message: string, ops: { classes?: string[]; resetAfter?: number; keepMessage?: boolean; title?: string } = {}) {
529535
const isTempMessage = typeof ops.resetAfter === 'number';
530536
if (isTempMessage && !this._elements.statusLabel.dataset['state']) {
531537
const statusLabel = this._elements.statusLabel.innerText;
@@ -534,14 +540,17 @@ export class InlineChatWidget {
534540
this.updateStatus(statusLabel, { classes, keepMessage: true });
535541
}, ops.resetAfter);
536542
}
537-
reset(this._elements.statusLabel, message);
543+
const renderedMessage = renderLabelWithIcons(message);
544+
reset(this._elements.statusLabel, ...renderedMessage);
538545
this._elements.statusLabel.className = `label status ${(ops.classes ?? []).join(' ')}`;
539546
this._elements.statusLabel.classList.toggle('hidden', !message);
540547
if (isTempMessage) {
541548
this._elements.statusLabel.dataset['state'] = 'temp';
542549
} else {
543550
delete this._elements.statusLabel.dataset['state'];
544551
}
552+
553+
this._elements.statusLabel.dataset['title'] = ops.title;
545554
this._onDidChangeHeight.fire();
546555
}
547556

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

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -61,59 +61,28 @@
6161
color: var(--vscode-descriptionForeground);
6262
font-size: 11px;
6363
align-self: baseline;
64-
display: inline-flex;
64+
padding-left: 10px;
65+
margin-left: auto;
6566
}
6667

6768
.monaco-workbench .inline-chat .status .label.hidden {
6869
display: none;
6970
}
7071

71-
.monaco-workbench .inline-chat .status .label.info {
72-
margin-right: auto;
73-
padding-left: 2px;
72+
.monaco-workbench .inline-chat .status .label.error {
73+
color: var(--vscode-errorForeground);
7474
}
7575

76-
.monaco-workbench .inline-chat .status .label.info > .codicon {
76+
.monaco-workbench .inline-chat .status .label.warn {
77+
color: var(--vscode-editorWarning-foreground);
78+
}
79+
80+
.monaco-workbench .inline-chat .status .label > .codicon {
7781
padding: 0 5px;
7882
font-size: 12px;
7983
line-height: 18px;
8084
}
8185

82-
.monaco-workbench .inline-chat .status .label.status {
83-
padding-left: 10px;
84-
padding-right: 4px;
85-
margin-left: auto;
86-
}
87-
88-
.monaco-workbench .inline-chat .status .label .slash-command-pill CODE {
89-
border-radius: 3px;
90-
padding: 0 1px;
91-
background-color: var(--vscode-chat-slashCommandBackground);
92-
color: var(--vscode-chat-slashCommandForeground);
93-
}
94-
95-
.monaco-workbench .inline-chat .detectedIntent {
96-
color: var(--vscode-descriptionForeground);
97-
padding: 5px 0px 5px 5px;
98-
}
99-
100-
.monaco-workbench .inline-chat .detectedIntent.hidden {
101-
display: none;
102-
}
103-
104-
.monaco-workbench .inline-chat .detectedIntent .slash-command-pill CODE {
105-
border-radius: 3px;
106-
padding: 0 1px;
107-
background-color: var(--vscode-chat-slashCommandBackground);
108-
color: var(--vscode-chat-slashCommandForeground);
109-
}
110-
111-
.monaco-workbench .inline-chat .detectedIntent .slash-command-pill a {
112-
color: var(--vscode-textLink-foreground);
113-
cursor: pointer;
114-
}
115-
116-
11786
.monaco-workbench .inline-chat .chatMessage .chatMessageContent .value {
11887
overflow: hidden;
11988
-webkit-user-select: text;
@@ -146,19 +115,6 @@
146115
display: none;
147116
}
148117

149-
.monaco-workbench .inline-chat .status .label A {
150-
color: var(--vscode-textLink-foreground);
151-
cursor: pointer;
152-
}
153-
154-
.monaco-workbench .inline-chat .status .label.error {
155-
color: var(--vscode-errorForeground);
156-
}
157-
158-
.monaco-workbench .inline-chat .status .label.warn {
159-
color: var(--vscode-editorWarning-foreground);
160-
}
161-
162118
.monaco-workbench .inline-chat .status .actions {
163119
display: flex;
164120
}

0 commit comments

Comments
 (0)