44 GitBranchIcon ,
55 RobotIcon ,
66} from "@phosphor-icons/react" ;
7+ import { taskFeedRunStatus } from "@posthog/core/canvas/channelFeed" ;
78import {
89 Avatar ,
910 AvatarFallback ,
@@ -37,7 +38,6 @@ import {
3738} from "@posthog/quill" ;
3839import { formatRelativeTimeShort , getLocalDayDiff } from "@posthog/shared" ;
3940import type { Task , TaskRunStatus } from "@posthog/shared/domain-types" ;
40- import { isTerminalStatus } from "@posthog/shared/domain-types" ;
4141import { getUserInitials } from "@posthog/ui/features/auth/userInitials" ;
4242import { TaskTabIcon } from "@posthog/ui/features/browser-tabs/TaskTabIcon" ;
4343import { mentionChipClass } from "@posthog/ui/features/canvas/components/MentionText" ;
@@ -46,7 +46,6 @@ import { useChannelTaskData } from "@posthog/ui/features/canvas/hooks/useChannel
4646import { useTaskThread } from "@posthog/ui/features/canvas/hooks/useTaskThread" ;
4747import { shouldOpenTaskCardInline } from "@posthog/ui/features/canvas/taskCardNavigation" ;
4848import { userDisplayName } from "@posthog/ui/features/canvas/utils/userDisplay" ;
49- import { useSessionSelector } from "@posthog/ui/features/sessions/useSession" ;
5049import {
5150 type SidebarPrState ,
5251 useTaskPrStatus ,
@@ -163,21 +162,14 @@ interface TaskStatusDisplay {
163162// deliberate end state we should not soften with a PR.
164163function useTaskStatusDisplay ( task : Task ) : TaskStatusDisplay {
165164 const data = useChannelTaskData ( task ) ;
166- const agentSettledAfterRun = useSessionSelector (
167- task . id ,
168- ( session ) =>
169- ! ! session &&
170- ( session . events ?. length ?? 0 ) > 0 &&
171- ! session . isPromptPending &&
172- ( session . pendingPermissions ?. size ?? 0 ) === 0 ,
173- ) ;
174165 const { prState } = useTaskPrStatus ( {
175166 id : task . id ,
176167 cloudPrUrl : data ?. cloudPrUrl ?? null ,
177168 taskRunEnvironment : data ?. taskRunEnvironment ?? null ,
178169 } ) ;
179170 const status = data ?. taskRunStatus ?? task . latest_run ?. status ;
180171 const environment = data ?. taskRunEnvironment ?? task . latest_run ?. environment ;
172+ const displayStatus = taskFeedRunStatus ( { status, environment } ) ;
181173 // `prState` is resolved async from git/`gh` and is routinely null for cloud
182174 // tasks (the details fetch hasn't landed, or there's no cached row). But the
183175 // PR URL itself is a hard signal a PR exists — the card's "PR" link keys off
@@ -209,10 +201,8 @@ function useTaskStatusDisplay(task: Task): TaskStatusDisplay {
209201 base = null ;
210202 } else if ( ! status ) {
211203 base = < Badge > Draft</ Badge > ;
212- } else if ( environment === "cloud" || isTerminalStatus ( status ) ) {
213- const effectiveStatus =
214- agentSettledAfterRun && ! isTerminalStatus ( status ) ? "completed" : status ;
215- base = statusBadge ( effectiveStatus ) ;
204+ } else if ( displayStatus ) {
205+ base = statusBadge ( displayStatus ) ;
216206 } else {
217207 // Local, non-terminal: the run status is unreliable (the backend row stays
218208 // "queued" while the agent runs on the creator's machine), so we render no
0 commit comments