From ba13852514b06ab94666f00807cf23c80d809652 Mon Sep 17 00:00:00 2001 From: Greg Richardson Date: Mon, 9 Dec 2024 18:01:17 -0700 Subject: [PATCH] feat: add back message animation --- apps/web/components/chat-message.tsx | 1 + apps/web/components/chat.tsx | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/apps/web/components/chat-message.tsx b/apps/web/components/chat-message.tsx index dfb3f79..3136ded 100644 --- a/apps/web/components/chat-message.tsx +++ b/apps/web/components/chat-message.tsx @@ -35,6 +35,7 @@ function ChatMessage({ message, isLast }: ChatMessageProps) { return ( + {' '} + {/* + * This is a hidden dummy message acting as an animation anchor + * before the real message is added to the chat. + * + * The animation starts in this element's position and moves over to + * the location of the real message after submit. + * + * It works by sharing the same `layoutId` between both message elements + * which framer motion requires to animate between them. + */} + {input && ( + + {input} + + )}