This commit is contained in:
2026-06-10 07:55:16 +08:00
parent 821eca9f0c
commit aaac7e9d98
31 changed files with 548 additions and 149 deletions
+5 -1
View File
@@ -11,6 +11,7 @@ export type StreamStatus = 'idle' | 'connecting' | 'streaming' | 'closed' | 'err
export interface UseRunStreamReturn {
status: Ref<StreamStatus>
runStatus: Ref<RunState>
exitCode: Ref<number | null>
logs: Ref<LogLine[]>
reconnect: () => void
close: () => void
@@ -24,11 +25,13 @@ interface WireFrame {
text?: string
ts?: string
status?: RunState
exit_code?: number
}
export function useRunStream(profileId: string): UseRunStreamReturn {
const status = ref<StreamStatus>('idle')
const runStatus = ref<RunState>('stopped')
const exitCode = ref<number | null>(null)
const logs = ref<LogLine[]>([])
const lastLogID = ref(0)
@@ -62,6 +65,7 @@ export function useRunStream(profileId: string): UseRunStreamReturn {
if (parsed.kind === 'state') {
if (parsed.status) runStatus.value = parsed.status
exitCode.value = parsed.exit_code ?? null
return
}
if (parsed.kind === 'slow_consumer_disconnect') {
@@ -124,5 +128,5 @@ export function useRunStream(profileId: string): UseRunStreamReturn {
connect()
onScopeDispose(close)
return { status, runStatus, logs, reconnect, close, clear }
return { status, runStatus, exitCode, logs, reconnect, close, clear }
}