Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/actions.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -278,7 +278,7 @@ async function submit(formData?: FormData, skip?: boolean) {
};
} catch (err: any) {
console.error('Failed to parse files or initialize resolution search:', err);
const errorStream = createStreamableValue<string>(`Failed to perform resolution search: ${err?.message || 'Invalid parameters.'}`);
const errorStream = createStreamableValue<string>('Failed to perform resolution search. Please try again.');
errorStream.done();
isGenerating.done(false);
uiStream.done();
Expand Down
6 changes: 4 additions & 2 deletions components/chat-share.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,8 @@ export function ChatShare({ chatId, className }: ChatShareProps) {
setEmailInput('')
fetchParticipants()
} catch (err: any) {
toast.error(err.message || 'Error inviting collaborator')
console.error('Failed to add collaborator:', err)
toast.error('Unable to invite collaborator. Please check the details and try again.')
}
})
}
Expand All@@ -93,7 +94,8 @@ export function ChatShare({ chatId, className }: ChatShareProps) {
toast.success('Collaborator removed')
fetchParticipants()
} catch (err: any) {
toast.error(err.message || 'Error removing collaborator')
console.error('Failed to remove collaborator:', err)
toast.error('Unable to remove collaborator. Please try again.')
}
}

Expand Down
3 changes: 2 additions & 1 deletion components/clear-history.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,7 +48,8 @@ export function ClearHistory({ empty }: ClearHistoryProps) {
startTransition(async () => {
const result = await clearChats()
if (result?.error) {
toast.error(result.error)
console.error('Clear history error:', result.error)
toast.error('Unable to clear history. Please try again.')
} else {
toast.success('History cleared')
}
Expand Down
14 changes: 10 additions & 4 deletions components/copilot-optimized.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,15 +96,21 @@ export const Copilot: React.FC<CopilotProps> = React.memo(({ inquiry }: CopilotP
onFormSubmit(e as unknown as React.FormEvent<HTMLFormElement>, true)
}, [onFormSubmit])

useEffect(() => {
if (error) {
console.error('Copilot inquiry error:', error)
}
}, [error])

// OPTIMIZATION: Memoize error card
const errorCard = useMemo(() => {
if (!error) return null;
return (
<Card className="p-4 w-full flex justify-between items-center">
<Card className="p-4 w-full flex justify-between items-center border-destructive/20 bg-destructive/10">
<div className="flex items-center space-x-2">
<Sparkles className="w-4 h-4" />
<h5 className="text-muted-foreground text-xs truncate">
{`error: ${error}`}
<Sparkles className="w-4 h-4 text-destructive" />
<h5 className="text-destructive text-xs truncate font-mono">
An error occurred during inquiry generation. Please try again.
</h5>
</div>
</Card>
Expand Down
14 changes: 10 additions & 4 deletions components/copilot.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,15 +96,21 @@ export const Copilot: React.FC<CopilotProps> = React.memo(({ inquiry }: CopilotP
onFormSubmit(e as unknown as React.FormEvent<HTMLFormElement>, true)
}, [onFormSubmit])

useEffect(() => {
if (error) {
console.error('Copilot inquiry error:', error)
}
}, [error])

// OPTIMIZATION: Memoize error card
const errorCard = useMemo(() => {
if (!error) return null;
return (
<Card className="p-4 w-full flex justify-between items-center">
<Card className="p-4 w-full flex justify-between items-center border-destructive/20 bg-destructive/10">
<div className="flex items-center space-x-2">
<Sparkles className="w-4 h-4" />
<h5 className="text-muted-foreground text-xs truncate">
{`error: ${error}`}
<Sparkles className="w-4 h-4 text-destructive" />
<h5 className="text-destructive text-xs truncate font-mono">
An error occurred during inquiry generation. Please try again.
</h5>
</div>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion components/download-report-button.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,7 @@ export const DownloadReportButton = () => {
toast.success('Report generated successfully', { id: toastId })
} catch (error) {
console.error('Failed to generate report:', error)
toast.error(`Report generation failed: ${error instanceof Error ? error.message : 'Unknown error'}`, { id: toastId })
toast.error('Report generation failed. Please try again.', { id: toastId })
} finally {
setIsGenerating(false)
setShowTemplate(false)
Expand Down
16 changes: 15 additions & 1 deletion components/message.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,11 +8,25 @@ import remarkMath from 'remark-math'
import rehypeKatex from 'rehype-katex'
import 'katex/dist/katex.min.css'

import { useEffect } from 'react'

export function BotMessage({ content }: { content: StreamableValue<string> }) {
const [data, error, pending] = useStreamableValue(content)

useEffect(() => {
if (error) {
console.error('BotMessage stream error:', error)
}
}, [error])

// Currently, sometimes error occurs after finishing the stream.
if (error) return <div>Error</div>
if (error) {
return (
<div className="text-destructive font-mono text-xs bg-destructive/10 p-3 rounded-lg border border-destructive/20 my-2">
An error occurred while generating the response. Please try again.
</div>
)
}

//modify the content to render LaTeX equations
const processedData = preprocessLaTeX(data || '')
Expand Down
3 changes: 2 additions & 1 deletion components/settings/components/settings.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,10 +150,11 @@ export function Settings({ initialTab = "system-prompt" }: SettingsProps) {
description: "Your settings have been saved successfully.",
})
} catch (error: any) {
console.error("Failed to save settings:", error)
// Error notification
toast({
title: "Something went wrong",
description: error.message || "Your settings could not be saved. Please try again.",
description: "Your settings could not be saved. Please try again.",
variant: "destructive",
})
} finally {
Expand Down
6 changes: 4 additions & 2 deletions components/settings/components/system-prompt-form.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,9 +34,10 @@ export function SystemPromptForm({ form }: SystemPromptFormProps) {
const result = await startSystemPromptGeneration(domain)

if (result.error) {
console.error("System prompt generation initiation error:", result.error)
toast({
title: "Generation failed",
description: result.error,
description: "An error occurred starting prompt generation. Please try again.",
variant: "destructive",
})
setIsGenerating(false)
Expand DownExpand Up@@ -69,12 +70,13 @@ export function SystemPromptForm({ form }: SystemPromptFormProps) {
const job = await getSystemPromptGenerationJob(jobId)

if (job.error || job.status === 'error') {
console.error("System prompt generation job error:", job.errorMessage || job.error)
if (interval) clearInterval(interval)
setJobId(null)
setIsGenerating(false)
toast({
title: "Generation error",
description: job.errorMessage || job.error || "An error occurred during generation.",
description: "An error occurred during prompt generation. Please try again.",
variant: "destructive",
})
} else if (job.status === 'complete') {
Expand Down
5 changes: 3 additions & 2 deletions components/settings/components/user-management-form.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,8 +49,9 @@ export function UserManagementForm({ form }: UserManagementFormProps) {
const result = await addUser({ email: newUserEmail, role: newUserRole as UserRole });

if (result.error) {
toast({ title: 'Error adding user', description: result.error, variant: 'destructive' });
form.setError("newUserEmail", { type: "manual", message: result.error });
console.error("Add user server error:", result.error);
toast({ title: 'Error adding user', description: 'Failed to add user. Please check the details and try again.', variant: 'destructive' });
form.setError("newUserEmail", { type: "manual", message: "Failed to add user." });
} else if (result.user) {
toast({ title: 'User Added', description: `${result.user.email} was successfully added.` });
append({
Expand Down
17 changes: 5 additions & 12 deletions components/sidebar/chat-history-client.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,13 +63,9 @@ export function ChatHistoryClient({}: ChatHistoryClientProps) {
const data: { chats: DrizzleChat[], nextOffset: number | null } = await response.json();
setChats(data.chats);
} catch (err) {
if (err instanceof Error) {
setError(err.message);
toast.error(`Error fetching chats: ${err.message}`);
} else {
setError('An unknown error occurred.');
toast.error('Error fetching chats: An unknown error occurred.');
}
console.error('Failed to fetch chats:', err);
setError('Failed to load chat history.');
toast.error('Unable to fetch chat history. Please try again.');
} finally {
setIsLoading(false);
}
Expand DownExpand Up@@ -97,11 +93,8 @@ export function ChatHistoryClient({}: ChatHistoryClientProps) {
setIsAlertDialogOpen(false);
router.refresh();
} catch (err) {
if (err instanceof Error) {
toast.error(err.message);
} else {
toast.error('An unknown error occurred while clearing history.');
}
console.error('Failed to clear chat history:', err);
toast.error('Unable to clear history. Please try again.');
setIsAlertDialogOpen(false);
}
});
Expand Down
3 changes: 2 additions & 1 deletion components/skyfi-section.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,14 +36,15 @@ export function SkyfiSection({ result }: SkyfiSectionProps) {

// Handle stream error explicitly
if (error) {
console.error('SkyFi tool execution error:', error)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

1. Render repeatedly logs errors 🐞 Bug◔ Observability

SkyfiSection calls console.error directly during render, so once the stream has failed every
subsequent render emits the same error again and can flood or obscure the diagnostic console. The
other changed stream consumers log on error transitions with useEffect, which avoids this
duplication.
Agent Prompt
## Issue description
`SkyfiSection` logs stream errors during render, causing duplicate log entries whenever the component rerenders with the same error.
## Issue Context
Move the diagnostic side effect out of the render branch and trigger it only when `error` changes, matching the other stream-rendering components in this PR.
## Fix Focus Areas
- components/skyfi-section.tsx[16-39]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

return (
<div>
<Section size="sm" className="pt-2 pb-0">
<ToolBadge tool="skyfiQueryTool">{`SkyFi MCP Error`}</ToolBadge>
</Section>
<Section title="Error Details">
<div className="text-destructive font-mono text-xs bg-destructive/10 p-3 rounded-lg border border-destructive/20">
{(error as any).message || String(error)}
An error occurred while communicating with SkyFi. Please try again later.
</div>
</Section>
</div>
Expand Down
6 changes: 4 additions & 2 deletions lib/agents/tools/retrieve.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,10 +42,12 @@ export const retrieveTool = ({ uiStream, fullResponse }: ToolProps) => ({
hasError = true
console.error('Retrieve API error:', error)

fullResponse += `\n${error} "${url}".`
fullResponse += `\nAn error occurred while retrieving content from "${url}".`

uiStream.update(
<Card className="p-4 mt-2 text-sm">{`${error} "${url}".`}</Card>
<Card className="p-4 mt-2 text-sm">
{`An error occurred while retrieving content from "${url}".`}
</Card>
)
return results
}
Expand Down