Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vs/base/browser/ui/button/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
border: 1px solid var(--vscode-button-border, transparent);
border-left-width: 0 !important;
border-radius: 0 2px 2px 0;
display: flex;
align-items: center;
}

.monaco-button-dropdown > .monaco-button.monaco-text-button {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface IOptions {
className?: string;
isAccessible?: boolean;
isResizeable?: boolean;
frameColor?: Color;
frameColor?: Color | string;
arrowColor?: Color;
keepEditorSelection?: boolean;
allowUnlimitedHeight?: boolean;
Expand All @@ -34,7 +34,7 @@ export interface IOptions {
}

export interface IStyles {
frameColor?: Color | null;
frameColor?: Color | string | null;
arrowColor?: Color | null;
}

Expand Down
19 changes: 16 additions & 3 deletions src/vs/workbench/contrib/inlineChat/browser/inlineChat.css
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,29 @@
/* create zone */

.monaco-editor .inline-chat-newfile-widget {
padding: 3px 0 6px 0;
background-color: var(--vscode-inlineChat-regionHighlight);
}

.monaco-editor .inline-chat-newfile-widget .title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 3px 6px 3px 0;
}

.monaco-editor .inline-chat-newfile-widget .title .detail {
margin-left: 4px;
}

.monaco-editor .inline-chat-newfile-widget .buttonbar-widget {
display: flex;
margin-left: auto;
margin-right: 8px;
}

.monaco-editor .inline-chat-newfile-widget .buttonbar-widget > .monaco-button {
display: inline-flex;
white-space: nowrap;
margin-left: 4px;
}

/* gutter decoration */
Expand All @@ -350,4 +364,3 @@
.monaco-editor .glyph-margin-widgets .cgmr.codicon-inline-chat-transparent:hover {
opacity: 1;
}

32 changes: 13 additions & 19 deletions src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { IModelDeltaDecoration } from 'vs/editor/common/model';
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
import { chatAgentLeader, chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes';
import { renderMarkdownAsPlaintext } from 'vs/base/browser/markdownRenderer';
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';

export const enum State {
CREATE_SESSION = 'CREATE_SESSION',
Expand Down Expand Up @@ -141,6 +142,7 @@ export class InlineChatController implements IEditorContribution {
@IKeybindingService private readonly _keybindingService: IKeybindingService,
@IChatAccessibilityService private readonly _chatAccessibilityService: IChatAccessibilityService,
@IChatAgentService private readonly _chatAgentService: IChatAgentService,
@IBulkEditService private readonly _bulkEditService: IBulkEditService,
) {
this._ctxHasActiveRequest = CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST.bindTo(contextKeyService);
this._ctxDidEdit = CTX_INLINE_CHAT_DID_EDIT.bindTo(contextKeyService);
Expand Down Expand Up @@ -266,7 +268,7 @@ export class InlineChatController implements IEditorContribution {
this._zone.value.setContainerMargins();
}

if (this._activeSession && this._activeSession.hasChangedText) {
if (this._activeSession && (this._activeSession.hasChangedText || this._activeSession.lastExchange)) {
widgetPosition = this._activeSession.wholeRange.value.getStartPosition().delta(-1);
}
if (this._activeSession) {
Expand Down Expand Up @@ -684,15 +686,15 @@ export class InlineChatController implements IEditorContribution {
if (reply.message) {
markdownContents.appendMarkdown(reply.message.value);
}
const replyResponse = response = new ReplyResponse(reply, markdownContents, this._activeSession.textModelN.uri, modelAltVersionIdNow, progressEdits);
const replyResponse = response = this._instaService.createInstance(ReplyResponse, reply, markdownContents, this._activeSession.textModelN.uri, modelAltVersionIdNow, progressEdits);

for (let i = progressEdits.length; i < replyResponse.allLocalEdits.length; i++) {
await this._makeChanges(replyResponse.allLocalEdits[i], undefined);
}

const a11yMessageResponse = renderMarkdownAsPlaintext(replyResponse.mdContent);

a11yResponse = this._strategy.checkChanges(replyResponse) && a11yVerboseInlineChat
a11yResponse = a11yVerboseInlineChat
? a11yMessageResponse ? localize('editResponseMessage2', "{0}, also review proposed changes in the diff editor.", a11yMessageResponse) : localize('editResponseMessage', "Review proposed changes in the diff editor.")
: a11yMessageResponse;
}
Expand Down Expand Up @@ -737,14 +739,10 @@ export class InlineChatController implements IEditorContribution {
assertType(this._strategy);

const { response } = this._activeSession.lastExchange!;
if (response instanceof ReplyResponse) {
// edit response -> complex...
this._zone.value.widget.updateMarkdownMessage(undefined);

const canContinue = this._strategy.checkChanges(response);
if (!canContinue) {
return State.CANCEL;
}
if (response instanceof ReplyResponse && response.workspaceEdit) {
// this reply cannot be applied in the normal inline chat UI and needs to be handled off to workspace edit
this._bulkEditService.apply(response.workspaceEdit, { showPreview: true });
return State.CANCEL;
}
return State.SHOW_RESPONSE;
}
Expand Down Expand Up @@ -778,7 +776,7 @@ export class InlineChatController implements IEditorContribution {
}
}

private async [State.SHOW_RESPONSE](): Promise<State.WAIT_FOR_INPUT | State.CANCEL> {
private async[State.SHOW_RESPONSE](): Promise<State.WAIT_FOR_INPUT | State.CANCEL> {
assertType(this._activeSession);
assertType(this._strategy);

Expand Down Expand Up @@ -822,18 +820,14 @@ export class InlineChatController implements IEditorContribution {
this._activeSession.lastExpansionState = this._zone.value.widget.expansionState;
this._zone.value.widget.updateToolbar(true);

const canContinue = this._strategy.checkChanges(response);
if (!canContinue) {
return State.CANCEL;
}
await this._strategy.renderChanges(response);
}
this._showWidget(false);

return State.WAIT_FOR_INPUT;
}

private async [State.PAUSE]() {
private async[State.PAUSE]() {

this._ctxDidEdit.reset();
this._ctxUserDidEdit.reset();
Expand All @@ -854,7 +848,7 @@ export class InlineChatController implements IEditorContribution {
this._activeSession = undefined;
}

private async [State.ACCEPT]() {
private async[State.ACCEPT]() {
assertType(this._activeSession);
assertType(this._strategy);
this._sessionStore.clear();
Expand All @@ -872,7 +866,7 @@ export class InlineChatController implements IEditorContribution {
this[State.PAUSE]();
}

private async [State.CANCEL]() {
private async[State.CANCEL]() {
assertType(this._activeSession);
assertType(this._strategy);
this._sessionStore.clear();
Expand Down
Loading