| 396 | const receivedMessageUuidsOrder: UUID[] = [] |
| 397 | |
| 398 | function trackReceivedMessageUuid(uuid: UUID): boolean { |
| 399 | if (receivedMessageUuids.has(uuid)) { |
| 400 | return false // duplicate |
| 401 | } |
| 402 | receivedMessageUuids.add(uuid) |
| 403 | receivedMessageUuidsOrder.push(uuid) |
| 404 | // Evict oldest entries when at capacity |
| 405 | if (receivedMessageUuidsOrder.length > MAX_RECEIVED_UUIDS) { |
| 406 | const toEvict = receivedMessageUuidsOrder.splice( |
| 407 | 0, |
| 408 | receivedMessageUuidsOrder.length - MAX_RECEIVED_UUIDS, |
| 409 | ) |
| 410 | for (const old of toEvict) { |
| 411 | receivedMessageUuids.delete(old) |
| 412 | } |
| 413 | } |
| 414 | return true // new UUID |
| 415 | } |
| 416 | |
| 417 | type PromptValue = string | ContentBlockParam[] |
| 418 | |