@@ -7,6 +7,7 @@ import type { Message } from "@/src/lib/db/schema";
77
88 type MessageInputProps = {
99 isLoading: boolean;
10+ isLoadingMessages: boolean;
1011 messages: Message[];
1112 onSubmit: (message: string) => void;
1213 };
@@ -16,7 +17,7 @@ export type MessageInputRef = {
1617 };
1718
1819 const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(
19- ({ isLoading, messages, onSubmit }, ref) => {
20+ ({ isLoading, isLoadingMessages, messages, onSubmit }, ref) => {
2021 const [input, setInput] = useState("");
2122 const [historyIndex, setHistoryIndex] = useState<number | null>(null);
2223 const textareaRef = useRef<HTMLTextAreaElement>(null);
@@ -55,11 +56,13 @@ const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(
5556 textarea.style.height = `${newHeight}px`;
5657 }, [input]);
5758
59+ const isAnyLoading = isLoading || isLoadingMessages;
60+
5861 const handleSubmit = (e?: React.FormEvent) => {
5962 if (e) {
6063 e.preventDefault();
6164 }
62- if (!input.trim() || isLoading) return;
65+ if (!input.trim() || isAnyLoading) return;
6366
6467 const inputValue = input.trim();
6568 onSubmit(inputValue);
@@ -113,15 +116,15 @@ const MessageInput = forwardRef<MessageInputRef, MessageInputProps>(
113116 value={input}
114117 onChange={(e) => setInput(e.target.value)}
115118 onKeyDown={handleKeyDown}
116- placeholder={isLoading ? "Loading answer..." : "Type a message..."}
117- disabled={isLoading}
119+ placeholder={isAnyLoading ? "Loading..." : "Type a message..."}
120+ disabled={isAnyLoading}
118121 rows={3}
119122 className="w-full resize-none overflow-y-auto p-4 pr-12 placeholder:italic placeholder:text-neutral-600 dark:placeholder:text-neutral-400 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 bg-transparent"
120123 />
121124 <div className="absolute bottom-2 right-2">
122- <BasicButton color="neutral" type="submit" disabled={isLoading}>
125+ <BasicButton color="neutral" type="submit" disabled={isAnyLoading}>
123126 <PaperPlaneIcon
124- className={`h-8 w-10 p-1.5 ${isLoading ? "animate-spin-and-color-cycle" : ""}`}
127+ className={`h-8 w-10 p-1.5 ${isAnyLoading ? "animate-spin-and-color-cycle" : ""}`}
125128 />
126129 </BasicButton>
127130 </div>