feat(chat-hook): get suggestions when sources is > 0

This commit is contained in:
ItzCrazyKns
2025-09-02 10:42:28 +05:30
parent a268ce345c
commit b0e8a33f1d

View File

@@ -686,15 +686,15 @@ export const ChatProvider = ({
(msg) => msg.messageId === messageId && msg.role === 'user',
);
const sourceMessageIndex = messagesRef.current.findIndex(
const sourceMessage = messagesRef.current.find(
(msg, i) => i > userMessageIndex && msg.role === 'source',
);
) as SourceMessage | undefined;
const suggestionMessageIndex = messagesRef.current.findIndex(
(msg, i) => i > userMessageIndex && msg.role === 'suggestion',
);
if (sourceMessageIndex != -1 && suggestionMessageIndex == -1) {
if (sourceMessage && sourceMessage.sources.length > 0 && suggestionMessageIndex == -1) {
const suggestions = await getSuggestions(messagesRef.current);
setMessages((prev) => {
return [