Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 12 commits intomainfromcj/agentcontainers-port-fix-2
Mar 18, 2025
Merged
Changes from1 commit
Commits
Show all changes
12 commits
Select commitHold shift + click to select a range
80ac9a3
chore(agent/agentcontainers): refactor runDockerInspect and convertDo…
johnstcnMar 11, 2025
0ecceb0
chore(agent/agentcontainers): add dedicated test for convertDockerIns…
johnstcnMar 11, 2025
55998d0
fix(agent/agentcontainers): fix incorrectly parsed port
johnstcnMar 11, 2025
fb78d33
nolint paralleltest
johnstcnMar 12, 2025
a7d1ea4
chore: adjust testdata structure
johnstcnMar 12, 2025
393f6e9
use a []byte instead of a string
johnstcnMar 12, 2025
95b156e
fix(agent/agentcontainers): create new WorkspaceAgentDevcontainerPort…
johnstcnMar 13, 2025
f8f3000
fix(site): correct container port link
johnstcnMar 13, 2025
999469f
chore(site): add stories for AgentDevcontainerCard
johnstcnMar 13, 2025
8338af3
make fmt lint
johnstcnMar 13, 2025
2f0180e
rm extraneous null check
johnstcnMar 18, 2025
1ae6015
address PR comment
johnstcnMar 18, 2025
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
PrevPrevious commit
NextNext commit
fix(site): correct container port link
  • Loading branch information
@johnstcn
johnstcn committedMar 13, 2025
commitf8f30003a1e2e0f379cf123b9d9eaabb4eb23578
56 changes: 37 additions & 19 deletionssite/src/modules/resources/AgentDevcontainerCard.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
import Link from "@mui/material/Link";
import type { Workspace, WorkspaceAgentDevcontainer } from "api/typesGenerated";
import type {
Workspace,
WorkspaceAgentDevcontainer,
WorkspaceAgentDevcontainerPort,
} from "api/typesGenerated";
import { ExternalLinkIcon } from "lucide-react";
import type { FC } from "react";
import { portForwardURL } from "utils/portForward";
import { AgentButton } from "./AgentButton";
import { AgentDevcontainerSSHButton } from "./SSHButton/SSHButton";
import { TerminalLink } from "./TerminalLink/TerminalLink";
import Tooltip, { type TooltipProps } from "@mui/material/Tooltip";

type AgentDevcontainerCardProps = {
container: WorkspaceAgentDevcontainer;
Expand DownExpand Up@@ -47,25 +52,38 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
/>
{wildcardHostname !== "" &&
container.ports.map((port) => {
let portLabel = `${port.port}/${port.network.toUpperCase()}`;
let hasHostBind =
port.host_port !== undefined &&
port.host_port !== null &&
port.host_ip !== undefined &&
port.host_ip !== null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm finding this quite strange. Why not only return from the API null or undefined? Having the API returning both types look strange to me.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this seems like it was meant to be double-bookkeeping, but with how the server types are set up, thenull conditionals won't ever trigger. TheomitEmpty JSON tag will make sure that if the values ofhost_ip orhost_port are missing, they'll always evaluate toundefined

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

👍 Will remove the extraneousnull checks.

let helperText = hasHostBind
? `${port.host_ip}:${port.host_port}`
: "Not bound to host";
return (
<Link
key={port.port}
color="inherit"
component={AgentButton}
underline="none"
startIcon={<ExternalLinkIcon className="size-icon-sm" />}
href={portForwardURL(
wildcardHostname,
port.port,
agentName,
workspace.name,
workspace.owner_name,
location.protocol === "https" ? "https" : "http",
)}
>
{port.process_name ||
`${port.port}/${port.network.toUpperCase()}`}
</Link>
<Tooltip key={portLabel} title={helperText}>
<span>
Comment on lines +68 to +69
Copy link
Member

Choose a reason for hiding this comment

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

Two questions:

  • Is there a reason why this code is using the MUI version of the tooltip, rather than the one we have in our components folder?
  • Is the span here doing anything? I could see needing it to change some flexbox behavior, but I don't see anything obvious that would require it

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Is there a reason why this code is using the MUI version of the tooltip, rather than the one we have in our components folder?

Copy-pasta, most likely!

Is the span here doing anything? I could see needing it to change some flexbox behavior, but I don't see anything obvious that would require it

The tooltip wouldn't display if the link was disabled; the<span> was a random StackOverflow find.

<Link
key={portLabel}
color="inherit"
component={AgentButton}
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 ofhasHostBind 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
MemberAuthor

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

@ParkreinerParkreinerMar 18, 2025
edited
Loading

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!,
Copy link
Member

Choose a reason for hiding this comment

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

Why are we making a non-nullable assertion forhost_port, when just a few lines above, we're checking whether it's defined? I'd rather do one of two things:

  • UpdateportForwardURL to acceptundefined values
  • Update the render logic to render something else out if the value is missing

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Update the render logic to render something else out if the value is missing

Do you have any suggestions for an alternative "nowhere" URL? If there is no host port, we can't forward in the Coder UI. Maybeabout:blank?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Defaulting href to an empty string if the link is disabled.

Parkreiner reacted with thumbs up emoji
agentName,
workspace.name,
workspace.owner_name,
location.protocol === "https" ? "https" : "http",
Copy link
Member

Choose a reason for hiding this comment

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

location.protocol should always be eitherhttps orhttp, right?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Correct.

)}
>
{portLabel}
</Link>
Copy link
Member

Choose a reason for hiding this comment

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

@BrunoQuaresma Have we switched over to Shad for link variants like this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It depends. I would not expect BE folks migrating the components to be honest, but in this case I think would make more sense to replace them by the new button component like this:

<ButtonasChild><ahref="..."onClick={...}/></Button>

Copy link
Member

Choose a reason for hiding this comment

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

Oh wait, sorry – got mixed up by the diff. Didn't realize the link was already here

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'd suggest we make this a follow-up?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's totally fine with me

</span>
</Tooltip>
);
})}
</div>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp