diff --git a/src/components/RoadmapAIChat/RoadmapAIChat.tsx b/src/components/RoadmapAIChat/RoadmapAIChat.tsx
index 0f84f8a82..08b0449a7 100644
--- a/src/components/RoadmapAIChat/RoadmapAIChat.tsx
+++ b/src/components/RoadmapAIChat/RoadmapAIChat.tsx
@@ -220,7 +220,9 @@ export function RoadmapAIChat(props: RoadmapAIChatProps) {
return;
}
- const jsx = await renderMessage(content, renderer);
+ const jsx = await renderMessage(content, renderer, {
+ isLoading: true,
+ });
flushSync(() => {
setStreamedMessage(jsx);
@@ -233,7 +235,9 @@ export function RoadmapAIChat(props: RoadmapAIChatProps) {
return;
}
- const jsx = await renderMessage(content, renderer);
+ const jsx = await renderMessage(content, renderer, {
+ isLoading: false,
+ });
const newMessages: RoamdapAIChatHistoryType[] = [
...messages,
{
diff --git a/src/components/RoadmapAIChat/UserProgressActionList.tsx b/src/components/RoadmapAIChat/UserProgressActionList.tsx
index cc84fe22a..3a76c91ce 100644
--- a/src/components/RoadmapAIChat/UserProgressActionList.tsx
+++ b/src/components/RoadmapAIChat/UserProgressActionList.tsx
@@ -69,10 +69,11 @@ type BulkUpdateResourceProgressResponse = {
type UserProgressActionListProps = {
roadmapId: string;
content: string;
+ isLoading?: boolean;
};
export function UserProgressActionList(props: UserProgressActionListProps) {
- const { roadmapId, content } = props;
+ const { roadmapId, content, isLoading = false } = props;
const toast = useToast();
const updateUserProgress = parseUserProgress(content);
@@ -157,12 +158,19 @@ export function UserProgressActionList(props: UserProgressActionListProps) {
diff --git a/src/lib/render-chat-message.tsx b/src/lib/render-chat-message.tsx
index a4fa9a629..9810e2a74 100644
--- a/src/lib/render-chat-message.tsx
+++ b/src/lib/render-chat-message.tsx
@@ -10,16 +10,24 @@ type MessagePart = {
type MessagePartRendererProps = {
content: string;
+ isLoading?: boolean;
};
export type MessagePartRenderer = (
props: MessagePartRendererProps,
) => React.ReactNode | string;
+export type MessagePartRendererOptions = {
+ isLoading?: boolean;
+};
+
export async function parseMessageParts(
content: string,
renderer: Record,
-): Promise {
+ options: MessagePartRendererOptions = {
+ isLoading: false,
+ },
+) {
const parts: MessagePart[] = [];
const regex = /<([a-zA-Z0-9\-]+)>(.*?)<\/\1>/gs;
@@ -46,7 +54,10 @@ export async function parseMessageParts(
});
}
- const output = renderer[tag]({ content: innerContent });
+ const output = renderer[tag]({
+ content: innerContent,
+ isLoading: options.isLoading,
+ });
parts.push({
id: nanoid(),
type: 'html',
@@ -81,7 +92,10 @@ export async function parseMessageParts(
}
const innerContent = content.slice(openingIndex + openingTag.length);
- const output = renderer[tag]({ content: innerContent });
+ const output = renderer[tag]({
+ content: innerContent,
+ isLoading: options.isLoading,
+ });
parts.push({
id: nanoid(),
type: 'html',
@@ -109,8 +123,11 @@ export async function parseMessageParts(
export async function renderMessage(
content: string,
renderer: Record,
+ options: MessagePartRendererOptions = {
+ isLoading: false,
+ },
) {
- const parts = await parseMessageParts(content, renderer);
+ const parts = await parseMessageParts(content, renderer, options);
return (