From cdf4aad4ae7d85c593475650f2a101d4bc0752a7 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Tue, 28 Jul 2026 20:15:56 +0200 Subject: [PATCH] =?UTF-8?q?fix(editor):=20Pi=20kinds=20end=20in=20digits?= =?UTF-8?q?=20=E2=80=94=20test=20the=20full=20board=20id=20before=20stripp?= =?UTF-8?q?ing=20the=20instance=20suffix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'raspberry-pi-3' minus the numeric suffix is 'raspberry-pi', which matches no kind, so freshly added Pis regressed to a sketch.ino group. --- frontend/src/store/useEditorStore.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/store/useEditorStore.ts b/frontend/src/store/useEditorStore.ts index 051b5f4e..6a4a37fe 100644 --- a/frontend/src/store/useEditorStore.ts +++ b/frontend/src/store/useEditorStore.ts @@ -387,11 +387,14 @@ export const useEditorStore = create((set, get) => ({ // Determine default file by group name convention or language mode. // All QEMU-Linux boards (Pi Zero/1/2/3/4/5 plus overlay piFamily // kinds like the UNIHIKER) default to script.py. Group ids follow - // `group-` and the first board of a kind uses the kind as - // its id ('-N' suffix for later instances), so strip both and ask - // isPiBoardKind — the same predicate every other Pi code path uses. - const boardIdPart = groupId.replace(/^group-/, '').replace(/-\d+$/, ''); - const isPi = isPiBoardKind(boardIdPart); + // `group-`; the first board of a kind uses the kind as its + // id, later instances append '-N'. Test the FULL id first — kinds + // themselves end in digits ('raspberry-pi-3'), so stripping the + // numeric suffix unconditionally would mangle them ('raspberry-pi' + // matched nothing and Pis regressed to sketch.ino). + const boardIdPart = groupId.replace(/^group-/, ''); + const isPi = + isPiBoardKind(boardIdPart) || isPiBoardKind(boardIdPart.replace(/-\d+$/, '')); const isMicroPython = languageMode === 'micropython'; const mainId = `${groupId}-main`; let fileName: string;