From 223520f749926a9af1c21319f6c4a6b082fa822c Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 26 Nov 2025 11:58:24 +0000 Subject: [PATCH 1/4] fix(site): only show waiting for input for active tasks --- site/src/pages/TasksPage/TasksPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/pages/TasksPage/TasksPage.tsx b/site/src/pages/TasksPage/TasksPage.tsx index 7a19ee601bb26..7b37c0371e950 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -44,7 +44,7 @@ const TasksPage: FC = () => { refetchInterval: 10_000, }); const idleTasks = tasksQuery.data?.filter( - (task) => task.current_state?.state === "idle", + (task) => task.status === "active" && task.current_state?.state === "idle", ); const displayedTasks = tab.value === "waiting-for-input" ? idleTasks : tasksQuery.data; From e5284324e36770cecd3580c55cbcc68c16ce4cfc Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 26 Nov 2025 12:04:47 +0000 Subject: [PATCH 2/4] update storybook --- .../src/pages/TasksPage/TasksPage.stories.tsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/site/src/pages/TasksPage/TasksPage.stories.tsx b/site/src/pages/TasksPage/TasksPage.stories.tsx index 2e12d96983196..8f5b69443c81f 100644 --- a/site/src/pages/TasksPage/TasksPage.stories.tsx +++ b/site/src/pages/TasksPage/TasksPage.stories.tsx @@ -145,6 +145,29 @@ export const LoadedTasksWaitingForInputTab: Story = { spyOn(API, "getTasks").mockResolvedValue([ { ...firstTask, + id: "active-idle-task", + display_name: "Active Idle Task", + status: "active", + current_state: { + ...firstTask.current_state, + state: "idle", + }, + }, + { + ...firstTask, + id: "paused-idle-task", + display_name: "Paused Idle Task", + status: "paused", + current_state: { + ...firstTask.current_state, + state: "idle", + }, + }, + { + ...firstTask, + id: "error-idle-task", + display_name: "Error Idle Task", + status: "error", current_state: { ...firstTask.current_state, state: "idle", @@ -161,6 +184,13 @@ export const LoadedTasksWaitingForInputTab: Story = { name: /waiting for input/i, }); await userEvent.click(waitingForInputTab); + + // Wait for the active idle task to appear. + await canvas.findByText("Active Idle Task"); + + // Only active idle tasks should be visible. + expect(canvas.queryByText("Paused Idle Task")).not.toBeInTheDocument(); + expect(canvas.queryByText("Error Idle Task")).not.toBeInTheDocument(); }); }, }; From 5e527db1aa384193530234a4df0c7e5e6e5f328c Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 26 Nov 2025 12:50:38 +0000 Subject: [PATCH 3/4] can it be??? --- site/src/pages/TasksPage/TasksPage.stories.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/site/src/pages/TasksPage/TasksPage.stories.tsx b/site/src/pages/TasksPage/TasksPage.stories.tsx index 8f5b69443c81f..63f08eccdbe85 100644 --- a/site/src/pages/TasksPage/TasksPage.stories.tsx +++ b/site/src/pages/TasksPage/TasksPage.stories.tsx @@ -185,12 +185,19 @@ export const LoadedTasksWaitingForInputTab: Story = { }); await userEvent.click(waitingForInputTab); - // Wait for the active idle task to appear. - await canvas.findByText("Active Idle Task"); + // Query within the table to check only visible rows + const table = await canvas.findByRole("table"); + const tableContent = within(table); - // Only active idle tasks should be visible. - expect(canvas.queryByText("Paused Idle Task")).not.toBeInTheDocument(); - expect(canvas.queryByText("Error Idle Task")).not.toBeInTheDocument(); + await tableContent.findByText("Active Idle Task"); + + // Only active idle tasks should be visible in the table + expect( + tableContent.queryByText("Paused Idle Task"), + ).not.toBeInTheDocument(); + expect( + tableContent.queryByText("Error Idle Task"), + ).not.toBeInTheDocument(); }); }, }; From 21568fcec5621f1bf01d69c3f791e5fae11c6181 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 26 Nov 2025 12:57:56 +0000 Subject: [PATCH 4/4] ??? --- .../src/pages/TasksPage/TasksPage.stories.tsx | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/site/src/pages/TasksPage/TasksPage.stories.tsx b/site/src/pages/TasksPage/TasksPage.stories.tsx index 63f08eccdbe85..20fe21ee147cb 100644 --- a/site/src/pages/TasksPage/TasksPage.stories.tsx +++ b/site/src/pages/TasksPage/TasksPage.stories.tsx @@ -10,7 +10,7 @@ import { withAuthProvider, withProxyProvider } from "testHelpers/storybook"; import type { Meta, StoryObj } from "@storybook/react-vite"; import { API } from "api/api"; import { MockUsers } from "pages/UsersPage/storybookData/users"; -import { expect, spyOn, userEvent, within } from "storybook/test"; +import { expect, spyOn, userEvent, waitFor, within } from "storybook/test"; import { getTemplatesQueryKey } from "../../api/queries/templates"; import TasksPage from "./TasksPage"; @@ -185,19 +185,22 @@ export const LoadedTasksWaitingForInputTab: Story = { }); await userEvent.click(waitingForInputTab); - // Query within the table to check only visible rows - const table = await canvas.findByRole("table"); - const tableContent = within(table); + // Wait for the table to update after tab switch + await waitFor(async () => { + const table = canvas.getByRole("table"); + const tableContent = within(table); - await tableContent.findByText("Active Idle Task"); + // Active idle task should be visible + expect(tableContent.getByText("Active Idle Task")).toBeInTheDocument(); - // Only active idle tasks should be visible in the table - expect( - tableContent.queryByText("Paused Idle Task"), - ).not.toBeInTheDocument(); - expect( - tableContent.queryByText("Error Idle Task"), - ).not.toBeInTheDocument(); + // Only active idle tasks should be visible in the table + expect( + tableContent.queryByText("Paused Idle Task"), + ).not.toBeInTheDocument(); + expect( + tableContent.queryByText("Error Idle Task"), + ).not.toBeInTheDocument(); + }); }); }, };