From 986040f561da4fbf9436f671e1e12d387d1802f3 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Thu, 15 May 2025 13:29:18 +0000 Subject: [PATCH 1/2] fix: avoid pulling containers when it is not enabled --- site/src/api/api.ts | 20 +++++--------------- site/src/modules/resources/AgentRow.tsx | 8 +++++++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/site/src/api/api.ts b/site/src/api/api.ts index 85a9860bc57c5..206e6e5f466f2 100644 --- a/site/src/api/api.ts +++ b/site/src/api/api.ts @@ -2453,21 +2453,11 @@ class ApiMethods { const params = new URLSearchParams( labels?.map((label) => ["label", label]), ); - - try { - const res = - await this.axios.get( - `/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`, - ); - return res.data; - } catch (err) { - // If the error is a 403, it means that experimental - // containers are not enabled on the agent. - if (isAxiosError(err) && err.response?.status === 403) { - return { containers: [] }; - } - throw err; - } + const res = + await this.axios.get( + `/api/v2/workspaceagents/${agentId}/containers?${params.toString()}`, + ); + return res.data; }; getInboxNotifications = async (startingBeforeId?: string) => { diff --git a/site/src/modules/resources/AgentRow.tsx b/site/src/modules/resources/AgentRow.tsx index c4d104501fd67..bdc09c7e9191b 100644 --- a/site/src/modules/resources/AgentRow.tsx +++ b/site/src/modules/resources/AgentRow.tsx @@ -40,6 +40,7 @@ import { PortForwardButton } from "./PortForwardButton"; import { AgentSSHButton } from "./SSHButton/SSHButton"; import { TerminalLink } from "./TerminalLink/TerminalLink"; import { VSCodeDesktopButton } from "./VSCodeDesktopButton/VSCodeDesktopButton"; +import { isAxiosError } from "axios"; export interface AgentRowProps { agent: WorkspaceAgent; @@ -160,7 +161,12 @@ export const AgentRow: FC = ({ select: (res) => res.containers.filter((c) => c.status === "running"), // TODO: Implement a websocket connection to get updates on containers // without having to poll. - refetchInterval: 10_000, + refetchInterval: (_, query) => { + const { error } = query.state; + return isAxiosError(error) && error.response?.status === 403 + ? false + : 10_000; + }, }); return ( From 21d3a4baf3bad3e257b1e117a174df1a601968cf Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Thu, 15 May 2025 13:39:27 +0000 Subject: [PATCH 2/2] FMT --- site/src/modules/resources/AgentRow.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/modules/resources/AgentRow.tsx b/site/src/modules/resources/AgentRow.tsx index bdc09c7e9191b..bc0751c332942 100644 --- a/site/src/modules/resources/AgentRow.tsx +++ b/site/src/modules/resources/AgentRow.tsx @@ -10,6 +10,7 @@ import type { WorkspaceAgent, WorkspaceAgentMetadata, } from "api/typesGenerated"; +import { isAxiosError } from "axios"; import { DropdownArrow } from "components/DropdownArrow/DropdownArrow"; import type { Line } from "components/Logs/LogLine"; import { Stack } from "components/Stack/Stack"; @@ -40,7 +41,6 @@ import { PortForwardButton } from "./PortForwardButton"; import { AgentSSHButton } from "./SSHButton/SSHButton"; import { TerminalLink } from "./TerminalLink/TerminalLink"; import { VSCodeDesktopButton } from "./VSCodeDesktopButton/VSCodeDesktopButton"; -import { isAxiosError } from "axios"; export interface AgentRowProps { agent: WorkspaceAgent;