From 7dc88b45e045b29b7cd0f2e26d88c4841ef88a4f Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Wed, 19 Aug 2026 15:28:47 +0200 Subject: [PATCH] fix(examples): code-only examples honor languageMode in the filename A micropython example that ships only 'code:' landed its Python in sketch.ino (the mode switch was right, the name was not - seen on the SensAirShuttle ws2812 example). main.py / main.c / sketch.ino by mode. --- frontend/src/utils/loadExample.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/loadExample.ts b/frontend/src/utils/loadExample.ts index 901828cb..4a405480 100644 --- a/frontend/src/utils/loadExample.ts +++ b/frontend/src/utils/loadExample.ts @@ -327,7 +327,16 @@ export async function loadExample( if (boardOwnedFiles.length > 0) { editorStore.loadFiles(boardOwnedFiles); } else { - const filename = isPiBoardKind(liveBoard.boardKind) ? 'main.cpp' : 'sketch.ino'; + // The name must match the mode the board was just switched into: + // MicroPython pastes main.py, ESP-IDF builds main.c — a bare `code:` + // example otherwise lands its Python in a file called sketch.ino. + const filename = isPiBoardKind(liveBoard.boardKind) + ? 'main.cpp' + : example.languageMode === 'micropython' + ? 'main.py' + : example.languageMode === 'espidf' + ? 'main.c' + : 'sketch.ino'; editorStore.loadFiles([{ name: filename, content: example.code }]); } } else if (chipGroupIds.length > 0) {