Merge pull request #312 from langflow-ai/feat/new-convo-indicator

properly show new conversations in side nav
This commit is contained in:
Mike Fortman 2025-10-27 13:51:47 -05:00 committed by GitHub
commit d8a8a5c961
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 0 deletions

View file

@ -87,6 +87,7 @@ export function Navigation({
refreshConversations, refreshConversations,
placeholderConversation, placeholderConversation,
setPlaceholderConversation, setPlaceholderConversation,
conversationLoaded,
} = useChat(); } = useChat();
const { loading } = useLoadingStore(); const { loading } = useLoadingStore();
@ -331,6 +332,25 @@ export function Navigation({
setCurrentConversationId, setCurrentConversationId,
]); ]);
useEffect(() => {
let activeConvo;
if (currentConversationId && conversations.length > 0) {
activeConvo = conversations.find(conv => conv.response_id === currentConversationId);
}
if (isOnChatPage) {
if ( conversations.length === 0 && !placeholderConversation) {
handleNewConversation();
} else if (activeConvo && !conversationLoaded) {
loadConversation(activeConvo);
refreshConversations();
} else if ( conversations.length > 0 && currentConversationId === null && !placeholderConversation) {
handleNewConversation();
}
}
}, [isOnChatPage, conversations, conversationLoaded]);
const newConversationFiles = conversationData?.messages const newConversationFiles = conversationData?.messages
.filter( .filter(
(message) => (message) =>

View file

@ -15,6 +15,7 @@ const eslintConfig = [
rules: { rules: {
"@typescript-eslint/no-unused-vars": "warn", "@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"react-hooks/exhaustive-deps": "off",
}, },
}, },
]; ];

View file

@ -63,6 +63,8 @@ interface ChatContextType {
clearConversationDocs: () => void; clearConversationDocs: () => void;
placeholderConversation: ConversationData | null; placeholderConversation: ConversationData | null;
setPlaceholderConversation: (conversation: ConversationData | null) => void; setPlaceholderConversation: (conversation: ConversationData | null) => void;
conversationLoaded: boolean;
setConversationLoaded: (loaded: boolean) => void;
} }
const ChatContext = createContext<ChatContextType | undefined>(undefined); const ChatContext = createContext<ChatContextType | undefined>(undefined);
@ -89,6 +91,7 @@ export function ChatProvider({ children }: ChatProviderProps) {
>([]); >([]);
const [placeholderConversation, setPlaceholderConversation] = const [placeholderConversation, setPlaceholderConversation] =
useState<ConversationData | null>(null); useState<ConversationData | null>(null);
const [conversationLoaded, setConversationLoaded] = useState(false);
// Debounce refresh requests to prevent excessive reloads // Debounce refresh requests to prevent excessive reloads
const refreshTimeoutRef = useRef<NodeJS.Timeout | null>(null); const refreshTimeoutRef = useRef<NodeJS.Timeout | null>(null);
@ -133,6 +136,7 @@ export function ChatProvider({ children }: ChatProviderProps) {
setConversationData(conversation); setConversationData(conversation);
// Clear placeholder when loading a real conversation // Clear placeholder when loading a real conversation
setPlaceholderConversation(null); setPlaceholderConversation(null);
setConversationLoaded(true);
// Clear conversation docs to prevent duplicates when switching conversations // Clear conversation docs to prevent duplicates when switching conversations
setConversationDocs([]); setConversationDocs([]);
}, []); }, []);
@ -143,6 +147,7 @@ export function ChatProvider({ children }: ChatProviderProps) {
setPreviousResponseIds({ chat: null, langflow: null }); setPreviousResponseIds({ chat: null, langflow: null });
setConversationData(null); setConversationData(null);
setConversationDocs([]); setConversationDocs([]);
setConversationLoaded(false);
// Create a temporary placeholder conversation to show in sidebar // Create a temporary placeholder conversation to show in sidebar
const placeholderConversation: ConversationData = { const placeholderConversation: ConversationData = {
@ -214,6 +219,8 @@ export function ChatProvider({ children }: ChatProviderProps) {
clearConversationDocs, clearConversationDocs,
placeholderConversation, placeholderConversation,
setPlaceholderConversation, setPlaceholderConversation,
conversationLoaded,
setConversationLoaded,
}), }),
[ [
endpoint, endpoint,
@ -231,6 +238,8 @@ export function ChatProvider({ children }: ChatProviderProps) {
addConversationDoc, addConversationDoc,
clearConversationDocs, clearConversationDocs,
placeholderConversation, placeholderConversation,
conversationLoaded,
setConversationLoaded,
] ]
); );