Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3ea541e
Add attach command and API endpoints for init-script and external age…
kacpersaw Jul 23, 2025
4818df1
add has_external_agents column to template_versions table
kacpersaw Jul 24, 2025
4bfdb83
add external workspace creation and agent instruction commands to cli
kacpersaw Jul 28, 2025
1044051
add has_external_agent to workspace builds
kacpersaw Jul 29, 2025
fd2458b
add list command for external workspaces
kacpersaw Jul 30, 2025
0c39f50
add AgentExternal component to display external agent connection deta…
kacpersaw Jul 30, 2025
23e555a
Merge remote-tracking branch 'origin/main' into kacpersaw/feat-coder-…
kacpersaw Jul 31, 2025
f9f5be1
add tests
kacpersaw Jul 31, 2025
e281f0e
Delete coder attach golden
kacpersaw Aug 5, 2025
d77522d
Hide agent apps when connecting & is external agent
kacpersaw Aug 5, 2025
451c806
Merge remote-tracking branch 'origin/main' into kacpersaw/feat-coder-…
kacpersaw Aug 5, 2025
f9274fe
Reformat code
kacpersaw Aug 5, 2025
00b6f26
Merge remote-tracking branch 'origin/main' into kacpersaw/feat-coder-…
kacpersaw Aug 6, 2025
c019a31
bump provisionerd proto version to v1.9
kacpersaw Aug 6, 2025
7d07857
Add beforeCreate and afterCreate to create handler, apply review sugg…
kacpersaw Aug 6, 2025
c462a69
Refactor init-script endpoint to use path params instead of query params
kacpersaw Aug 6, 2025
2d2dfec
Refactor init-script endpoint, apply review suggestions for db
kacpersaw Aug 6, 2025
387fc04
Apply FE review suggestions
kacpersaw Aug 6, 2025
c2588ea
Return 404 if workspace agent is authenticated through instance id
kacpersaw Aug 6, 2025
33dd778
Merge UpdateTemplateVersionAITaskByJobID and UpdateTemplateVersionExt…
kacpersaw Aug 7, 2025
c413479
update external agent credentials to include command in response
kacpersaw Aug 7, 2025
3c1d694
Bump terraform-provider-coder to v2.10.0
kacpersaw Aug 8, 2025
73acd0f
Merge remote-tracking branch 'origin/main' into kacpersaw/feat-coder-…
kacpersaw Aug 8, 2025
7cc6861
Regenerate sql
kacpersaw Aug 8, 2025
da68c20
Fix lint & tests
kacpersaw Aug 8, 2025
2e24741
Regenerate dump.sql
kacpersaw Aug 8, 2025
682ea60
Fix provision test
kacpersaw Aug 8, 2025
51967a5
update external agent credentials summary and adjust authorization ch…
kacpersaw Aug 8, 2025
f060324
merge UpdateWorkspaceBuildAITaskByID with UpdateWorkspaceBuildExterna…
kacpersaw Aug 8, 2025
ff6e8fa
Apply suggestions from code review
kacpersaw Aug 8, 2025
e2a7182
Apply review suggestions
kacpersaw Aug 8, 2025
141bc54
Merge branch 'main' into kacpersaw/feat-coder-attach
kacpersaw Aug 8, 2025
a75c1f4
make gen
kacpersaw Aug 8, 2025
22f2c00
Merge remote-tracking branch 'origin/main' into kacpersaw/feat-coder-…
kacpersaw Aug 11, 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
Prev Previous commit
Next Next commit
Reformat code
  • Loading branch information
kacpersaw committed Aug 5, 2025
commit f9274fe41eabb485e9aa76ed6f3505a4e27de124
23 changes: 17 additions & 6 deletions site/src/components/CodeExample/CodeExample.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import type { Interpolation, Theme } from "@emotion/react";
import { useState, type FC } from "react";
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
import { CopyButton } from "../CopyButton/CopyButton";
import { TooltipContent, TooltipTrigger, TooltipProvider, Tooltip } from "components/Tooltip/Tooltip";
import { Button } from "components/Button/Button";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "components/Tooltip/Tooltip";
import { EyeIcon, EyeOffIcon } from "lucide-react";
import { type FC, useState } from "react";
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
import { CopyButton } from "../CopyButton/CopyButton";

