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

reveal widget when response is cancelled, errored, or without code changes #239956

Merged
merged 2 commits into from
Feb 7, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { IInstantiationService } from '../../../../../platform/instantiation/com
import { IChatEditingSession, IModifiedFileEntry } from '../../common/chatEditingService.js';
import { MenuId } from '../../../../../platform/actions/common/actions.js';
import { ActionViewItem } from '../../../../../base/browser/ui/actionbar/actionViewItems.js';
import { IEditorService } from '../../../../services/editor/common/editorService.js';
import { IActionRunner } from '../../../../../base/common/actions.js';
import { $, addDisposableGenericMouseMoveListener, append, EventLike, reset } from '../../../../../base/browser/dom.js';
import { renderIcon } from '../../../../../base/browser/ui/iconLabel/iconLabels.js';
Expand Down Expand Up @@ -46,7 +45,6 @@ class ChatEditorOverlayWidget implements IOverlayWidget {

constructor(
private readonly _editor: ICodeEditor,
@IEditorService editorService: IEditorService,
@IHoverService private readonly _hoverService: IHoverService,
@IChatService private readonly _chatService: IChatService,
@IInstantiationService private readonly _instaService: IInstantiationService,
Expand Down
11 changes: 7 additions & 4 deletions src/vs/workbench/contrib/inlineChat/browser/inlineChatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,15 @@ export class StopSessionAction2 extends AbstractInline2ChatAction {
id: 'inlineChat2.stop',
title: localize2('stop', "Stop"),
f1: true,
precondition: ContextKeyExpr.and(CTX_HAS_SESSION.isEqualTo('empty'), CTX_INLINE_CHAT_VISIBLE),
keybinding: {
precondition: CTX_INLINE_CHAT_VISIBLE,
keybinding: [{
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyCode.Escape,
secondary: [KeyMod.CtrlCmd | KeyCode.KeyI]
},
}, {
when: CTX_HAS_SESSION.isEqualTo('empty'),
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.CtrlCmd | KeyCode.KeyI,
}],
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1279,10 +1279,11 @@ export class InlineChatController2 implements IEditorContribution {

this._store.add(autorunWithStore((r, store) => {

const model = editorObs.model.read(r);
const session = this._currentSession.read(r);
const isActive = this._isActiveController.read(r);

if (!session || !isActive) {
if (!session || !isActive || !model) {
visibleSessionObs.set(undefined, undefined);
return;
}
Expand All @@ -1291,12 +1292,35 @@ export class InlineChatController2 implements IEditorContribution {
const showShowUntil = this._showWidgetOverrideObs.read(r);
const hasNoRequests = chatModel.getRequests().length === 0;


const responseListener = store.add(new MutableDisposable());

store.add(chatModel.onDidChange(e => {
if (e.kind === 'addRequest') {
transaction(tx => {
this._showWidgetOverrideObs.set(false, tx);
visibleSessionObs.set(undefined, tx);
});
const { response } = e.request;
if (!response) {
return;
}
responseListener.value = response.onDidChange(async e => {

if (!response.isComplete) {
return;
}

const shouldShow = response.isCanceled // cancelled
|| response.result?.errorDetails // errors
|| !response.response.value.find(part => part.kind === 'textEditGroup'
&& part.edits.length > 0
&& isEqual(part.uri, model.uri)); // NO edits for file

if (shouldShow) {
visibleSessionObs.set(session, undefined);
}
});
}
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {

const store = new DisposableStore();
store.add(toDisposable(() => {
this._chatService.cancelCurrentRequestForSession(chatModel.sessionId);
editingSession.reject();
this._sessions2.delete(uri);
this._onDidChangeSessions.fire(this);
Expand Down
Loading