Skip to content

Commit 200d501

Browse files
committed
fix(webapp): show Idle session status on the run page badge too
The run/span panel derived the session badge from closedAt/expiresAt only, so it could read Active where the sessions list and detail page now read Idle. It now uses the same run-liveness derivation as the rest of the sessions surface.
1 parent 3947881 commit 200d501

1 file changed

Lines changed: 24 additions & 7 deletions

File tree

apps/webapp/app/presenters/v3/SpanPresenter.server.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { runStore } from "~/v3/runStore.server";
3636
import { getTaskEventStoreTableForRun, type TaskEventStoreTable } from "~/v3/taskEventStore.server";
3737
import { isFailedRunStatus, isFinalRunStatus } from "~/v3/taskStatus";
3838
import { BasePresenter } from "./basePresenter.server";
39+
import { deriveSessionStatus } from "./deriveSessionStatus";
3940
import { WaitpointPresenter } from "./WaitpointPresenter.server";
4041
import {
4142
controlPlaneResolver,
@@ -358,25 +359,41 @@ export class SpanPresenter extends BasePresenter {
358359
taskIdentifier: true,
359360
closedAt: true,
360361
expiresAt: true,
362+
currentRunId: true,
361363
},
362364
},
363365
},
364366
})
365367
: null;
366368

369+
// Resolve the session's current run so the badge reflects run liveness
370+
// (the same IDLE-vs-ACTIVE distinction as the sessions list/detail), not
371+
// just closedAt/expiresAt. Env-scoped, matching the run reads here.
372+
const sessionCurrentRun =
373+
sessionRun && sessionRun.session.currentRunId
374+
? await runStore.findRun(
375+
{
376+
id: sessionRun.session.currentRunId,
377+
runtimeEnvironmentId: run.runtimeEnvironmentId,
378+
},
379+
{ select: { status: true } },
380+
this._replica
381+
)
382+
: null;
383+
367384
const session = sessionRun
368385
? {
369386
friendlyId: sessionRun.session.friendlyId,
370387
externalId: sessionRun.session.externalId,
371388
type: sessionRun.session.type,
372389
taskIdentifier: sessionRun.session.taskIdentifier,
373-
status:
374-
sessionRun.session.closedAt != null
375-
? ("CLOSED" as const)
376-
: sessionRun.session.expiresAt != null &&
377-
sessionRun.session.expiresAt.getTime() < Date.now()
378-
? ("EXPIRED" as const)
379-
: ("ACTIVE" as const),
390+
status: deriveSessionStatus({
391+
closedAt: sessionRun.session.closedAt,
392+
expiresAt: sessionRun.session.expiresAt,
393+
hasCurrentRun: sessionRun.session.currentRunId != null,
394+
currentRunStatus: sessionCurrentRun?.status,
395+
now: Date.now(),
396+
}),
380397
reason: sessionRun.reason,
381398
triggeredAt: sessionRun.triggeredAt,
382399
}

0 commit comments

Comments
 (0)