adds live HTML, SVG, JSX, and TSX fences rendered in an opaque-origin sandbox="allow-scripts" iframe with a restrictive CSP and no network access
loads Sucrase dynamically only when a JSX/TSX preview opens, replacing the 686-line hand-written lexer/parser with a maintained parser and preserving actionable compiler errors
keeps Preact as the small per-preview runtime and supplies local React/ReactDOM/Preact module shims inside the frame
removes the subjective plot/prose/canvas critique heuristics, scaffold/retry grading, render nudge, and forced-fence recovery path; the backend now validates language plus non-empty source, then the browser compiles/renders/reports errors
preserves narrow cueing so ordinary chat does not pay for a non-stream tool turn
Review structure
This is the preview half split out of the closed PR #4. Runtime reliability fixes are isolated in #5 and should land first; this branch is otherwise based directly on current main and can be rebased after #5 merges.
Validation
frontend lint passed
JSX/TSX transform suite: 14/14 passed, including comparison-vs-JSX, Math.sin(t) / 6, TSX generic arrows, imports/exports, malformed JSX, and malformed TypeScript
production Vite build passed; Sucrase is emitted as a lazy 200.58 kB / 45.68 kB gzip chunk
production dependency audit: 0 vulnerabilities
broad Python suite on Windows: 99 passed, 1 skipped, with 4 current-main/merge-order failures deselected (two POSIX file-mode assertions, one Windows path-separator assertion, and the SQLite handle test fixed by #5)
## Summary
- adds live HTML, SVG, JSX, and TSX fences rendered in an opaque-origin `sandbox="allow-scripts"` iframe with a restrictive CSP and no network access
- loads Sucrase dynamically only when a JSX/TSX preview opens, replacing the 686-line hand-written lexer/parser with a maintained parser and preserving actionable compiler errors
- keeps Preact as the small per-preview runtime and supplies local React/ReactDOM/Preact module shims inside the frame
- removes the subjective plot/prose/canvas critique heuristics, scaffold/retry grading, render nudge, and forced-fence recovery path; the backend now validates language plus non-empty source, then the browser compiles/renders/reports errors
- preserves narrow cueing so ordinary chat does not pay for a non-stream tool turn
## Review structure
This is the preview half split out of the closed PR #4. Runtime reliability fixes are isolated in #5 and should land first; this branch is otherwise based directly on current `main` and can be rebased after #5 merges.
## Validation
- frontend lint passed
- JSX/TSX transform suite: 14/14 passed, including comparison-vs-JSX, `Math.sin(t) / 6`, TSX generic arrows, imports/exports, malformed JSX, and malformed TypeScript
- production Vite build passed; Sucrase is emitted as a lazy 200.58 kB / 45.68 kB gzip chunk
- production dependency audit: 0 vulnerabilities
- broad Python suite on Windows: 99 passed, 1 skipped, with 4 current-`main`/merge-order failures deselected (two POSIX file-mode assertions, one Windows path-separator assertion, and the SQLite handle test fixed by #5)
- manual browser smoke covered HTML, React imports, typed TSX/generics, division expressions, unsupported third-party imports, and malformed JSX error reporting
Load Sucrase only when a JSX/TSX preview is opened, remove the hand-written transform, and leave subjective render evaluation to the reader while retaining structural fence validation.
Closing as superseded by #11: this branch (7262e77, 952ef8a) carried forward as-is, plus a hung-frame watchdog for the preview iframe (a runaway/synchronous-loop script had nothing detecting it) and a fix requiring approval for action-tool calls guessed from content even under the "allow" policy (a content-JSON-recovered call is weaker evidence than a native tool_calls field). Merged onto main.
Thanks for the sandbox work here - the CSP/postMessage/origin-isolation design held up under review with no changes needed.
Closing as superseded by #11: this branch (7262e77, 952ef8a) carried forward as-is, plus a hung-frame watchdog for the preview iframe (a runaway/synchronous-loop script had nothing detecting it) and a fix requiring approval for action-tool calls guessed from `content` even under the "allow" policy (a content-JSON-recovered call is weaker evidence than a native tool_calls field). Merged onto main.
Thanks for the sandbox work here - the CSP/postMessage/origin-isolation design held up under review with no changes needed.
Pull request closed
Please reopen this pull request to perform a merge.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
sandbox="allow-scripts"iframe with a restrictive CSP and no network accessReview structure
This is the preview half split out of the closed PR #4. Runtime reliability fixes are isolated in #5 and should land first; this branch is otherwise based directly on current
mainand can be rebased after #5 merges.Validation
Math.sin(t) / 6, TSX generic arrows, imports/exports, malformed JSX, and malformed TypeScriptmain/merge-order failures deselected (two POSIX file-mode assertions, one Windows path-separator assertion, and the SQLite handle test fixed by #5)Closing as superseded by #11: this branch (
7262e77,952ef8a) carried forward as-is, plus a hung-frame watchdog for the preview iframe (a runaway/synchronous-loop script had nothing detecting it) and a fix requiring approval for action-tool calls guessed fromcontenteven under the "allow" policy (a content-JSON-recovered call is weaker evidence than a native tool_calls field). Merged onto main.Thanks for the sandbox work here - the CSP/postMessage/origin-isolation design held up under review with no changes needed.
Pull request closed