mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Type terminal Chat source generations by their owner
This commit is contained in:
+4
-4
@@ -10,7 +10,7 @@ import { mergeOne, sortForImageNormalization } from './native-chat-session-assem
|
||||
|
||||
export type IncrementalChatAssembler = {
|
||||
/** Changes whenever the published list is not an extension of its previous prefix. */
|
||||
generation: object
|
||||
generation: symbol
|
||||
byId: Map<string, NativeChatMessage>
|
||||
byTurn: Map<string, NativeChatMessage>
|
||||
// Last emitted sorted output; stable reference until a mutation occurs.
|
||||
@@ -18,7 +18,7 @@ export type IncrementalChatAssembler = {
|
||||
}
|
||||
|
||||
export function createIncrementalAssembler(): IncrementalChatAssembler {
|
||||
return { generation: {}, byId: new Map(), byTurn: new Map(), messages: [] }
|
||||
return { generation: Symbol(), byId: new Map(), byTurn: new Map(), messages: [] }
|
||||
}
|
||||
|
||||
/** Reset from a windowed base using the canonical transcript-only assembly path. */
|
||||
@@ -31,7 +31,7 @@ export function reset(
|
||||
for (const message of base) {
|
||||
mergeOne(assembler.byId, assembler.byTurn, message)
|
||||
}
|
||||
assembler.generation = {}
|
||||
assembler.generation = Symbol()
|
||||
assembler.messages = [...sortForImageNormalization(Array.from(assembler.byId.values()))]
|
||||
return assembler.messages
|
||||
}
|
||||
@@ -59,7 +59,7 @@ export function applyAppends(
|
||||
return assembler.messages
|
||||
}
|
||||
|
||||
assembler.generation = {}
|
||||
assembler.generation = Symbol()
|
||||
assembler.messages = [...sortForImageNormalization(Array.from(assembler.byId.values()))]
|
||||
return assembler.messages
|
||||
}
|
||||
|
||||
+4
-1
@@ -48,7 +48,10 @@ export function useNativeChatAssembledMessages(args: {
|
||||
}): {
|
||||
assembledMessages: NativeChatMessage[]
|
||||
normalizedMessages: NativeChatMessage[]
|
||||
sourceObservation: { messages: readonly NativeChatMessage[]; generation: object }
|
||||
sourceObservation: {
|
||||
messages: readonly NativeChatMessage[]
|
||||
generation: IncrementalChatAssembler['generation']
|
||||
}
|
||||
} {
|
||||
const committedCacheRef = useRef<AssemblyCache | null>(null)
|
||||
const { agent, sessionId, baseMessages, appended } = args
|
||||
|
||||
+7
-2
@@ -1,4 +1,5 @@
|
||||
import type { AgentType } from '../../../../../../../shared/agent-status/contracts/agent-status-types'
|
||||
import type { IncrementalChatAssembler } from '../assembly/native-chat-incremental-assembler'
|
||||
import { releaseNativeChatReceiptDependencies } from '../../../../../../../shared/native-chat/transcript/native-chat-pending-witnesses'
|
||||
import {
|
||||
nativeChatSourcePosition,
|
||||
@@ -27,7 +28,11 @@ type PendingOwner = {
|
||||
pending: NativeChatPendingSend[]
|
||||
boundary?: NativeChatSourceBoundary
|
||||
sessionId?: string
|
||||
search?: { generation: object; length: number; found: boolean }
|
||||
search?: {
|
||||
generation: IncrementalChatAssembler['generation']
|
||||
length: number
|
||||
found: boolean
|
||||
}
|
||||
}
|
||||
const pendingSendCache = new Map<string, PendingOwner>()
|
||||
let pendingSendCounter = 0
|
||||
@@ -56,7 +61,7 @@ export function observePendingSendCache(
|
||||
scope: NativeChatPendingSendScope,
|
||||
messages: readonly NativeChatMessage[],
|
||||
sessionId: string,
|
||||
generation?: object
|
||||
generation?: IncrementalChatAssembler['generation']
|
||||
): void {
|
||||
const key = pendingSendScopeKey(scope)
|
||||
const owner = pendingSendCache.get(key) ?? { pending: [] }
|
||||
|
||||
+5
-1
@@ -5,6 +5,7 @@ import type {
|
||||
NativeChatTurnLifecycle
|
||||
} from '../../../../../../../shared/native-chat/native-chat-types'
|
||||
import type { NativeChatOlderPageResult } from '../../../viewport/history/native-chat-pagination'
|
||||
import type { IncrementalChatAssembler } from '../assembly/native-chat-incremental-assembler'
|
||||
|
||||
export type ReadState =
|
||||
| { phase: 'loading' }
|
||||
@@ -20,7 +21,10 @@ export function isNativeChatTranscriptUnsettled(phase: ReadState['phase']): bool
|
||||
|
||||
export type NativeChatLiveSession = NativeChatSession & {
|
||||
/** Canonical source publication paired with its append/reset provenance, before display folding. */
|
||||
sourceObservation?: { messages: readonly NativeChatMessage[]; generation: object }
|
||||
sourceObservation?: {
|
||||
messages: readonly NativeChatMessage[]
|
||||
generation: IncrementalChatAssembler['generation']
|
||||
}
|
||||
/** Latest provider turn boundary, used to settle orphaned running tool rows. */
|
||||
transcriptLifecycle?: NativeChatTurnLifecycle
|
||||
/** Hook-reported human wait not yet ended by the transcript; absent on hookless lanes. */
|
||||
|
||||
Reference in New Issue
Block a user