Skip to content

Commit 686848e

Browse files
committed
fix(mothership): find a detached workflows run behind global CLI flags
1 parent 5db7961 commit 686848e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎apps/sim/lib/mothership/async-runs/repository.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,14 @@ describe('the workflow run a settled call left running', () => {
476476
).toBe('run-1')
477477
})
478478

479+
it('is a workflows run behind global flags', () => {
480+
expect(
481+
detachedWorkflowExecutionId(
482+
cli(['--output', 'json', 'workflows', 'run', 'wf-1', '--wait-timeout', '240'], 4, running)
483+
)
484+
).toBe('run-1')
485+
})
486+
479487
it('is a workflow tool answered still running', () => {
480488
expect(
481489
detachedWorkflowExecutionId({

‎apps/sim/lib/mothership/async-runs/repository.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,11 @@ export function detachedWorkflowExecutionId(call: {
19481948
if (call.executableName === 'sim_cli') {
19491949
const request = toRecordOrNull(toRecordOrNull(call.args)?.request)
19501950
const argv = toRecordOrNull(request?.invocation)?.argv
1951-
if (!Array.isArray(argv) || argv[0] !== 'workflows' || argv[1] !== 'run') return undefined
1951+
// The command path, wherever global flags (`--output json`) put it, never `workflows runs`.
1952+
const end = Array.isArray(argv) && argv.includes('--') ? argv.indexOf('--') : undefined
1953+
const tokens = Array.isArray(argv) ? argv.slice(0, end) : []
1954+
if (!tokens.some((token, index) => token === 'workflows' && tokens[index + 1] === 'run'))
1955+
return undefined
19521956
if (result.exitCode !== 4 || typeof result.stdout !== 'string') return undefined
19531957
try {
19541958
const record = toRecordOrNull(JSON.parse(result.stdout))

0 commit comments

Comments
 (0)