Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ui/src/components/AssistantPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,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}`,
Expand Down
10 changes: 10 additions & 0 deletions ui/src/hooks/useConversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ export function useConversation(projectName: string | null, conversationId: numb
queryFn: () => api.getAssistantConversation(projectName!, conversationId!),
enabled: !!projectName && !!conversationId,
staleTime: 30_000, // Cache for 30 seconds
retry: (failureCount, error) => {
// Don't retry on "not found" errors (404) - conversation doesn't exist
if (error instanceof Error && (
error.message.toLowerCase().includes('not found') ||
error.message === 'HTTP 404'
)) {
return false
}
return failureCount < 3
},
})
}

Expand Down