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 and Footer Components for Improved Structure and Clarity

Salman-Ahameddb67f87da009
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 a2b44e2c..29403fc5 100644
--- a/packages/app/src/react/features/ai-chat/components/chats.tsx
+++ b/packages/app/src/react/features/ai-chat/components/chats.tsx
@@ -26,15 +26,12 @@ const combineRefs =
export const Chats: FC = () => {
const { ref: allRefs, agent: agentData, chat, files, scroll } = useChatStores() || {};
+ const { messages, isStreaming, retryMessage } = chat || {};
+ const { handleScroll, smartScrollToBottom, shouldAutoScroll } = scroll || {};
+
const agent = agentData?.data;
const containerRef = allRefs?.container;
const handleFileDrop = files.addFiles;
- const { messages, isStreaming, retryMessage } = chat || {};
-
- // ============================================================================
- // SCROLL BEHAVIOR
- // ============================================================================
- const { handleScroll, smartScrollToBottom, shouldAutoScroll } = scroll || {};
const ref = useRef<HTMLDivElement>(null);
const dropzoneRef = useDragAndDrop({ onDrop: handleFileDrop });
diff --git a/packages/app/src/react/features/ai-chat/components/footer.tsx b/packages/app/src/react/features/ai-chat/components/footer.tsx
index aa896eef..759091c3 100644
--- a/packages/app/src/react/features/ai-chat/components/footer.tsx
+++ b/packages/app/src/react/features/ai-chat/components/footer.tsx
@@ -6,9 +6,10 @@ const CHAT_WARNING_INFO =
"SmythOS can make mistakes, always check your work. We don't store chat history, save important work."; // eslint-disable-line quotes
export const Footer: FC = () => {
- const { files, scroll } = useChatStores();
- const { errorMessage, clearError } = files || {};
- const { showScrollButton, scrollToBottom } = scroll || {};
+ const {
+ files: { errorMessage, clearError },
+ scroll: { showScrollButton, scrollToBottom },
+ } = useChatStores();
return (
<div className="w-full max-w-4xl pt-2.5">
diff --git a/packages/app/src/react/shared/types/chat.types.ts b/packages/app/src/react/shared/types/chat.types.ts
deleted file mode 100644
index 4f1ab318..00000000
--- a/packages/app/src/react/shared/types/chat.types.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-export interface FileMetadata {
- key?: string;
- publicUrl?: string;
- fileType?: string;
- previewUrl?: string;
- isUploading?: boolean;
-}
-
-export interface FileWithMetadata {
- file: File;
- metadata: FileMetadata;
- id: string;
-}
-
-export interface IChatMessage {
- me: boolean;
- message: string;
- type?: 'user' | 'system' | 'thinking';
- avatar?: string;
- isReplying?: boolean;
- isError?: boolean;
- isFirstMessage?: boolean;
- files?: FileWithMetadata[];
- hideMessage?: boolean;
- statusMessage?: string; // Inline thinking message to show with system messages
- isLast?: boolean; // Whether this is the last message in the chat
- isRetrying?: boolean; // Whether this message is being retried
- onRetryClick?: () => void; // Function to call when retry is clicked
-}