@@ -2,7 +2,12 @@ import type { Interpolation, Theme } from "@emotion/react";
2
2
import InfoOutlined from "@mui/icons-material/InfoOutlined" ;
3
3
import WarningRounded from "@mui/icons-material/WarningRounded" ;
4
4
import { workspaceResolveAutostart } from "api/queries/workspaceQuota" ;
5
- import type { Template , TemplateVersion , Workspace } from "api/typesGenerated" ;
5
+ import type {
6
+ Template ,
7
+ TemplateVersion ,
8
+ Workspace ,
9
+ WorkspaceBuild ,
10
+ } from "api/typesGenerated" ;
6
11
import { MemoizedInlineMarkdown } from "components/Markdown/Markdown" ;
7
12
import formatDistanceToNow from "date-fns/formatDistanceToNow" ;
8
13
import dayjs from "dayjs" ;
@@ -82,6 +87,9 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
82
87
workspace . latest_build . status === "running" &&
83
88
! workspace . health . healthy
84
89
) {
90
+ const troubleshootingURL = findTroubleshootingURL ( workspace . latest_build ) ;
91
+ const hasActions = permissions . updateWorkspace || troubleshootingURL ;
92
+
85
93
notifications . push ( {
86
94
title : "Workspace is unhealthy" ,
87
95
severity : "warning" ,
@@ -94,10 +102,21 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
94
102
.
95
103
</ >
96
104
) ,
97
- actions : permissions . updateWorkspace ? (
98
- < NotificationActionButton onClick = { onRestartWorkspace } >
99
- Restart
100
- </ NotificationActionButton >
105
+ actions : hasActions ? (
106
+ < >
107
+ { permissions . updateWorkspace && (
108
+ < NotificationActionButton onClick = { onRestartWorkspace } >
109
+ Restart
110
+ </ NotificationActionButton >
111
+ ) }
112
+ { troubleshootingURL && (
113
+ < NotificationActionButton
114
+ onClick = { ( ) => window . open ( troubleshootingURL , "_blank" ) }
115
+ >
116
+ Troubleshooting
117
+ </ NotificationActionButton >
118
+ ) }
119
+ </ >
101
120
) : undefined ,
102
121
} ) ;
103
122
}
@@ -254,3 +273,18 @@ const styles = {
254
273
gap : 12 ,
255
274
} ,
256
275
} satisfies Record < string , Interpolation < Theme > > ;
276
+
277
+ const findTroubleshootingURL = (
278
+ workspaceBuild : WorkspaceBuild ,
279
+ ) : string | undefined => {
280
+ for ( const resource of workspaceBuild . resources ) {
281
+ if ( resource . agents ) {
282
+ for ( const agent of resource . agents ) {
283
+ if ( agent . troubleshooting_url ) {
284
+ return agent . troubleshooting_url ;
285
+ }
286
+ }
287
+ }
288
+ }
289
+ return undefined ;
290
+ } ;
0 commit comments