Skip to content

Commit d74ba5c

Browse files
fix(api): active session count excludes killed/completed/crashed (#3334) (#3396)
/v1/sessions/stats now filters out killed, completed, and crashed sessions from the 'active' count. The 'byStatus' breakdown still includes all statuses for full visibility. Fixes: #3334
1 parent f384d3f commit d74ba5c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/routes/sessions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ export function registerSessionRoutes(app: FastifyInstance, ctx: RouteContext):
263263
byStatus[s.status] = (byStatus[s.status] ?? 0) + 1;
264264
}
265265
const global = metrics.getGlobalMetrics(all.length);
266+
// #3334: active should only count live sessions, not killed/completed/crashed
267+
const activeCount = all.filter(s => s.status !== "killed" && s.status !== "completed" && s.status !== "crashed").length;
266268
return {
267-
active: all.length,
269+
active: activeCount,
268270
byStatus,
269271
totalCreated: global.sessions.total_created,
270272
totalCompleted: global.sessions.completed,

0 commit comments

Comments
 (0)