diff --git a/packages/core/src/stepFunctions/activation.ts b/packages/core/src/stepFunctions/activation.ts index 4898fc36b54..ab37cb7a09a 100644 --- a/packages/core/src/stepFunctions/activation.ts +++ b/packages/core/src/stepFunctions/activation.ts @@ -96,7 +96,7 @@ async function registerStepFunctionCommands( }), Commands.register('aws.stepfunctions.publishStateMachine', async (node?: any) => { const region: string | undefined = node?.regionCode - await publishStateMachine(awsContext, outputChannel, region) + await publishStateMachine({ awsContext: awsContext, outputChannel: outputChannel, region: region }) }) ) } diff --git a/packages/core/src/stepFunctions/commands/publishStateMachine.ts b/packages/core/src/stepFunctions/commands/publishStateMachine.ts index e07b21b86f2..385a412478f 100644 --- a/packages/core/src/stepFunctions/commands/publishStateMachine.ts +++ b/packages/core/src/stepFunctions/commands/publishStateMachine.ts @@ -15,14 +15,21 @@ import { refreshStepFunctionsTree } from '../explorer/stepFunctionsNodes' import { PublishStateMachineWizard, PublishStateMachineWizardState } from '../wizards/publishStateMachineWizard' const localize = nls.loadMessageBundle() -export async function publishStateMachine( - awsContext: AwsContext, - outputChannel: vscode.OutputChannel, +interface publishStateMachineParams { + awsContext: AwsContext + outputChannel: vscode.OutputChannel region?: string -) { + text?: vscode.TextDocument +} +export async function publishStateMachine(params: publishStateMachineParams) { const logger: Logger = getLogger() + let textDocument: vscode.TextDocument | undefined - const textDocument = vscode.window.activeTextEditor?.document + if (params.text) { + textDocument = params.text + } else { + textDocument = vscode.window.activeTextEditor?.document + } if (!textDocument) { logger.error('Could not get active text editor for state machine definition') @@ -53,17 +60,17 @@ export async function publishStateMachine( } try { - const response = await new PublishStateMachineWizard(region).run() + const response = await new PublishStateMachineWizard(params.region).run() if (!response) { return } const client = new DefaultStepFunctionsClient(response.region) if (response?.createResponse) { - await createStateMachine(response.createResponse, text, outputChannel, response.region, client) + await createStateMachine(response.createResponse, text, params.outputChannel, response.region, client) refreshStepFunctionsTree(response.region) } else if (response?.updateResponse) { - await updateStateMachine(response.updateResponse, text, outputChannel, response.region, client) + await updateStateMachine(response.updateResponse, text, params.outputChannel, response.region, client) } } catch (err) { logger.error(err as Error) diff --git a/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts b/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts index 13477db19e2..2b548ab957f 100644 --- a/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts +++ b/packages/core/src/stepFunctions/workflowStudio/handleMessage.ts @@ -202,15 +202,22 @@ async function saveFileMessageHandler(request: SaveFileRequestMessage, context: } /** - * Handler for saving a file and starting the state machine deployment flow, while also switching to default editor. + * Handler for saving a file and starting the state machine deployment flow while staying in WFS view. * Triggered when the user triggers 'Save and Deploy' action in WFS * @param request The request message containing the file contents. * @param context The webview context containing the necessary information for saving the file. */ async function saveFileAndDeployMessageHandler(request: SaveFileRequestMessage, context: WebviewContext) { await saveFileMessageHandler(request, context) - await closeCustomEditorMessageHandler(context) - await publishStateMachine(globals.awsContext, globals.outputChannel) + await publishStateMachine({ + awsContext: globals.awsContext, + outputChannel: globals.outputChannel, + text: context.textDocument, + }) + + telemetry.ui_click.emit({ + elementId: 'stepfunctions_saveAndDeploy', + }) } /** diff --git a/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditor.ts b/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditor.ts index da1a9f2e9bf..ba719856516 100644 --- a/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditor.ts +++ b/packages/core/src/stepFunctions/workflowStudio/workflowStudioEditor.ts @@ -147,16 +147,18 @@ export class WorkflowStudioEditor { // The text document acts as our model, thus we send and event to the webview on file save to trigger update contextObject.disposables.push( - vscode.workspace.onDidSaveTextDocument(async () => { - await telemetry.stepfunctions_saveFile.run(async (span) => { - span.record({ - id: contextObject.fileId, - saveType: 'MANUAL_SAVE', - source: 'VSCODE', - isInvalidJson: isInvalidJsonFile(contextObject.textDocument), + vscode.workspace.onDidSaveTextDocument(async (savedDocument) => { + if (savedDocument.uri.toString() === this.documentUri.toString()) { + await telemetry.stepfunctions_saveFile.run(async (span) => { + span.record({ + id: contextObject.fileId, + saveType: 'MANUAL_SAVE', + source: 'VSCODE', + isInvalidJson: isInvalidJsonFile(contextObject.textDocument), + }) + await broadcastFileChange(contextObject, 'MANUAL_SAVE') }) - await broadcastFileChange(contextObject, 'MANUAL_SAVE') - }) + } }) ) diff --git a/packages/toolkit/.changes/next-release/Bug Fix-8beaac0b-fb5e-42bd-8ecf-a185266a9f04.json b/packages/toolkit/.changes/next-release/Bug Fix-8beaac0b-fb5e-42bd-8ecf-a185266a9f04.json new file mode 100644 index 00000000000..1d0f2041fa8 --- /dev/null +++ b/packages/toolkit/.changes/next-release/Bug Fix-8beaac0b-fb5e-42bd-8ecf-a185266a9f04.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "State Machine deployments can now be initiated directly from Workflow Studio without closing the editor" +} diff --git a/packages/toolkit/.changes/next-release/Bug Fix-de3cdda1-252e-4d04-96cb-7fb935649c0e.json b/packages/toolkit/.changes/next-release/Bug Fix-de3cdda1-252e-4d04-96cb-7fb935649c0e.json new file mode 100644 index 00000000000..2e1c167dccd --- /dev/null +++ b/packages/toolkit/.changes/next-release/Bug Fix-de3cdda1-252e-4d04-96cb-7fb935649c0e.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "Step Function performance metrics now accurately reflect only Workflow Studio document activity" +}