Show sent messages before the server confirms them

The composer now puts the bubble and clears the input as soon as you send, so a slow connection never holds either. The bot's status row reads "<name> is getting your message..." until the saved message arrives (by response or push), then switches to thinking. A failed send removes the bubble and restores the text and files.
This commit is contained in:
2026-10-20 14:50:20 +01:00
parent 4f7e0a6bf0
commit 8425631b3a
9 changed files with 323 additions and 42 deletions
@@ -104,10 +104,28 @@ export default function useComposerAttachments({ bot_id, workspace_id }: Params)
setPending((prev) => prev.filter((item) => item.key != key));
};
/**
* Puts files already uploaded back, after a send that didn't make it.
*/
const restore = ({ attachments }: { attachments: BotMessageAttachment[] }) => {
if (!attachments.length) return;
setPending((prev) => [
...prev,
...attachments.map((attachment) => ({
key: `restored-${attachment.id}-${Date.now()}`,
name: attachment.name,
status: "ready" as const,
attachment,
})),
]);
};
return {
pending,
add,
remove,
restore,
clear: () => {
revoke({ items: pending });
setPending([]);