feat(site-builder): capture recent console errors for issue reports

Ring buffer of the most recent console.error/window-error messages
(20 max, 500 chars each, message text only) for Task 19's report
payload. installConsoleErrorBuffer() is idempotent via a marker
stamped on the patched console.error itself (not just a module-scoped
flag), so React 18 StrictMode double-invocation or HMR re-running this
module's top level can't wrap an already-patched console.error and
build a growing chain. The patch always chains to the original.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-09 10:37:32 -07:00
co-authored by Claude Opus 5
parent aba0d187d7
commit 9be71e8fd1
3 changed files with 181 additions and 0 deletions
+5
View File
@@ -2,8 +2,13 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import { App } from './App';
import { WhpConfig } from './types';
import { installConsoleErrorBuffer } from './utils/console-buffer';
import './styles/editor.css';
// Installed before React mounts so errors thrown during the first render are
// captured too.
installConsoleErrorBuffer();
// Read WHP_CONFIG injected by PHP wrapper (or null for standalone dev)
const whpConfig: WhpConfig | null = (window as any).WHP_CONFIG || null;