fix(chart): improve error handling and color variety

- Add quotaExceeded flag to response for better error UX
- Show dedicated quota exceeded state with upgrade button
- Improve AI prompt to better detect data patterns
- Add chart type-specific colors (blue, indigo, emerald, violet, etc.)
- Replace generic primary/10 colors with varied accent colors

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Antigravity
2026-05-23 09:19:52 +00:00
parent a122a0eade
commit 18ffd76c1e
16 changed files with 1042 additions and 134 deletions

View File

@@ -17,6 +17,7 @@ export interface SuggestChartsResponse {
detectedData: string
hasData: boolean
error?: string
quotaExceeded?: boolean
}
export interface SuggestChartsRequest {
@@ -42,12 +43,16 @@ export async function suggestCharts(request: SuggestChartsRequest): Promise<Sugg
if (!response.ok) {
const errorData = await response.json().catch(() => ({ error: 'Unknown error' }))
const isQuotaError = response.status === 402 || errorData.error === 'QUOTA_EXCEEDED'
return {
suggestions: [],
analyzedText: '',
detectedData: '',
hasData: false,
error: errorData.error || `HTTP ${response.status}`,
error: isQuotaError
? 'AI quota exceeded. Please upgrade your plan to continue using AI features.'
: (errorData.error || `HTTP ${response.status}`),
quotaExceeded: isQuotaError,
}
}