interface CodeExampleProps {
code: string;
Expand Down Expand Up @@ -41,8 +46,14 @@ export const CodeExample: FC<CodeExampleProps> = ({
? code.replace(redactPattern, redactReplacement)
: code;

const showButtonLabel = showFullValue ? "Hide sensitive data" : "Show sensitive data";
const icon = showFullValue ? <EyeOffIcon className="h-4 w-4" /> : <EyeIcon className="h-4 w-4" />;
const showButtonLabel = showFullValue
? "Hide sensitive data"
: "Show sensitive data";
const icon = showFullValue ? (
<EyeOffIcon className="h-4 w-4" />
) : (
<EyeIcon className="h-4 w-4" />
);

return (
<div css={styles.container} className={className}>
Expand Down
9 changes: 2 additions & 7 deletions site/src/modules/resources/AgentExternal.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react";
import { chromatic } from "testHelpers/chromatic";
import {
MockWorkspace,
MockWorkspaceAgent,
} from "testHelpers/entities";
import {
withDashboardProvider,
} from "testHelpers/storybook";
import { MockWorkspace, MockWorkspaceAgent } from "testHelpers/entities";
import { withDashboardProvider } from "testHelpers/storybook";
import { AgentExternal } from "./AgentExternal";

const meta: Meta<typeof AgentExternal> = {
Expand Down
38 changes: 23 additions & 15 deletions site/src/modules/resources/AgentExternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { API } from "api/api";
import type { Workspace, WorkspaceAgent } from "api/typesGenerated";
import isChromatic from "chromatic/isChromatic";
import { CodeExample } from "components/CodeExample/CodeExample";
import { useEffect, useState, type FC } from "react";
import { type FC, useEffect, useState } from "react";

interface AgentExternalProps {
isExternalAgent: boolean;
Expand All @@ -16,7 +16,9 @@ export const AgentExternal: FC<AgentExternalProps> = ({
agent,
workspace,
}) => {
const [externalAgentToken, setExternalAgentToken] = useState<string | null>(null);
const [externalAgentToken, setExternalAgentToken] = useState<string | null>(
null,
);

const origin = isChromatic() ? "https://example.com" : window.location.origin;
let initScriptURL = `${origin}/api/v2/init-script`;
Expand All @@ -25,25 +27,31 @@ export const AgentExternal: FC<AgentExternalProps> = ({
}

useEffect(() => {
if (isExternalAgent && (agent.status === "timeout" || agent.status === "connecting")) {
if (
isExternalAgent &&
(agent.status === "timeout" || agent.status === "connecting")
) {
API.getWorkspaceAgentCredentials(workspace.id, agent.name).then((res) => {
setExternalAgentToken(res.agent_token);
});
}
}, [isExternalAgent, agent.status, workspace.id, agent.name]);

return <section css={styles.externalAgentSection}>
<p>
Please run the following command to attach an agent to the {workspace.name} workspace:
</p>
<CodeExample
code={`CODER_AGENT_TOKEN="${externalAgentToken}" curl -fsSL "${initScriptURL}" | sh`}
secret={false}
redactPattern={/CODER_AGENT_TOKEN="([^"]+)"/g}
redactReplacement={`CODER_AGENT_TOKEN="********"`}
redactShowButton={true}
/>
</section>;
return (
<section css={styles.externalAgentSection}>
<p>
Please run the following command to attach an agent to the{" "}
{workspace.name} workspace:
</p>
<CodeExample
code={`CODER_AGENT_TOKEN="${externalAgentToken}" curl -fsSL "${initScriptURL}" | sh`}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the generation of the command should be moved to the backend and returned from the API, so we can keep it all in one place. This will need to eventually vary by OS/arch (curl | sh doesn't work on windows).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can extend the credentials endpoint and add another field for the ready-to-go command. Unless you have a different idea?

Copy link
Member

Choose a reason for hiding this comment

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

That sounds good to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

secret={false}
redactPattern={/CODER_AGENT_TOKEN="([^"]+)"/g}
redactReplacement={`CODER_AGENT_TOKEN="********"`}
redactShowButton={true}
/>
</section>
);
};

const styles = {
Expand Down
16 changes: 10 additions & 6 deletions site/src/modules/resources/AgentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import AutoSizer from "react-virtualized-auto-sizer";
import type { FixedSizeList as List, ListOnScrollProps } from "react-window";
import { AgentApps, organizeAgentApps } from "./AgentApps/AgentApps";
import { AgentDevcontainerCard } from "./AgentDevcontainerCard";
import { AgentExternal } from "./AgentExternal";
import { AgentLatency } from "./AgentLatency";
import { AGENT_LOG_LINE_HEIGHT } from "./AgentLogs/AgentLogLine";
import { AgentLogs } from "./AgentLogs/AgentLogs";
Expand All @@ -40,7 +41,6 @@ import { TerminalLink } from "./TerminalLink/TerminalLink";
import { VSCodeDesktopButton } from "./VSCodeDesktopButton/VSCodeDesktopButton";
import { useAgentContainers } from "./useAgentContainers";
import { useAgentLogs } from "./useAgentLogs";
import { AgentExternal } from "./AgentExternal";

interface AgentRowProps {
agent: WorkspaceAgent;
Expand Down Expand Up @@ -76,7 +76,7 @@ export const AgentRow: FC<AgentRowProps> = ({
const { proxy } = useProxy();
const [showLogs, setShowLogs] = useState(
["starting", "start_timeout"].includes(agent.lifecycle_state) &&
hasStartupFeatures,
hasStartupFeatures,
);
const agentLogs = useAgentLogs(agent, showLogs);
const logListRef = useRef<List>(null);
Expand Down Expand Up @@ -296,10 +296,14 @@ export const AgentRow: FC<AgentRowProps> = ({
</section>
)}


{isExternalAgent && (agent.status === "timeout" || agent.status === "connecting") && (
<AgentExternal isExternalAgent={isExternalAgent} agent={agent} workspace={workspace} />
)}
{isExternalAgent &&
(agent.status === "timeout" || agent.status === "connecting") && (
<AgentExternal
isExternalAgent={isExternalAgent}
agent={agent}
workspace={workspace}
/>
)}

<AgentMetadata initialMetadata={initialMetadata} agent={agent} />
</div>
Expand Down
Loading