📝 Migrate playgrounds in documentation to StackBlitz#6753
Conversation
Replace @codesandbox/sandpack-react with @stackblitz/sdk for interactive code playgrounds. Migrate all test snippets from Jest syntax (jest.fn) to Vitest syntax (vi.fn with explicit imports). Update the snippet validation spec to run Vitest instead of Jest. Remove jest.config.cjs and Jest dependencies that are no longer needed. https://claude.ai/code/session_01S8LkWyJcRRfX5gGUx2ZZeB
|
|
|
||
| useEffect(() => { | ||
| if (!ref.current) return; | ||
| sdk.embedProject( |
There was a problem hiding this comment.
@claude is there a clean up? Probably worth calling it to avoid double mount
There was a problem hiding this comment.
Claude finished @dubzzz's task in 1m 1s —— View job
- Analyze the
useEffectinAdventPlayground.tsxfor cleanup - Fix both
AdventPlayground.tsxandPlaygrounds.tsx
Good catch! Both useEffect hooks were missing cleanup. sdk.embedProject injects an iframe into the container div, so without cleanup React strict mode's double-mount would create two iframes.
Added return () => { el.innerHTML = ''; } to both:
AdventPlayground.tsx:56— clears the embed on unmountPlaygrounds.tsx:43— same fix for theStackBlitzEmbedcomponent
Pushed in cf1660b.
Co-authored-by: Nicolas DUBIEN <[email protected]>
| }; | ||
| }; | ||
|
|
||
| function StackBlitzEmbed({ files, options = {} }: EmbedProps) { |
There was a problem hiding this comment.
@claude I have this error:
Unable to run Embedded Project
Looks like this project is being embedded without proper isolation headers.
Please fix it.
I also want to never hide the show ansewr button
| }; | ||
| }; | ||
|
|
||
| function StackBlitzEmbed({ files, options = {} }: EmbedProps) { |
There was a problem hiding this comment.
@claude I want the code editor to run the tests in live for the user, it seems that your current setup does not run any test
|
@claude take into account the untreated commets |
|
Claude finished @dubzzz's task in 9m 57s —— View job Addressing untreated review comments
Changes made (4a5d2a1)Fix: Isolation headers error — Replaced Fix: Always show "Show answer" button — Removed the conditional Fix: Tests running live — Added Cleanup — Removed the Note: CSP update neededThe CI workflow ( |
Replace sdk.embedProject (WebContainers) with form POST to stackblitz.com/run which loads in an iframe served from StackBlitz's own domain, avoiding the need for isolation headers on the host page. Also: always show "Show answer" button, add --watch flag to vitest startCommand, and remove @stackblitz/sdk dependency. Co-authored-by: Nicolas DUBIEN <[email protected]>
|
@claude move back to the SDK as you said it would work on fast-check.dev just make sure that our CSP are correctly defined for it |
|
Claude finished @dubzzz's task in 3m 12s —— View job Reverting to StackBlitz SDK with proper CSP
Changes made (53591d9)Reverted both Added CSP update needed (manual)I cannot modify - frame-src 'self' *.codesandbox.io www.youtube-nocookie.com;
+ frame-src 'self' *.stackblitz.com www.youtube-nocookie.com;This is required for the StackBlitz SDK embeds to load in the iframe on |
Replace the form POST workaround with the proper StackBlitz SDK embedProject() API. Add @stackblitz/sdk back to website dependencies. Co-authored-by: Nicolas DUBIEN <[email protected]>
|
@claude in advent 22 we have a mismatch between two names: computeSantaMindScore and findOptimalPacking import { test, expect } from 'vitest'; // declare type Icon = '🎄' | '🦌' | '⛄' | '🛷' | '🎈' | '🎀' | '🎅' | '🎁'; please list me all the other cases with mismatch |
|
Claude finished @dubzzz's task in 2m 23s —— View job Checking Advent of PBT puzzles for function name mismatches
ResultsI checked all 24 days. Day 22 is the only function name mismatch:
All other days (1–21, 23–24) have matching function names between the import and the type declaration. Bonus finding: Day 10 return type mismatchDay 10 has a return type mismatch (not a name mismatch):
This is a different kind of mismatch — the function name is correct, but the declared return type in the signature ( |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
@fast-check/ava
fast-check
@fast-check/jest
@fast-check/packaged
@fast-check/poisoning
@fast-check/vitest
@fast-check/worker
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6753 +/- ##
=======================================
Coverage 94.86% 94.86%
=======================================
Files 209 209
Lines 5665 5665
Branches 1489 1488 -1
=======================================
Hits 5374 5374
Misses 283 283
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
This PR migrates the interactive code playgrounds in the documentation from CodeSandbox's Sandpack to StackBlitz's SDK. The change affects the race condition detection tutorial and Advent of PBT puzzles.
Key Changes
Playground Components:
SandpackProviderand related Sandpack components with a newStackBlitzEmbedcomponent that uses@stackblitz/sdkStackBlitzEmbedcomponent that handles StackBlitz project embedding with configurable options (height, openFile, view, hideExplorer)package.jsongeneration to include StackBlitz-specific configuration (installDependencies, startCommand)Test Infrastructure:
.spec.jsto.test.jsto match Vitest conventionsimport { test, expect, vi } from 'vitest') instead of Jestjest.fn()withvi.fn()throughout test snippetsStyling:
.openInCodeSandboxto.playgroundActionsDependencies:
@codesandbox/sandpack-reactand@codesandbox/sandpack-themes@jest/globals@stackblitz/sdkas a dependencyBenefits
Checklist
https://claude.ai/code/session_01S8LkWyJcRRfX5gGUx2ZZeB