fix(chart): rewrite suggestion logic with better error handling
- Remove conflicting tool approach, use direct JSON - Add fallback: extract numbers from regex if AI fails - Add debug section to show what content was analyzed - Be more lenient: any 2+ numbers = valid chart - Better error messages - Add console logging for debugging Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,7 @@ export function ChartSuggestionsDialog({
|
||||
suggestCharts({ content, selection, noteId })
|
||||
.then(data => {
|
||||
if (aborted) return
|
||||
console.log('[ChartSuggestionsDialog] Response:', data)
|
||||
setResponse(data)
|
||||
setLoading(false)
|
||||
})
|
||||
@@ -61,10 +62,10 @@ export function ChartSuggestionsDialog({
|
||||
console.error('[ChartSuggestionsDialog] Error:', err)
|
||||
setResponse({
|
||||
suggestions: [],
|
||||
analyzedText: '',
|
||||
detectedData: '',
|
||||
analyzedText: textToAnalyze?.substring(0, 100) || '',
|
||||
detectedData: 'Error occurred',
|
||||
hasData: false,
|
||||
error: err.message || 'Failed to load suggestions',
|
||||
error: err.message || 'Network error - check console',
|
||||
})
|
||||
setLoading(false)
|
||||
})
|
||||
@@ -192,6 +193,17 @@ export function ChartSuggestionsDialog({
|
||||
<li>• Percentages or proportions</li>
|
||||
<li>• Time-series data</li>
|
||||
</ul>
|
||||
<div className="mt-4 pt-4 border-t border-border/50">
|
||||
<details className="text-left">
|
||||
<summary className="text-xs text-muted-foreground cursor-pointer hover:text-foreground">
|
||||
Debug: Show what was analyzed
|
||||
</summary>
|
||||
<pre className="mt-2 text-xs bg-muted p-2 rounded overflow-auto max-h-32">
|
||||
{textToAnalyze.substring(0, 500)}
|
||||
{textToAnalyze.length > 500 && '...'}
|
||||
</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user