Skip to content

Commit 77ce461

Browse files
authored
fix(resume): capture pause block names and keep the resume page off the execution snapshot (#10104)
* fix(resume): stop shipping the execution snapshot to the resume page * improvement(resume): capture pause block names at pause time and keep display reads off the snapshot
1 parent ac5c50a commit 77ce461

22 files changed

Lines changed: 364 additions & 191 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/(interfaces)/resume/[workflowId]/[executionId]/resume-page-client.tsx‎

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,6 @@ function StatusBadge({ status }: { status: string }) {
106106
)
107107
}
108108

109-
function getBlockNameFromSnapshot(
110-
executionSnapshot: { snapshot?: string } | null | undefined,
111-
blockId: string | undefined
112-
): string | null {
113-
if (!executionSnapshot?.snapshot || !blockId) return null
114-
try {
115-
const parsed = JSON.parse(executionSnapshot.snapshot)
116-
const workflowState = parsed?.workflow
117-
if (!workflowState?.blocks || !Array.isArray(workflowState.blocks)) return null
118-
const block = workflowState.blocks.find((b: { id: string }) => b.id === blockId)
119-
return block?.metadata?.name || null
120-
} catch {
121-
return null
122-
}
123-
}
124-
125109
const DISPLAY_VALUE_PREVIEW_MAX_CHARS = 5000
126110

127111
function truncateForPreview(text: string): { text: string; truncated: boolean } {
@@ -697,13 +681,7 @@ export default function ResumeExecutionPage({
697681
selectedStatus === 'queued' ||
698682
(isHumanMode && hasInputFormat && (!isFormComplete || Object.keys(formErrors).length > 0))
699683

700-
const getBlockName = (pause: PausePointWithQueue) => {
701-
const pauseBlockId = pause.blockId || pause.triggerBlockId
702-
return (
703-
getBlockNameFromSnapshot(executionDetail?.executionSnapshot, pauseBlockId) ||
704-
'Human in the Loop'
705-
)
706-
}
684+
const getBlockName = (pause: PausePointWithQueue) => pause.blockName || 'Human in the Loop'
707685

708686
if (loadingExecution) {
709687
return (

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,23 @@ describe('GET /api/resume/[workflowId]/[executionId]', () => {
121121
expect(response.status).toBe(403)
122122
expect(await response.json()).toEqual({ error: 'Insufficient workspace permissions' })
123123
})
124+
125+
it('reads the execution snapshot unless the resume page opts out', async () => {
126+
await GET(
127+
createMockRequest(
128+
'GET',
129+
undefined,
130+
{},
131+
'http://localhost/api/resume/workflow-1/execution-1?includeSnapshot=false'
132+
),
133+
createRouteContext(params)
134+
)
135+
for (const { call } of routeCases) await call()
136+
137+
expect(mocks.execute.mock.calls.map(([call]) => call.input.includeSnapshot)).toEqual([
138+
false,
139+
true,
140+
true,
141+
])
142+
})
124143
})

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export const GET = defineInternalJsonRoute({
1515
reason: 'Preserve existing authenticated resume-detail behavior',
1616
}),
1717
errorPolicy: internalWorkflowErrorPolicies.concealWorkflowAuthorization,
18-
mapInput: ({ params }) => ({
18+
mapInput: ({ params, query }) => ({
1919
workflowId: params.workflowId,
2020
executionId: params.executionId,
21+
includeSnapshot: query.includeSnapshot,
2122
}),
2223
useCase: readPausedWorkflowExecution,
2324
responseHeaders: () => ({ 'Cache-Control': 'private, no-store' }),

‎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,

0 commit comments

Comments
 (0)