diff --git a/app/server/engine.js b/app/server/engine.js index 3c6bf73..990b3cf 100644 --- a/app/server/engine.js +++ b/app/server/engine.js @@ -195,6 +195,15 @@ function releaseHeld(sessionId) { dispatchQueued(); } +// 用户主动「断开」: held 会话放弃保持租约,结版为 completed(区别于终止的 cancelled) +function releaseHold(sessionId) { + const s = getSession(sessionId); + if (!s) throw Object.assign(new Error('会话不存在'), { status_code: 404 }); + if (s.status !== 'held') throw Object.assign(new Error('会话不在保持中'), { status_code: 409 }); + releaseHeld(sessionId); + return { ok: true }; +} + // active 但闲置(从未发言/无未回应消息)→ 按租约释放,语义同 held 到期 function releaseIdleActive(sessionId) { const s = getSession(sessionId); @@ -535,6 +544,7 @@ module.exports = { postUserMessage, startExecution, stop, + releaseHold, deleteSession, getSession, getRun, diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index f6edcb0..44e40a2 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -89,9 +89,9 @@ body { .session-meta { font-size: 12px; color: #888; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; } .badge { font-size: 11px; padding: 1px 7px; border-radius: 8px; white-space: nowrap; } .badge.active { background: #e3f2e6; color: #217a34; } -.badge.queued { background: #fff4dc; color: #a06a00; } +.badge.queued { background: #e8eefc; color: #4a5f87; } .badge.completed { background: #eceff5; color: #5c6674; } -.badge.held { background: #efeafc; color: #6b46c8; } +.badge.held { background: #fff4dc; color: #a06a00; } .badge.cancelled { background: #fdecea; color: #b3382c; } .session-del { color: #c33; background: none; border: none; font-size: 12px; padding: 6px; } @@ -100,11 +100,30 @@ body { display: flex; align-items: center; padding: 8px 12px; background: #fff; border-bottom: 1px solid #e8e8ee; } -.status-pill { font-size: 12px; color: #666; } +/* 会话窗口顶部状态栏随状态染色:执行中=绿底、保持中=黄底,一眼区分 */ +.phase-bar.active { background: #f0f9f2; border-bottom-color: #cde8d3; } +.phase-bar.held { background: #fffbe8; border-bottom-color: #f5e3b3; } +/* 状态胶囊:带圆点,按状态配色(活跃=绿、保持=黄、排队=蓝灰、终止=红) */ +.status-pill { + display: inline-flex; align-items: center; gap: 6px; + font-size: 12px; padding: 3px 10px; border-radius: 10px; + background: #eceff5; color: #5c6674; +} +.status-pill::before { + content: ''; width: 7px; height: 7px; border-radius: 50%; + background: currentColor; flex-shrink: 0; +} +.status-pill.active { background: #e3f2e6; color: #1c7a2e; } +.status-pill.active::before { animation: pill-pulse 1.2s ease-in-out infinite; } +.status-pill.held { background: #fff4dc; color: #8a6400; } +.status-pill.queued { background: #e8eefc; color: #4a5f87; } +.status-pill.cancelled { background: #fdecea; color: #b3382c; } +@keyframes pill-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } } .stop-link { background: none; border: none; cursor: pointer; color: #c33; font-size: 12px; padding: 2px 6px; margin-left: 2px; } +.stop-link.muted { color: #8a6400; } .stop-link:active { opacity: 0.6; } /* ---- 消息 ---- */ diff --git a/app/server/public/index.html b/app/server/public/index.html index c989a8e..a9099a1 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -113,6 +113,6 @@
- +