From 8cc854059794ae6dff551e024fe0074a1ba4c280 Mon Sep 17 00:00:00 2001 From: dotta Date: Fri, 20 Mar 2026 06:22:51 -0500 Subject: [PATCH] Fix live run indicator: only show blue dot when a run is actually active MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously used routine run status ("received"/"issue_created") which are not the right signal. Now queries heartbeatsApi.liveRunsForIssue() on the active issue to check if an agent is actually running — the same source of truth the LiveRunWidget uses. Co-Authored-By: Paperclip --- ui/src/pages/RoutineDetail.tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ui/src/pages/RoutineDetail.tsx b/ui/src/pages/RoutineDetail.tsx index 59fa33aa..3de5129e 100644 --- a/ui/src/pages/RoutineDetail.tsx +++ b/ui/src/pages/RoutineDetail.tsx @@ -16,6 +16,7 @@ import { Zap, } from "lucide-react"; import { routinesApi, type RoutineTriggerResponse, type RotateRoutineTriggerResponse } from "../api/routines"; +import { heartbeatsApi } from "../api/heartbeats"; import { LiveRunWidget } from "../components/LiveRunWidget"; import { agentsApi } from "../api/agents"; import { projectsApi } from "../api/projects"; @@ -281,18 +282,20 @@ export function RoutineDetail() { queryFn: () => routinesApi.get(routineId!), enabled: !!routineId, }); + const activeIssueId = routine?.activeIssue?.id; + const { data: liveRuns } = useQuery({ + queryKey: queryKeys.issues.liveRuns(activeIssueId!), + queryFn: () => heartbeatsApi.liveRunsForIssue(activeIssueId!), + enabled: !!activeIssueId, + refetchInterval: 3000, + }); + const hasLiveRun = (liveRuns ?? []).length > 0; const { data: routineRuns } = useQuery({ queryKey: queryKeys.routines.runs(routineId!), queryFn: () => routinesApi.listRuns(routineId!), enabled: !!routineId, - refetchInterval: (query) => { - const runs = query.state.data ?? []; - return runs.some((r) => r.status === "received" || r.status === "issue_created") ? 3000 : false; - }, + refetchInterval: hasLiveRun ? 3000 : false, }); - const hasLiveRun = (routineRuns ?? []).some( - (run) => run.status === "received" || run.status === "issue_created", - ); const relatedActivityIds = useMemo( () => ({ triggerIds: routine?.triggers.map((trigger) => trigger.id) ?? [], @@ -985,12 +988,9 @@ export function RoutineDetail() { - {hasLiveRun && (() => { - const liveRun = (routineRuns ?? []).find((r) => r.status === "received" || r.status === "issue_created"); - const issueId = liveRun?.linkedIssue?.id ?? routine?.activeIssue?.id; - if (!issueId || !routine) return null; - return ; - })()} + {hasLiveRun && activeIssueId && routine && ( + + )} {(routineRuns ?? []).length === 0 ? (

No runs yet.

) : (