Skip to content

Commit 673be9e

Browse files
d-csclaude
andcommitted
fix(webapp): treat FAILED buffered runs as terminal in spans/trace routes + align workerQueue default
Addresses three Devin review findings on PR #3755: - api.v1.runs.\$runId.spans.\$spanId.ts and api.v1.runs.\$runId.trace.ts: the buffered-run response branch hardcoded isError:false and only checked CANCELED for isPartial, so a FAILED buffered run rendered as "still in progress" — SDK consumers would poll forever. Now derives both flags from CANCELED and FAILED, matching syntheticTrace.server.ts. - ApiRetrieveRunPresenter.synthesiseFoundRunFromBuffer: workerQueue defaulted to "main" while syntheticSpanRun.server.ts uses "". The API response's `region` is sourced via `run.workerQueue || undefined`, so "main" was advertising a region the run hadn't yet been assigned to. Aligned to "" so unassigned buffered runs coerce to region: undefined. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fe633cd commit 673be9e

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,11 @@ function synthesiseFoundRunFromBuffer(buffered: SyntheticRun): FoundRun {
647647
attemptNumber: null,
648648
engine: "V2",
649649
taskEventStore: "taskEvent",
650-
workerQueue: buffered.workerQueue ?? "main",
650+
// Empty string when absent (matches syntheticSpanRun.server.ts and lets
651+
// `createCommonRunStructure`'s `run.workerQueue || undefined` coerce the
652+
// API response's `region` to undefined instead of advertising a
653+
// misleading "main" region for a not-yet-assigned buffered run).
654+
workerQueue: buffered.workerQueue ?? "",
651655
parentTaskRun: null,
652656
rootTaskRun: null,
653657
childRuns: [],

apps/webapp/app/routes/api.v1.runs.$runId.spans.$spanId.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,20 @@ export const loader = createLoaderApiRoute(
8989
if (resolved.run.spanId !== params.spanId) {
9090
return json({ error: "Span not found" }, { status: 404 });
9191
}
92+
// CANCELED and FAILED are terminal states. A FAILED buffered run is
93+
// errored (drainer exhausted retries or gate rejected it) and must
94+
// not signal "still in progress" — mirrors syntheticTrace.server.ts.
95+
const isCancelled = resolved.run.status === "CANCELED";
96+
const isFailed = resolved.run.status === "FAILED";
9297
return json(
9398
{
9499
spanId: resolved.run.spanId,
95100
parentId: resolved.run.parentSpanId ?? null,
96101
runId: resolved.run.friendlyId,
97102
message: resolved.run.taskIdentifier ?? "",
98-
isError: false,
99-
isPartial: resolved.run.status !== "CANCELED",
100-
isCancelled: resolved.run.status === "CANCELED",
103+
isError: isFailed,
104+
isPartial: !isCancelled && !isFailed,
105+
isCancelled,
101106
level: "TRACE",
102107
startTime: resolved.run.createdAt,
103108
durationMs: 0,

apps/webapp/app/routes/api.v1.runs.$runId.trace.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ export const loader = createLoaderApiRoute(
9797
events: [],
9898
startTime: buffered.createdAt,
9999
duration: 0,
100-
isError: false,
101-
// Cancelled is a terminal state — the span shouldn't
102-
// signal "still in progress" once it's been cancelled.
103-
// Mirrors the sibling api.v1.runs.$runId.spans.$spanId.ts
104-
// and syntheticTrace.server.ts logic.
105-
isPartial: buffered.status !== "CANCELED",
100+
isError: buffered.status === "FAILED",
101+
// CANCELED and FAILED are terminal states — the span
102+
// shouldn't signal "still in progress" once the run has
103+
// reached either. Mirrors the sibling
104+
// api.v1.runs.$runId.spans.$spanId.ts and
105+
// syntheticTrace.server.ts logic.
106+
isPartial: buffered.status !== "CANCELED" && buffered.status !== "FAILED",
106107
isCancelled: buffered.status === "CANCELED",
107108
level: "TRACE",
108109
queueName: buffered.queue ?? undefined,

0 commit comments

Comments
 (0)