Skip to content

Commit f34cfd1

Browse files
authored
fix: handle APPLIED_LOCALLY state better in cloud fix ui (#2642)
1 parent 1707e70 commit f34cfd1

File tree

5 files changed

+72
-108
lines changed

5 files changed

+72
-108
lines changed

libs/shared/cloud-fix-webview/.storybook/stories/nx-cloud-fix.stories.ts

Lines changed: 0 additions & 106 deletions
This file was deleted.

libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.stories.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,21 @@ export const Applied: Story = {
164164
},
165165
};
166166

167+
export const AppliedLocally: Story = {
168+
args: {
169+
details: {
170+
...mockDetails,
171+
runGroup: {
172+
...mockDetails.runGroup,
173+
aiFix: {
174+
...mockDetails.runGroup.aiFix!,
175+
userAction: 'APPLIED_LOCALLY',
176+
},
177+
},
178+
},
179+
},
180+
};
181+
167182
export const Ignored: Story = {
168183
args: {
169184
details: {
@@ -178,6 +193,22 @@ export const Ignored: Story = {
178193
},
179194
},
180195
};
196+
export const UncommittedChanges: Story = {
197+
args: {
198+
details: {
199+
...mockDetails,
200+
runGroup: {
201+
...mockDetails.runGroup,
202+
aiFix: {
203+
...mockDetails.runGroup.aiFix!,
204+
userAction: 'NONE',
205+
},
206+
},
207+
hasUncommittedChanges: true,
208+
},
209+
onApplyLocally: (...args) => console.log('onApplyLocally', args),
210+
},
211+
};
181212

182213
export const VerificationFailed: Story = {
183214
args: {

libs/shared/cloud-fix-webview/src/nx-cloud-fix-component.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ export class NxCloudFixComponent extends EditorContext(LitElement) {
202202
}
203203

204204
private handleApplyLocally() {
205-
if (this.details && this.onApplyLocally) {
205+
if (
206+
this.details &&
207+
this.onApplyLocally &&
208+
!this.details?.hasUncommittedChanges
209+
) {
206210
this.onApplyLocally(this.details);
207211
}
208212
}
@@ -356,6 +360,29 @@ export class NxCloudFixComponent extends EditorContext(LitElement) {
356360
`;
357361
}
358362

363+
if (aiFix.userAction === 'APPLIED_LOCALLY') {
364+
return html`
365+
<div
366+
class="border-border bg-background relative m-0 border p-6 text-center"
367+
>
368+
<div
369+
class="mx-auto mb-4 flex h-16 w-16 flex-col items-center justify-center"
370+
>
371+
<icon-element
372+
icon="git-branch"
373+
class="text-success leading-none"
374+
></icon-element>
375+
</div>
376+
<h2 class="text-foreground m-0 mb-2 text-lg font-semibold">
377+
Fix Applied Locally
378+
</h2>
379+
<p class="text-foreground m-0 text-sm opacity-80">
380+
The suggested changes have been applied locally.
381+
</p>
382+
</div>
383+
`;
384+
}
385+
359386
const showActions = true;
360387

361388
return html`

libs/shared/types/src/lib/cloud-info.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ export type AITaskFixStatus =
5757
| 'FAILED'
5858
| 'NOT_EXECUTABLE';
5959

60-
export type AITaskFixUserAction = 'NONE' | 'APPLIED' | 'REJECTED';
60+
export type AITaskFixUserAction =
61+
| 'NONE'
62+
| 'APPLIED'
63+
| 'REJECTED'
64+
| 'APPLIED_LOCALLY';
6165

6266
export type AITaskFixUserActionOrigin =
6367
| 'NX_CLOUD_APP'

libs/vscode/nx-cloud-view/src/nx-cloud-fix-tree-item.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ export class NxCloudFixTreeItem
7777
'check',
7878
new ThemeColor('notebookStatusSuccessIcon.foreground'),
7979
);
80+
} else if (userAction === 'APPLIED_LOCALLY') {
81+
this.contextValue += '-appliedLocally';
82+
this.label =
83+
'The suggested changes have been applied to your local branch';
84+
this.iconPath = new ThemeIcon(
85+
'git-branch',
86+
new ThemeColor('notebookStatusSuccessIcon.foreground'),
87+
);
8088
} else if (userAction === 'REJECTED') {
8189
this.contextValue += '-rejected';
8290
this.label = 'Fix rejected by user';

0 commit comments

Comments
 (0)