Skip to content

[WIP] Hide simulator when editor is hidden to mute it#854

Draft
microbit-grace wants to merge 5 commits into
mainfrom
sim-sound
Draft

[WIP] Hide simulator when editor is hidden to mute it#854
microbit-grace wants to merge 5 commits into
mainfrom
sim-sound

Conversation

@microbit-grace
Copy link
Copy Markdown

@microbit-grace microbit-grace commented Apr 9, 2026

  • Hides simulator when on data samples / testing model pages.
  • Shows simulator when on code page.

Fixes #772

- Hides simulator when landing on a page that is not the code page
- Shows simulator when landing/navigating to code page
- Hides simulator onBack from code page

Fixes #772
Comment on lines +341 to +343
// Wait for simulator to finish hiding before showing simulator.
await hideSimulatorPromiseRef.current;
await driverRef.current?.showSimulator();
Copy link
Copy Markdown
Author

@microbit-grace microbit-grace Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite this wait, it doesn't work. Navigating quickly to code page straight after loading testing model page doesn't show the simulator. It causes the simulator to disappear from the editor. The user would need to toggle the showing/hiding of the simulator to get it to become visible again.

Copy link
Copy Markdown
Author

@microbit-grace microbit-grace Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps listening to the simevent would help (see potential editor sim events) in getting a more accurate indication of the sim state, but there's a comment in makecode-embed saying that it doesn't get fired.

Getting the simevent would also help in potentially being able to use stopSimulator instead of hideSimulator. I used hide because it stops the simulator from loading without needing to figure out when the sim is loaded. Stop simulator would require knowing when the simulator is loaded before calling it so that it can take effect.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Preview build will be at
https://review-createai.microbit.org/sim-sound/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simulator sounds can run when MakeCode is not visible including in quite unexpected cases

1 participant