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.

Enhance Chat Input and Context with File Uploading State

Salman-Ahamede53c618b38de
diff --git a/packages/app/src/react/features/ai-chat/components/input.tsx b/packages/app/src/react/features/ai-chat/components/input.tsx
index 39e5e802..a972aecf 100644
--- a/packages/app/src/react/features/ai-chat/components/input.tsx
+++ b/packages/app/src/react/features/ai-chat/components/input.tsx
@@ -30,10 +30,9 @@ export const ChatInput = () => {
const fileInputRef = useRef<HTMLInputElement>(null);
const { isStreaming, isChatCreating, isProcessing, sendMessage, stopGenerating } = chat || {};
- const { data: files, addFiles, removeFile, clearFiles } = filesData || {};
+ const { data: files, uploadingIds, addFiles, removeFile, clearFiles } = filesData || {};
const maxLength = MAX_CHAT_MESSAGE_LENGTH;
- const isFilesLoading = filesData?.isLoading;
const isMaxFilesUploaded = files.length >= 10;
const isDisabled = isChatCreating || agent.isLoading.agent;
@@ -231,7 +230,7 @@ export const ChatInput = () => {
key={`${fileWithMetadata.id}`}
file={fileWithMetadata}
onRemove={() => handleRemoveFile(index)}
- isUploading={isFilesLoading} // .has(fileWithMetadata.id)
+ isUploading={uploadingIds.has(fileWithMetadata.id)}
/>
))}
</div>
diff --git a/packages/app/src/react/features/ai-chat/contexts/chat.tsx b/packages/app/src/react/features/ai-chat/contexts/chat.tsx
index 5fb53237..e48b5993 100644
--- a/packages/app/src/react/features/ai-chat/contexts/chat.tsx
+++ b/packages/app/src/react/features/ai-chat/contexts/chat.tsx
@@ -14,6 +14,7 @@ export interface IChatContext {
isLoading: boolean;
errorMessage: string;
data: IMessageFile[];
+ uploadingIds: Set<string>;
addFiles: (newFiles: File[]) => Promise<void>;
removeFile: (index: number) => Promise<void>;
clearError: () => void;
@@ -56,6 +57,7 @@ export const ChatContext = createContext<IChatContext>({
data: [],
isLoading: false,
errorMessage: '',
+ uploadingIds: new Set(),
addFiles: async () => {},
removeFile: async () => {},
clearError: () => {},
diff --git a/packages/app/src/react/features/ai-chat/hooks/use-attachments.ts b/packages/app/src/react/features/ai-chat/hooks/use-attachments.ts
index 38101422..7a9d3824 100644
--- a/packages/app/src/react/features/ai-chat/hooks/use-attachments.ts
+++ b/packages/app/src/react/features/ai-chat/hooks/use-attachments.ts
@@ -40,7 +40,7 @@ export const useAttachments = (props: IProps) => {
const addFiles = useCallback(
async (newFiles: File[]) => {
- if (files.length === 0) return;
+ if (newFiles.length === 0) return;
const remainingSlots = FILE_LIMITS.MAX_ATTACHED_FILES - files.length;
if (remainingSlots <= 0) {
@@ -147,6 +147,7 @@ export const useAttachments = (props: IProps) => {
return {
data: files,
isLoading,
+ uploadingIds,
errorMessage,
addFiles,