diff --git a/.nx/workflows/windows-distribution-config.yaml b/.nx/workflows/windows-distribution-config.yaml index 61b3c4c7ee..3d0741cd8a 100644 --- a/.nx/workflows/windows-distribution-config.yaml +++ b/.nx/workflows/windows-distribution-config.yaml @@ -2,3 +2,9 @@ distribute-on: small-changeset: 3 windows-medium-js medium-changeset: 4 windows-medium-js large-changeset: 6 windows-medium-js + +assignment-rules: + - project: intellij + target: build + runs-on: + - windows-medium-js diff --git a/libs/shared/cloud-fix-webview/.storybook/stories/nx-cloud-fix.stories.ts b/libs/shared/cloud-fix-webview/.storybook/stories/nx-cloud-fix.stories.ts deleted file mode 100644 index c9465c5dec..0000000000 --- a/libs/shared/cloud-fix-webview/.storybook/stories/nx-cloud-fix.stories.ts +++ /dev/null @@ -1,106 +0,0 @@ -import { html } from 'lit'; -import type { Meta, StoryObj } from '@storybook/web-components'; -import '../../src/nx-cloud-fix-component'; -import type { NxCloudFixDetails } from '@nx-console/shared-types'; - -const meta: Meta = { - title: 'Cloud Fix/NxCloudFixComponent', - tags: ['autodocs'], - render: (args) => html` - console.log('Apply clicked')} - .onApplyLocally=${() => console.log('Apply Locally clicked')} - .onReject=${() => console.log('Reject clicked')} - .onShowDiff=${() => console.log('Show Diff clicked')} - > - `, - argTypes: { - details: { control: 'object' }, - }, -}; - -export default meta; -type Story = StoryObj; - -const baseDetails: NxCloudFixDetails = { - cipe: { - cipeUrl: 'https://cloud.nx.app/runs/123', - id: '123', - status: 'FAILED', - createdAt: new Date().toISOString(), - }, - runGroup: { - runGroup: 'e2e', - runGroupId: 'rg-123', - aiFix: { - suggestedFix: true, - suggestedFixDescription: 'fix: Update configuration for TypeScript 5.0', - suggestedFixReasoning: - 'The build is failing because the `tsconfig.json` file is using an outdated TypeScript configuration. The error shows that `moduleResolution: "node"` is deprecated. We need to update it to `moduleResolution: "bundler"` for TypeScript 5.0+ compatibility. Additionally, the `target` should be updated from `es2015` to `es2022` for better modern JavaScript support.', - suggestedFixStatus: 'COMPLETED', - verificationStatus: 'COMPLETED', - taskIds: ['app:build'], - userAction: null, - }, - }, - terminalOutput: ` -> nx run app:build - -tsconfig.json:5:15 - error TS5098: Option 'moduleResolution: "node"' is deprecated and will be removed in a future release. Please use 'moduleResolution: "node10"' or 'moduleResolution: "bundler"' instead. - -5 "moduleResolution": "node", - ~~~~~~~ - -Found 1 error. -`, - hasUncommittedChanges: false, -}; - -export const WithInlineCode: Story = { - args: { - details: { - ...baseDetails, - runGroup: { - ...baseDetails.runGroup, - aiFix: { - ...baseDetails.runGroup.aiFix!, - suggestedFixReasoning: - 'The build is failing because `tsconfig.json` is using deprecated options. The `moduleResolution: "node"` setting needs to be updated to `moduleResolution: "bundler"` for TypeScript 5.0+. Also update `target: "es2015"` to `target: "es2022"`.', - }, - }, - }, - }, -}; - -export const MultipleInlineCode: Story = { - args: { - details: { - ...baseDetails, - runGroup: { - ...baseDetails.runGroup, - aiFix: { - ...baseDetails.runGroup.aiFix!, - suggestedFixReasoning: - 'The test is failing due to a missing import. Add `import { render } from "@testing-library/react"` at the top of `app.spec.tsx`. Also ensure that `jest.config.ts` includes the `setupFilesAfterEnv` option pointing to `./test-setup.ts`.', - }, - }, - }, - }, -}; - -export const NoInlineCode: Story = { - args: { - details: { - ...baseDetails, - runGroup: { - ...baseDetails.runGroup, - aiFix: { - ...baseDetails.runGroup.aiFix!, - suggestedFixReasoning: - 'The build is failing because of a configuration issue. Update the TypeScript configuration to use the latest settings compatible with your project requirements.', - }, - }, - }, - }, -}; diff --git a/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.stories.ts b/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.stories.ts index e87a32106b..7e7fcf3e10 100644 --- a/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.stories.ts +++ b/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.stories.ts @@ -164,6 +164,21 @@ export const Applied: Story = { }, }; +export const AppliedLocally: Story = { + args: { + details: { + ...mockDetails, + runGroup: { + ...mockDetails.runGroup, + aiFix: { + ...mockDetails.runGroup.aiFix!, + userAction: 'APPLIED_LOCALLY', + }, + }, + }, + }, +}; + export const Ignored: Story = { args: { details: { @@ -178,6 +193,22 @@ export const Ignored: Story = { }, }, }; +export const UncommittedChanges: Story = { + args: { + details: { + ...mockDetails, + runGroup: { + ...mockDetails.runGroup, + aiFix: { + ...mockDetails.runGroup.aiFix!, + userAction: 'NONE', + }, + }, + hasUncommittedChanges: true, + }, + onApplyLocally: (...args) => console.log('onApplyLocally', args), + }, +}; export const VerificationFailed: Story = { args: { diff --git a/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.ts b/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.ts index 84adc8cde2..1e1a85f267 100644 --- a/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.ts +++ b/libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.ts @@ -202,7 +202,11 @@ export class NxCloudFixComponent extends EditorContext(LitElement) { } private handleApplyLocally() { - if (this.details && this.onApplyLocally) { + if ( + this.details && + this.onApplyLocally && + !this.details?.hasUncommittedChanges + ) { this.onApplyLocally(this.details); } } @@ -356,6 +360,29 @@ export class NxCloudFixComponent extends EditorContext(LitElement) { `; } + if (aiFix.userAction === 'APPLIED_LOCALLY') { + return html` +
+
+ +
+

+ Fix Applied Locally +

+

+ The suggested changes have been applied locally. +

+
+ `; + } + const showActions = true; return html` diff --git a/libs/shared/types/src/lib/cloud-info.ts b/libs/shared/types/src/lib/cloud-info.ts index 4da6d07104..c24d54985b 100644 --- a/libs/shared/types/src/lib/cloud-info.ts +++ b/libs/shared/types/src/lib/cloud-info.ts @@ -57,7 +57,11 @@ export type AITaskFixStatus = | 'FAILED' | 'NOT_EXECUTABLE'; -export type AITaskFixUserAction = 'NONE' | 'APPLIED' | 'REJECTED'; +export type AITaskFixUserAction = + | 'NONE' + | 'APPLIED' + | 'REJECTED' + | 'APPLIED_LOCALLY'; export type AITaskFixUserActionOrigin = | 'NX_CLOUD_APP' diff --git a/libs/vscode/nx-cloud-view/src/nx-cloud-fix-tree-item.ts b/libs/vscode/nx-cloud-view/src/nx-cloud-fix-tree-item.ts index 69e0983641..82622fee30 100644 --- a/libs/vscode/nx-cloud-view/src/nx-cloud-fix-tree-item.ts +++ b/libs/vscode/nx-cloud-view/src/nx-cloud-fix-tree-item.ts @@ -77,6 +77,14 @@ export class NxCloudFixTreeItem 'check', new ThemeColor('notebookStatusSuccessIcon.foreground'), ); + } else if (userAction === 'APPLIED_LOCALLY') { + this.contextValue += '-appliedLocally'; + this.label = + 'The suggested changes have been applied to your local branch'; + this.iconPath = new ThemeIcon( + 'git-branch', + new ThemeColor('notebookStatusSuccessIcon.foreground'), + ); } else if (userAction === 'REJECTED') { this.contextValue += '-rejected'; this.label = 'Fix rejected by user';