mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
* fix: handle malformed XML from DeepSeek gracefully Add early XML validation with parsererror check before calling replaceNodes to prevent application crashes when AI models generate malformed XML with unescaped special characters. Changes: - Add toast import from sonner - Parse and validate XML before processing - Add parsererror detection to catch malformed XML early - Wrap replaceNodes in try-catch for additional safety - Add user-friendly toast notifications for all error cases - Change console.log to console.error for validation failures Fixes #220 #230 #231 * fix: prevent toast spam during streaming and merge silent failure fixes - Only show error toasts after streaming completes (not during partial updates) - Track which tool calls have shown errors to prevent duplicate toasts - Merge clipboard copy error handling from PR #236 - Merge feedback submission error handling from PR #237 - Add comments explaining streaming vs completion behavior * refactor: simplify toast deduplication with boolean flag Based on code review feedback, simplified the approach from tracking per-tool-call IDs in a Set to using a single boolean flag. Changes: - Replaced Set<string> with boolean ref for toast tracking - Removed toolCallId and showToast parameters from handleDisplayChart - Reset flag when streaming starts (simpler mental model) - Same behavior: one toast per streaming session, no spam Benefits: - Fewer concepts (1 boolean vs Set + 2 parameters) - No manual coordination between call sites - Easier to understand and maintain - ~15 fewer lines of tracking logic * fix: only show toast for final malformed XML, not during streaming - Remove errorToastShownRef tracking (no longer needed) - Add showToast parameter to handleDisplayChart (default false) - Pass false during streaming (XML may be incomplete) - Pass true at completion (show toast if final XML is malformed) - Simpler and more explicit error handling