스튜디오 앱에 프롬프트 작성 도우미 채팅 + 생성 진행률 바 추가

이미지/동영상/사진편집/이모티콘세트 탭과 ComfyUI 탭 양쪽에 AI 프롬프트
도우미를 붙여, 한국어로 설명하면 SDXL/FLUX/LTX용 영어 프롬프트를 만들어줌.
생성 중에는 예상 소요시간 기준 진행률 바를 표시.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
kimandClaude Sonnet 5 committed 2026-08-06 12:27:39 +09:00
1 parent 6014e51ba3
commit 6a61c3f4af
4 files changed
+263 -9

No files matched your search

+46
View File
@@ -427,4 +427,50 @@ export function registerImagegenRoutes(app: Express): void {
fs.unlinkSync(target);
res.json({ success: true });
});
// Prompt-writing helper for the studio app's chat sidebar. One-shot, non-streaming
// Ollama call (no tools/history/personality-context machinery — this is a small
// conversational assist, not a full agent turn) using whatever model is currently
// configured as primary. The system prompt asks the model to always close its
// reply with a fenced PROMPT:/NEGATIVE: block so the frontend can offer an
// "적용" button that lifts the crafted prompt straight into the form fields.
app.post('/api/studio/prompt-assist', async (req: Request, res: Response) => {
const user = (req as any).user;
if (!user) return res.status(401).json({ error: 'Unauthorized' });
const mode = req.body?.mode === 'video' ? 'video' : 'image';
const messages = Array.isArray(req.body?.messages) ? req.body.messages : [];
if (messages.length === 0) return res.status(400).json({ error: 'messages required' });
const systemPrompt = mode === 'video'
? `당신은 이미지/동영상 생성 스튜디오 앱에 내장된 프롬프트 작성 도우미입니다. 사용자가 한국어로 설명하는 장면을 LTX-Video/CogVideoX 같은 동영상 diffusion 모델에 적합한 영어 프롬프트로 다듬어주세요 (카메라 움직임, 조명, 분위기, 동작 묘사 포함). 대화는 한국어로 하되, 답변 맨 끝에는 반드시 아래 형식의 블록을 붙이세요:\n\`\`\`\nPROMPT: <영어 프롬프트>\nNEGATIVE: <네거티브 프롬프트, 없으면 빈 칸>\n\`\`\``
: `당신은 이미지/동영상 생성 스튜디오 앱에 내장된 프롬프트 작성 도우미입니다. 사용자가 한국어로 설명하는 이미지를 SDXL/FLUX 같은 이미지 diffusion 모델에 적합한 영어 프롬프트로 다듬어주세요 (스타일, 조명, 구도, 디테일 태그 포함). 대화는 한국어로 하되, 답변 맨 끝에는 반드시 아래 형식의 블록을 붙이세요:\n\`\`\`\nPROMPT: <영어 프롬프트>\nNEGATIVE: <네거티브 프롬프트, 없으면 빈 칸>\n\`\`\``;
try {
const { getConfig } = await import('../../config/config.js');
const rawCfg = getConfig().getConfig() as any;
const provider: string = rawCfg.llm?.provider || 'ollama';
const model: string = rawCfg.llm?.providers?.[provider]?.model || rawCfg.models?.primary || 'gemma4:31b-cloud';
const endpoint: string = rawCfg.ollama?.endpoint || 'http://localhost:11434';
const r = await fetch(`${endpoint}/api/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model,
messages: [{ role: 'system', content: systemPrompt }, ...messages],
stream: false,
}),
signal: AbortSignal.timeout(60_000),
});
if (!r.ok) return res.status(502).json({ error: `ollama HTTP ${r.status}` });
const data: any = await r.json();
const reply = String(data?.message?.content || '').trim();
if (!reply) return res.status(502).json({ error: 'empty response from model' });
res.json({ reply });
} catch (err: any) {
console.error('[imagegen] prompt-assist failed:', err);
res.status(500).json({ error: err?.message || 'prompt-assist failed unexpectedly' });
}
});
}
+11
View File
@@ -690,6 +690,17 @@
</div>
</div>
<!-- WOL-GATE WAKE LOG -->
<div id="wolgate-section" style="display:flex;flex-direction:column;flex-shrink:0;max-height:120px;min-height:80px;overflow:hidden;border:1px solid var(--border);border-radius:8px;background:var(--panel-2);margin-bottom:6px">
<div style="padding:4px 8px;border-bottom:1px solid var(--border);flex-shrink:0;display:flex;align-items:center;justify-content:space-between">
<div style="font-size:9px;text-transform:uppercase;letter-spacing:1.5px;color:var(--muted)">wol-gate 깨우기 로그</div>
<button onclick="refreshWolGateLog()" style="background:none;border:none;color:var(--muted);cursor:pointer;font-size:10px;font-family:inherit">↻</button>
</div>
<div id="wolgate-log" style="flex:1;overflow-y:auto;padding:6px 10px;font-size:10px;line-height:1.6;font-family:'JetBrains Mono',monospace">
<div style="color:var(--muted);text-align:center;padding:10px 0;opacity:0.5">불러오는 중...</div>
</div>
</div>
<!-- PROCESS LOG -->
<div id="process-section" style="display:flex;flex-direction:column;flex:1 1 100px;overflow:hidden;min-height:100px">
<div style="padding:4px 10px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--border);flex-shrink:0">
+170 -9
View File
@@ -23,8 +23,9 @@ body{background:var(--bg);color:var(--text);font-family:system-ui,sans-serif;fon
.st-tab.active{color:var(--brand);border-bottom-color:var(--brand);}
.st-layout{flex:1;display:flex;min-height:0;overflow:hidden;}
.st-comfy-layout{flex:1;display:flex;flex-direction:column;min-height:0;overflow:hidden;}
.st-comfy-layout{flex:1;display:flex;flex-direction:row;min-height:0;overflow:hidden;}
.st-comfy-note{flex-shrink:0;padding:8px 14px;font-size:12px;color:var(--muted);background:var(--bg-soft);border-bottom:1px solid var(--line);}
.st-comfy-assist{width:280px;flex-shrink:0;display:flex;flex-direction:column;gap:6px;padding:10px;border-left:1px solid var(--line);background:var(--panel-2);overflow:hidden;}
.st-form{width:320px;flex-shrink:0;display:flex;flex-direction:column;gap:10px;padding:14px;border-right:1px solid var(--line);background:var(--panel);overflow-y:auto;}
.st-field{display:flex;flex-direction:column;gap:4px;}
.st-field label{font-size:11px;font-weight:700;color:var(--muted);}
@@ -45,6 +46,8 @@ body{background:var(--bg);color:var(--text);font-family:system-ui,sans-serif;fon
.st-spinner{width:32px;height:32px;border:3px solid var(--line);border-top-color:var(--brand);border-radius:50%;animation:st-spin 0.8s linear infinite;margin:0 auto 10px;}
@keyframes st-spin{to{transform:rotate(360deg);}}
.st-status{font-size:12px;color:var(--muted);margin-top:6px;}
.st-progress-track{width:220px;height:6px;border-radius:3px;background:var(--line);margin:10px auto 0;overflow:hidden;}
.st-progress-fill{height:100%;background:var(--brand);border-radius:3px;width:0%;transition:width .4s linear;}
.st-error{color:#ef4444;font-size:12px;}
.st-gallery{flex-shrink:0;border-top:1px solid var(--line);background:var(--panel);padding:8px 12px;max-height:130px;overflow-y:auto;}
@@ -152,19 +155,40 @@ body{background:var(--bg);color:var(--text);font-family:system-ui,sans-serif;fon
</div>
<div class="st-comfy-layout" id="comfy-layout" style="display:none">
<div class="st-comfy-note" id="comfy-note">
ComfyUI 원본 화면입니다 — 노드 그래프를 직접 짜서 실행할 수 있습니다.
<div style="display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden">
<div class="st-comfy-note" id="comfy-note">
ComfyUI 원본 화면입니다 — 노드 그래프를 직접 짜서 실행할 수 있습니다.
</div>
<iframe id="comfy-frame" style="width:100%;flex:1;border:none;background:#1a1a1a"></iframe>
</div>
<div class="st-comfy-assist" id="comfy-assist-panel">
<div style="font-size:11px;font-weight:700;color:var(--muted);padding-bottom:4px">💬 프롬프트 도우미</div>
<div id="comfy-assist-messages" style="flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:6px;font-size:12px"></div>
<div style="display:flex;gap:6px;flex-shrink:0">
<input id="comfy-assist-input" placeholder="예: 빨간 팬더가 책 읽는 장면" style="flex:1;font-size:12px" onkeydown="if(event.key==='Enter'){event.preventDefault();sendComfyAssist();}">
<button type="button" class="hdr-btn" style="font-size:11px" onclick="sendComfyAssist()">전송</button>
</div>
<div class="st-hint" style="margin:0">노드 그래프에는 자동으로 안 들어가서, 만든 프롬프트를 복사해서 CLIPTextEncode 노드에 직접 붙여넣으세요.</div>
</div>
<iframe id="comfy-frame" style="width:100%;flex:1;border:none;background:#1a1a1a"></iframe>
</div>
<div class="st-layout">
<div class="st-form">
<div id="common-fields" style="display:contents">
<div class="st-field">
<label>프롬프트</label>
<div style="display:flex;align-items:center;justify-content:space-between">
<label style="margin:0">프롬프트</label>
<button type="button" class="hdr-btn" style="font-size:11px;padding:2px 8px" onclick="togglePromptAssist()">💬 프롬프트 도우미</button>
</div>
<textarea id="f-prompt" rows="4" placeholder="예: a red panda reading a book, cozy lighting"></textarea>
</div>
<div id="prompt-assist-panel" style="display:none;flex-direction:column;gap:6px;border:1px solid var(--border);border-radius:8px;background:var(--panel-2);padding:8px;margin:-4px 0 4px">
<div id="prompt-assist-messages" style="max-height:220px;overflow-y:auto;display:flex;flex-direction:column;gap:6px;font-size:12px"></div>
<div style="display:flex;gap:6px">
<input id="prompt-assist-input" placeholder="예: 빨간 팬더가 책 읽는 장면, 아늑한 조명" style="flex:1;font-size:12px" onkeydown="if(event.key==='Enter'){event.preventDefault();sendPromptAssist();}">
<button type="button" class="hdr-btn" style="font-size:11px" onclick="sendPromptAssist()">전송</button>
</div>
</div>
<div class="st-field">
<label>네거티브 프롬프트 (선택)</label>
<textarea id="f-neg" rows="2" placeholder="blurry, low quality, deformed"></textarea>
@@ -334,6 +358,123 @@ body{background:var(--bg);color:var(--text);font-family:system-ui,sans-serif;fon
const TOKEN_KEY='smallclaw_token';
function getToken(){try{return sessionStorage.getItem(TOKEN_KEY)||localStorage.getItem(TOKEN_KEY)||'';}catch{return '';}}
function authH(extra){const t=getToken();const h={...(extra||{})};if(t)h['Authorization']='Bearer '+t;return h;}
function escHtml(s){return String(s ?? '').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));}
// --- Prompt-writing assistant (chat sidebar) ---------------------------------
let promptAssistHistory=[];
function togglePromptAssist(){
const el=document.getElementById('prompt-assist-panel');
const showing = el.style.display!=='none';
el.style.display = showing ? 'none' : 'flex';
if(!showing) document.getElementById('prompt-assist-input').focus();
}
function extractPromptBlock(text){
const m=text.match(/PROMPT:\s*([^\n]*)\n?NEGATIVE:\s*([^\n]*)/);
if(!m) return null;
return {prompt:m[1].trim(), negative:m[2].trim()};
}
// Applies the CURRENT contents of the per-message editable textareas, not the
// original AI-generated text — the user may have tweaked a word or two first.
function applyPromptAssist(idx){
const p=document.getElementById(`pa-prompt-${idx}`);
const n=document.getElementById(`pa-neg-${idx}`);
if(!p) return;
document.getElementById('f-prompt').value=p.value;
if(n) document.getElementById('f-neg').value=n.value;
}
function renderPromptAssist(loading){
const el=document.getElementById('prompt-assist-messages');
el.innerHTML = promptAssistHistory.map((m,i)=>{
const isUser = m.role==='user';
const extracted = !isUser ? extractPromptBlock(m.content) : null;
const shown = extracted ? m.content.replace(/```[\s\S]*?```/,'').trim() : m.content;
const editable = extracted ? `
<div style="margin-top:6px;display:flex;flex-direction:column;gap:4px">
<label style="font-size:10px;opacity:0.7">프롬프트 (직접 수정 가능)</label>
<textarea id="pa-prompt-${i}" rows="3" style="font-size:11px;font-family:'JetBrains Mono',monospace;background:var(--panel-2);border:1px solid var(--line);border-radius:6px;padding:6px 8px;color:var(--text);resize:vertical">${escHtml(extracted.prompt)}</textarea>
<label style="font-size:10px;opacity:0.7">네거티브 프롬프트</label>
<textarea id="pa-neg-${i}" rows="2" style="font-size:11px;font-family:'JetBrains Mono',monospace;background:var(--panel-2);border:1px solid var(--line);border-radius:6px;padding:6px 8px;color:var(--text);resize:vertical">${escHtml(extracted.negative)}</textarea>
<button type="button" class="hdr-btn" style="font-size:10px;align-self:flex-start" onclick="applyPromptAssist(${i})">✓ 프롬프트에 적용</button>
</div>` : '';
return `<div style="align-self:${isUser?'flex-end':'flex-start'};max-width:90%;background:${isUser?'var(--brand)':'var(--bg3)'};color:${isUser?'#fff':'inherit'};border-radius:8px;padding:6px 9px;white-space:pre-wrap">${escHtml(shown)}${editable}</div>`;
}).join('') + (loading ? `<div style="align-self:flex-start;color:var(--muted);font-size:11px">생각 중...</div>` : '');
el.scrollTop = el.scrollHeight;
}
async function sendPromptAssist(){
const input=document.getElementById('prompt-assist-input');
const text=input.value.trim();
if(!text) return;
input.value='';
promptAssistHistory.push({role:'user', content:text});
renderPromptAssist(true);
try{
const mode = currentTab==='video' ? 'video' : 'image';
const r=await fetch('/api/studio/prompt-assist',{method:'POST',headers:authH({'Content-Type':'application/json'}),body:JSON.stringify({messages:promptAssistHistory, mode})});
const data=await r.json();
if(!r.ok) throw new Error(data.error||'요청 실패');
promptAssistHistory.push({role:'assistant', content:data.reply});
}catch(e){
promptAssistHistory.push({role:'assistant', content:'오류: '+e.message});
}
renderPromptAssist(false);
}
// --- Same prompt-writing assistant, docked beside the raw ComfyUI iframe -----
// Can't reach into the iframe's node graph reliably (depends on ComfyUI's internal
// JS globals, which could break on a ComfyUI update), so this offers copy-to-clipboard
// instead of an auto-apply button — user pastes into whichever CLIPTextEncode node
// they're working on.
let comfyAssistHistory=[];
function renderComfyAssist(loading){
const el=document.getElementById('comfy-assist-messages');
el.innerHTML = comfyAssistHistory.map((m,i)=>{
const isUser = m.role==='user';
const extracted = !isUser ? extractPromptBlock(m.content) : null;
const shown = extracted ? m.content.replace(/```[\s\S]*?```/,'').trim() : m.content;
const editable = extracted ? `
<div style="margin-top:6px;display:flex;flex-direction:column;gap:4px">
<label style="font-size:10px;opacity:0.7">프롬프트</label>
<textarea id="ca-prompt-${i}" rows="3" style="font-size:11px;font-family:'JetBrains Mono',monospace;background:var(--panel-2);border:1px solid var(--line);border-radius:6px;padding:6px 8px;color:var(--text);resize:vertical">${escHtml(extracted.prompt)}</textarea>
<button type="button" class="hdr-btn" style="font-size:10px;align-self:flex-start" onclick="copyComfyAssist(${i}, this)">📋 복사</button>
</div>` : '';
return `<div style="align-self:${isUser?'flex-end':'flex-start'};max-width:95%;background:${isUser?'var(--brand)':'var(--bg3)'};color:${isUser?'#fff':'inherit'};border-radius:8px;padding:6px 9px;white-space:pre-wrap">${escHtml(shown)}${editable}</div>`;
}).join('') + (loading ? `<div style="align-self:flex-start;color:var(--muted);font-size:11px">생각 중...</div>` : '');
el.scrollTop = el.scrollHeight;
}
async function copyComfyAssist(idx, btn){
const p=document.getElementById(`ca-prompt-${idx}`);
if(!p) return;
const orig=btn.textContent;
let ok=false;
try{
await navigator.clipboard.writeText(p.value);
ok=true;
}catch(e){
// Clipboard API can be gated behind a permission prompt in some contexts
// (embedded/automated browsers) — fall back to the older selection-based
// copy instead of alert()ing, which would just be another blocking dialog.
try{ p.select(); ok=document.execCommand('copy'); }catch(e2){}
}
btn.textContent = ok ? '✓ 복사됨' : '복사 실패 — 직접 선택해서 복사하세요';
setTimeout(()=>{btn.textContent=orig;},1500);
}
async function sendComfyAssist(){
const input=document.getElementById('comfy-assist-input');
const text=input.value.trim();
if(!text) return;
input.value='';
comfyAssistHistory.push({role:'user', content:text});
renderComfyAssist(true);
try{
const r=await fetch('/api/studio/prompt-assist',{method:'POST',headers:authH({'Content-Type':'application/json'}),body:JSON.stringify({messages:comfyAssistHistory, mode:'image'})});
const data=await r.json();
if(!r.ok) throw new Error(data.error||'요청 실패');
comfyAssistHistory.push({role:'assistant', content:data.reply});
}catch(e){
comfyAssistHistory.push({role:'assistant', content:'오류: '+e.message});
}
renderComfyAssist(false);
}
async function checkAuth(){
if(!getToken()){location.href='/login.html?redirect='+encodeURIComponent(location.pathname);return false;}
try{const r=await fetch('/api/auth/status',{headers:authH()});if(!r.ok){location.href='/login.html?redirect='+encodeURIComponent(location.pathname);return false;}const d=await r.json();if(!d.authenticated){location.href='/login.html?redirect='+encodeURIComponent(location.pathname);return false;}return true;}
@@ -751,14 +892,34 @@ function onVideoModelChange(){
}
let genStartTime=0, genTimer=null;
// Rough expected durations per mode, used to animate an estimated (not real — ComfyUI
// only exposes true step-by-step progress over a websocket, not worth the backend
// rework for this) progress bar. Capped at 95% until the actual response lands, so it
// never lies about being "done" before the result is really back.
function estimatedGenMs(){
if(currentTab==='video'){
const m=document.getElementById('f-video-model').value;
return m==='ltx_hq' ? 95000 : m==='cogvideox' ? 120000 : 60000;
}
if(currentTab==='edit') return 15000;
if(currentTab==='sticker'){
const n=document.getElementById('f-phrases').value.split('\n').map(s=>s.trim()).filter(Boolean).length;
return 15000 + Math.max(1,n)*3000;
}
return document.getElementById('f-quality').value==='high' ? 50000 : 15000;
}
function startTimer(){
genStartTime=Date.now();
const btn=document.getElementById('gen-btn');
btn.disabled=true;
const verb = genVerb();
const estMs = estimatedGenMs();
genTimer=setInterval(()=>{
const s=((Date.now()-genStartTime)/1000).toFixed(0);
const elapsed = Date.now()-genStartTime;
const s=(elapsed/1000).toFixed(0);
btn.textContent=verb+' 중... ('+s+'초)';
const fill=document.getElementById('gen-progress-fill');
if(fill) fill.style.width=Math.min(95, (elapsed/estMs)*95).toFixed(0)+'%';
},500);
}
function stopTimer(){
@@ -849,7 +1010,7 @@ async function runEdit(){
const body={path:uploadedPhotoPath, style};
if(style==='cartoon') body.strength=parseFloat(document.getElementById('f-strength').value);
const resultArea=document.getElementById('result-area');
resultArea.innerHTML='<div style="text-align:center"><div class="st-spinner"></div><div class="st-status">스타일 변환 중...</div></div>';
resultArea.innerHTML='<div style="text-align:center"><div class="st-spinner"></div><div class="st-status">스타일 변환 중...</div><div class="st-progress-track"><div class="st-progress-fill" id="gen-progress-fill"></div></div></div>';
startTimer();
try{
const r=await fetch('/api/imagegen/edit-image',{method:'POST',headers:authH({'Content-Type':'application/json'}),body:JSON.stringify(body)});
@@ -900,7 +1061,7 @@ async function runStickerSet(){
const body={path:uploadedStickerPath, style, phrases};
if(style==='cartoon') body.strength=parseFloat(document.getElementById('f-strength2').value);
const resultArea=document.getElementById('result-area');
resultArea.innerHTML='<div style="text-align:center"><div class="st-spinner"></div><div class="st-status">이모티콘 세트 만드는 중... (스타일 변환 → 배경 제거 → 문구 '+phrases.length+'개)</div></div>';
resultArea.innerHTML='<div style="text-align:center"><div class="st-spinner"></div><div class="st-status">이모티콘 세트 만드는 중... (스타일 변환 → 배경 제거 → 문구 '+phrases.length+'개)</div><div class="st-progress-track"><div class="st-progress-fill" id="gen-progress-fill"></div></div></div>';
startTimer();
try{
const r=await fetch('/api/imagegen/make-sticker-set',{method:'POST',headers:authH({'Content-Type':'application/json'}),body:JSON.stringify(body)});
@@ -929,7 +1090,7 @@ async function generate(){
const statusMsg = currentTab==='video' ? '동영상 생성 중... 최대 1~2분 정도 걸릴 수 있어요'
: isHighQuality ? '고품질(FLUX.1) 이미지 생성 중... 최대 1분 정도 걸릴 수 있어요'
: '이미지 생성 중...';
resultArea.innerHTML='<div style="text-align:center"><div class="st-spinner"></div><div class="st-status">'+statusMsg+'</div></div>';
resultArea.innerHTML='<div style="text-align:center"><div class="st-spinner"></div><div class="st-status">'+statusMsg+'</div><div class="st-progress-track"><div class="st-progress-fill" id="gen-progress-fill"></div></div></div>';
startTimer();
const body={
+36
View File
@@ -956,6 +956,40 @@ async function resolveApproval(id, decision) {
loadApprovals();
}
async function refreshWolGateLog() {
const el = document.getElementById('wolgate-log');
if (!el) return;
try {
const data = await api('/api/wol-gate-log');
const lines = (data && data.lines) || [];
if (lines.length === 0) {
el.innerHTML = '<div style="color:var(--muted);text-align:center;padding:10px 0;opacity:0.5">로그 없음</div>';
return;
}
const colorFor = (t) => t === 'success' ? 'var(--brand)' : t === 'warn' ? '#e0a030' : 'var(--muted)';
el.innerHTML = lines.map(l => {
if (!l.event) {
// Startup/misc lines without structured fields — show raw text, muted, with time prefix.
const prefix = l.time ? `[${l.time}] ` : '';
return `<div style="color:var(--muted);opacity:0.6;white-space:pre-wrap;word-break:break-all;margin-bottom:6px">${escHtml(prefix + l.text)}</div>`;
}
const rows = [
['time', l.time],
['IP', l.ip],
['경로', l.method && l.host != null ? `${l.method} ${l.host}${l.path || ''}` : null],
['UA', l.ua],
].filter(([, v]) => v);
return `<div style="border-left:2px solid ${colorFor(l.type)};padding:2px 0 2px 6px;margin-bottom:6px">
<div style="color:${colorFor(l.type)};font-weight:600">${escHtml(l.event)}</div>
${rows.map(([k, v]) => `<div style="color:var(--muted);white-space:pre-wrap;word-break:break-all"><span style="opacity:0.7">${k}:</span> ${escHtml(v)}</div>`).join('')}
</div>`;
}).join('');
el.scrollTop = el.scrollHeight;
} catch (e) {
el.innerHTML = '<div style="color:var(--muted);text-align:center;padding:10px 0;opacity:0.5">불러오기 실패: ' + escHtml(String(e.message || e)) + '</div>';
}
}
function fmtPercent(v, digits = 0) {
const n = Number(v);
if (!Number.isFinite(n)) return '--%';
@@ -1318,6 +1352,8 @@ updateQueuedPromptUI();
setInterval(checkStatus, 10000);
setInterval(loadSystemStats, 3000);
setInterval(loadApprovals, 5000);
refreshWolGateLog();
setInterval(refreshWolGateLog, 60000);
setMode('chat'); // Start in chat mode
setSidebarTab('jobs');