Skip to content

fix(agent/agentcontainers): improve testing of convertDockerInspect, return correct host port #16887

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 12 commits into from
Mar 18, 2025
Merged
Prev Previous commit
address PR comment
  • Loading branch information
johnstcn committed Mar 18, 2025
commit 1ae601554607d1e60614f0446e7b283ddfc44ea2
25 changes: 12 additions & 13 deletions site/src/modules/resources/AgentDevcontainerCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import Link from "@mui/material/Link";
import Tooltip, { type TooltipProps } from "@mui/material/Tooltip";
import type {
Workspace,
WorkspaceAgentDevcontainer,
WorkspaceAgentDevcontainerPort,
} from "api/typesGenerated";
import type { Workspace, WorkspaceAgentDevcontainer } from "api/typesGenerated";
import { ExternalLinkIcon } from "lucide-react";
import type { FC } from "react";
import { portForwardURL } from "utils/portForward";
Expand Down Expand Up @@ -58,6 +54,16 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
const helperText = hasHostBind
? `${port.host_ip}:${port.host_port}`
: "Not bound to host";
const linkDest = hasHostBind
? portForwardURL(
wildcardHostname,
port.host_port!,
agentName,
workspace.name,
workspace.owner_name,
location.protocol === "https" ? "https" : "http",
)
: "";
return (
<Tooltip key={portLabel} title={helperText}>
<span>
Expand All @@ -68,14 +74,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
underline="none"
startIcon={<ExternalLinkIcon className="size-icon-sm" />}
disabled={!hasHostBind}
Copy link
Member

Choose a reason for hiding this comment

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

Is the value of hasHostBind likely to change over time? If I'm reading this right, it feels weird to me that we could be rendering out a link that is always disabled. At that point, why make it an interactive element in the first place?

Copy link
Member Author

Choose a reason for hiding this comment

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

It could change if the user bound the remote port to a local port and rebuilt the container. My reasoning for including the non-interactive variants was that if they simply didn't show up in the UI, it would be more confusing to users. Having it show up with a tooltip explaining why it was not enabled felt "right" to me.

Copy link
Member

@Parkreiner Parkreiner Mar 18, 2025

Choose a reason for hiding this comment

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

Yeah, I think that's a solid solution. I guess I'm just usually a little more skittish about disabled UI elements for accessibility reasons. But if/when that becomes a priority, I think it should be easy to update the component

href={portForwardURL(
wildcardHostname,
port.host_port!,
agentName,
workspace.name,
workspace.owner_name,
location.protocol === "https" ? "https" : "http",
)}
href={linkDest}
>
{portLabel}
</Link>
Expand Down
Loading