@@ -251,6 +251,11 @@ function projectExecutionStatus(
251251export interface ProjectedWorkflowExecutionStatus {
252252 status : WorkflowExecutionStatusResponse
253253 projection : LogFieldProjection
254+ /**
255+ * The execution whose recorded state answered: the run itself, or the parent run a settled
256+ * resume attempt continued. Further reads of the run's state (its pause points) use this id.
257+ */
258+ stateExecutionId : string
254259}
255260
256261/**
@@ -270,14 +275,18 @@ export interface ProjectedWorkflowExecutionStatus {
270275export async function getProjectedWorkflowExecutionStatus (
271276 input : GetWorkflowExecutionStatusInput
272277) : Promise < ProjectedWorkflowExecutionStatus | null > {
273- const status = await readWorkflowExecutionStatus ( input )
274- if ( ! status ) return null
278+ const resolved = await readWorkflowExecutionStatus ( input )
279+ if ( ! resolved ) return null
275280 const projection = await resolveLogFieldProjection (
276281 input . viewerUserId ,
277282 input . workspaceId ,
278283 input . workspaceOrganizationId
279284 )
280- return { status : projectExecutionStatus ( status , projection ) , projection }
285+ return {
286+ status : projectExecutionStatus ( resolved . status , projection ) ,
287+ projection,
288+ stateExecutionId : resolved . stateExecutionId ,
289+ }
281290}
282291
283292/**
@@ -330,9 +339,18 @@ async function readRunDeploymentVersion(
330339 return row ?. version ?? null
331340}
332341
342+ /**
343+ * A status resource and the execution whose recorded state answered it: the run itself, or
344+ * for a settled resume attempt with no log row of its own, the parent run it continued.
345+ */
346+ interface ResolvedExecutionStatus {
347+ status : WorkflowExecutionStatusResponse
348+ stateExecutionId : string
349+ }
350+
333351async function readWorkflowExecutionStatus (
334352 input : GetWorkflowExecutionStatusInput
335- ) : Promise < WorkflowExecutionStatusResponse | null > {
353+ ) : Promise < ResolvedExecutionStatus | null > {
336354 const { workflowId, executionId, includeOutput, selectedOutputs } = input
337355
338356 const [ logRow ] = await db
@@ -412,13 +430,16 @@ async function readWorkflowExecutionStatus(
412430 for ( const jobId of queueJobIds ) {
413431 const job = await jobQueue . getJob ( jobId )
414432 if ( ! job || job . metadata . workflowId !== workflowId ) continue
415- return projectQueueJob ( job , { executionId, includeOutput, workflowId } , deploymentVersion )
433+ return {
434+ status : projectQueueJob ( job , { executionId, includeOutput, workflowId } , deploymentVersion ) ,
435+ stateExecutionId : executionId ,
436+ }
416437 }
417438 }
418439
419440 if ( projectedResume ) {
420441 const startedAt = projectedResume . claimedAt ?? projectedResume . queuedAt
421- return {
442+ const status : WorkflowExecutionStatusResponse = {
422443 executionId,
423444 workflowId,
424445 status : 'queued' ,
@@ -434,6 +455,7 @@ async function readWorkflowExecutionStatus(
434455 finalOutput : null ,
435456 blockOutputs : null ,
436457 }
458+ return { status, stateExecutionId : executionId }
437459 }
438460
439461 if ( ! logRow ) {
@@ -442,7 +464,12 @@ async function readWorkflowExecutionStatus(
442464 ...input ,
443465 executionId : resumeAttempt . parentExecutionId ,
444466 } )
445- return run ? projectSettledResumeAttempt ( executionId , resumeAttempt , run ) : null
467+ return run
468+ ? {
469+ status : projectSettledResumeAttempt ( executionId , resumeAttempt , run . status ) ,
470+ stateExecutionId : run . stateExecutionId ,
471+ }
472+ : null
446473 }
447474
448475 const [ pausedRow ] = await db
@@ -509,7 +536,10 @@ async function readWorkflowExecutionStatus(
509536 const readsExecutionData =
510537 selectedOutputs . length > 0 || statusesReadingExecutionData ( includeOutput ) . includes ( status )
511538 if ( ! readsExecutionData ) {
512- return { ...resource , error : null , finalOutput : null , blockOutputs : null }
539+ return {
540+ status : { ...resource , error : null , finalOutput : null , blockOutputs : null } ,
541+ stateExecutionId : executionId ,
542+ }
513543 }
514544
515545 const requestedBlockIds = [
@@ -538,7 +568,10 @@ async function readWorkflowExecutionStatus(
538568 ? pickSelectedOutputs ( selectedOutputs , materialized . blockOutputs )
539569 : null
540570
541- return { ...resource , error, finalOutput, blockOutputs }
571+ return {
572+ status : { ...resource , error, finalOutput, blockOutputs } ,
573+ stateExecutionId : executionId ,
574+ }
542575}
543576
544577/** Most pause points a run detail lists; a run over it lists its earliest registered points. */
0 commit comments