코드 에디터: Arduino 컴파일 오류를 AI 채팅으로 자동 전송
오류 발생 시 codeAiAppend(system) 대신 sendCompileErrorToAI()로 에러 메시지 + 코드 컨텍스트를 AI 입력창에 넣고 즉시 전송. arduino / esp32 / 에뮬레이터 버튼 세 경로 모두 적용. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+12
-5
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user