Skip to content

Commit 47bf3aa

Browse files
committed
fix(webapp): compare per-key running against the per-key concurrency limit
On a concurrency-keyed queue the limit applies per key, but the run inspector's Concurrency tile rendered the queue-wide running count against that per-key limit, so a run could read "8 / 2 · 100%" while its own key sat at 1 of 2. The at-limit check already used the key's count, so the number and the warning disagreed. Use the key's running count for the value and the percentage too; non-keyed queues are unchanged.
1 parent f4a6698 commit 47bf3aa

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.spans.$spanParam/route.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,10 +1281,15 @@ function WaitingInQueueBlock({
12811281
const running = fresh ? toNumber(fresh.running) : waiting.running;
12821282
const limit = waiting.concurrencyLimit ?? (fresh ? toNumber(fresh.q_limit) || null : null);
12831283

1284-
// The concurrency limit applies per key on keyed queues. PENDING renders as "Queued".
1285-
const atLimit = limit !== null && (key ? key.running >= limit : running >= limit);
1284+
// The concurrency limit applies per key on keyed queues, so the tile has to compare like with
1285+
// like: the key's own running count against the per-key limit. `running` above is queue-wide,
1286+
// which would render "8 / 2 · 100%" while this run's key sits at 1 of 2. PENDING renders as
1287+
// "Queued".
1288+
const runningAgainstLimit = key ? key.running : running;
1289+
const atLimit = limit !== null && runningAgainstLimit >= limit;
12861290
const showAtLimit = status === "PENDING" && atLimit && !paused;
1287-
const pct = limit && limit > 0 ? Math.min(100, Math.round((running / limit) * 100)) : null;
1291+
const pct =
1292+
limit && limit > 0 ? Math.min(100, Math.round((runningAgainstLimit / limit) * 100)) : null;
12881293
const waitedMs = Math.max(0, Date.now() - new Date(createdAt).getTime());
12891294

12901295
// Why the run is held, surfaced as a warning icon on the Status tile (queue-page style) rather
@@ -1317,7 +1322,7 @@ function WaitingInQueueBlock({
13171322
/>
13181323
<MiniStat
13191324
title="Concurrency"
1320-
value={running.toLocaleString()}
1325+
value={runningAgainstLimit.toLocaleString()}
13211326
valueClassName={cn(atLimit && "text-warning")}
13221327
suffix={
13231328
limit !== null

0 commit comments

Comments
 (0)