mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
fix assumptions with chat.exitAfterDelegation and chats in the sidebar (#281039)
This commit is contained in:
@@ -284,7 +284,7 @@ class CreateRemoteAgentJobAction {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (requestData) {
|
if (requestData) {
|
||||||
await widget.handleDelegationExitIfNeeded(requestData.agent);
|
await widget.handleDelegationExitIfNeeded(defaultAgent, requestData.agent);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error creating remote coding agent job', e);
|
console.error('Error creating remote coding agent job', e);
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ export interface IChatWidget {
|
|||||||
clear(): Promise<void>;
|
clear(): Promise<void>;
|
||||||
getViewState(): IChatModelInputState | undefined;
|
getViewState(): IChatModelInputState | undefined;
|
||||||
lockToCodingAgent(name: string, displayName: string, agentId?: string): void;
|
lockToCodingAgent(name: string, displayName: string, agentId?: string): void;
|
||||||
handleDelegationExitIfNeeded(agent: IChatAgentData | undefined): Promise<void>;
|
handleDelegationExitIfNeeded(sourceAgent: Pick<IChatAgentData, 'id' | 'name'> | undefined, targetAgent: IChatAgentData | undefined): Promise<void>;
|
||||||
|
|
||||||
delegateScrollFromMouseWheelEvent(event: IMouseWheelEvent): void;
|
delegateScrollFromMouseWheelEvent(event: IMouseWheelEvent): void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1309,8 +1309,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleDelegationExitIfNeeded(agent: IChatAgentData | undefined): Promise<void> {
|
async handleDelegationExitIfNeeded(sourceAgent: Pick<IChatAgentData, 'id' | 'name'> | undefined, targetAgent: IChatAgentData | undefined): Promise<void> {
|
||||||
if (!this._shouldExitAfterDelegation(agent)) {
|
if (!this._shouldExitAfterDelegation(sourceAgent, targetAgent)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1321,20 +1321,29 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _shouldExitAfterDelegation(agent: IChatAgentData | undefined): boolean {
|
private _shouldExitAfterDelegation(sourceAgent: Pick<IChatAgentData, 'id' | 'name'> | undefined, targetAgent: IChatAgentData | undefined): boolean {
|
||||||
|
if (!targetAgent) {
|
||||||
|
// Undefined behavior
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.configurationService.getValue<boolean>(ChatConfiguration.ExitAfterDelegation)) {
|
if (!this.configurationService.getValue<boolean>(ChatConfiguration.ExitAfterDelegation)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!agent) {
|
// Never exit if the source and target are the same (that means that you're providing a follow up, etc.)
|
||||||
|
// NOTE: sourceAgent would be the chatWidget's 'lockedAgent'
|
||||||
|
if (sourceAgent && sourceAgent.id === targetAgent.id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!isIChatViewViewContext(this.viewContext)) {
|
if (!isIChatViewViewContext(this.viewContext)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contribution = this.chatSessionsService.getChatSessionContribution(agent.id);
|
const contribution = this.chatSessionsService.getChatSessionContribution(targetAgent.id);
|
||||||
if (!contribution) {
|
if (!contribution) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -2311,7 +2320,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||||||
|
|
||||||
this.input.acceptInput(isUserQuery);
|
this.input.acceptInput(isUserQuery);
|
||||||
this._onDidSubmitAgent.fire({ agent: result.agent, slashCommand: result.slashCommand });
|
this._onDidSubmitAgent.fire({ agent: result.agent, slashCommand: result.slashCommand });
|
||||||
this.handleDelegationExitIfNeeded(result.agent);
|
this.handleDelegationExitIfNeeded(this._lockedAgent, result.agent);
|
||||||
this.currentRequest = result.responseCompletePromise.then(() => {
|
this.currentRequest = result.responseCompletePromise.then(() => {
|
||||||
const responses = this.viewModel?.getItems().filter(isResponseVM);
|
const responses = this.viewModel?.getItems().filter(isResponseVM);
|
||||||
const lastResponse = responses?.[responses.length - 1];
|
const lastResponse = responses?.[responses.length - 1];
|
||||||
|
|||||||
Reference in New Issue
Block a user