MCPcopy Index your code
hub / github.com/TanStack/ai / finishRun

Method finishRun

packages/ai-client/src/devtools.ts:1357–1390  ·  view source on GitHub ↗
(
    runId: string,
    eventType: 'run:completed' | 'run:errored' | 'run:cancelled',
    status: 'completed' | 'errored' | 'cancelled',
    error?: string,
  )

Source from the content-addressed store, hash-verified

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

Callers 4

generateMethod · 0.45
stopMethod · 0.45
generateMethod · 0.45
stopMethod · 0.45

Calls 7

ensureRunStartedMethod · 0.95
completeProgressMethod · 0.95
getProgressMethod · 0.95
upsertRunMethod · 0.95
emitStateMethod · 0.95
nowMethod · 0.80
emitRunLifecycleMethod · 0.45

Tested by

no test coverage detected