feat(editor): compile-diagnostics seam — publish raw build output for editor markers

This commit is contained in:
David Montero Crespo 2026-08-15 06:44:35 +02:00
parent 55bc03d281
commit 7c3b1c6e24
2 changed files with 32 additions and 0 deletions

View File

@ -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) {

View File

@ -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);
}
}