@@ -16,6 +16,11 @@ import { SystemResources } from "./systems.js";
1616/** Chunk size for fetching waitpoints to avoid NAPI string conversion limits */
1717const WAITPOINT_CHUNK_SIZE = 100 ;
1818
19+ /** Waitpoint with optional completedByTaskRun info including taskIdentifier */
20+ type WaitpointWithTaskRun = Waitpoint & {
21+ completedByTaskRun : { taskIdentifier : string } | null ;
22+ } ;
23+
1924export type ExecutionSnapshotSystemOptions = {
2025 resources : SystemResources ;
2126 heartbeatTimeouts : HeartbeatTimeouts ;
@@ -57,7 +62,7 @@ function enhanceExecutionSnapshot(
5762 */
5863function enhanceExecutionSnapshotWithWaitpoints (
5964 snapshot : ExecutionSnapshotWithCheckpoint ,
60- waitpoints : Waitpoint [ ] ,
65+ waitpoints : WaitpointWithTaskRun [ ] | Waitpoint [ ] ,
6166 completedWaitpointOrder : string [ ]
6267) : EnhancedExecutionSnapshot {
6368 return {
@@ -78,6 +83,11 @@ function enhanceExecutionSnapshotWithWaitpoints(
7883 indexes . push ( undefined ) ;
7984 }
8085
86+ // Extract taskIdentifier from completedByTaskRun if available
87+ const taskIdentifier = 'completedByTaskRun' in w && w . completedByTaskRun
88+ ? w . completedByTaskRun . taskIdentifier
89+ : undefined ;
90+
8191 return indexes . map ( ( index ) => {
8292 return {
8393 id : w . id ,
@@ -89,22 +99,23 @@ function enhanceExecutionSnapshotWithWaitpoints(
8999 w . userProvidedIdempotencyKey && ! w . inactiveIdempotencyKey ? w . idempotencyKey : undefined ,
90100 completedByTaskRun : w . completedByTaskRunId
91101 ? {
92- id : w . completedByTaskRunId ,
93- friendlyId : RunId . toFriendlyId ( w . completedByTaskRunId ) ,
94- batch : snapshot . batchId
95- ? {
96- id : snapshot . batchId ,
97- friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
98- }
99- : undefined ,
100- }
102+ id : w . completedByTaskRunId ,
103+ friendlyId : RunId . toFriendlyId ( w . completedByTaskRunId ) ,
104+ taskIdentifier,
105+ batch : snapshot . batchId
106+ ? {
107+ id : snapshot . batchId ,
108+ friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
109+ }
110+ : undefined ,
111+ }
101112 : undefined ,
102113 completedAfter : w . completedAfter ?? undefined ,
103114 completedByBatch : w . completedByBatchId
104115 ? {
105- id : w . completedByBatchId ,
106- friendlyId : BatchId . toFriendlyId ( w . completedByBatchId ) ,
107- }
116+ id : w . completedByBatchId ,
117+ friendlyId : BatchId . toFriendlyId ( w . completedByBatchId ) ,
118+ }
108119 : undefined ,
109120 output : w . output ?? undefined ,
110121 outputType : w . outputType ,
@@ -137,14 +148,19 @@ async function getSnapshotWaitpointIds(
137148async function fetchWaitpointsInChunks (
138149 prisma : PrismaClientOrTransaction ,
139150 waitpointIds : string [ ]
140- ) : Promise < Waitpoint [ ] > {
151+ ) : Promise < WaitpointWithTaskRun [ ] > {
141152 if ( waitpointIds . length === 0 ) return [ ] ;
142153
143- const allWaitpoints : Waitpoint [ ] = [ ] ;
154+ const allWaitpoints : WaitpointWithTaskRun [ ] = [ ] ;
144155 for ( let i = 0 ; i < waitpointIds . length ; i += WAITPOINT_CHUNK_SIZE ) {
145156 const chunk = waitpointIds . slice ( i , i + WAITPOINT_CHUNK_SIZE ) ;
146157 const waitpoints = await prisma . waitpoint . findMany ( {
147158 where : { id : { in : chunk } } ,
159+ include : {
160+ completedByTaskRun : {
161+ select : { taskIdentifier : true } ,
162+ } ,
163+ } ,
148164 } ) ;
149165 allWaitpoints . push ( ...waitpoints ) ;
150166 }
@@ -233,19 +249,19 @@ export function executionDataFromSnapshot(snapshot: EnhancedExecutionSnapshot):
233249 } ,
234250 batch : snapshot . batchId
235251 ? {
236- id : snapshot . batchId ,
237- friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
238- }
252+ id : snapshot . batchId ,
253+ friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
254+ }
239255 : undefined ,
240256 checkpoint : snapshot . checkpoint
241257 ? {
242- id : snapshot . checkpoint . id ,
243- friendlyId : snapshot . checkpoint . friendlyId ,
244- type : snapshot . checkpoint . type ,
245- location : snapshot . checkpoint . location ,
246- imageRef : snapshot . checkpoint . imageRef ,
247- reason : snapshot . checkpoint . reason ?? undefined ,
248- }
258+ id : snapshot . checkpoint . id ,
259+ friendlyId : snapshot . checkpoint . friendlyId ,
260+ type : snapshot . checkpoint . type ,
261+ location : snapshot . checkpoint . location ,
262+ imageRef : snapshot . checkpoint . imageRef ,
263+ reason : snapshot . checkpoint . reason ?? undefined ,
264+ }
249265 : undefined ,
250266 completedWaitpoints : snapshot . completedWaitpoints ,
251267 } ;
0 commit comments