Structure SSE update patches

This commit is contained in:
weishu
2026-05-21 10:44:46 +08:00
parent 2e1e2d39db
commit 41f6b37d69
10 changed files with 162 additions and 145 deletions
+18 -2
View File
@@ -1,8 +1,24 @@
import type { Machine } from '../types/api'
function getLastSpawnError(runnerState: unknown): { message: string; at?: number } | null {
if (!runnerState || typeof runnerState !== 'object' || Array.isArray(runnerState)) {
return null
}
const lastSpawnError = (runnerState as { lastSpawnError?: unknown }).lastSpawnError
if (!lastSpawnError || typeof lastSpawnError !== 'object' || Array.isArray(lastSpawnError)) {
return null
}
const message = (lastSpawnError as { message?: unknown }).message
if (typeof message !== 'string' || message.length === 0) {
return null
}
const at = (lastSpawnError as { at?: unknown }).at
return typeof at === 'number' ? { message, at } : { message }
}
export function formatRunnerSpawnError(machine: Machine | null): string | null {
const lastSpawnError = machine?.runnerState?.lastSpawnError
if (!lastSpawnError?.message) {
const lastSpawnError = getLastSpawnError(machine?.runnerState)
if (!lastSpawnError) {
return null
}