UI: 会话状态配色 + 保持中支持断开
- 会话列表徽标与顶部状态胶囊按状态配色:活跃=绿、保持=黄、排队=蓝灰、终止=红 - 会话窗口顶部状态栏整体染色,便于区分执行中/已完成 - 活跃中按钮为「终止」;保持中改为「断开」,新增 /api/sessions/:id/release 释放保持租约并结版为已完成(非取消)
This commit is contained in:
@@ -195,6 +195,15 @@ function releaseHeld(sessionId) {
|
|||||||
dispatchQueued();
|
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 到期
|
// active 但闲置(从未发言/无未回应消息)→ 按租约释放,语义同 held 到期
|
||||||
function releaseIdleActive(sessionId) {
|
function releaseIdleActive(sessionId) {
|
||||||
const s = getSession(sessionId);
|
const s = getSession(sessionId);
|
||||||
@@ -535,6 +544,7 @@ module.exports = {
|
|||||||
postUserMessage,
|
postUserMessage,
|
||||||
startExecution,
|
startExecution,
|
||||||
stop,
|
stop,
|
||||||
|
releaseHold,
|
||||||
deleteSession,
|
deleteSession,
|
||||||
getSession,
|
getSession,
|
||||||
getRun,
|
getRun,
|
||||||
|
|||||||
@@ -89,9 +89,9 @@ body {
|
|||||||
.session-meta { font-size: 12px; color: #888; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
|
.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 { font-size: 11px; padding: 1px 7px; border-radius: 8px; white-space: nowrap; }
|
||||||
.badge.active { background: #e3f2e6; color: #217a34; }
|
.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.completed { background: #eceff5; color: #5c6674; }
|
||||||
.badge.held { background: #efeafc; color: #6b46c8; }
|
.badge.held { background: #fff4dc; color: #a06a00; }
|
||||||
.badge.cancelled { background: #fdecea; color: #b3382c; }
|
.badge.cancelled { background: #fdecea; color: #b3382c; }
|
||||||
.session-del { color: #c33; background: none; border: none; font-size: 12px; padding: 6px; }
|
.session-del { color: #c33; background: none; border: none; font-size: 12px; padding: 6px; }
|
||||||
|
|
||||||
@@ -100,11 +100,30 @@ body {
|
|||||||
display: flex; align-items: center;
|
display: flex; align-items: center;
|
||||||
padding: 8px 12px; background: #fff; border-bottom: 1px solid #e8e8ee;
|
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 {
|
.stop-link {
|
||||||
background: none; border: none; cursor: pointer;
|
background: none; border: none; cursor: pointer;
|
||||||
color: #c33; font-size: 12px; padding: 2px 6px; margin-left: 2px;
|
color: #c33; font-size: 12px; padding: 2px 6px; margin-left: 2px;
|
||||||
}
|
}
|
||||||
|
.stop-link.muted { color: #8a6400; }
|
||||||
.stop-link:active { opacity: 0.6; }
|
.stop-link:active { opacity: 0.6; }
|
||||||
|
|
||||||
/* ---- 消息 ---- */
|
/* ---- 消息 ---- */
|
||||||
|
|||||||
@@ -113,6 +113,6 @@
|
|||||||
<div class="toast hidden" id="toast"></div>
|
<div class="toast hidden" id="toast"></div>
|
||||||
|
|
||||||
<!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS -->
|
<!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS -->
|
||||||
<script src="/js/app.js?v=20260831f"></script>
|
<script src="/js/app.js?v=20260901a"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -355,8 +355,15 @@ function updatePhaseUI(d) {
|
|||||||
text += ' · ' + d.model_id;
|
text += ' · ' + d.model_id;
|
||||||
}
|
}
|
||||||
pill.textContent = text;
|
pill.textContent = text;
|
||||||
// 活跃中/保持中提供终止入口(保持中点终止 = 主动放弃占用的模型)
|
// 状态胶囊配色:活跃中绿(执行中)、保持中黄(已答完、保持模型中)等;状态栏整体同步染色
|
||||||
$('stop-btn').classList.toggle('hidden', state.status !== 'active' && state.status !== 'held');
|
pill.className = 'status-pill ' + (state.status || '');
|
||||||
|
$('phase-bar').className = 'phase-bar ' + (state.status || '');
|
||||||
|
// 活跃中提供「终止」;保持中改为「断开」(主动放弃保持租约,会话结为已完成)
|
||||||
|
const btn = $('stop-btn');
|
||||||
|
const actionable = state.status === 'active' || state.status === 'held';
|
||||||
|
btn.classList.toggle('hidden', !actionable);
|
||||||
|
btn.textContent = state.status === 'held' ? '断开' : '终止';
|
||||||
|
btn.classList.toggle('muted', state.status === 'held');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- 文件 ----------
|
// ---------- 文件 ----------
|
||||||
@@ -472,10 +479,16 @@ const ui = {
|
|||||||
},
|
},
|
||||||
async stopSession() {
|
async stopSession() {
|
||||||
if (!state.sessionId) return;
|
if (!state.sessionId) return;
|
||||||
|
const held = state.status === 'held';
|
||||||
try {
|
try {
|
||||||
|
if (held) {
|
||||||
|
await req('POST', '/api/sessions/' + state.sessionId + '/release');
|
||||||
|
toast('已断开,模型已释放');
|
||||||
|
} else {
|
||||||
await req('POST', '/api/sessions/' + state.sessionId + '/stop');
|
await req('POST', '/api/sessions/' + state.sessionId + '/stop');
|
||||||
toast('已发送终止指令');
|
toast('已发送终止指令');
|
||||||
} catch (e) { toast('终止失败:' + e.message); }
|
}
|
||||||
|
} catch (e) { toast((held ? '断开失败:' : '终止失败:') + e.message); }
|
||||||
},
|
},
|
||||||
async uploadFiles(ev) {
|
async uploadFiles(ev) {
|
||||||
const input = ev.target;
|
const input = ev.target;
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ router.post('/:id/stop', wrap((req, res) => {
|
|||||||
res.json(engine.stop(req.params.id));
|
res.json(engine.stop(req.params.id));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// 断开:held 会话主动放弃模型保持租约,结版为已完成(非终止)
|
||||||
|
router.post('/:id/release', wrap((req, res) => {
|
||||||
|
res.json(engine.releaseHold(req.params.id));
|
||||||
|
}));
|
||||||
|
|
||||||
// SSE 事件流
|
// SSE 事件流
|
||||||
router.get('/:id/stream', (req, res) => {
|
router.get('/:id/stream', (req, res) => {
|
||||||
const session = engine.getSession(req.params.id);
|
const session = engine.getSession(req.params.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user