(action: SetStateAction<unknown[]>)
| 276 | let state: Snapshot = { messages: [], streamingText: null } |
| 277 | |
| 278 | const setMessages = (action: SetStateAction<unknown[]>) => { |
| 279 | const nextMessages = |
| 280 | typeof action === 'function' |
| 281 | ? (action as (prev: unknown[]) => unknown[])(state.messages) |
| 282 | : action |
| 283 | |
| 284 | const messagesChanged = nextMessages !== state.messages |
| 285 | const nextStreamingText = |
| 286 | messagesChanged && state.streamingText !== null ? null : state.streamingText |
| 287 | |
| 288 | state = { |
| 289 | messages: nextMessages, |
| 290 | streamingText: nextStreamingText, |
| 291 | } |
| 292 | history.push({ ...state }) |
| 293 | } |
| 294 | |
| 295 | const onStreamingText = (f: (current: string | null) => string | null) => { |
| 296 | const next = f(state.streamingText) |
no outgoing calls
no test coverage detected