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')
| 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. */ |
| 73 | function 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 | |
| 97 | function findMessageByLocalId( |
| 98 | sessionId: string, |