{{ message }}
fix(oceans): clear guide typing timer and sounds on level transition#73499
Open
stephenliang wants to merge 6 commits into
Open
fix(oceans): clear guide typing timer and sounds on level transition#73499stephenliang wants to merge 6 commits into
stephenliang wants to merge 6 commits into
Conversation
setInitialState() overwrote the guideTypingTimer handle without clearing the interval, so the typing sound effect continued after navigating to a new level. Clear it before resetting state. Also stop all playing sounds in the useEffect cleanup so nothing bleeds across level transitions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
stopUIRerender() only stopped the RAF loop but kept the module-level uiRoot reference. When OceansLab unmounts (navigating to a non-fish level) and remounts (navigating back), renderUI() skipped createRoot because uiRoot was still non-null, rendering into the detached old container. Null it on cleanup so a fresh root is created for the new container. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace uiRoot=null with container element comparison so createRoot is only called when the DOM container actually changes (avoids React "container already passed to createRoot" warning on appMode changes). - Clear guideTypingTimer in stopUIRerender so no new playSound calls fire after sounds.stopAllAudio() during cleanup. - Change #container-react box-sizing from content-box to border-box to match the prod apps bundle; fixes 2-column layout on level 8 (long mode) which needs 3 columns. - Update tests with stopUIRerender coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
96fdf72 to
6863389
Compare
MUI's global reset forces border-box on all elements via inherit. The blanket #container-react * rule crushed the counter and erase button whose %-based padding is additive (content-box). Reset the container to content-box so children inherit it, and opt only the word-attribute buttons into border-box. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The box-sizing fix belongs in the studio host (where MUI lives), not in the oceans package (which should be host-agnostic). Remove the #container-react and word-button box-sizing rules from scenes.css and apply `content-box` via MUI `sx` on the wrapping `<Box>` in OceansContainer instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Null guideTypingTimer in state after clearInterval in stopUIRerender so Guide.tsx's !state.guideTypingTimer gate doesn't block new timers. - Remove unnecessary `if (guideTypingTimer)` guards; clearInterval on undefined is a spec-defined no-op and the guard skips timer ID 0. - Add clearInterval to resetState() (public API, was leaking intervals). - Replace uiRoot! non-null assertion with optional chaining. - Add "why" comment on CssBaseline box-sizing override. Co-Authored-By: Claude Opus 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
setInitialState()overwroteguideTypingTimerwithout callingclearInterval, so the typing sound effect continued firing after a level transition.stopUIRerendernow also clears the timer so component teardown is clean.App.tsxuseEffect cleanup now callssounds.stopAllAudio()before stopping the render loop so no in-flight audio bleeds across levels.createRootwhen the container actually changes (unmount→remount), avoiding the "container already passed to createRoot" warning on appMode changes.border-boxvia inheritance on all elements. The oceans UI was authored forcontent-box(%-based padding on counter/erase button is additive). Applycontent-boxon#container-reactandborder-boxon word buttons via MUIsxin the studio host component, keeping the oceans package host-agnostic.#container-reactbox-sizing override from the oceans package since it's now the studio host's responsibility.Test plan
test/unit/oceans/init.test.ts— verifiessetInitialStateclears an activeguideTypingTimerandstopUIRerenderclears the timer on teardown🤖 Generated with Claude Code