Core: Fix stepping back through story interactions panel#32793
Conversation
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes ✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (4)**/*.{js,jsx,json,html,ts,tsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
code/**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
{code/**,scripts/**}/**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (1)
Comment |
|
View your CI Pipeline Execution ↗ for commit 1d4ca46
☁️ Nx Cloud last updated this comment at |
|
Hey @ia319 thanks a lot for investigating this! While testing it locally by:
|
|
@yannbf 2025-10-27.21-06-07.mp4 |
| const { isDebugging } = this.getState(storyId); | ||
| if (newPhase === 'preparing' && isDebugging) { | ||
| return resetState({ storyId, renderPhase: newPhase }); | ||
| return resetState({ storyId, renderPhase: newPhase, isDebugging }); |
There was a problem hiding this comment.
Hey @ghengeveld can you check whether there was a reason not to pass isDebugging here? Otherwise both if statements should probably be merged into something like this:
if (newPhase === 'playing' || newPhase === 'preparing' && isDebugging) {
return resetState({ storyId, renderPhase: newPhase, isDebugging });
}
You're so right! Probably an Nx cache issue. I checked it again, also in a sandbox, and it works well. Thank you so much! I'll just double check with @ghengeveld before merging this. |

Closes #32630
What I did
Change:
I've updated the renderPhaseChanged handler to correctly pass the isDebugging variable to resetState when the newPhase is 'preparing'.
What is the cause of the bug?
isDebugging: false): TherenderPhaseChangedhandler fires withnewPhase: 'playing'. This hits theelse if (newPhase === 'playing')block (L227)which correctly passes the
isDebugging: truestate, and the debugger works.On the second "Back" click (from
isDebugging: true):isDebugging: true) calls thestartfunction, which emitsFORCE_REMOUNTwith{ isDebugging: true }.renderPhaseChangedhandler, but this time withnewPhase: 'preparing'.if (newPhase === 'preparing' && isDebugging)block (L225).resetStateis called without passing theisDebuggingvariable.resetStateto use its default value ofisDebugging = false(from L112).isDebugging: falsestate incorrectly terminates the debug session. When theinterceptfunction (L469), checks this flag and seesfalsePromisethat pauses execution. Instead, it immediately callsinvoke, causing theplayfunction to execute all remaining steps without stopping.Recurrence log
PS: The problem will occur as long as
startis called twice (or any timestartis called whileisDebuggingis alreadytrue), such as clicking a specific step in the log (which also callsstart).Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
In the sandbox, the relevant interactions are fine
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit