Skip to content

Commit be05f23

Browse files
authored
fix(nxls): make runLinkId nullable for cloud future compat (#2455)
1 parent 7271fc5 commit be05f23

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export type CIPERunGroup = {
3838
};
3939

4040
export type CIPERun = {
41-
linkId: string;
41+
linkId?: string;
42+
executionId?: string;
4243
command: string;
4344
status?: CIPEExecutionStatus;
4445
numFailedTasks?: number;

libs/vscode/nx-cloud-view/src/cloud-recent-cipe-view.ts

+33-27
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class CIPETreeItem extends BaseRecentCIPETreeItem implements Disposable {
4747

4848
constructor(
4949
public cipe: CIPEInfo,
50-
private treeDataProvider: AbstractTreeProvider<BaseRecentCIPETreeItem>
50+
private treeDataProvider: AbstractTreeProvider<BaseRecentCIPETreeItem>,
5151
) {
5252
let title = cipe.branch;
5353
if (cipe.commitTitle) {
@@ -71,7 +71,7 @@ class CIPETreeItem extends BaseRecentCIPETreeItem implements Disposable {
7171
}
7272

7373
this.description = formatMillis(
74-
(cipe.completedAt ?? Date.now()) - cipe.createdAt
74+
(cipe.completedAt ?? Date.now()) - cipe.createdAt,
7575
);
7676

7777
this.id = cipe.ciPipelineExecutionId;
@@ -92,17 +92,17 @@ class CIPETreeItem extends BaseRecentCIPETreeItem implements Disposable {
9292
if (this.cipe.status === 'SUCCEEDED') {
9393
this.iconPath = new ThemeIcon(
9494
'pass',
95-
new ThemeColor('notebookStatusSuccessIcon.foreground')
95+
new ThemeColor('notebookStatusSuccessIcon.foreground'),
9696
);
9797
} else if (isFailedStatus(this.cipe.status)) {
9898
this.iconPath = new ThemeIcon(
9999
'error',
100-
new ThemeColor('notebookStatusErrorIcon.foreground')
100+
new ThemeColor('notebookStatusErrorIcon.foreground'),
101101
);
102102
} else {
103103
this.iconPath = new ThemeIcon(
104104
'loading~spin',
105-
new ThemeColor('notebookStatusRunningIcon.foreground')
105+
new ThemeColor('notebookStatusRunningIcon.foreground'),
106106
);
107107
}
108108
}
@@ -136,8 +136,8 @@ class CIPETreeItem extends BaseRecentCIPETreeItem implements Disposable {
136136
runGroup.runs
137137
.filter((run) => run.status && isFailedStatus(run.status))
138138
.map(
139-
(run) => new RunTreeItem(run, this.cipe.ciPipelineExecutionId)
140-
)
139+
(run) => new RunTreeItem(run, this.cipe.ciPipelineExecutionId),
140+
),
141141
),
142142
];
143143
}
@@ -152,7 +152,7 @@ class CIPETreeItem extends BaseRecentCIPETreeItem implements Disposable {
152152

153153
if (this.cipe.runGroups.length === 1) {
154154
return this.cipe.runGroups[0].runs.map(
155-
(run) => new RunTreeItem(run, this.cipe.ciPipelineExecutionId)
155+
(run) => new RunTreeItem(run, this.cipe.ciPipelineExecutionId),
156156
);
157157
} else {
158158
return this.cipe.runGroups.map((runGroup) => {
@@ -169,7 +169,10 @@ class CIPETreeItem extends BaseRecentCIPETreeItem implements Disposable {
169169
class RunGroupTreeItem extends BaseRecentCIPETreeItem {
170170
type = 'runGroup' as const;
171171

172-
constructor(public runGroup: CIPERunGroup, public cipeId: string) {
172+
constructor(
173+
public runGroup: CIPERunGroup,
174+
public cipeId: string,
175+
) {
173176
super(runGroup.ciExecutionEnv ?? runGroup.runGroup);
174177

175178
this.collapsibleState = TreeItemCollapsibleState.Expanded;
@@ -196,11 +199,14 @@ class RunGroupTreeItem extends BaseRecentCIPETreeItem {
196199
class RunTreeItem extends BaseRecentCIPETreeItem {
197200
type = 'run' as const;
198201

199-
constructor(public run: CIPERun, public cipeId: string) {
202+
constructor(
203+
public run: CIPERun,
204+
public cipeId: string,
205+
) {
200206
super(run.command);
201207

202208
this.collapsibleState = TreeItemCollapsibleState.None;
203-
this.id = `${cipeId}-${run.linkId}`;
209+
this.id = `${cipeId}-${run.linkId ?? run.executionId}`;
204210
this.setIcon();
205211
this.contextValue = 'run';
206212
}
@@ -213,17 +219,17 @@ class RunTreeItem extends BaseRecentCIPETreeItem {
213219
) {
214220
this.iconPath = new ThemeIcon(
215221
'loading~spin',
216-
new ThemeColor('notebookStatusRunningIcon.foreground')
222+
new ThemeColor('notebookStatusRunningIcon.foreground'),
217223
);
218224
} else if (this.run.status === 'SUCCEEDED') {
219225
this.iconPath = new ThemeIcon(
220226
'pass',
221-
new ThemeColor('notebookStatusSuccessIcon.foreground')
227+
new ThemeColor('notebookStatusSuccessIcon.foreground'),
222228
);
223229
} else if (isFailedStatus(this.run.status)) {
224230
this.iconPath = new ThemeIcon(
225231
'error',
226-
new ThemeColor('notebookStatusErrorIcon.foreground')
232+
new ThemeColor('notebookStatusErrorIcon.foreground'),
227233
);
228234
}
229235
}
@@ -255,7 +261,7 @@ export class CloudRecentCIPEProvider extends AbstractTreeProvider<BaseRecentCIPE
255261

256262
constructor(
257263
actor: ActorRef<any, EventObject>,
258-
private fileDecorationProvider: CIPEFileDecorationProvider
264+
private fileDecorationProvider: CIPEFileDecorationProvider,
259265
) {
260266
super();
261267

@@ -273,7 +279,7 @@ export class CloudRecentCIPEProvider extends AbstractTreeProvider<BaseRecentCIPE
273279
});
274280
}
275281
override getChildren(
276-
element?: BaseRecentCIPETreeItem | undefined
282+
element?: BaseRecentCIPETreeItem | undefined,
277283
): ProviderResult<BaseRecentCIPETreeItem[]> {
278284
if (!this.recentCIPEInfo) {
279285
return undefined;
@@ -295,19 +301,19 @@ export class CloudRecentCIPEProvider extends AbstractTreeProvider<BaseRecentCIPE
295301
return element.getChildren();
296302
}
297303
override getParent(
298-
element: BaseRecentCIPETreeItem
304+
element: BaseRecentCIPETreeItem,
299305
): ProviderResult<BaseRecentCIPETreeItem | null | undefined> {
300306
return undefined;
301307
}
302308

303309
static create(
304310
extensionContext: ExtensionContext,
305-
actor: ActorRef<any, EventObject>
311+
actor: ActorRef<any, EventObject>,
306312
) {
307313
const fileDecorationProvider = new CIPEFileDecorationProvider();
308314
const recentCIPEProvider = new CloudRecentCIPEProvider(
309315
actor,
310-
fileDecorationProvider
316+
fileDecorationProvider,
311317
);
312318

313319
extensionContext.subscriptions.push(
@@ -325,7 +331,7 @@ export class CloudRecentCIPEProvider extends AbstractTreeProvider<BaseRecentCIPE
325331
source: 'cloud-view',
326332
});
327333
commands.executeCommand('vscode.open', treeItem.cipe.cipeUrl);
328-
}
334+
},
329335
),
330336
commands.registerCommand(
331337
'nxCloud.showRunInApp',
@@ -337,7 +343,7 @@ export class CloudRecentCIPEProvider extends AbstractTreeProvider<BaseRecentCIPE
337343
source: 'cloud-view',
338344
});
339345
commands.executeCommand('vscode.open', treeItem.run.runUrl);
340-
}
346+
},
341347
),
342348
commands.registerCommand(
343349
'nxCloud.showCommitForCIPE',
@@ -351,14 +357,14 @@ export class CloudRecentCIPEProvider extends AbstractTreeProvider<BaseRecentCIPE
351357
});
352358
commands.executeCommand('vscode.open', treeItem.cipe.commitUrl);
353359
}
354-
}
360+
},
355361
),
356362
commands.registerCommand('nxCloud.openApp', async () => {
357363
if (recentCIPEProvider.workspaceUrl) {
358364
getTelemetry().logUsage('cloud.open-app');
359365
commands.executeCommand(
360366
'vscode.open',
361-
recentCIPEProvider.workspaceUrl
367+
recentCIPEProvider.workspaceUrl,
362368
);
363369
} else {
364370
// this shouldn't happen but as a fallback, we try to guess the cloud url
@@ -373,11 +379,11 @@ export class CloudRecentCIPEProvider extends AbstractTreeProvider<BaseRecentCIPE
373379
commands.executeCommand('vscode.open', cloudUrlWithTracking);
374380
} else {
375381
showErrorMessageWithOpenLogs(
376-
'Something went wrong while retrieving the Nx Cloud URL.'
382+
'Something went wrong while retrieving the Nx Cloud URL.',
377383
);
378384
}
379385
}
380-
})
386+
}),
381387
);
382388
}
383389
}
@@ -395,11 +401,11 @@ class CIPEFileDecorationProvider implements FileDecorationProvider {
395401

396402
const failedTasks = runGroup?.runs.reduce(
397403
(total, run) => total + (run.numFailedTasks ?? 0),
398-
0
404+
0,
399405
);
400406
const totalTasks = runGroup?.runs.reduce(
401407
(total, run) => total + (run.numTasks ?? 0),
402-
0
408+
0,
403409
);
404410

405411
if (failedTasks && failedTasks > 0) {

0 commit comments

Comments
 (0)