Skip to content

Commit ef19cfb

Browse files
committed
fix(sim-cli): name no resume command for a timed pause, which the resume route refuses
1 parent 46b2fdc commit ef19cfb

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

‎packages/sim-cli/src/commands/protocol/workflow-run-get.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe('sim workflows runs get on a paused run', () => {
123123
contextId: 'ctx_1',
124124
pauseKind: 'human',
125125
runId: RUN_ID,
126-
points: [{ contextId: 'ctx_1', status: 'paused' }],
126+
points: [{ contextId: 'ctx_1', kind: 'human', status: 'paused' }],
127127
},
128128
}
129129
answer({ data: run })

‎packages/sim-cli/src/commands/protocol/workflow-run-wait.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ interface RunPayload {
7878
pauseKind?: string | null
7979
resumeAt?: string | null
8080
runId?: string
81-
points?: Array<{ contextId: string; status: string }>
81+
points?: Array<{ contextId: string; kind: string; status: string }>
8282
} | null
8383
}
8484

@@ -157,7 +157,7 @@ describe('workflows runs wait', () => {
157157
pauseKind: 'human',
158158
contextId: 'ctx_9',
159159
runId: 'run_1',
160-
points: [{ contextId: 'ctx_9', status: 'paused' }],
160+
points: [{ contextId: 'ctx_9', kind: 'human', status: 'paused' }],
161161
},
162162
})
163163

@@ -178,7 +178,7 @@ describe('workflows runs wait', () => {
178178
pauseKind: 'human',
179179
contextId: 'ctx_9',
180180
runId: 'exec_9',
181-
points: [{ contextId: 'ctx_9', status: 'paused' }],
181+
points: [{ contextId: 'ctx_9', kind: 'human', status: 'paused' }],
182182
},
183183
})
184184

‎packages/sim-cli/src/runtime/paused-run.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ describe('withResumeNext', () => {
3030
})
3131
})
3232

33+
it('names no command for a timed pause, which resumes on its own', () => {
34+
const timed = { contextId: 'later', kind: 'time', status: 'paused' }
35+
expect(
36+
withResumeNext('executeWorkflow', {
37+
...paused,
38+
paused: { runId: 'run_top', points: [timed, point('ctx_9')] },
39+
})
40+
).toMatchObject({ next: 'sim workflows runs resume run_top --workflow wf_1 --context ctx_9' })
41+
const onlyTimed = { ...paused, paused: { runId: 'run_top', points: [timed] } }
42+
expect(withResumeNext('executeWorkflow', onlyTimed)).toBe(onlyTimed)
43+
})
44+
3345
it('names one command per waiting point, quoting a branch context', () => {
3446
const several = {
3547
...paused,

‎packages/sim-cli/src/runtime/paused-run.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ function resumeCommand(runId: string, workflowId: string, contextId: string): st
2222
}
2323

2424
/**
25-
* The exact `runs resume` command for a paused run record, one line per point still waiting. The
26-
* server names the run to resume in `paused.runId` (for a resumed run that paused again, the run
27-
* it resumed, not the record's own `runId`) and each point's `contextId`. Null when nothing waits
28-
* or an id is not in the format the server issues, so no untrusted text reaches a printed
29-
* command.
25+
* The exact `runs resume` command for a paused run record, one line per human pause still waiting
26+
* (a timed pause resumes on its own, and the resume route refuses it). The server names the run to
27+
* resume in `paused.runId` (for a resumed run that paused again, the run it resumed, not the
28+
* record's own `runId`) and each point's `contextId`. Null when nothing waits or an id is not in
29+
* the format the server issues, so no untrusted text reaches a printed command.
3030
*/
3131
export function resumeCommandFor(
3232
record: Record<string, unknown>,
@@ -37,7 +37,7 @@ export function resumeCommandFor(
3737
if (!issuedId(runId) || !issuedId(workflowId)) return null
3838
const commands: string[] = []
3939
for (const point of Array.isArray(paused?.points) ? paused.points : []) {
40-
if (!isRecordLike(point) || point.status !== 'paused') continue
40+
if (!isRecordLike(point) || point.status !== 'paused' || point.kind !== 'human') continue
4141
if (!issuedId(point.contextId)) return null
4242
commands.push(resumeCommand(runId, workflowId, point.contextId))
4343
}

0 commit comments

Comments
 (0)