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

Function createOptimisticMessage

web/src/hooks/mutations/useSendMessage.ts:73–95  ·  view source on GitHub ↗

Create an optimistic message for display. Extracted as an extension point * so a future floating-UI PR can route queued messages to a separate area.

(input: SendMessageInput, status: 'queued' | 'sending')

Source from the content-addressed store, hash-verified

71/** Create an optimistic message for display. Extracted as an extension point
72 * so a future floating-UI PR can route queued messages to a separate area. */
73function createOptimisticMessage(input: SendMessageInput, status: 'queued' | 'sending'): DecryptedMessage {
74 return {
75 id: input.localId,
76 seq: null,
77 localId: input.localId,
78 content: {
79 role: 'user',
80 content: {
81 type: 'text',
82 text: input.text,
83 attachments: input.attachments
84 }
85 },
86 createdAt: input.createdAt,
87 // Explicit null so the strict-null queued check matches. A pre-V8 hub
88 // response that omits the field entirely (`undefined`) is treated as
89 // already-invoked and stays in the thread, not the floating bar.
90 invokedAt: null,
91 scheduledAt: input.scheduledAt ?? null,
92 status,
93 originalText: input.text,
94 }
95}
96
97function findMessageByLocalId(
98 sessionId: string,

Callers 1

useSendMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected