mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-03-19 20:03:08 +00:00
Merge pull request #105 from nioasoft/fix/assistant-conversation-404-handling
fix: handle 404 errors for deleted assistant conversations
This commit is contained in:
@@ -50,11 +50,23 @@ export function AssistantPanel({ projectName, isOpen, onClose }: AssistantPanelP
|
||||
)
|
||||
|
||||
// Fetch conversation details when we have an ID
|
||||
const { data: conversationDetail, isLoading: isLoadingConversation } = useConversation(
|
||||
const { data: conversationDetail, isLoading: isLoadingConversation, error: conversationError } = useConversation(
|
||||
projectName,
|
||||
conversationId
|
||||
)
|
||||
|
||||
// Clear stored conversation ID if it no longer exists (404 error)
|
||||
useEffect(() => {
|
||||
if (conversationError && conversationId) {
|
||||
const message = conversationError.message.toLowerCase()
|
||||
// Only clear for 404 errors, not transient network issues
|
||||
if (message.includes('not found') || message.includes('404')) {
|
||||
console.warn(`Conversation ${conversationId} not found, clearing stored ID`)
|
||||
setConversationId(null)
|
||||
}
|
||||
}
|
||||
}, [conversationError, conversationId])
|
||||
|
||||
// Convert API messages to ChatMessage format for the chat component
|
||||
const initialMessages: ChatMessage[] | undefined = conversationDetail?.messages.map((msg) => ({
|
||||
id: `db-${msg.id}`,
|
||||
|
||||
Reference in New Issue
Block a user