From 0c46d52f42793f73429a385bfcdb5311846828c5 Mon Sep 17 00:00:00 2001 From: kim Date: Thu, 11 Jun 2026 22:59:50 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=97=90=EB=94=94?= =?UTF-8?q?=ED=84=B0:=20Arduino=20=EC=BB=B4=ED=8C=8C=EC=9D=BC=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=EB=A5=BC=20AI=20=EC=B1=84=ED=8C=85=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=9E=90=EB=8F=99=20=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 오류 발생 시 codeAiAppend(system) 대신 sendCompileErrorToAI()로 에러 메시지 + 코드 컨텍스트를 AI 입력창에 넣고 즉시 전송. arduino / esp32 / 에뮬레이터 버튼 세 경로 모두 적용. Co-Authored-By: Claude Sonnet 4.6 --- web-ui/code.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/web-ui/code.js b/web-ui/code.js index b307fa4..688f462 100644 --- a/web-ui/code.js +++ b/web-ui/code.js @@ -897,7 +897,7 @@ function openArduinoEmulator() { body: JSON.stringify({ code: file.content, board: 'uno' }), }).then(r => r.json()).then(data => { if (btn) { btn.textContent = '🔌 에뮬레이터'; btn.disabled = false; } - if (data.error) { codeAiAppend('system', '⚠️ 컴파일 오류:\n' + data.error); return; } + if (data.error) { sendCompileErrorToAI(data.error, file.name, file.content); return; } sessionStorage.setItem('arduino_sketch', file.content); sessionStorage.setItem('arduino_hex', data.hex); sessionStorage.setItem('arduino_filename', file.name); @@ -1323,7 +1323,7 @@ function codeRunWith(mode) { body: JSON.stringify({ code: file.content, board: 'esp32' }), }).then(r => r.json()).then(data => { if (data.error) { - codeAiAppend('system', '⚠️ 컴파일 오류:\n' + data.error); + sendCompileErrorToAI(data.error, file.name, file.content); return; } sessionStorage.setItem('arduino_merged', data.merged); @@ -1344,9 +1344,8 @@ function codeRunWith(mode) { body: JSON.stringify({ code: file.content, board }), }).then(r => r.json()).then(data => { if (data.error) { - let msg = '⚠️ 컴파일 오류:\n' + data.error; - if (data.install) msg += '\n\n설치 필요:\n' + data.install; - codeAiAppend('system', msg); + const extra = data.install ? `\n\n설치 필요: ${data.install}` : ''; + sendCompileErrorToAI(data.error + extra, file.name, file.content); return; } sessionStorage.setItem('arduino_hex', data.hex); @@ -1382,6 +1381,14 @@ function codeRunWith(mode) { }, codeTermOpen ? 0 : 500); } +function sendCompileErrorToAI(error, filename, code) { + const inp = document.getElementById('code-ai-input'); + if (!inp) return; + const codeBlock = code ? `\n\n코드:\n\`\`\`cpp\n${code}\n\`\`\`` : ''; + inp.value = `아두이노 컴파일 오류가 발생했습니다. 원인을 설명하고 수정해줘.\n\n파일: ${filename}\n오류:\n\`\`\`\n${error}\n\`\`\`${codeBlock}`; + codeAiSend(); +} + function codeSendSelectionToAI() { if (!monacoEditor) return; const sel = monacoEditor.getSelection();