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

chore: simplify AgentRow interface#18087

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
BrunoQuaresma merged 9 commits intomainfrombq/refactor-agent-row
May 29, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 2 additions & 0 deletionssite/src/api/queries/deployment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
import { API } from "api/api";
import { disabledRefetchOptions } from "./util";

export const deploymentConfigQueryKey = ["deployment", "config"];

Expand DownExpand Up@@ -26,6 +27,7 @@ export const deploymentStats = () => {

export const deploymentSSHConfig = () => {
return {
...disabledRefetchOptions,
queryKey: ["deployment", "sshConfig"],
queryFn: API.getDeploymentSSHConfig,
};
Expand Down
12 changes: 6 additions & 6 deletionssite/src/modules/resources/AgentMetadata.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,24 +42,24 @@ export const AgentMetadataView: FC<AgentMetadataViewProps> = ({ metadata }) => {

interface AgentMetadataProps {
agent: WorkspaceAgent;
storybookMetadata?: WorkspaceAgentMetadata[];
initialMetadata?: WorkspaceAgentMetadata[];
}

const maxSocketErrorRetryCount = 3;

export const AgentMetadata: FC<AgentMetadataProps> = ({
agent,
storybookMetadata,
initialMetadata,
}) => {
const [activeMetadata, setActiveMetadata] = useState(storybookMetadata);
const [activeMetadata, setActiveMetadata] = useState(initialMetadata);
useEffect(() => {
// This is an unfortunate pitfall with this component's testing setup,
// but even though we use the value ofstorybookMetadata as the initial
// but even though we use the value ofinitialMetadata as the initial
// value of the activeMetadata, we cannot put activeMetadata itself into
// the dependency array. If we did, we would destroy and rebuild each
// connection every single time a new message comes in from the socket,
// because the socket has to be wired up to the state setter
if (storybookMetadata !== undefined) {
if (initialMetadata !== undefined) {
return;
}

Expand DownExpand Up@@ -118,7 +118,7 @@ export const AgentMetadata: FC<AgentMetadataProps> = ({
window.clearTimeout(timeoutId);
activeSocket?.close();
};
}, [agent.id,storybookMetadata]);
}, [agent.id,initialMetadata]);

if (activeMetadata === undefined) {
return (
Expand Down
46 changes: 19 additions & 27 deletionssite/src/modules/resources/AgentRow.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react";
import { spyOn } from "@storybook/test";
import { API } from "api/api";
import { getPreferredProxy } from "contexts/ProxyContext";
import { chromatic } from "testHelpers/chromatic";
import * as M from "testHelpers/entities";
Expand DownExpand Up@@ -95,8 +97,7 @@ const meta: Meta<typeof AgentRow> = {
logs_length: logs.length,
},
workspace: M.MockWorkspace,
showApps: true,
storybookAgentMetadata: defaultAgentMetadata,
initialMetadata: defaultAgentMetadata,
},
decorators: [withProxyProvider(), withDashboardProvider, withWebSocket],
parameters: {
Expand All@@ -121,24 +122,6 @@ type Story = StoryObj<typeof AgentRow>;

export const Example: Story = {};

export const HideSSHButton: Story = {
args: {
hideSSHButton: true,
},
};

export const HideVSCodeDesktopButton: Story = {
args: {
hideVSCodeDesktopButton: true,
},
};

export const NotShowingApps: Story = {
args: {
showApps: false,
},
};

export const BunchOfApps: Story = {
args: {
agent: {
Expand All@@ -155,14 +138,13 @@ export const BunchOfApps: Story = {
],
},
workspace: M.MockWorkspace,
showApps: true,
},
};

export const Connecting: Story = {
args: {
agent: M.MockWorkspaceAgentConnecting,
storybookAgentMetadata: [],
initialMetadata: [],
},
};

Expand DownExpand Up@@ -190,7 +172,7 @@ export const Started: Story = {
export const StartedNoMetadata: Story = {
args: {
...Started.args,
storybookAgentMetadata: [],
initialMetadata: [],
},
};

Expand DownExpand Up@@ -243,20 +225,30 @@ export const ShowingPortForward: Story = {
};

export const Outdated: Story = {
beforeEach: () => {
spyOn(API, "getBuildInfo").mockResolvedValue({
...M.MockBuildInfo,
version: "v99.999.9999+c1cdf14",
agent_api_version: "1.0",
});
},
args: {
agent: M.MockWorkspaceAgentOutdated,
workspace: M.MockWorkspace,
serverVersion: "v99.999.9999+c1cdf14",
serverAPIVersion: "1.0",
},
};

export const Deprecated: Story = {
beforeEach: () => {
spyOn(API, "getBuildInfo").mockResolvedValue({
...M.MockBuildInfo,
version: "v99.999.9999+c1cdf14",
agent_api_version: "2.0",
});
},
args: {
agent: M.MockWorkspaceAgentDeprecated,
workspace: M.MockWorkspace,
serverVersion: "v99.999.9999+c1cdf14",
serverAPIVersion: "2.0",
},
};

Expand Down
159 changes: 0 additions & 159 deletionssite/src/modules/resources/AgentRow.test.tsx
View file
Open in desktop

This file was deleted.

Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp