mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Handle session.idle event to fix resumed sessions showing as active
This commit is contained in:
1 parent
dc7964021d
commit
8aabb79328
2 files changed
+32
No files matched your search
@@ -116,6 +116,13 @@ export interface SSEInstallationUpdateAvailableEvent {
|
||||
}
|
||||
}
|
||||
|
||||
export interface SSESessionIdleEvent {
|
||||
type: 'session.idle'
|
||||
properties: {
|
||||
sessionID: string
|
||||
}
|
||||
}
|
||||
|
||||
export type SSEEvent =
|
||||
| SSEMessagePartUpdatedEvent
|
||||
| SSEMessageUpdatedEvent
|
||||
@@ -124,6 +131,7 @@ export type SSEEvent =
|
||||
| SSESessionUpdatedEvent
|
||||
| SSESessionDeletedEvent
|
||||
| SSESessionCompactedEvent
|
||||
| SSESessionIdleEvent
|
||||
| SSETodoUpdatedEvent
|
||||
| SSEPermissionUpdatedEvent
|
||||
| SSEPermissionRepliedEvent
|
||||
|
||||
@@ -240,6 +240,30 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
|
||||
break
|
||||
}
|
||||
|
||||
case 'session.idle': {
|
||||
if (!('sessionID' in event.properties)) break
|
||||
|
||||
const { sessionID } = event.properties
|
||||
const currentData = queryClient.getQueryData<MessageListResponse>(['opencode', 'messages', opcodeUrl, sessionID, directory])
|
||||
if (!currentData) break
|
||||
|
||||
const now = Date.now()
|
||||
const updated = currentData.map(msg => {
|
||||
if (msg.info.role !== 'assistant') return msg
|
||||
if ('completed' in msg.info.time && msg.info.time.completed) return msg
|
||||
return {
|
||||
...msg,
|
||||
info: {
|
||||
...msg.info,
|
||||
time: { ...msg.info.time, completed: now }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
queryClient.setQueryData(['opencode', 'messages', opcodeUrl, sessionID, directory], updated)
|
||||
break
|
||||
}
|
||||
|
||||
case 'permission.updated':
|
||||
if ('id' in event.properties) {
|
||||
permissionEvents.emit({ type: 'add', permission: event.properties })
|
||||
|
||||
Reference in new issue
Block a user