Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Refactor Chats component to improve structure and readability by consolidating message rendering logic and adjusting class names for better layout management.

Salman-Ahamed08fcd1db20b0
diff --git a/packages/app/src/react/features/ai-chat/components/chats.tsx b/packages/app/src/react/features/ai-chat/components/chats.tsx
index 1204d855..d54b6f5a 100644
--- a/packages/app/src/react/features/ai-chat/components/chats.tsx
+++ b/packages/app/src/react/features/ai-chat/components/chats.tsx
@@ -56,36 +56,34 @@ export const Chats: FC<MessagesProps> = (props) => {
className="w-full h-full overflow-auto relative scroll-smooth mt-16 flex justify-center items-center"
>
<div
- className="w-full h-full max-w-4xl"
+ ref={ref}
onScroll={handleScroll}
- ref={combineRefs(containerRef, dropzoneRef)}
+ className="w-full h-full max-w-4xl flex-1 pb-4 space-y-6 px-2.5"
>
- <div className="w-full flex-1 pb-4 space-y-6 px-2.5" ref={ref}>
- {messages.map((message, i) => {
- const isLast = i === messages.length - 1;
- const onRetryClick = message.isError && isLast ? retryLastMessage : undefined;
- const retry = isRetrying && isLast;
+ {messages.map((message, i) => {
+ const isLast = i === messages.length - 1;
+ const onRetryClick = message.isError && isLast ? retryLastMessage : undefined;
+ const retry = isRetrying && isLast;
- return (
- <div key={i}>
- <Chat
- {...message}
- avatar={avatar}
- isRetrying={retry}
- isError={message.isError}
- onRetryClick={onRetryClick}
- scrollToBottom={smartScrollToBottom}
- />
+ return (
+ <div key={i}>
+ <Chat
+ {...message}
+ avatar={avatar}
+ isRetrying={retry}
+ isError={message.isError}
+ onRetryClick={onRetryClick}
+ scrollToBottom={smartScrollToBottom}
+ />
- {retry && (
- <button onClick={retryLastMessage} className="pt-1.5">
- Retry
- </button>
- )}
- </div>
- );
- })}
- </div>
+ {retry && (
+ <button onClick={retryLastMessage} className="pt-1.5">
+ Retry
+ </button>
+ )}
+ </div>
+ );
+ })}
</div>
</div>
);