diff --git a/components/chat/chat-page.tsx b/components/chat/chat-page.tsx index 7cbb016..49b2df6 100644 --- a/components/chat/chat-page.tsx +++ b/components/chat/chat-page.tsx @@ -1167,8 +1167,13 @@ export function ChatPage() { : message, ), ); - } catch { - // Canvas é best-effort: mantém o texto completo na bolha. + } catch (error) { + // Canvas é best-effort (a resposta permanece íntegra), mas o erro + // precisa ser visível para diagnóstico em produção. + console.error("[canvas] falha ao criar/atualizar canvas", error); + toast.error( + `Falha ao abrir o Canvas: ${error instanceof Error ? error.message : "erro desconhecido"}`, + ); } } diff --git a/lib/canvas-detector.flappy.test.ts b/lib/canvas-detector.flappy.test.ts new file mode 100644 index 0000000..40a5d2f --- /dev/null +++ b/lib/canvas-detector.flappy.test.ts @@ -0,0 +1,133 @@ +import { describe, expect, it } from "vitest"; +import { buildDisplayText, detectCanvas } from "./canvas-detector"; + +// Reprodução fiel da resposta real de 15:30 (mistral/ministral-8b): +// fence ```html GRANDE contendo template literals com backticks no meio das +// linhas (`${birdY}px`), CSS com #ids e estrutura HTML completa. +const flappyHtml = [ + "", + '', + "", + ' ', + " ", + "", + "", + '
', + '
Pontuação: 0
', + ' ', + '
', + "
", + "