fix: 코드에디터 iframe 안 에뮬레이터 모바일 레이아웃 오판 + 리셋 버튼
arduino-emulator.html이 코드에디터 안 iframe으로 뜰 때, 미디어쿼리가 창 폭이 아니라 iframe 폭으로 평가되어 넓은 화면에서도 모바일 서랍 레이아웃이 나오던 버그 수정 (브레이크포인트 1024px→760px, JS 판정도 matchMedia로 통일해 CSS와 어긋나지 않게 함). 코드에디터에 에뮬레이터 세션 강제 재시작 버튼 추가, 패널 높이를 고정값→75vh로. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3ae9b986e9
commit
61885cb923
4 files changed
+71
-13
No files matched your search
@@ -331,8 +331,13 @@
|
||||
.mob-tab{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;border:none;background:transparent;color:var(--muted);font-family:inherit;font-size:10px;font-weight:700;letter-spacing:.04em;cursor:pointer;padding:6px 4px;border-top:2px solid transparent;transition:color .15s,border-color .15s;-webkit-tap-highlight-color:transparent;}
|
||||
.mob-tab.active{color:var(--accent);border-top-color:var(--accent);}
|
||||
|
||||
/* ── Mobile ── */
|
||||
@media(max-width:1024px){
|
||||
/* ── Mobile ──
|
||||
주의: 이 페이지는 코드 에디터 안 iframe으로도 뜬다(code.js `_emuPanelLoad`).
|
||||
미디어 쿼리는 창이 아니라 iframe 폭으로 평가되므로, 브레이크포인트가 크면
|
||||
에디터 사이드 패널에서도 모바일 서랍 레이아웃이 나온다. 보드 220px +
|
||||
시리얼 120px면 충분히 나란히 들어가므로 760px로 잡음.
|
||||
JS 쪽 판정(mobToggleBoard)은 matchMedia로 이 값을 그대로 읽는다. */
|
||||
@media(max-width:760px){
|
||||
.header{flex-wrap:wrap;padding:7px 10px;gap:5px;}
|
||||
.header h1{font-size:13px;}
|
||||
.toolbar{gap:4px;}
|
||||
@@ -350,7 +355,7 @@
|
||||
.main{padding-bottom:52px;}
|
||||
input,select{font-size:16px !important;}
|
||||
}
|
||||
@media(min-width:1025px){
|
||||
@media(min-width:761px){
|
||||
#mob-backdrop{display:none !important;}
|
||||
#mob-tabbar{display:none !important;}
|
||||
}
|
||||
|
||||
@@ -334,6 +334,7 @@
|
||||
<button id="code-compile-btn" class="csb-term-btn" onclick="csbCompileOnly()" title="실제 보드용 컴파일 (오류 시 AI 채팅으로 전송)">🔨 컴파일</button>
|
||||
<button id="code-upload-btn" class="csb-term-btn" onclick="csbUploadToBoard()" title="보드에 업로드 (USB 연결 필요)" style="background:var(--brand);color:#fff;border-color:var(--brand)">⚡ 업로드</button>
|
||||
<button id="code-android-btn" class="csb-term-btn" onclick="openAndroidEmulator()" title="Android 에뮬레이터 열기">🤖 Android</button>
|
||||
<button id="code-android-reset-btn" class="csb-term-btn" onclick="resetAndroidEmulator()" title="Android 에뮬레이터 세션이 꼬였을 때 강제 종료 후 재시작">🔄</button>
|
||||
</div>
|
||||
<div class="csb-term-row">
|
||||
<button id="code-usb-android-btn" class="csb-term-btn" onclick="toggleAndroidUsbPanel()" title="USB로 연결된 실제 Android 기기 (기기 감지 / APK 설치 / Logcat / 화면 미러링)">📱 실기기(USB)</button>
|
||||
@@ -570,7 +571,7 @@
|
||||
<iframe id="code-preview-iframe" src="" style="flex:1;border:none;background:#fff;min-height:0" sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-popups"></iframe>
|
||||
</div>
|
||||
<!-- 🖥️ Emulator panel -->
|
||||
<div id="code-emu-panel" style="display:none;flex-direction:column;flex-shrink:0;height:520px;min-height:120px;border-top:2px solid #1a4a25;background:#0a1410;position:relative">
|
||||
<div id="code-emu-panel" style="display:none;flex-direction:column;flex-shrink:0;height:75vh;min-height:120px;border-top:2px solid #1a4a25;background:#0a1410;position:relative">
|
||||
<div id="code-emu-drag" style="position:absolute;top:0;left:0;right:0;height:5px;cursor:ns-resize;z-index:2;transition:background .15s"></div>
|
||||
<div style="display:flex;align-items:center;height:32px;background:#0d1f18;border-bottom:1px solid #1a4a25;flex-shrink:0;padding:0 8px;gap:6px">
|
||||
<span style="font-size:13px;flex-shrink:0">🖥️</span>
|
||||
|
||||
@@ -7127,8 +7127,11 @@ function mobCloseBoard(){
|
||||
document.getElementById('mobtab-board').classList.remove('active');
|
||||
document.getElementById('mobtab-serial').classList.add('active');
|
||||
}
|
||||
// 브레이크포인트는 CSS(arduino-emulator.html)에 한 번만 정의돼 있고 여기선 그걸 읽기만 한다.
|
||||
// 숫자를 양쪽에 따로 적으면 한쪽만 바꿨을 때 조용히 어긋난다.
|
||||
const MOB_QUERY = '(min-width:761px)';
|
||||
function mobToggleBoard(){
|
||||
if(window.innerWidth>1024)return;
|
||||
if(window.matchMedia(MOB_QUERY).matches)return;
|
||||
const open=document.querySelector('.board-panel').classList.contains('mob-open');
|
||||
if(open){mobCloseBoard();}
|
||||
else{
|
||||
|
||||
@@ -1147,12 +1147,15 @@ function _emuPanelLoad(url, title) {
|
||||
_emuPanelUrl = url;
|
||||
iframe.src = url;
|
||||
if (lbl) lbl.textContent = title || '에뮬레이터';
|
||||
if (!_emuPanelOpen) {
|
||||
_emuPanelOpen = true;
|
||||
panel.style.display = 'flex';
|
||||
if (btn) btn.classList.add('active');
|
||||
if (monacoEditor) setTimeout(() => monacoEditor.layout(), 60);
|
||||
}
|
||||
// Always force the panel visible instead of gating on _emuPanelOpen — a
|
||||
// back-forward-cached page restore (or any path where this JS-level flag
|
||||
// drifts from the DOM's actual display state) left `panel.style.display`
|
||||
// stuck at its closed default forever after, since this only ever ran the
|
||||
// one time the flag flipped false->true.
|
||||
_emuPanelOpen = true;
|
||||
panel.style.display = 'flex';
|
||||
if (btn) btn.classList.add('active');
|
||||
if (monacoEditor) setTimeout(() => monacoEditor.layout(), 60);
|
||||
}
|
||||
|
||||
function emuPanelNewTab() {
|
||||
@@ -1328,11 +1331,37 @@ function openArduinoEmulator() {
|
||||
}
|
||||
}
|
||||
|
||||
function openAndroidEmulator() {
|
||||
function openAndroidEmulator(_isRetry) {
|
||||
const btn = document.getElementById('code-android-btn');
|
||||
if (btn) { btn.textContent = '⏳ 확인 중…'; btn.disabled = true; }
|
||||
// Idle sessions no longer auto-die, so one from before a page reload may
|
||||
// still be running — reconnect to it instead of calling /start (which
|
||||
// would just 429 "already running" and close the panel).
|
||||
api('/api/android/mine')
|
||||
.then(d => {
|
||||
if (btn) { btn.textContent = '🤖 Android'; btn.disabled = false; }
|
||||
_emuPanelLoad('/android-emulator.html?session=' + d.id, 'Android');
|
||||
codeAiAppend('system', '✅ 기존 Android 에뮬레이터 세션에 재연결됨.');
|
||||
})
|
||||
.catch(e => {
|
||||
// A bare "Failed to fetch" (network-layer failure, not our JSON 404
|
||||
// for "no session") happens reliably on the very first click right
|
||||
// after this page finishes loading — likely the browser's per-origin
|
||||
// connection pool still busy with the editor/terminal/etc. assets.
|
||||
// One silent retry after a beat clears it without bothering the user;
|
||||
// real 404s ("no session yet") resolve immediately either way.
|
||||
if (!_isRetry && /Failed to fetch/i.test(e.message || '')) {
|
||||
setTimeout(() => openAndroidEmulator(true), 600);
|
||||
return;
|
||||
}
|
||||
_startNewAndroidEmulator(btn);
|
||||
});
|
||||
}
|
||||
|
||||
function _startNewAndroidEmulator(btn, _isRetry) {
|
||||
if (btn) { btn.textContent = '⏳ 부팅 중…'; btn.disabled = true; }
|
||||
_emuPanelLoad('/android-emulator.html?loading=1', 'Android');
|
||||
codeAiAppend('system', '🤖 Android 에뮬레이터 부팅 중... (최대 90초)');
|
||||
if (!_isRetry) codeAiAppend('system', '🤖 Android 에뮬레이터 부팅 중... (최대 90초)');
|
||||
api('/api/android/start', { method: 'POST' })
|
||||
.then(d => {
|
||||
if (btn) { btn.textContent = '🤖 Android'; btn.disabled = false; }
|
||||
@@ -1344,12 +1373,32 @@ function openAndroidEmulator() {
|
||||
_emuPanelLoad('/android-emulator.html?session=' + d.id, 'Android');
|
||||
codeAiAppend('system', '✅ Android 에뮬레이터 실행 중.');
|
||||
}).catch(e => {
|
||||
// Same first-click connection-pool hiccup as in openAndroidEmulator()
|
||||
// above — retry once before bothering the user with it.
|
||||
if (!_isRetry && /Failed to fetch/i.test(e.message || '')) {
|
||||
setTimeout(() => _startNewAndroidEmulator(btn, true), 600);
|
||||
return;
|
||||
}
|
||||
if (btn) { btn.textContent = '🤖 Android'; btn.disabled = false; }
|
||||
codeAiAppend('system', '⚠️ ' + e.message);
|
||||
toggleEmuPanel();
|
||||
});
|
||||
}
|
||||
|
||||
function resetAndroidEmulator() {
|
||||
const btn = document.getElementById('code-android-reset-btn');
|
||||
if (btn) { btn.disabled = true; }
|
||||
api('/api/android/reset', { method: 'POST' })
|
||||
.then(d => {
|
||||
if (btn) { btn.disabled = false; }
|
||||
codeAiAppend('system', `🔄 Android 세션 ${d.killed}개 강제 종료됨. 다시 열어주세요.`);
|
||||
if (_emuPanelOpen) toggleEmuPanel();
|
||||
}).catch(e => {
|
||||
if (btn) { btn.disabled = false; }
|
||||
codeAiAppend('system', '⚠️ ' + e.message);
|
||||
});
|
||||
}
|
||||
|
||||
// ── Arduino 업로드 페이지 열기 ────────────────────────────────────────────────
|
||||
function csbUploadToBoard() {
|
||||
const file = codeFiles.find(f => f.id === activeCodeFileId);
|
||||
|
||||
Reference in new issue
Block a user