Skip to content

The Open Standard for Generative UI

export shell components

abhishek3aa5f0474a43
diff --git a/frontend-sdk/packages/react-ui/src/components/Shell/Thread.tsx b/frontend-sdk/packages/react-ui/src/components/Shell/Thread.tsx
index 356b3b341..fb93e13a2 100644
--- a/frontend-sdk/packages/react-ui/src/components/Shell/Thread.tsx
+++ b/frontend-sdk/packages/react-ui/src/components/Shell/Thread.tsx
@@ -70,13 +70,7 @@ export const AssistantMessageContainer = ({
return (
<div className={clsx("crayon-shell-thread-message-assistant", className)}>
<img src={logoUrl} alt="Assistant" className="crayon-shell-thread-message-assistant__logo" />
- <div
- className={clsx({
- "crayon-shell-thread-message-assistant__text": typeof children === "string",
- })}
- >
- {children}
- </div>
+ <div>{children}</div>
</div>
);
};
@@ -100,18 +94,24 @@ export const RenderMessage = ({ message, className }: { message: Message; classN
const MessageContainer =
message.role === "user" ? UserMessageContainer : AssistantMessageContainer;
- if (message.role === "assistant" && message.responseTemplate) {
- const Template = responseTemplates[message.responseTemplate.name];
-
- const Fallback = responseTemplates["fallback"]?.Component || FallbackTemplate;
-
+ if (message.role === "assistant") {
return (
<MessageContainer className={className}>
- {Template ? (
- <Template.Component {...message.responseTemplate.templateProps} />
- ) : (
- <Fallback {...message.responseTemplate.templateProps} />
- )}
+ {message.message?.map((stringOrTemplate) => {
+ if (typeof stringOrTemplate === "string") {
+ return (
+ <div className="crayon-shell-thread-message-assistant__text">{stringOrTemplate}</div>
+ );
+ }
+
+ const Template = responseTemplates[stringOrTemplate.name];
+ const Fallback = responseTemplates["fallback"]?.Component || FallbackTemplate;
+ return Template ? (
+ <Template.Component {...stringOrTemplate.templateProps} />
+ ) : (
+ <Fallback />
+ );
+ })}
</MessageContainer>
);
}
diff --git a/frontend-sdk/packages/react-ui/src/components/Shell/index.ts b/frontend-sdk/packages/react-ui/src/components/Shell/index.ts
index e69de29bb..965b55090 100644
--- a/frontend-sdk/packages/react-ui/src/components/Shell/index.ts
+++ b/frontend-sdk/packages/react-ui/src/components/Shell/index.ts
@@ -0,0 +1,6 @@
+export * from "./Container";
+export * from "./MobileHeader";
+export * from "./Sidebar";
+export * from "./store";
+export * from "./Thread";
+export * from "./ThreadList";
diff --git a/frontend-sdk/packages/react-ui/src/components/Shell/stories/Shell.stories.tsx b/frontend-sdk/packages/react-ui/src/components/Shell/stories/Shell.stories.tsx
index 5e4fa6554..f049cd9ba 100644
--- a/frontend-sdk/packages/react-ui/src/components/Shell/stories/Shell.stories.tsx
+++ b/frontend-sdk/packages/react-ui/src/components/Shell/stories/Shell.stories.tsx
@@ -65,7 +65,7 @@ export const Default = {
id: crypto.randomUUID(),
role: "assistant",
type: "response",
- message: "Hello",
+ message: ["Hello"],
},
];
},
@@ -80,7 +80,7 @@ export const Default = {
id: crypto.randomUUID(),
role: "assistant",
type: "response",
- message: "sadfasdf",
+ message: ["sadfasdf"],
},
];
},