From cf6a6096714e497dc8c229866bae154ac83049ce Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Mon, 15 Jun 2026 11:57:10 -0300 Subject: [PATCH] Raspberri pi 4 y 5 --- .../__tests__/multi-board-integration.test.ts | 20 +++++++++++++++++++ .../raspberry-pi/RaspberryPiWorkspace.tsx | 9 +++++++-- frontend/src/i18n/locales/de/common2.json | 2 +- frontend/src/i18n/locales/en/common2.json | 2 +- frontend/src/i18n/locales/es/common2.json | 2 +- frontend/src/i18n/locales/fr/common2.json | 2 +- frontend/src/i18n/locales/it/common2.json | 2 +- frontend/src/i18n/locales/ja/common2.json | 2 +- frontend/src/i18n/locales/pt-br/common2.json | 2 +- frontend/src/i18n/locales/ru/common2.json | 2 +- frontend/src/i18n/locales/zh-cn/common2.json | 2 +- frontend/src/pages/EditorPage.tsx | 11 ++++++---- frontend/src/store/useEditorStore.ts | 8 ++++++-- 13 files changed, 49 insertions(+), 17 deletions(-) diff --git a/frontend/src/__tests__/multi-board-integration.test.ts b/frontend/src/__tests__/multi-board-integration.test.ts index e0f433cd..5dc7c960 100644 --- a/frontend/src/__tests__/multi-board-integration.test.ts +++ b/frontend/src/__tests__/multi-board-integration.test.ts @@ -196,6 +196,26 @@ describe('useEditorStore — file groups', () => { expect(updated['group-raspberry-pi-3'][0].name).toMatch(/\.py$/); }); + // Regression: every Linux Pi (not just the 3) must default to a Python file + // and the Pi workspace, never the Arduino sketch. The Pico (RP2040) is a + // microcontroller and must stay on .ino. + it.each(['raspberry-pi-zero', 'raspberry-pi-1', 'raspberry-pi-2', 'raspberry-pi-4', 'raspberry-pi-5'])( + 'createFileGroup creates a .py file for %s', + (kind) => { + const { createFileGroup } = useEditorStore.getState(); + createFileGroup(`group-${kind}`); + const updated = useEditorStore.getState().fileGroups; + expect(updated[`group-${kind}`][0].name).toMatch(/\.py$/); + }, + ); + + it('createFileGroup keeps the Raspberry Pi Pico on a .ino sketch (not Linux)', () => { + const { createFileGroup } = useEditorStore.getState(); + createFileGroup('group-raspberry-pi-pico'); + const updated = useEditorStore.getState().fileGroups; + expect(updated['group-raspberry-pi-pico'][0].name).toMatch(/\.ino$/); + }); + it('createFileGroup accepts custom initial files', () => { const { createFileGroup } = useEditorStore.getState(); createFileGroup('group-custom', [ diff --git a/frontend/src/components/raspberry-pi/RaspberryPiWorkspace.tsx b/frontend/src/components/raspberry-pi/RaspberryPiWorkspace.tsx index 44165bf2..6533e35a 100644 --- a/frontend/src/components/raspberry-pi/RaspberryPiWorkspace.tsx +++ b/frontend/src/components/raspberry-pi/RaspberryPiWorkspace.tsx @@ -13,6 +13,7 @@ import { VirtualFileSystem } from './VirtualFileSystem'; import { useVfsStore } from '../../store/useVfsStore'; import { getBoardBridge, useSimulatorStore } from '../../store/useSimulatorStore'; import { attachSlavesFromCanvas } from '../../simulation/piSlaveScanner'; +import { boardDisplayName } from '../../types/board'; // Lazy-load PiTerminal so @xterm/xterm is only bundled when needed const PiTerminal = lazy(() => import('./PiTerminal').then((m) => ({ default: m.PiTerminal }))); @@ -37,6 +38,10 @@ export const RaspberryPiWorkspace: React.FC = ({ boar const setContent = useVfsStore((s) => s.setContent); const getNode = useVfsStore((s) => s.getNode); + // Display the active board's real name (Pi 3B / 4B / 5 / Zero / …) instead of + // a hardcoded "Raspberry Pi 3B" — the workspace serves the whole Pi family. + const boardLabel = board ? boardDisplayName(board) : 'Raspberry Pi'; + // Auto-connect terminal when board starts running useEffect(() => { if (!board?.running) { @@ -127,7 +132,7 @@ export const RaspberryPiWorkspace: React.FC = ({ boar
{/* Pi-specific toolbar */}
- Raspberry Pi 3B + {boardLabel}
{/* Status indicator */} = ({ boar
🖥️
-
{t('editor.pi.offlineTitle')}
+
{t('editor.pi.offlineTitle', { board: boardLabel })}
{t('editor.pi.offlineSubtitle')}
@@ -540,7 +543,7 @@ export const EditorPage: React.FC = () => { setConsoleOpen={setConsoleOpen} compileLogs={compileLogs} setCompileLogs={setCompileLogs} - centerSlot={!isRaspberryPi3 ? : null} + centerSlot={!isLinuxPi ? : null} />
@@ -548,7 +551,7 @@ export const EditorPage: React.FC = () => { {/* Editor area: Pi workspace or Monaco editor */}
- {isRaspberryPi3 && activeBoardId ? ( + {isLinuxPi && activeBoardId ? ( diff --git a/frontend/src/store/useEditorStore.ts b/frontend/src/store/useEditorStore.ts index 4871b5b8..775345e1 100644 --- a/frontend/src/store/useEditorStore.ts +++ b/frontend/src/store/useEditorStore.ts @@ -348,8 +348,12 @@ export const useEditorStore = create((set, get) => ({ modified: false, })); } else { - // Determine default file by group name convention or language mode - const isPi = groupId.includes('raspberry-pi-3'); + // Determine default file by group name convention or language mode. + // All Linux Pi boards (Zero/1/2/3/4/5) default to script.py; the Pico + // (RP2040) is browser-emulated and not a Linux Pi. Mirrors + // isPiBoardKind() in types/board.ts, adapted to the `group-` convention. + const isPi = + groupId.includes('raspberry-pi-') && !groupId.includes('raspberry-pi-pico'); const isMicroPython = languageMode === 'micropython'; const mainId = `${groupId}-main`; let fileName: string;