Skip to content

Commit 9958b00

Browse files
committed
improvement(resume): capture pause block names at pause time and keep display reads off the snapshot
1 parent e0b95cc commit 9958b00

20 files changed

Lines changed: 311 additions & 259 deletions

File tree

‎apps/docs/openapi-core.json‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,16 @@
638638
"type": "string",
639639
"example": "e4f8d2b6-9a1c-4e3d-8b7f-5c0a2d9e6f13"
640640
}
641+
},
642+
{
643+
"name": "includeSnapshot",
644+
"in": "query",
645+
"required": false,
646+
"description": "Whether to include `executionSnapshot`, which carries every block's output and can be large. Defaults to `true`.",
647+
"schema": {
648+
"type": "boolean",
649+
"default": true
650+
}
641651
}
642652
],
643653
"responses": {
@@ -1792,6 +1802,10 @@
17921802
"type": "string",
17931803
"description": "The block ID where execution paused."
17941804
},
1805+
"blockName": {
1806+
"type": "string",
1807+
"description": "Name of the paused block as the run executed it. Absent for a point paused before names were recorded whose run had no deployment version."
1808+
},
17951809
"response": {
17961810
"description": "Data returned by the block before pausing, including display data and form fields."
17971811
},
@@ -1949,7 +1963,7 @@
19491963
"properties": {
19501964
"executionSnapshot": {
19511965
"type": "object",
1952-
"description": "Serialized execution state for resumption.",
1966+
"description": "Serialized execution state for resumption. Omitted when the resume path is read with `includeSnapshot=false`.",
19531967
"properties": {
19541968
"snapshot": {
19551969
"type": "string",

‎apps/docs/openapi-v2-workflows.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16140,7 +16140,7 @@
1614016140
"type": "null"
1614116141
}
1614216142
],
16143-
"description": "Name of the block in the deployment version the run executed, or null for a manual run or when the version no longer exists."
16143+
"description": "Name of the block as the run executed it. Null only for a point paused before names were recorded whose run was manual or whose deployment version no longer exists."
1614416144
},
1614516145
"kind": {
1614616146
"type": "string",

‎apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('ResumeExecutionPageWrapper', () => {
6464

6565
expect(mocks.authorize).toHaveBeenCalledWith({
6666
principal: createSessionPrincipal(),
67-
input: PAGE_PARAMS,
67+
input: { ...PAGE_PARAMS, includeSnapshot: false },
6868
})
6969
expect(result.props).toMatchObject({
7070
params: PAGE_PARAMS,

‎apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/page.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default async function ResumeExecutionPageWrapper({
5353
userId: session.user.id,
5454
sessionId: session.session.id,
5555
},
56-
input: { workflowId, executionId },
56+
input: { workflowId, executionId, includeSnapshot: false },
5757
})
5858
} catch (error) {
5959
const classified = asOrchestrationError(error)

‎apps/sim/app/api/resume/[workflowId]/[executionId]/route.test.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ describe('GET /api/resume/[workflowId]/[executionId]', () => {
122122
expect(await response.json()).toEqual({ error: 'Insufficient workspace permissions' })
123123
})
124124

125-
it('leaves the execution snapshot out only when the resume page asks', async () => {
126-
const pageRead = await GET(
125+
it('reads the execution snapshot unless the resume page opts out', async () => {
126+
await GET(
127127
createMockRequest(
128128
'GET',
129129
undefined,
@@ -132,11 +132,12 @@ describe('GET /api/resume/[workflowId]/[executionId]', () => {
132132
),
133133
createRouteContext(params)
134134
)
135-
const apiRead = await GET(request(), createRouteContext(params))
135+
for (const { call } of routeCases) await call()
136136

137-
const pageBody = await pageRead.json()
138-
expect(pageBody).not.toHaveProperty('executionSnapshot')
139-
expect(pageBody.pausePoints).toEqual(detail.pausePoints)
140-
expect((await apiRead.json()).executionSnapshot).toEqual(detail.executionSnapshot)
137+
expect(mocks.execute.mock.calls.map(([call]) => call.input.includeSnapshot)).toEqual([
138+
false,
139+
true,
140+
true,
141+
])
141142
})
142143
})

‎apps/sim/app/api/resume/[workflowId]/[executionId]/route.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { omit } from '@sim/utils/object'
21
import { resumeWorkflowExecutionContract } from '@/lib/api/contracts/workflows'
32
import { defineInternalJsonRoute, internalRateLimits } from '@/lib/api/server/routes'
43
import { internalWorkflowErrorPolicies, internalWorkflowReadAuth } from '@/lib/workflows/api'
@@ -23,8 +22,8 @@ export const GET = defineInternalJsonRoute({
2322
}),
2423
useCase: readPausedWorkflowExecution,
2524
responseHeaders: () => ({ 'Cache-Control': 'private, no-store' }),
26-
present: (executionDetail, { input }) => ({
27-
...(input.includeSnapshot ? executionDetail : omit(executionDetail, ['executionSnapshot'])),
25+
present: (executionDetail) => ({
26+
...executionDetail,
2827
pausePoints: executionDetail.pausePoints.map((pausePoint) => ({ ...pausePoint })),
2928
queue: executionDetail.queue.map((queueEntry) => ({ ...queueEntry })),
3029
}),

‎apps/sim/app/api/workflows/[id]/paused/[executionId]/route.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const GET = defineInternalJsonRoute({
1818
mapInput: ({ params }) => ({
1919
workflowId: params.id,
2020
executionId: params.executionId,
21+
includeSnapshot: true,
2122
}),
2223
useCase: readPausedWorkflowExecution,
2324
responseHeaders: () => ({ 'Cache-Control': 'private, no-store' }),

‎apps/sim/executor/execution/engine.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ describe('ExecutionEngine', () => {
413413
expect(nodeOrchestrator.executeNode).toHaveBeenCalledWith(context, 'both')
414414
})
415415

416-
it('records paused block completion before returning paused result', async () => {
416+
it('records paused block completion and the paused block name before returning paused result', async () => {
417417
const node = createMockNode('hitl', 'function')
418418
const dag = createMockDAG([node])
419419
const context = createMockContext({
@@ -441,6 +441,9 @@ describe('ExecutionEngine', () => {
441441
const result = await engine.run('hitl')
442442

443443
expect(result.status).toBe('paused')
444+
expect(result.pausePoints).toEqual([
445+
expect.objectContaining({ contextId: 'pause-1', blockId: 'hitl', blockName: 'Block hitl' }),
446+
])
444447
expect(nodeOrchestrator.handleNodeCompletion).toHaveBeenCalledWith(
445448
context,
446449
'hitl',

‎apps/sim/executor/execution/engine.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ export class ExecutionEngine {
657657
...capturePauseDisplay(pause, registry),
658658
contextId: pause.contextId,
659659
blockId: pause.blockId,
660+
blockName: this.dag.nodes.get(pause.blockId)?.block.metadata?.name,
660661
response: pause.response,
661662
registeredAt: pause.timestamp,
662663
resumeStatus: 'paused' as ResumeStatus,

‎apps/sim/executor/types.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ export type ResumeStatus = 'paused' | 'resumed' | 'failed' | 'queued' | 'resumin
8181
export interface PausePoint {
8282
contextId: string
8383
blockId?: string
84+
/**
85+
* The paused block's name as the run executed it, recorded when the pause is captured.
86+
* Points persisted before names were recorded lack it; readers name those from the run's
87+
* deployment version instead of the execution snapshot.
88+
*/
89+
blockName?: string
8490
response: any
8591
registeredAt: string
8692
resumeStatus: ResumeStatus

0 commit comments

Comments
 (0)