Experiment: JS-driven story loop with Promise handshake#95
Open
EmilioBejasa wants to merge 4 commits into
Open
Experiment: JS-driven story loop with Promise handshake#95EmilioBejasa wants to merge 4 commits into
EmilioBejasa wants to merge 4 commits into
Conversation
JS owns the entire story sequence: createPreparedStoryMapping() once,
then for (story of allStories) { render; await notifyStoryReady(id) }.
notifyStoryReady() is a Promise call — native resolves it after taking
the screenshot, letting JS advance to the next story.
No event emitter, no isBlockingSynchronousMethod, no manifest pre-load.
renderResolverRef bridges the async loop to React's useEffect commit phase.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fect Two fixes for blank screenshots: 1. buildPreparedStories() accesses _preview.storyStoreValue directly instead of calling createPreparedStoryMapping(), which waits on storeInitialization- Promise. That Promise only resolves when the Storybook UI renders — which never happens in our test scenario. The importFn is a sync map lookup so loadStory() resolves in the next microtask. 2. Remove renderResolverRef. Instead of resolving an intermediate Promise in useEffect and then calling notifyStoryReady from an async loop, call notifyStoryReady directly in useEffect([storyContent, error]). This matches how the main branch calls notifyStoryReady: immediately after the commit, with no extra microtask hop that could race against Fabric's native mutations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
Without an explicit measure/layout pass, Screenshot.snap(surface.view) captures a blank bitmap on Fabric. Mirror what the old arch path already does with ViewHelpers so the view tree is software-rendered and properly sized before capture. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ViewHelpers only sets software layer on the root view. Fabric child views retain hardware display lists which view.draw(canvas) cannot capture, producing blank (white background only) screenshots. Walk the full tree and set LAYER_TYPE_SOFTWARE on every node before snapping. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StoryRenderercallscreatePreparedStoryMapping()once on mount, then iterates all stories in afor...ofloopawait StorybookRegistry.notifyStoryReady(storyId)— a standard Promise call that resolves only after the test thread takes the screenshotallStoriesDone()signals the test thread to exit and unmount the surfaceHow it works
The
renderResolverRefpattern bridges React's async render to thefor...ofloop: the loop awaits a Promise whoseresolveis stored in a ref and called fromuseEffect([storyContent, error])— the only reliable signal that React has committed the render.Why useEffect is necessary
setCurrentStoryId()schedules a render asynchronously. CallingnotifyStoryReady()immediately after would race against React's scheduler and potentially screenshot the wrong state.useEffectfires after commit, guaranteeing the view is painted before native is notified.Advantages over sync-story-blocking branch
newArchEnabled=true) — uses standard@ReactMethodPromiseTest plan
🤖 Generated with Claude Code