mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-02-02 07:23:35 +00:00
fix: improve 404 detection for deleted conversations
- Check for 'not found' message (server response) in addition to '404' - Only clear stored conversation ID on actual 404 errors - Prevent unnecessary retries for deleted conversations - Don't clear conversation on transient network errors Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,8 +57,12 @@ export function AssistantPanel({ projectName, isOpen, onClose }: AssistantPanelP
|
|||||||
// Clear stored conversation ID if it no longer exists (404 error)
|
// Clear stored conversation ID if it no longer exists (404 error)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (conversationError && conversationId) {
|
if (conversationError && conversationId) {
|
||||||
console.warn(`Conversation ${conversationId} not found, clearing stored ID`)
|
const message = conversationError.message.toLowerCase()
|
||||||
setConversationId(null)
|
// 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])
|
}, [conversationError, conversationId])
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,11 @@ export function useConversation(projectName: string | null, conversationId: numb
|
|||||||
enabled: !!projectName && !!conversationId,
|
enabled: !!projectName && !!conversationId,
|
||||||
staleTime: 30_000, // Cache for 30 seconds
|
staleTime: 30_000, // Cache for 30 seconds
|
||||||
retry: (failureCount, error) => {
|
retry: (failureCount, error) => {
|
||||||
// Don't retry on 404 errors (conversation doesn't exist)
|
// Don't retry on "not found" errors (404) - conversation doesn't exist
|
||||||
if (error instanceof Error && error.message.includes('404')) {
|
if (error instanceof Error && (
|
||||||
|
error.message.toLowerCase().includes('not found') ||
|
||||||
|
error.message === 'HTTP 404'
|
||||||
|
)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return failureCount < 3
|
return failureCount < 3
|
||||||
|
|||||||
Reference in New Issue
Block a user