Live terminal output (#1347)

* Add live terminal output

* Fix scrolling

* Refactor loading

* Fallback to polling if endpoint fails

* Comment

* Move clientId to executionStore
Refactor types

* Remove polling
This commit is contained in:
pythongosssss
2024-11-08 20:38:21 +00:00
committed by GitHub
parent 0161a670cf
commit 7e0b87dd32
7 changed files with 156 additions and 68 deletions

View File

@@ -11,7 +11,8 @@ import {
type User,
type Settings,
type UserDataFullInfo,
validateComfyNodeDef
validateComfyNodeDef,
LogsRawResponse
} from '@/types/apiTypes'
import axios from 'axios'
@@ -202,11 +203,6 @@ class ComfyApi extends EventTarget {
new CustomEvent('status', { detail: msg.data.status })
)
break
case 'progress':
this.dispatchEvent(
new CustomEvent('progress', { detail: msg.data })
)
break
case 'executing':
this.dispatchEvent(
new CustomEvent('executing', {
@@ -214,29 +210,15 @@ class ComfyApi extends EventTarget {
})
)
break
case 'progress':
case 'executed':
this.dispatchEvent(
new CustomEvent('executed', { detail: msg.data })
)
break
case 'execution_start':
this.dispatchEvent(
new CustomEvent('execution_start', { detail: msg.data })
)
break
case 'execution_success':
this.dispatchEvent(
new CustomEvent('execution_success', { detail: msg.data })
)
break
case 'execution_error':
this.dispatchEvent(
new CustomEvent('execution_error', { detail: msg.data })
)
break
case 'execution_cached':
case 'logs':
this.dispatchEvent(
new CustomEvent('execution_cached', { detail: msg.data })
new CustomEvent(msg.type, { detail: msg.data })
)
break
default:
@@ -720,6 +702,17 @@ class ComfyApi extends EventTarget {
return (await axios.get(this.internalURL('/logs'))).data
}
async getRawLogs(): Promise<LogsRawResponse> {
return (await axios.get(this.internalURL('/logs/raw'))).data
}
async subscribeLogs(enabled: boolean): Promise<void> {
return await axios.patch(this.internalURL('/logs/subscribe'), {
enabled,
clientId: this.clientId
})
}
async getFolderPaths(): Promise<Record<string, string[]>> {
return (await axios.get(this.internalURL('/folder_paths'))).data
}