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: standardize className handling across AI chat components

Salman-Ahamedbc249ed3ab26
diff --git a/packages/app/src/react/features/ai-chat/components/chat/markdown-renderer.tsx b/packages/app/src/react/features/ai-chat/components/chat/markdown-renderer.tsx
index 45f3093a..40c7ca71 100644
--- a/packages/app/src/react/features/ai-chat/components/chat/markdown-renderer.tsx
+++ b/packages/app/src/react/features/ai-chat/components/chat/markdown-renderer.tsx
@@ -3,12 +3,10 @@ import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { CodeBlock } from '@react/features/ai-chat/components';
+import { TClassName, TMessageProps } from '@react/features/ai-chat/types';
import { cn } from '@react/shared/utils/general';
-type TProps = {
- message: string;
- className?: string;
-};
+type TProps = TClassName & TMessageProps;
export const MarkdownRenderer: FC<TProps> = ({ message, className }) => {
return (
diff --git a/packages/app/src/react/features/ai-chat/components/common/icons.tsx b/packages/app/src/react/features/ai-chat/components/common/icons.tsx
index c497645e..5f30e0a1 100644
--- a/packages/app/src/react/features/ai-chat/components/common/icons.tsx
+++ b/packages/app/src/react/features/ai-chat/components/common/icons.tsx
@@ -1,6 +1,7 @@
+import { TClassName } from '@react/features/ai-chat/types';
import { cn } from '@react/shared/utils/general';
-export const ArrowLeftIcon = ({ className }: { className?: string }) => (
+export const ArrowLeftIcon = ({ className }: TClassName) => (
<svg
className={cn('size-5', className)}
fill="none"
@@ -13,13 +14,13 @@ export const ArrowLeftIcon = ({ className }: { className?: string }) => (
</svg>
);
-export const CloseIcon = ({ className }: { className?: string }) => (
+export const CloseIcon = ({ className }: TClassName) => (
<svg className={cn('size-6', className)} fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M6 18L18 6M6 6l12 12" />
</svg>
);
-export const AttachmentIcon = ({ className }: { className?: string }) => (
+export const AttachmentIcon = ({ className }: TClassName) => (
<svg
className={cn('w-[17px] h-4', className)}
viewBox="0 0 17 16"
@@ -38,7 +39,7 @@ export const AttachmentIcon = ({ className }: { className?: string }) => (
</svg>
);
-export const SendIcon = ({ className }: { className?: string }) => (
+export const SendIcon = ({ className }: TClassName) => (
<svg
className={cn('size-4', className)}
viewBox="0 0 16 16"
@@ -55,7 +56,7 @@ export const SendIcon = ({ className }: { className?: string }) => (
);
// Info circle icon
-export const InfoIcon = ({ className }: { className?: string }) => (
+export const InfoIcon = ({ className }: TClassName) => (
<svg
width="20"
height="20"
@@ -75,7 +76,7 @@ export const InfoIcon = ({ className }: { className?: string }) => (
);
/** Retry/refresh icon (circular arrow) */
-export const RetryIcon = ({ className }: { className?: string }) => (
+export const RetryIcon = ({ className }: TClassName) => (
<svg
width="20"
height="20"
diff --git a/packages/app/src/react/features/ai-chat/components/footer/upload-menu.tsx b/packages/app/src/react/features/ai-chat/components/footer/upload-menu.tsx
index b478f599..6bb5c89c 100644
--- a/packages/app/src/react/features/ai-chat/components/footer/upload-menu.tsx
+++ b/packages/app/src/react/features/ai-chat/components/footer/upload-menu.tsx
@@ -1,29 +1,30 @@
import { FC, useCallback, useEffect, useRef, useState } from 'react';
+import { TClassName } from '@react/features/ai-chat/types';
import { Camera, Paperclip } from 'lucide-react';
-interface MenuItem {
+type TMenuItem = {
id: string;
label: string;
shortcut?: string;
- icon: FC<{ className?: string }>;
+ icon: FC<TClassName>;
onClick: () => void;
-}
+};
-interface UploadMenuProps {
+type TProps = {
isOpen: boolean;
onClose: () => void;
onAddFiles: () => void;
onTakeScreenshot: () => void;
triggerRef: React.RefObject<HTMLButtonElement | null>;
-}
-export const UploadMenu: FC<UploadMenuProps> = (props) => {
+};
+export const UploadMenu: FC<TProps> = (props) => {
const { isOpen, onClose, onAddFiles, onTakeScreenshot, triggerRef } = props;
const menuRef = useRef<HTMLDivElement>(null);
const [isVisible, setIsVisible] = useState(false);
- const menuItems: MenuItem[] = [
+ const menuItems: TMenuItem[] = [
{
id: 'add-files',
label: 'Add files or photos',
diff --git a/packages/app/src/react/features/ai-chat/components/header/model-dropdown/provider-icon.tsx b/packages/app/src/react/features/ai-chat/components/header/model-dropdown/provider-icon.tsx
index 7eb2f71f..9e65a5b1 100644
--- a/packages/app/src/react/features/ai-chat/components/header/model-dropdown/provider-icon.tsx
+++ b/packages/app/src/react/features/ai-chat/components/header/model-dropdown/provider-icon.tsx
@@ -1,13 +1,13 @@
import { FC, useState } from 'react';
import { cn } from '@react/shared/utils/general';
+import { TClassName } from '@react/features/ai-chat/types';
-interface IProps {
+type TProps = TClassName & {
provider: string;
- className?: string;
-}
+};
-export const ProviderIcon: FC<IProps> = ({ provider, className = 'size-5 rounded-full' }) => {
+export const ProviderIcon: FC<TProps> = ({ provider, className = 'size-5 rounded-full' }) => {
const [hasError, setHasError] = useState<boolean>(false);
if (hasError) {
diff --git a/packages/app/src/react/features/ai-chat/components/skeleton.tsx b/packages/app/src/react/features/ai-chat/components/skeleton.tsx
index e6227b55..1b421359 100644
--- a/packages/app/src/react/features/ai-chat/components/skeleton.tsx
+++ b/packages/app/src/react/features/ai-chat/components/skeleton.tsx
@@ -1,7 +1,8 @@
+import { TClassName } from '@react/features/ai-chat/types';
import { cn } from '@react/shared/utils/general';
import { FC } from 'react';
-export const Skeleton: FC<{ className?: string }> = ({ className }) => (
+export const Skeleton: FC<TClassName> = ({ className }) => (
<div
className={cn(
'bg-gradient-to-r from-slate-200 via-slate-300 to-slate-200 animate-pulse',
diff --git a/packages/app/src/react/features/ai-chat/types/common.ts b/packages/app/src/react/features/ai-chat/types/common.ts
index f6292ebe..b262f9b0 100644
--- a/packages/app/src/react/features/ai-chat/types/common.ts
+++ b/packages/app/src/react/features/ai-chat/types/common.ts
@@ -1,2 +1,3 @@
export type TChildren = { children: React.ReactNode };
+export type TClassName = { className?: string };
export type TMessageProps = { message: string };