Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joh/young-catshark #198416

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -144,6 +145,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 @@ -270,7 +272,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 @@ -688,15 +690,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 @@ -741,14 +743,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 @@ -782,7 +780,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 @@ -826,18 +824,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 @@ -858,7 +852,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 @@ -876,7 +870,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
Loading