improve instance launch and log streaming UX
This commit is contained in:
@@ -991,6 +991,10 @@ function isSessionBusy(instanceId: string, sessionId: string): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
function isSessionMessagesLoading(instanceId: string, sessionId: string): boolean {
|
||||
return Boolean(loading().loadingMessages.get(instanceId)?.has(sessionId))
|
||||
}
|
||||
|
||||
async function loadMessages(instanceId: string, sessionId: string, force = false): Promise<void> {
|
||||
// If force reload, clear the loaded cache
|
||||
if (force) {
|
||||
@@ -1834,24 +1838,6 @@ function handleTuiToast(_instanceId: string, event: any): void {
|
||||
})
|
||||
}
|
||||
|
||||
function handleSessionIdle(instanceId: string, event: any): void {
|
||||
const sessionID = event.properties?.sessionID
|
||||
if (!sessionID) return
|
||||
|
||||
const instanceSessions = sessions().get(instanceId)
|
||||
const session = instanceSessions?.get(sessionID)
|
||||
const label = session?.title?.trim() ? session.title : sessionID
|
||||
const instanceFolder = instances().get(instanceId)?.folder ?? instanceId
|
||||
const instanceName = instanceFolder.split(/[\\/]/).filter(Boolean).pop() ?? instanceFolder
|
||||
|
||||
showToastNotification({
|
||||
title: instanceName,
|
||||
message: `Session ${label ? `"${label}"` : sessionID} is idle`,
|
||||
variant: "info",
|
||||
duration: 10000,
|
||||
})
|
||||
}
|
||||
|
||||
sseManager.onMessageUpdate = handleMessageUpdate
|
||||
sseManager.onMessageRemoved = handleMessageRemoved
|
||||
sseManager.onMessagePartRemoved = handleMessagePartRemoved
|
||||
@@ -1859,7 +1845,6 @@ sseManager.onSessionUpdate = handleSessionUpdate
|
||||
sseManager.onSessionCompacted = handleSessionCompacted
|
||||
sseManager.onSessionError = handleSessionError
|
||||
sseManager.onTuiToast = handleTuiToast
|
||||
sseManager.onSessionIdle = handleSessionIdle
|
||||
|
||||
export {
|
||||
sessions,
|
||||
@@ -1889,6 +1874,7 @@ export {
|
||||
getChildSessions,
|
||||
getSessionFamily,
|
||||
isSessionBusy,
|
||||
isSessionMessagesLoading,
|
||||
updateSessionAgent,
|
||||
updateSessionModel,
|
||||
getDefaultModel,
|
||||
|
||||
Reference in New Issue
Block a user