(options?: {
messages?: unknown[]
conversationId?: string
createConversationId?: () => string
isFullscreen?: boolean
onCompactBoundary?: () => void
})
| 26 | } |
| 27 | |
| 28 | function createDeps(options?: { |
| 29 | messages?: unknown[] |
| 30 | conversationId?: string |
| 31 | createConversationId?: () => string |
| 32 | isFullscreen?: boolean |
| 33 | onCompactBoundary?: () => void |
| 34 | }): { |
| 35 | deps: ApplyLocalQueryEventDeps |
| 36 | getMessages: () => unknown[] |
| 37 | getConversationId: () => string |
| 38 | setConversationIdCalls: string[] |
| 39 | removeTranscriptCalls: string[] |
| 40 | } { |
| 41 | const messagesState = createState<unknown[]>(options?.messages ?? []) |
| 42 | const streamModeState = createState<any>('idle') |
| 43 | const streamingToolUsesState = createState<any[]>([]) |
| 44 | |
| 45 | let conversationId = options?.conversationId ?? 'conversation-0' |
| 46 | const setConversationIdCalls: string[] = [] |
| 47 | const removeTranscriptCalls: string[] = [] |
| 48 | let responseLength = 0 |
| 49 | |
| 50 | const deps: ApplyLocalQueryEventDeps = { |
| 51 | setMessages: messagesState.set, |
| 52 | setConversationId: id => { |
| 53 | conversationId = id |
| 54 | setConversationIdCalls.push(id) |
| 55 | }, |
| 56 | createConversationId: options?.createConversationId, |
| 57 | setResponseLength: updater => { |
| 58 | responseLength = updater(responseLength) |
| 59 | }, |
| 60 | setStreamMode: streamModeState.set, |
| 61 | setStreamingToolUses: streamingToolUsesState.set, |
| 62 | removeTranscriptMessage: uuid => { |
| 63 | removeTranscriptCalls.push(uuid) |
| 64 | }, |
| 65 | onCompactBoundary: options?.onCompactBoundary, |
| 66 | isFullscreen: options?.isFullscreen ?? false, |
| 67 | streamAdapter: createTestStreamAdapter(), |
| 68 | } |
| 69 | |
| 70 | return { |
| 71 | deps, |
| 72 | getMessages: messagesState.get, |
| 73 | getConversationId: () => conversationId, |
| 74 | setConversationIdCalls, |
| 75 | removeTranscriptCalls, |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | function createTestStreamAdapter(): LocalStreamMessageAdapter { |
| 80 | return { |
no test coverage detected