(
runId: string,
eventType: 'run:completed' | 'run:errored' | 'run:cancelled',
status: 'completed' | 'errored' | 'cancelled',
error?: string,
)
| 1355 | } |
| 1356 | |
| 1357 | finishRun( |
| 1358 | runId: string, |
| 1359 | eventType: 'run:completed' | 'run:errored' | 'run:cancelled', |
| 1360 | status: 'completed' | 'errored' | 'cancelled', |
| 1361 | error?: string, |
| 1362 | ): void { |
| 1363 | this.ensureRunStarted(runId) |
| 1364 | const completedAt = Date.now() |
| 1365 | const completedProgress = |
| 1366 | status === 'completed' ? this.completeProgress() : this.getProgress() |
| 1367 | const runStatus = |
| 1368 | status === 'completed' |
| 1369 | ? 'success' |
| 1370 | : status === 'errored' |
| 1371 | ? 'error' |
| 1372 | : 'cancelled' |
| 1373 | |
| 1374 | this.upsertRun(runId, { |
| 1375 | status: runStatus, |
| 1376 | isLoading: false, |
| 1377 | progress: completedProgress, |
| 1378 | completedAt, |
| 1379 | ...(error ? { error } : { clearError: true }), |
| 1380 | }) |
| 1381 | |
| 1382 | if (this.activeRunId === runId) { |
| 1383 | this.activeRunId = null |
| 1384 | } |
| 1385 | this.activeRunStarted = false |
| 1386 | this.emitRunLifecycle(eventType, runId, status, { |
| 1387 | ...(error ? { error } : {}), |
| 1388 | }) |
| 1389 | this.emitState() |
| 1390 | } |
| 1391 | |
| 1392 | getActiveRunId(): string | null { |
| 1393 | return this.activeRunId |
no test coverage detected