mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
clear parent widget after continue on (#279651)
This commit is contained in:
@@ -40,6 +40,7 @@ import { IChatWidgetService } from '../chat.js';
|
||||
import { CHAT_SETUP_ACTION_ID } from './chatActions.js';
|
||||
import { PromptFileVariableKind, toPromptFileVariableEntry } from '../../common/chatVariableEntries.js';
|
||||
import { NEW_CHAT_SESSION_ACTION_ID } from '../chatSessions/common.js';
|
||||
import { isResponseVM } from '../../common/chatViewModel.js';
|
||||
|
||||
export const enum ActionLocation {
|
||||
ChatWidget = 'chatWidget',
|
||||
@@ -278,10 +279,64 @@ class CreateRemoteAgentJobAction {
|
||||
);
|
||||
|
||||
await chatService.removeRequest(sessionResource, addedRequest.id);
|
||||
await chatService.sendRequest(sessionResource, userPrompt, {
|
||||
const requestData = await chatService.sendRequest(sessionResource, userPrompt, {
|
||||
agentIdSilent: continuationTargetType,
|
||||
attachedContext: attachedContext.asArray(),
|
||||
});
|
||||
|
||||
if (requestData) {
|
||||
await requestData.responseCompletePromise;
|
||||
|
||||
const checkAndClose = () => {
|
||||
const items = widget.viewModel?.getItems() ?? [];
|
||||
const lastItem = items[items.length - 1];
|
||||
|
||||
if (lastItem && isResponseVM(lastItem) && lastItem.isComplete && !lastItem.model.isPendingConfirmation.get()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (checkAndClose()) {
|
||||
await widget.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// Monitor subsequent responses when pending confirmations block us from closing
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
let disposed = false;
|
||||
let disposable: IDisposable | undefined;
|
||||
let timeout: ReturnType<typeof setTimeout> | undefined;
|
||||
const cleanup = () => {
|
||||
if (!disposed) {
|
||||
disposed = true;
|
||||
if (timeout !== undefined) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
if (disposable) {
|
||||
disposable.dispose();
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
disposable = widget.viewModel!.onDidChange(() => {
|
||||
if (checkAndClose()) {
|
||||
cleanup();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
timeout = setTimeout(() => {
|
||||
cleanup();
|
||||
resolve();
|
||||
}, 30_000); // 30 second timeout
|
||||
} catch (e) {
|
||||
cleanup();
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
|
||||
await widget.clear();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error creating remote coding agent job', e);
|
||||
throw e;
|
||||
|
||||
Reference in New Issue
Block a user