From 4908f30cb45b39344ed3efd0a4ce65cce0e27327 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 23:10:26 +0000 Subject: [PATCH 1/3] fix: use first app in order instead of latest_app_status for focus in tasks This change modifies both the tasks page (list view) and individual task page to focus on the first app in order rather than the most recently active app. Previously, Claude terminal apps would auto-focus because they report status updates frequently, making them the 'latest_app_status'. Now the focus respects the app ordering as defined in templates. Changes: - TasksPage: Use first app from all agents instead of latest_app_status.app_id - TaskApps: Use first app in apps array instead of latest_app_status.app_id - Both components now exclude AI_APP_CHAT_SLUG consistently Fixes the issue where Claude terminal apps always auto-focus instead of respecting the defined app order in templates. --- site/src/pages/TaskPage/TaskApps.tsx | 9 +++++---- site/src/pages/TasksPage/TasksPage.tsx | 27 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/site/src/pages/TaskPage/TaskApps.tsx b/site/src/pages/TaskPage/TaskApps.tsx index 7954447853c1e..44b2917986e50 100644 --- a/site/src/pages/TaskPage/TaskApps.tsx +++ b/site/src/pages/TaskPage/TaskApps.tsx @@ -33,11 +33,12 @@ export const TaskApps: FC = ({ task }) => { .filter((a) => !!a && a.slug !== AI_APP_CHAT_SLUG); const [activeAppId, setActiveAppId] = useState(() => { - const appId = task.workspace.latest_app_status?.app_id; - if (!appId) { - throw new Error("No active app found in task"); + // Use the first app in order instead of the most recently active app + const firstApp = apps[0]; + if (!firstApp) { + throw new Error("No apps found in task"); } - return appId; + return firstApp.id; }); const activeApp = apps.find((app) => app.id === activeAppId); diff --git a/site/src/pages/TasksPage/TasksPage.tsx b/site/src/pages/TasksPage/TasksPage.tsx index c12436c109996..08fcc7e2b01c5 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -31,6 +31,7 @@ import { import { useAuthenticated } from "hooks"; import { ExternalLinkIcon, RotateCcwIcon, SendIcon } from "lucide-react"; import { AI_PROMPT_PARAMETER_NAME, type Task } from "modules/tasks/tasks"; +import { AI_APP_CHAT_SLUG } from "../TaskPage/constants"; import { WorkspaceAppStatus } from "modules/workspaces/WorkspaceAppStatus/WorkspaceAppStatus"; import { type FC, type ReactNode, useState } from "react"; import { Helmet } from "react-helmet-async"; @@ -328,11 +329,31 @@ const TasksTable: FC = ({ templates, filter }) => { tasks.map(({ workspace, prompt }) => { const templateDisplayName = workspace.template_display_name ?? workspace.template_name; - const status = workspace.latest_app_status; + + // Get all apps from all agents, excluding the chat UI app + const allApps = workspace.latest_build.resources + .flatMap((r) => r.agents) + .filter((a) => !!a) + .flatMap((a) => a.apps) + .filter((app) => app.slug !== AI_APP_CHAT_SLUG); + + // Use the first app in order instead of the most recently active app + const focusedApp = allApps[0]; + + // Find the agent that contains the focused app const agent = workspace.latest_build.resources .flatMap((r) => r.agents) - .find((a) => a?.id === status?.agent_id); - const app = agent?.apps.find((a) => a.id === status?.app_id); + .filter((a) => !!a) + .find((a) => a.apps.some((app) => app.id === focusedApp?.id)); + + // Create a status object for the focused app, or fall back to latest_app_status + const status = focusedApp ? { + ...workspace.latest_app_status, + app_id: focusedApp.id, + agent_id: agent?.id || workspace.latest_app_status?.agent_id, + } : workspace.latest_app_status; + + const app = focusedApp; return ( From b505578d6e1bb4a52737260acb0a2aa9834e8775 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:13:52 +0000 Subject: [PATCH 2/3] fix: format TasksPage.tsx with biome --- site/src/pages/TasksPage/TasksPage.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/site/src/pages/TasksPage/TasksPage.tsx b/site/src/pages/TasksPage/TasksPage.tsx index 08fcc7e2b01c5..3c7c25c089533 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -329,30 +329,32 @@ const TasksTable: FC = ({ templates, filter }) => { tasks.map(({ workspace, prompt }) => { const templateDisplayName = workspace.template_display_name ?? workspace.template_name; - + // Get all apps from all agents, excluding the chat UI app const allApps = workspace.latest_build.resources .flatMap((r) => r.agents) .filter((a) => !!a) .flatMap((a) => a.apps) .filter((app) => app.slug !== AI_APP_CHAT_SLUG); - + // Use the first app in order instead of the most recently active app const focusedApp = allApps[0]; - + // Find the agent that contains the focused app const agent = workspace.latest_build.resources .flatMap((r) => r.agents) .filter((a) => !!a) .find((a) => a.apps.some((app) => app.id === focusedApp?.id)); - + // Create a status object for the focused app, or fall back to latest_app_status - const status = focusedApp ? { - ...workspace.latest_app_status, - app_id: focusedApp.id, - agent_id: agent?.id || workspace.latest_app_status?.agent_id, - } : workspace.latest_app_status; - + const status = focusedApp + ? { + ...workspace.latest_app_status, + app_id: focusedApp.id, + agent_id: agent?.id || workspace.latest_app_status?.agent_id, + } + : workspace.latest_app_status; + const app = focusedApp; return ( From 1e6dbe191e4ac25028be4d3553f27f9a06d1c72d Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:28:31 +0000 Subject: [PATCH 3/3] fix: reorder imports in TasksPage.tsx per biome rules --- 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 3c7c25c089533..88b37769f9730 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -31,7 +31,6 @@ import { import { useAuthenticated } from "hooks"; import { ExternalLinkIcon, RotateCcwIcon, SendIcon } from "lucide-react"; import { AI_PROMPT_PARAMETER_NAME, type Task } from "modules/tasks/tasks"; -import { AI_APP_CHAT_SLUG } from "../TaskPage/constants"; import { WorkspaceAppStatus } from "modules/workspaces/WorkspaceAppStatus/WorkspaceAppStatus"; import { type FC, type ReactNode, useState } from "react"; import { Helmet } from "react-helmet-async"; @@ -40,6 +39,7 @@ import { Link as RouterLink } from "react-router-dom"; import TextareaAutosize from "react-textarea-autosize"; import { pageTitle } from "utils/page"; import { relativeTime } from "utils/time"; +import { AI_APP_CHAT_SLUG } from "../TaskPage/constants"; import { type UserOption, UsersCombobox } from "./UsersCombobox"; type TasksFilter = {