Skip to content
Draft
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@
"category": "Azure",
"icon": "$(chat-sparkle)"
},
{
"command": "azureResourceGroups.reRunWithCopilot",
"title": "%azureResourceGroups.reRunWithCopilot%",
"category": "Azure",
"icon": "$(refresh)"
},
{
"command": "azureTenantsView.refresh",
"title": "%azureResourceGroups.refresh%",
Expand Down Expand Up @@ -624,6 +630,11 @@
"command": "azureResourceGroups.askAgentAboutActivityLogItem",
"when": "view == azureActivityLog && viewItem =~ /activityItem/i",
"group": "inline"
},
{
"command": "azureResourceGroups.reRunWithCopilot",
"when": "view == azureActivityLog && viewItem =~ /activityItem/i",
"group": "inline"
}
],
"commandPalette": [
Expand Down Expand Up @@ -678,6 +689,10 @@
{
"command": "azureResourceGroups.askAgentAboutActivityLogItem",
"when": "never"
},
{
"command": "azureResourceGroups.reRunWithCopilot",
"when": "never"
}
],
"azureResourceGroups.groupBy": [
Expand Down Expand Up @@ -946,7 +961,7 @@
"@azure/arm-resources-profile-2020-09-01-hybrid": "^2.1.0",
"@microsoft/vscode-azext-azureauth": "^5.1.1",
"@microsoft/vscode-azext-azureutils": "^4.0.0",
"@microsoft/vscode-azext-utils": "^4.0.0",
"@microsoft/vscode-azext-utils": "file:../vscode-azuretools/utils/microsoft-vscode-azext-utils-4.0.2.tgz",
"buffer": "^6.0.3",
"form-data": "^4.0.4",
"fs-extra": "^11.3.0",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"Do not translate '@azure'; it is syntax for addressing the Azure agent."
]
},
"azureResourceGroups.reRunWithCopilot": "Rerun Command with Copilot...",
"walkthrough.askAzure.description": {
"message": "Enter @azure in the GitHub Copilot Chat to start a conversation.\n @azure can help with learning about Azure, deploying resources, troubleshooting web app problems, querying Azure costs and more without having to switch to the Azure Portal.\n[Chat with @azure](command:azureResourceGroups.askAzure?%5B%22What%20kinds%20of%20things%20can%20you%20help%20me%20with?%22%5D)",
"comment": [
Expand Down
2 changes: 2 additions & 0 deletions src/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { askAgentAboutActivityLog } from '../chat/askAgentAboutActivityLog/askAg
import { askAgentAboutResource } from '../chat/askAgentAboutResource';
import { askAzureInCommandPalette } from '../chat/askAzure';
import { uploadFileToCloudShell } from '../cloudConsole/uploadFileToCloudShell';
import { reRunWithCopilot } from '../copilot/reRunWithCopilot';
import { ext } from '../extensionVariables';
import { TargetServiceRoleAssignmentItem } from '../managedIdentity/TargetServiceRoleAssignmentItem';
import { BranchDataItemWrapper } from '../tree/BranchDataItemWrapper';
Expand Down Expand Up @@ -134,6 +135,7 @@ export function registerCommands(): void {
registerCommand("azureResourceGroups.askAgentAboutActivityLog", async (context: IActionContext, _node: ActivityItem) => await askAgentAboutActivityLog(context));
registerCommandWithTreeNodeUnwrapping("azureResourceGroups.askAgentAboutActivityLogItem", askAgentAboutActivityLog);
registerCommandWithTreeNodeUnwrapping<{ id?: string }>("azureResourceGroups.askAgentAboutResource", (context, node) => askAgentAboutResource(context, node));
registerCommand('azureResourceGroups.reRunWithCopilot', async (context: IActionContext, item: ActivityItem) => await reRunWithCopilot(context, item));
}

async function handleAzExtTreeItemRefresh(context: IActionContext, node?: ResourceGroupsItem): Promise<void> {
Expand Down
41 changes: 41 additions & 0 deletions src/copilot/reRunWithCopilot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CopilotUserInput, createSubscriptionContext, executeCommandWithAddedContext, type IActionContext } from "@microsoft/vscode-azext-utils";
import * as vscode from "vscode";
import { ActivitySelectedCache } from "../chat/askAgentAboutActivityLog/ActivitySelectedCache";
import { convertActivityTreeToSimpleObjectArray, ConvertedActivityItem } from "../chat/tools/GetAzureActivityLog/convertActivityTree";
import { GetAzureActivityLogContext } from "../chat/tools/GetAzureActivityLog/GetAzureActivityLogContext";
import { ActivityItem } from "../tree/activityLog/ActivityItem";

export async function reRunWithCopilot(context: IActionContext, item: ActivityItem): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We discussed it offline, but prefer it to be rerunWithCopilot just for stylistic reasons. Also may want to be more specific, like rerunAzureActivityWithCopilot so people are aware that this is specifically for retrying commands that are in the activity log.

const activitySelectedCache = ActivitySelectedCache.getInstance();
activitySelectedCache.addActivity(item.id);

const activityContext: GetAzureActivityLogContext = {
...context,
activitySelectedCache: activitySelectedCache
Copy link
Contributor

@MicroFish91 MicroFish91 Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think I should make a separate update to uncouple the cache from this context so you won't be forced to add it like this just to leverage the helper function below.

}

const activityItems: ConvertedActivityItem[] = await convertActivityTreeToSimpleObjectArray(activityContext);
context.ui = new CopilotUserInput(vscode, JSON.stringify(activityItems));

// if subscription exists then add it to the context and
let wizardContext = context
const subscription = activityItems[0].activityAttributes?.subscription
if (subscription) {
const subscriptionContext = createSubscriptionContext(subscription);
wizardContext = { ...context, ...subscriptionContext };
}

// An item will always be passed in so we will only need to look at the first item in the array
const callbackId = activityItems[0]?.callbackId;
if (callbackId) {
// todo: change this as the subscription may not always be the third thing passed in
await executeCommandWithAddedContext(callbackId, wizardContext, undefined, undefined, subscription)
} else {
throw new Error(vscode.l10n.t('Failed to rerun with Copilot. Activity item callback ID not found.'));
}
}