mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-08-11 01:13:39 +00:00
fix(ui): handle session created SSE events
Route session.created events through the existing session update handler so sessions emitted by newer OpenCode servers are normalized and stored instead of being logged as unknown SSE events. When a created session is a root session, prepend it to the session pagination id list so the sidebar renders it immediately without waiting for a full session refetch. Child sessions continue to use the existing parent-thread behavior. Validated with npm run typecheck --workspace packages/ui.
This commit is contained in:
parent
8b5ffa1905
commit
a4bd7583dd
2 changed files with 9 additions and 1 deletions
|
|
@ -68,12 +68,15 @@ interface ServerInstanceDisposedEvent {
|
|||
}
|
||||
}
|
||||
|
||||
type EventSessionCreated = Omit<EventSessionUpdated, "type"> & { type: "session.created" }
|
||||
|
||||
type SSEEvent =
|
||||
| MessageUpdateEvent
|
||||
| MessageRemovedEvent
|
||||
| MessagePartUpdatedEvent
|
||||
| MessagePartRemovedEvent
|
||||
| MessagePartDeltaEvent
|
||||
| EventSessionCreated
|
||||
| EventSessionUpdated
|
||||
| EventSessionCompacted
|
||||
| EventSessionError
|
||||
|
|
@ -151,6 +154,9 @@ class SSEManager {
|
|||
case "session.updated":
|
||||
this.onSessionUpdate?.(instanceId, event as EventSessionUpdated)
|
||||
break
|
||||
case "session.created":
|
||||
this.onSessionUpdate?.(instanceId, event as EventSessionUpdated)
|
||||
break
|
||||
case "session.compacted":
|
||||
this.onSessionCompacted?.(instanceId, event as EventSessionCompacted)
|
||||
break
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ import {
|
|||
type SessionRetryState,
|
||||
type SessionStatus,
|
||||
} from "../types/session"
|
||||
import { ensureSessionParentExpanded, sessions, setSessions, syncInstanceSessionIndicator, withSession } from "./session-state"
|
||||
import { ensureSessionParentExpanded, prependSessionListId, sessions, setSessions, syncInstanceSessionIndicator, withSession } from "./session-state"
|
||||
import { normalizeMessagePart } from "./message-v2/normalizers"
|
||||
import { updateSessionInfo } from "./message-v2/session-info"
|
||||
import { tGlobal } from "../lib/i18n"
|
||||
|
|
@ -544,6 +544,8 @@ function handleSessionUpdate(instanceId: string, event: EventSessionUpdated): vo
|
|||
setSessionRevertV2(instanceId, info.id, info.revert ?? null)
|
||||
if (newSession.parentId) {
|
||||
drainAutoAcceptPermissionsForInstance(instanceId)
|
||||
} else {
|
||||
prependSessionListId(instanceId, newSession.id)
|
||||
}
|
||||
|
||||
log.info(`[SSE] New session created: ${info.id}`, newSession)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue