From ecbe6f1825d9d43bbcdeaec7ec40076544a33880 Mon Sep 17 00:00:00 2001 From: kicer Date: Mon, 31 Aug 2026 10:57:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=89=8D=E7=AB=AF=E3=80=8C?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E6=89=A7=E8=A1=8C/=E7=BB=88=E6=AD=A2?= =?UTF-8?q?=E3=80=8D=E9=98=B6=E6=AE=B5=E5=BC=80=E5=85=B3=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=9Aphase-bar=20=E4=BB=85=E4=BF=9D=E7=95=99=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E8=83=B6=E5=9B=8A=EF=BC=9B=E5=8E=BB=E6=8E=89=20state.?= =?UTF-8?q?phase=20=E5=8F=8A=20phase=20SSE=20=E7=9B=91=E5=90=AC=E3=80=81to?= =?UTF-8?q?gglePhase=E3=80=81=E5=88=97=E8=A1=A8=E3=80=8C=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E4=B8=AD=E9=98=B6=E6=AE=B5=E3=80=8D=E5=BE=BD=E7=AB=A0=E4=B8=8E?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=20CSS=EF=BC=88=E5=90=8E=E7=AB=AF=20/start=20?= =?UTF-8?q?/stop=20=E6=8E=A5=E5=8F=A3=E4=BF=9D=E7=95=99=EF=BC=8C=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E8=B0=83=E7=94=A8=E6=9C=AC=E5=B0=B1=E4=B8=8D=E5=8F=97?= =?UTF-8?q?=20phase=20=E9=97=A8=E6=8E=A7=EF=BC=8C=E7=BA=AF=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E5=8D=B3=E5=8F=AF=E9=A9=B1=E5=8A=A8=20AI=20=E5=B9=B2?= =?UTF-8?q?=E6=B4=BB=EF=BC=89=EF=BC=9B=E9=A1=BA=E6=89=8B=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=A9=BA=E6=80=81=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/server/public/css/style.css | 15 ++--------- app/server/public/index.html | 3 +-- app/server/public/js/app.js | 47 ++++----------------------------- 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 9f81b89..3b0420f 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -75,25 +75,14 @@ body { .badge.queued { background: #fff4dc; color: #a06a00; } .badge.completed { background: #eceff5; color: #5c6674; } .badge.cancelled { background: #fdecea; color: #b3382c; } -.badge.execution { background: #e8ecfd; color: #3550b8; } .session-del { color: #c33; background: none; border: none; font-size: 12px; padding: 6px; } -/* ---- 阶段开关条 ---- */ +/* ---- 任务状态栏 ---- */ .phase-bar { - display: flex; align-items: center; justify-content: space-between; + display: flex; align-items: center; padding: 8px 12px; background: #fff; border-bottom: 1px solid #e8e8ee; } .status-pill { font-size: 12px; color: #666; } -.phase-switch { - border: none; border-radius: 18px; padding: 8px 18px; - font-size: 14px; font-weight: 600; color: #fff; cursor: pointer; - box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18); - transition: background 0.2s; -} -.phase-switch.planning { background: #2e9d54; } -.phase-switch.planning:active { background: #268547; } -.phase-switch.execution { background: #d2483c; } -.phase-switch.execution:active { background: #b13a2f; } /* ---- 消息 ---- */ .messages { diff --git a/app/server/public/index.html b/app/server/public/index.html index 5878849..c97b494 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -45,10 +45,9 @@ - +
-- -
diff --git a/app/server/public/js/app.js b/app/server/public/js/app.js index 5954c9f..90b5a2a 100644 --- a/app/server/public/js/app.js +++ b/app/server/public/js/app.js @@ -8,7 +8,6 @@ if (typeof marked !== 'undefined') { const state = { sessionId: null, - phase: 'planning', status: '', es: null, streamEl: null, @@ -120,11 +119,10 @@ async function loadSessions() { el.innerHTML = rows.map(s => { const st = { queued: '排队中', active: '活跃中', completed: '已完成', cancelled: '已终止' }[s.status] || s.status; const badge = '' + st + (s.status === 'queued' && s.queue_pos ? ' #' + s.queue_pos : '') + ''; - const phase = s.phase === 'execution' ? '执行中阶段' : ''; return '
' + '
' + '
' + esc(s.title || s.id) + '
' + - '
' + esc(s.id) + '' + badge + phase + + '
' + esc(s.id) + '' + badge + (s.model_id ? '' + esc(s.model_id) + '' : '') + '
' + '
' + '' + @@ -217,7 +215,6 @@ async function renderDetail(detail) { state.streamText = ''; state.toolCards = {}; const s = detail.session; - state.phase = s.phase; state.status = s.status; updatePhaseUI(); $('chat-title').textContent = s.title || s.id; @@ -227,7 +224,7 @@ async function renderDetail(detail) { if (m.role === 'assistant') appendToolCardsFromAssistant(m, box); } if (!detail.messages.length) { - box.innerHTML = '
描述你的需求,AI 会先和你讨论(规划阶段)。
'; + box.innerHTML = '
描述你的需求,AI 会和你讨论并直接干活。
'; } scrollBottom(); loadFiles(); @@ -246,13 +243,8 @@ function connectStream() { es.addEventListener('status', ev => { const d = JSON.parse(ev.data); state.status = d.status; - state.phase = d.phase; updatePhaseUI(d); }); - es.addEventListener('phase', ev => { - state.phase = JSON.parse(ev.data).phase; - updatePhaseUI(); - }); es.addEventListener('assistant_delta', ev => { const d = JSON.parse(ev.data); if (!state.streamEl) { @@ -312,25 +304,16 @@ function connectStream() { }); } -// ---------- 阶段开关 ---------- +// ---------- 任务状态 ---------- function updatePhaseUI(d) { - const btn = $('phase-switch'); const pill = $('status-pill'); const stMap = { queued: '排队中', active: '活跃中', completed: '已完成', cancelled: '已终止' }; let text = stMap[state.status] || state.status || '--'; if (d && d.queue_pos) text += '(第 ' + d.queue_pos + ' 位)'; if (state.status === 'active') { - const run = d && d.running; - text = '活跃中 · ' + (state.phase === 'execution' ? '执行' : '规划') + (d && d.model_id ? ' · ' + d.model_id : ''); + text = '活跃中' + (d && d.model_id ? ' · ' + d.model_id : ''); } pill.textContent = text; - if (state.phase === 'execution') { - btn.textContent = '■ 终止'; - btn.className = 'phase-switch execution'; - } else { - btn.textContent = '▶ 开始执行'; - btn.className = 'phase-switch planning'; - } } // ---------- 文件 ---------- @@ -340,7 +323,7 @@ async function loadFiles() { const files = await req('GET', '/api/sessions/' + state.sessionId + '/files'); const el = $('files-list'); if (!files.length) { - el.innerHTML = '
还没有文件。上传文件或在执行阶段让 AI 生成。
'; + el.innerHTML = '
还没有文件。上传文件或在对话中让 AI 生成。
'; return; } el.innerHTML = files.map(f => { @@ -423,26 +406,6 @@ const ui = { scrollBottom(); } catch (e) { toast('发送失败:' + e.message); } }, - async togglePhase() { - if (!state.sessionId) return; - try { - if (state.phase === 'planning') { - await req('POST', '/api/sessions/' + state.sessionId + '/start'); - state.phase = 'execution'; - updatePhaseUI(); - const box = $('messages'); - const wrap = document.createElement('div'); - wrap.className = 'msg me'; - wrap.innerHTML = '
我(开始执行)
' + - '
我说完了,你可以开始干活了。先把我上面说的需求整理成 task.md 文件写入任务目录,然后按照 task.md 开始执行。
'; - box.appendChild(wrap); - scrollBottom(); - } else { - await req('POST', '/api/sessions/' + state.sessionId + '/stop'); - toast('已发送终止指令'); - } - } catch (e) { toast('操作失败:' + e.message); } - }, toggleFiles() { state.filePanelOpen = !state.filePanelOpen; $('files-panel').classList.toggle('hidden', !state.filePanelOpen);