pxt-microbit icon indicating copy to clipboard operation
pxt-microbit copied to clipboard

Switching projects sometimes loads the previous project code into the new one

Open microbit-carlos opened this issue 5 months ago • 3 comments

We haven't found a way to constantly replicate this yet, but we have seen it multiple times now, so raising here for visibility and to check if other people have experienced it and could help us debug it or replicate it.

Essentially, when switching MakeCode projects, sometimes after going back and forth between screens that "hide" the blocks or code view (for example, going into the settings, extension search, etc), it sometimes seems to load the code from the previously opened project. I have the feeling this only happens when moving around the MakeCode editor really quickly (so little time between opening a project and going into the other views, and then back into the code), but it's just an impression and might not be a trigger.

For example, the first time this happened to me I did something like this:

  • Open an old project with code
  • Created a new project
  • Loaded and extension
  • When the blocks view was shown again, instead of a blank project it had loaded the code from the old project

microbit-carlos avatar Jul 22 '25 16:07 microbit-carlos

Today I had it triggered like this:

  • Open an old project with several sound blocks, essentially doing a sound level plot on the display
  • Back to the home page, loaded a different project that simply sent the sound level via serial
  • Went to the project settings to see the pxt.json file (I was checking which version of an extension it was using)
  • Went back to the Javascript code and instead of the "send sound level via serial" code, it loaded the "plot the sound level on the display" code from the other project.
  • I was switching between files in the javascript view, and it eventually loaded the original "send sound level via serial" code

However, during this session it was stuck with this weird compilation error:

Image

I couldn't download the hex file due to the compilation error, but using the "share link" generated a sharable project that does work as expected: https://makecode.microbit.org/_fEDRWFRqVf14

Once I went to the home page and loaded the same project again it did work as expected.

microbit-carlos avatar Jul 22 '25 16:07 microbit-carlos

@microbit-carlos by any chance you had multiple tabs with MakeCode?

abchatra avatar Jul 22 '25 16:07 abchatra

I have not found a different MakeCode tab in my Chrome windows this morning, but I have closed things between the issue report and now, and while I don't recall seeing a Makecode tab in those closed windows, there is a small chance there could have been one. I'll keep an eye for that as well if I trigger it again.

microbit-carlos avatar Jul 23 '25 09:07 microbit-carlos