@@ -2,7 +2,12 @@ import type { Interpolation, Theme } from "@emotion/react";
22import InfoOutlined from "@mui/icons-material/InfoOutlined" ;
33import WarningRounded from "@mui/icons-material/WarningRounded" ;
44import { 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" ;
611import { MemoizedInlineMarkdown } from "components/Markdown/Markdown" ;
712import formatDistanceToNow from "date-fns/formatDistanceToNow" ;
813import dayjs from "dayjs" ;
@@ -82,6 +87,9 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
8287 workspace . latest_build . status === "running" &&
8388 ! workspace . health . healthy
8489 ) {
90+ const troubleshootingURL = findTroubleshootingURL ( workspace . latest_build ) ;
91+ const hasActions = permissions . updateWorkspace || troubleshootingURL ;
92+
8593 notifications . push ( {
8694 title : "Workspace is unhealthy" ,
8795 severity : "warning" ,
@@ -94,10 +102,21 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
94102 .
95103 </ >
96104 ) ,
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+ </ >
101120 ) : undefined ,
102121 } ) ;
103122 }
@@ -254,3 +273,18 @@ const styles = {
254273 gap : 12 ,
255274 } ,
256275} 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