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
12 changes: 11 additions & 1 deletion components/apps/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ Keep each section brief (1-2 sentences max). Be helpful and conversational.`,
}),
})

if (!response.ok) {
const errorBody = await response.json().catch(() => null)
throw new Error(
errorBody?.message || errorBody?.error || `Request failed (${response.status})`,
)
}

const { text } = await response.json()
setChatHistory((prev) => [...prev, { role: "assistant", content: text, isStructured: true }])

Expand All @@ -283,7 +290,10 @@ Keep each section brief (1-2 sentences max). Be helpful and conversational.`,
...prev,
{
role: "assistant",
content: "I encountered an error processing your request. Please try again.",
content:
error instanceof Error
? error.message
: "I encountered an error processing your request. Please try again.",
isStructured: false,
},
])
Expand Down
23 changes: 21 additions & 2 deletions components/apps/notes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function Notes() {
const [searchQuery, setSearchQuery] = useState("")
const [isAnalyzing, setIsAnalyzing] = useState(false)
const [analyzingNoteId, setAnalyzingNoteId] = useState<number | null>(null)
const [aiError, setAiError] = useState<string | null>(null)

const currentNote = notes.find((n) => n.id === selectedNote)

Expand Down Expand Up @@ -97,6 +98,7 @@ export function Notes() {

setIsAnalyzing(true)
setAnalyzingNoteId(noteId)
setAiError(null)
setIsProcessing(true)
setCurrentThinking(`Analyzing "${note.title}"...`)

Expand All @@ -121,6 +123,13 @@ Respond with a JSON object (no markdown):
}),
})

if (!response.ok) {
const errorBody = await response.json().catch(() => null)
throw new Error(
errorBody?.message || errorBody?.error || `Request failed (${response.status})`,
)
}

const { text } = await response.json()

// Parse the AI response
Expand Down Expand Up @@ -148,8 +157,10 @@ Respond with a JSON object (no markdown):
} catch {
// Silently handle parse errors - AI response format may vary
}
} catch {
// Silently handle categorization errors
} catch (error) {
setAiError(
error instanceof Error ? error.message : "Categorization failed. Please try again.",
)
} finally {
setIsAnalyzing(false)
setAnalyzingNoteId(null)
Expand Down Expand Up @@ -357,6 +368,14 @@ Respond with a JSON object (no markdown):
</div>
)}

{aiError && (
<div className="px-8 pb-4">
<p className="text-sm text-destructive bg-destructive/10 p-3 rounded-lg">
<span className="font-medium">Categorization failed:</span> {aiError}
</p>
</div>
)}

<div className="flex-1 px-8 pb-8 overflow-auto">
<textarea
className="w-full h-full resize-none focus:outline-none text-notes-foreground bg-transparent text-lg leading-relaxed"
Expand Down
14 changes: 13 additions & 1 deletion components/apps/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,13 @@ OUTPUT: [simulated output]`,
}),
})

if (!response.ok) {
const errorBody = await response.json().catch(() => null)
throw new Error(
errorBody?.message || errorBody?.error || `Request failed (${response.status})`,
)
}

const { text } = await response.json()

setHistory((prev) => {
Expand All @@ -465,7 +472,12 @@ OUTPUT: [simulated output]`,
const filtered = prev.filter((h) => h.type !== "thinking")
return [
...filtered,
{ type: "output", content: "Agent error: Unable to analyze command. Falling back to direct execution." },
{
type: "output",
content: `Agent error: ${
error instanceof Error ? error.message : "Unable to analyze command."
} Falling back to direct execution.`,
},
]
})

Expand Down