improve instance launch and log streaming UX

This commit is contained in:
Shantur Rathore
2025-11-09 02:06:05 +00:00
parent 9bba0aad8a
commit 47f3948aec
7 changed files with 296 additions and 65 deletions

View File

@@ -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,