From 7c3b1c6e249bb56e9e86ac79db7d229835ca1840 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Sat, 15 Aug 2026 06:44:35 +0200 Subject: [PATCH] =?UTF-8?q?feat(editor):=20compile-diagnostics=20seam=20?= =?UTF-8?q?=E2=80=94=20publish=20raw=20build=20output=20for=20editor=20mar?= =?UTF-8?q?kers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/editor/EditorToolbar.tsx | 8 +++++++ frontend/src/lib/intellisenseRegistry.ts | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/frontend/src/components/editor/EditorToolbar.tsx b/frontend/src/components/editor/EditorToolbar.tsx index 5d9344d7..f7a0c888 100644 --- a/frontend/src/components/editor/EditorToolbar.tsx +++ b/frontend/src/components/editor/EditorToolbar.tsx @@ -1,6 +1,7 @@ import { useState, useCallback, useRef, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { registerEditorCommand } from '../../lib/editorCommands'; +import { publishCompileOutput } from '../../lib/intellisenseRegistry'; import { useEditorStore, chipFileGroupId } from '../../store/useEditorStore'; import { useSimulatorStore, piRerunScript } from '../../store/useSimulatorStore'; import { decideEngine } from '../../lib/instantEngine'; @@ -594,6 +595,13 @@ export const EditorToolbar = ({ const resultLogs = parseCompileResult(result, boardLabel, boardTarget, lastStreamedLen > 0); setCompileLogs((prev: CompilationLog[]) => [...prev, ...resultLogs]); + // Intellisense seam: hand the raw compiler text to the overlay so it + // can paint file:line markers in the editor. Empty string clears the + // markers after a successful build. No-op in OSS. + publishCompileOutput( + result.success ? '' : [result.stderr, result.error].filter(Boolean).join('\n'), + ); + if (result.success) { const program = result.hex_content ?? result.binary_content ?? null; if (program && activeBoardId) { diff --git a/frontend/src/lib/intellisenseRegistry.ts b/frontend/src/lib/intellisenseRegistry.ts index 5649916d..ef3f49f6 100644 --- a/frontend/src/lib/intellisenseRegistry.ts +++ b/frontend/src/lib/intellisenseRegistry.ts @@ -43,3 +43,27 @@ function run(impl: IntellisenseImpl, monaco: unknown): void { console.warn('[oss] intellisense impl threw:', err); } } + +/** + * Compile-diagnostics seam. The editor toolbar publishes the raw compiler + * output after every build (empty string on success, to clear); with the + * pro overlay loaded, its sink parses gcc/mpy positions out of the text + * and paints Monaco markers on the affected lines. Inert in OSS. + */ + +type CompileOutputSink = (raw: string) => void; + +let _compileSink: CompileOutputSink | null = null; + +export function installCompileDiagnosticsSink(sink: CompileOutputSink | null): void { + _compileSink = sink; +} + +export function publishCompileOutput(raw: string): void { + try { + _compileSink?.(raw); + } catch (err) { + // eslint-disable-next-line no-console + console.warn('[oss] compile-diagnostics sink threw:', err); + } +}