mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Resolve various warnings during export
This commit is contained in:
@@ -260,7 +260,7 @@ function AutomationsCard(props: AutomationsCardProps) {
|
|||||||
const dayOfMonth = getDayOfMonthFromCron(automationData.crontime);
|
const dayOfMonth = getDayOfMonthFromCron(automationData.crontime);
|
||||||
setIntervalString(`Monthly on the ${dayOfMonth}`);
|
setIntervalString(`Monthly on the ${dayOfMonth}`);
|
||||||
}
|
}
|
||||||
}, [updatedAutomationData, props.automation]);
|
}, [updatedAutomationData, automation]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -275,7 +275,7 @@ function AutomationsCard(props: AutomationsCardProps) {
|
|||||||
})
|
})
|
||||||
setToastMessage('');
|
setToastMessage('');
|
||||||
}
|
}
|
||||||
}, [toastMessage]);
|
}, [toastMessage, updatedAutomationData, automation, toast]);
|
||||||
|
|
||||||
if (isDeleted) {
|
if (isDeleted) {
|
||||||
return null;
|
return null;
|
||||||
@@ -955,7 +955,7 @@ export default function Automations() {
|
|||||||
setAllNewAutomations([...allNewAutomations, newAutomationData]);
|
setAllNewAutomations([...allNewAutomations, newAutomationData]);
|
||||||
setNewAutomationData(null);
|
setNewAutomationData(null);
|
||||||
}
|
}
|
||||||
}, [newAutomationData]);
|
}, [newAutomationData, allNewAutomations]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
|
|||||||
@@ -37,26 +37,29 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
const [processingMessage, setProcessingMessage] = useState(false);
|
const [processingMessage, setProcessingMessage] = useState(false);
|
||||||
const [agentMetadata, setAgentMetadata] = useState<AgentData | null>(null);
|
const [agentMetadata, setAgentMetadata] = useState<AgentData | null>(null);
|
||||||
|
|
||||||
|
const setQueryToProcess = props.setQueryToProcess;
|
||||||
|
const onConversationIdChange = props.onConversationIdChange;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const storedMessage = localStorage.getItem("message");
|
const storedMessage = localStorage.getItem("message");
|
||||||
if (storedMessage) {
|
if (storedMessage) {
|
||||||
setProcessingMessage(true);
|
setProcessingMessage(true);
|
||||||
props.setQueryToProcess(storedMessage);
|
setQueryToProcess(storedMessage);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [setQueryToProcess]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (message) {
|
if (message) {
|
||||||
setProcessingMessage(true);
|
setProcessingMessage(true);
|
||||||
props.setQueryToProcess(message);
|
setQueryToProcess(message);
|
||||||
}
|
}
|
||||||
}, [message]);
|
}, [message, setQueryToProcess]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (conversationId) {
|
if (conversationId) {
|
||||||
props.onConversationIdChange?.(conversationId);
|
onConversationIdChange?.(conversationId);
|
||||||
}
|
}
|
||||||
}, [conversationId]);
|
}, [conversationId, onConversationIdChange]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.streamedMessages &&
|
if (props.streamedMessages &&
|
||||||
|
|||||||
@@ -184,6 +184,20 @@ export function modifyFileFilterForConversation(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function createNewConversation(slug: string) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/api/chat/sessions?client=web&agent_slug=${slug}`, { method: "POST" });
|
||||||
|
if (!response.ok) throw new Error(`Failed to fetch chat sessions with status: ${response.status}`);
|
||||||
|
const data = await response.json();
|
||||||
|
const conversationID = data.conversation_id;
|
||||||
|
if (!conversationID) throw new Error("Conversation ID not found in response");
|
||||||
|
return conversationID;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error creating new conversation:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function uploadDataForIndexing(
|
export function uploadDataForIndexing(
|
||||||
files: FileList,
|
files: FileList,
|
||||||
setWarning: (warning: string) => void,
|
setWarning: (warning: string) => void,
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
|||||||
scrollToBottomAfterDataLoad();
|
scrollToBottomAfterDataLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [chatHistoryRef.current, data]);
|
}, [data, currentPage]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!hasMoreMessages || fetchingData) return;
|
if (!hasMoreMessages || fetchingData) return;
|
||||||
@@ -111,7 +111,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, [sentinelRef.current, hasMoreMessages, currentPage, fetchingData]);
|
}, [hasMoreMessages, currentPage, fetchingData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setHasMoreMessages(true);
|
setHasMoreMessages(true);
|
||||||
@@ -160,7 +160,7 @@ export default function ChatHistory(props: ChatHistoryProps) {
|
|||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchMoreMessages = (currentPage: number) => {
|
function fetchMoreMessages(currentPage: number) {
|
||||||
if (!hasMoreMessages || fetchingData) return;
|
if (!hasMoreMessages || fetchingData) return;
|
||||||
const nextPage = currentPage + 1;
|
const nextPage = currentPage + 1;
|
||||||
|
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ export default function ChatInputArea(props: ChatInputProps) {
|
|||||||
startRecordingAndTranscribe();
|
startRecordingAndTranscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [recording]);
|
}, [recording, mediaRecorder]);
|
||||||
|
|
||||||
const chatInputRef = useRef<HTMLTextAreaElement>(null);
|
const chatInputRef = useRef<HTMLTextAreaElement>(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ export default function ChatMessage(props: ChatMessageProps) {
|
|||||||
|
|
||||||
// Sanitize and set the rendered markdown
|
// Sanitize and set the rendered markdown
|
||||||
setMarkdownRendered(DOMPurify.sanitize(markdownRendered));
|
setMarkdownRendered(DOMPurify.sanitize(markdownRendered));
|
||||||
}, [props.chatMessage.message]);
|
}, [props.chatMessage.message, props.chatMessage.intent]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (copySuccess) {
|
if (copySuccess) {
|
||||||
|
|||||||
@@ -74,11 +74,13 @@ export const ModelPicker: React.FC<any> = (props: ModelPickerProps) => {
|
|||||||
|
|
||||||
let userData = useAuthenticatedData();
|
let userData = useAuthenticatedData();
|
||||||
|
|
||||||
|
const setModelUsed = props.setModelUsed;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.setModelUsed && selectedModel) {
|
if (setModelUsed && selectedModel) {
|
||||||
props.setModelUsed(selectedModel);
|
setModelUsed(selectedModel);
|
||||||
}
|
}
|
||||||
}, [selectedModel]);
|
}, [selectedModel, setModelUsed]);
|
||||||
|
|
||||||
if (!models) {
|
if (!models) {
|
||||||
return <div>Loading...</div>;
|
return <div>Loading...</div>;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default function NavMenu() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!initialLoadDone) return;
|
if (!initialLoadDone) return;
|
||||||
toggleDarkMode(darkMode);
|
toggleDarkMode(darkMode);
|
||||||
}, [darkMode]);
|
}, [darkMode, initialLoadDone]);
|
||||||
|
|
||||||
function toggleDarkMode(darkMode: boolean) {
|
function toggleDarkMode(darkMode: boolean) {
|
||||||
if (darkMode) {
|
if (darkMode) {
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ function ChatSessionActionMenu(props: ChatSessionActionMenuProps) {
|
|||||||
setShowShareUrl(true);
|
setShowShareUrl(true);
|
||||||
setIsSharing(false);
|
setIsSharing(false);
|
||||||
}
|
}
|
||||||
}, [isSharing]);
|
}, [isSharing, props.conversationId]);
|
||||||
|
|
||||||
if (isRenaming) {
|
if (isRenaming) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { useAuthenticatedData, UserConfig, useUserConfig } from '@/app/common/au
|
|||||||
import { convertColorToBorderClass } from '@/app/common/colorUtils';
|
import { convertColorToBorderClass } from '@/app/common/colorUtils';
|
||||||
import { getIconFromIconName } from '@/app/common/iconUtils';
|
import { getIconFromIconName } from '@/app/common/iconUtils';
|
||||||
import { AgentData } from '@/app/agents/page';
|
import { AgentData } from '@/app/agents/page';
|
||||||
|
import { createNewConversation } from './common/chatFunctions';
|
||||||
|
|
||||||
|
|
||||||
interface ChatBodyDataProps {
|
interface ChatBodyDataProps {
|
||||||
@@ -32,20 +33,6 @@ interface ChatBodyDataProps {
|
|||||||
isLoadingUserConfig: boolean;
|
isLoadingUserConfig: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createNewConvo(slug: string) {
|
|
||||||
try {
|
|
||||||
const response = await fetch(`/api/chat/sessions?client=web&agent_slug=${slug}`, { method: "POST" });
|
|
||||||
if (!response.ok) throw new Error(`Failed to fetch chat sessions with status: ${response.status}`);
|
|
||||||
const data = await response.json();
|
|
||||||
const conversationID = data.conversation_id;
|
|
||||||
if (!conversationID) throw new Error("Conversation ID not found in response");
|
|
||||||
return conversationID;
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error creating new conversation:", error);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function ChatBodyData(props: ChatBodyDataProps) {
|
function ChatBodyData(props: ChatBodyDataProps) {
|
||||||
const [message, setMessage] = useState('');
|
const [message, setMessage] = useState('');
|
||||||
const [processingMessage, setProcessingMessage] = useState(false);
|
const [processingMessage, setProcessingMessage] = useState(false);
|
||||||
@@ -56,6 +43,8 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
const [agents, setAgents] = useState<AgentData[]>([]);
|
const [agents, setAgents] = useState<AgentData[]>([]);
|
||||||
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
|
||||||
|
|
||||||
|
const onConversationIdChange = props.onConversationIdChange;
|
||||||
|
|
||||||
const agentsFetcher = () => window.fetch('/api/agents').then(res => res.json()).catch(err => console.log(err));
|
const agentsFetcher = () => window.fetch('/api/agents').then(res => res.json()).catch(err => console.log(err));
|
||||||
const { data: agentsData, error } = useSWR<AgentData[]>('agents', agentsFetcher, { revalidateOnFocus: false });
|
const { data: agentsData, error } = useSWR<AgentData[]>('agents', agentsFetcher, { revalidateOnFocus: false });
|
||||||
|
|
||||||
@@ -107,7 +96,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
agent => getIconFromIconName(agent.icon, agent.color) || <Image key={agent.name} src={agent.avatar} alt={agent.name} width={50} height={50} />
|
agent => getIconFromIconName(agent.icon, agent.color) || <Image key={agent.name} src={agent.avatar} alt={agent.name} width={50} height={50} />
|
||||||
);
|
);
|
||||||
setAgentIcons(agentIcons);
|
setAgentIcons(agentIcons);
|
||||||
}, [agentsData]);
|
}, [agentsData, props.isMobileWidth]);
|
||||||
|
|
||||||
function shuffleSuggestionsCards() {
|
function shuffleSuggestionsCards() {
|
||||||
shuffleAndSetOptions();
|
shuffleAndSetOptions();
|
||||||
@@ -118,8 +107,8 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
if (message && !processingMessage) {
|
if (message && !processingMessage) {
|
||||||
setProcessingMessage(true);
|
setProcessingMessage(true);
|
||||||
try {
|
try {
|
||||||
const newConversationId = await createNewConvo(selectedAgent || "khoj");
|
const newConversationId = await createNewConversation(selectedAgent || "khoj");
|
||||||
props.onConversationIdChange?.(newConversationId);
|
onConversationIdChange?.(newConversationId);
|
||||||
window.location.href = `/chat?conversationId=${newConversationId}`;
|
window.location.href = `/chat?conversationId=${newConversationId}`;
|
||||||
localStorage.setItem('message', message);
|
localStorage.setItem('message', message);
|
||||||
}
|
}
|
||||||
@@ -134,7 +123,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
if (message) {
|
if (message) {
|
||||||
setProcessingMessage(true);
|
setProcessingMessage(true);
|
||||||
};
|
};
|
||||||
}, [selectedAgent, message]);
|
}, [selectedAgent, message, processingMessage, onConversationIdChange]);
|
||||||
|
|
||||||
function fillArea(link: string, type: string, prompt: string) {
|
function fillArea(link: string, type: string, prompt: string) {
|
||||||
if (!link) {
|
if (!link) {
|
||||||
|
|||||||
@@ -201,8 +201,6 @@ export default function Search() {
|
|||||||
|
|
||||||
}, [searchQuery]);
|
}, [searchQuery]);
|
||||||
|
|
||||||
console.log('searchResults', searchResults);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={`h-full ${styles.sidePanel}`}>
|
<div className={`h-full ${styles.sidePanel}`}>
|
||||||
|
|||||||
@@ -37,24 +37,26 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
const [processingMessage, setProcessingMessage] = useState(false);
|
const [processingMessage, setProcessingMessage] = useState(false);
|
||||||
const [agentMetadata, setAgentMetadata] = useState<AgentData | null>(null);
|
const [agentMetadata, setAgentMetadata] = useState<AgentData | null>(null);
|
||||||
|
|
||||||
|
const setQueryToProcess = props.setQueryToProcess
|
||||||
|
const streamedMessages = props.streamedMessages;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (message) {
|
if (message) {
|
||||||
setProcessingMessage(true);
|
setProcessingMessage(true);
|
||||||
props.setQueryToProcess(message);
|
setQueryToProcess(message);
|
||||||
}
|
}
|
||||||
}, [message]);
|
}, [message, setQueryToProcess]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("Streamed messages", props.streamedMessages);
|
if (streamedMessages &&
|
||||||
if (props.streamedMessages &&
|
streamedMessages.length > 0 &&
|
||||||
props.streamedMessages.length > 0 &&
|
streamedMessages[streamedMessages.length - 1].completed) {
|
||||||
props.streamedMessages[props.streamedMessages.length - 1].completed) {
|
|
||||||
|
|
||||||
setProcessingMessage(false);
|
setProcessingMessage(false);
|
||||||
} else {
|
} else {
|
||||||
setMessage('');
|
setMessage('');
|
||||||
}
|
}
|
||||||
}, [props.streamedMessages]);
|
}, [streamedMessages]);
|
||||||
|
|
||||||
if (!props.publicConversationSlug && !props.conversationId) {
|
if (!props.publicConversationSlug && !props.conversationId) {
|
||||||
return (
|
return (
|
||||||
@@ -167,7 +169,7 @@ export default function SharedChat() {
|
|||||||
setMessages(prevMessages => [...prevMessages, newStreamMessage]);
|
setMessages(prevMessages => [...prevMessages, newStreamMessage]);
|
||||||
setProcessQuerySignal(true);
|
setProcessQuerySignal(true);
|
||||||
}
|
}
|
||||||
}, [queryToProcess]);
|
}, [queryToProcess, conversationId, paramSlug]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (processQuerySignal) {
|
if (processQuerySignal) {
|
||||||
@@ -251,7 +253,7 @@ export default function SharedChat() {
|
|||||||
setMessages(prevMessages => [...prevMessages, newStreamMessage]);
|
setMessages(prevMessages => [...prevMessages, newStreamMessage]);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, [conversationId]);
|
}, [conversationId, queryToProcess]);
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
|
|||||||
Reference in New Issue
Block a user