MCPcopy Create free account
hub / github.com/tiann/hapi / appendOptimisticMessage

Function appendOptimisticMessage

web/src/lib/message-window-store.ts:1010–1022  ·  view source on GitHub ↗
(sessionId: string, message: DecryptedMessage)

Source from the content-addressed store, hash-verified

1008}
1009
1010export function appendOptimisticMessage(sessionId: string, message: DecryptedMessage): void {
1011 updateState(sessionId, (prev) => {
1012 const merged = mergeMessages(prev.messages, [message])
1013 const { kept, dropped } = trimVisibleWithDropped(merged, 'append')
1014 const pending = filterPendingAgainstVisible(prev.pending, kept)
1015 return buildState(prev, {
1016 messages: kept,
1017 pending,
1018 atBottom: true,
1019 ...cursorUpdatesAfterAppendTrim(kept, dropped)
1020 })
1021 }, true)
1022}
1023
1024export function updateMessageStatus(sessionId: string, localId: string, status: MessageStatus): void {
1025 if (!localId) {

Callers 3

useSendMessageFunction · 0.90
useCancelQueuedMessageFunction · 0.90

Calls 6

mergeMessagesFunction · 0.90
updateStateFunction · 0.85
trimVisibleWithDroppedFunction · 0.85
buildStateFunction · 0.85

Tested by

no test coverage detected