Skip to content

fix: add link to troubleshooting #16592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export const NotificationActionButton: FC<ButtonProps> = (props) => {
variant="text"
css={{
textDecoration: "underline",
padding: 0,
paddingLeft: 0,
paddingRight: 8,
paddingTop: 0,
paddingBottom: 0,
height: "auto",
minWidth: "auto",
"&:hover": { background: "none", textDecoration: "underline" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import type { Interpolation, Theme } from "@emotion/react";
import InfoOutlined from "@mui/icons-material/InfoOutlined";
import WarningRounded from "@mui/icons-material/WarningRounded";
import { workspaceResolveAutostart } from "api/queries/workspaceQuota";
import type { Template, TemplateVersion, Workspace } from "api/typesGenerated";
import type {
Template,
TemplateVersion,
Workspace,
WorkspaceBuild,
} from "api/typesGenerated";
import { MemoizedInlineMarkdown } from "components/Markdown/Markdown";
import formatDistanceToNow from "date-fns/formatDistanceToNow";
import dayjs from "dayjs";
Expand Down Expand Up @@ -82,6 +87,9 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
workspace.latest_build.status === "running" &&
!workspace.health.healthy
) {
const troubleshootingURL = findTroubleshootingURL(workspace.latest_build);
const hasActions = permissions.updateWorkspace || troubleshootingURL;

notifications.push({
title: "Workspace is unhealthy",
severity: "warning",
Expand All @@ -94,10 +102,21 @@ export const WorkspaceNotifications: FC<WorkspaceNotificationsProps> = ({
.
</>
),
actions: permissions.updateWorkspace ? (
<NotificationActionButton onClick={onRestartWorkspace}>
Restart
</NotificationActionButton>
actions: hasActions ? (
<>
{permissions.updateWorkspace && (
<NotificationActionButton onClick={onRestartWorkspace}>
Restart
</NotificationActionButton>
)}
{troubleshootingURL && (
<NotificationActionButton
onClick={() => window.open(troubleshootingURL, "_blank")}
>
Troubleshooting
</NotificationActionButton>
)}
</>
) : undefined,
});
}
Expand Down Expand Up @@ -254,3 +273,18 @@ const styles = {
gap: 12,
},
} satisfies Record<string, Interpolation<Theme>>;

const findTroubleshootingURL = (
workspaceBuild: WorkspaceBuild,
): string | undefined => {
for (const resource of workspaceBuild.resources) {
if (resource.agents) {
for (const agent of resource.agents) {
if (agent.troubleshooting_url) {
return agent.troubleshooting_url;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: I can imagine a situation where a multi-agent workspace has a different troubleshooting URL for each agent. We might need some design changes to show multiple troubleshooting URLs though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this case! I concluded that having different Troubleshooting guides for various agents is an edge case.

}
}
}
}
return undefined;
};
Loading