Skip to content

Commit 2fbdc5d

Browse files
authored
adopt IChatPullRequestContent in CreateRemoteAgentJobAction (microsoft#257907)
* adopt IChatPullRequestContent in CreateRemoteAgentJobAction * add version flag * comment * more comments
1 parent b49ad47 commit 2fbdc5d

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { toChatHistoryContent } from '../../common/chatModel.js';
2828
import { IChatMode, IChatModeService } from '../../common/chatModes.js';
2929
import { chatVariableLeader } from '../../common/chatParserTypes.js';
3030
import { ChatRequestParser } from '../../common/chatRequestParser.js';
31-
import { IChatService } from '../../common/chatService.js';
31+
import { IChatPullRequestContent, IChatService } from '../../common/chatService.js';
3232
import { ChatAgentLocation, ChatConfiguration, ChatModeKind, } from '../../common/constants.js';
3333
import { ILanguageModelChatMetadata } from '../../common/languageModels.js';
3434
import { ILanguageModelToolsService } from '../../common/languageModelToolsService.js';
@@ -658,31 +658,36 @@ export class CreateRemoteAgentJobAction extends Action2 {
658658
});
659659

660660
// Execute the remote command
661-
const resultMarkdown: string | undefined = await commandService.executeCommand(agent.command, {
661+
const result: Omit<IChatPullRequestContent, 'kind'> | string | undefined = await commandService.executeCommand(agent.command, {
662662
userPrompt,
663663
summary: summary || userPrompt,
664664
followup,
665+
_version: 2, // Signal that we support the new response format
665666
});
666667

667-
let content = new MarkdownString(
668-
resultMarkdown,
669-
CreateRemoteAgentJobAction.markdownStringTrustedOptions
670-
);
671-
if (!resultMarkdown) {
672-
content = new MarkdownString(
673-
localize('remoteAgentError', "Coding agent session cancelled."),
674-
CreateRemoteAgentJobAction.markdownStringTrustedOptions
675-
);
668+
if (result && typeof result === 'object') { /* _version === 2 */
669+
chatModel.acceptResponseProgress(addedRequest, { kind: 'pullRequest', ...result });
670+
} else if (typeof result === 'string') {
671+
chatModel.acceptResponseProgress(addedRequest, {
672+
kind: 'markdownContent',
673+
content: new MarkdownString(
674+
localize('remoteAgentResponse', "Coding agent response: {0}", result),
675+
CreateRemoteAgentJobAction.markdownStringTrustedOptions
676+
)
677+
});
678+
// Extension will open up the pull request in another view
679+
widget.clear();
680+
} else {
681+
chatModel.acceptResponseProgress(addedRequest, {
682+
kind: 'markdownContent',
683+
content: new MarkdownString(
684+
localize('remoteAgentError', "Coding agent session cancelled."),
685+
CreateRemoteAgentJobAction.markdownStringTrustedOptions
686+
)
687+
});
676688
}
677-
678-
chatModel.acceptResponseProgress(addedRequest, { content, kind: 'markdownContent' });
679689
chatModel.setResponse(addedRequest, {});
680690
chatModel.completeResponse(addedRequest);
681-
682-
// Clear chat (start a new chat)
683-
if (resultMarkdown) {
684-
widget.clear();
685-
}
686691
} finally {
687692
remoteJobCreatingKey.set(false);
688693
}

0 commit comments

Comments
 (0)