From 91412dc351d69e4a72feef8e83eabc7f1db7b71f Mon Sep 17 00:00:00 2001 From: ci-check Date: Sat, 28 Nov 2026 19:53:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20sessions=20UI=20=E2=80=94=20live=20means?= =?UTF-8?q?=20active=20(recent),=20hide=20:side:/:sub:=20children=20by=20d?= =?UTF-8?q?efault=20(#7876)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sessions page's Live filter was a no-op: `live` meant "resident in the in-memory pool", and the pool only evicts when full, so on a long-running daemon every session seen since process start stayed live (104/104 rows marked live while ~3 were actually active). A restart just moved the same sessions to History. P1: `live` is now recency-gated active — in memory AND seen within 10 min (the repo's existing active/fresh convention, SPLIT_CANARY_FRESH_MS / PERSONA_LINEAGE_FRESH_MS). The state filter, the overview live count, and the row/detail badges all key off the active state. P2: client-minted child conversations (:side:/:sub:, one-shot auxiliary calls) are hidden from the list by default (new "show side/sub sessions" toggle) and inherit the parent's clientHint, so omp's auxiliary calls read as omp instead of the UA-sniffed "claude". Closes #7876 --- src/plugin.ts | 2 +- src/server/admin.ts | 4 +- src/web/client.ts | 25 ++++++++++--- src/web/i18n.ts | 12 +++++- src/web/page.ts | 2 +- src/web/sessions-data.ts | 76 ++++++++++++++++++++++++++++++-------- src/web/styles.ts | 4 ++ tests/web-sessions.test.ts | 76 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 175 insertions(+), 26 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index 867038aef8..77820b7dee 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -801,7 +801,7 @@ export function pluginRuntimeInfoFor(agent: string | undefined, model: string | const CHILD_CONVERSATION_SUFFIX = /:(?:side(?::conversation)?|sub):[^:]+$/; const MAX_CHILD_CONVERSATION_DEPTH = 4; -function parentConversationId(conversationId: string): string | undefined { +export function parentConversationId(conversationId: string): string | undefined { const parent = conversationId.replace(CHILD_CONVERSATION_SUFFIX, ""); return parent !== conversationId && parent.length > 0 ? parent : undefined; } diff --git a/src/server/admin.ts b/src/server/admin.ts index dd3684131b..821ac3b96e 100644 --- a/src/server/admin.ts +++ b/src/server/admin.ts @@ -1414,7 +1414,8 @@ async function sendWebSessions(res: http.ServerResponse, req: http.IncomingMessa u.searchParams.has("q") || u.searchParams.has("protocol") || u.searchParams.has("client") || - u.searchParams.has("state"); + u.searchParams.has("state") || + u.searchParams.has("children"); if (paged) { const rawSize = Number(u.searchParams.get("pageSize")); const pageSize = Number.isFinite(rawSize) && rawSize > 0 ? Math.min(Math.floor(rawSize), 200) : 50; @@ -1428,6 +1429,7 @@ async function sendWebSessions(res: http.ServerResponse, req: http.IncomingMessa protocol: u.searchParams.get("protocol") ?? undefined, client: u.searchParams.get("client") ?? undefined, state, + showChildren: u.searchParams.get("children") === "1", page, pageSize, })), diff --git a/src/web/client.ts b/src/web/client.ts index 5ca025d133..ea882393eb 100644 --- a/src/web/client.ts +++ b/src/web/client.ts @@ -722,7 +722,7 @@ export const WEB_CLIENT = `(function () { // not live. const named = Boolean(s.title || s.label || s.firstBlockHint); const name = s.title || s.label || s.firstBlockHint || t("ses.no_title"); - const live = s.live && !s.restored; + const live = s.live; // Only actively running sessions get a status tag; disk/restored rows carry none. // The whole cell is a real hash anchor: plain clicks route inside the SPA exactly as // before (the row handler bails on ), while Ctrl/Cmd+click or middle-click opens @@ -803,9 +803,14 @@ export const WEB_CLIENT = `(function () { const laneChip = s.engineLane === "inline" ? ' inline' : s.engineLane === "server" ? ' srv' : ""; + // #7876: child (:side:/:sub:) sessions are one-shot auxiliary calls — + // mark them so the row reads as a sub-call, not a top-level session. + const childChip = s.child + ? ' ' + t("ses.badge_child") + "" + : ""; const clientCell = clientHint - ? '' + escapeHtml(clientHint) + "" + laneChip - : '' + t("common.none") + "" + laneChip; + ? '' + escapeHtml(clientHint) + "" + laneChip + childChip + : '' + t("common.none") + "" + laneChip + childChip; tr.innerHTML = "" + sessionTitleCell(s) + '' + clientCell + '' + protoBadge(s.protocol) + '' + escapeHtml(hostOf(s.upstreamOrigin)) + '' + (s.requests ? s.requests : t("common.none")) + '' + fmtW(s.contextBest ? s.contextBest.tokens : s.contextTokens) + '' + (s.inputTokens ? fmtW(s.inputTokens) : '' + t("common.none") + "") + "" + savedTd(s) + hitTd(s) + switchTd(s) + '' + (s.foldCount || 0) + '' + (s.blocks || 0) + '' + timeAgo(s.lastSeen) + ""; } let navTimer = null; @@ -1847,11 +1852,14 @@ function changelogCatOf(rawLine) { const protocol = filterValue("ses-protocol"); const client = filterValue("ses-client"); const state = filterValue("ses-state"); + const childrenEl = $("ses-children"); + const showChildren = Boolean(childrenEl && childrenEl.checked); return API_ROOT + "/sessions?page=" + page + "&pageSize=" + SES_PAGE_SIZE + (q ? "&q=" + encodeURIComponent(q) : "") + (protocol ? "&protocol=" + encodeURIComponent(protocol) : "") + (client ? "&client=" + encodeURIComponent(client) : "") + - (state ? "&state=" + encodeURIComponent(state) : ""); + (state ? "&state=" + encodeURIComponent(state) : "") + + (showChildren ? "&children=1" : ""); } function filterValue(id) { const el = $(id); @@ -1893,7 +1901,8 @@ function changelogCatOf(rawLine) { } function hasActiveFilters() { const q = (($("ses-search") && $("ses-search").value) || "").trim(); - return Boolean(q || filterValue("ses-protocol") || filterValue("ses-client") || filterValue("ses-state")); + const childrenEl = $("ses-children"); + return Boolean(q || filterValue("ses-protocol") || filterValue("ses-client") || filterValue("ses-state") || (childrenEl && childrenEl.checked)); } function updatePager() { const prev = $("ses-prev"); @@ -1922,6 +1931,8 @@ function changelogCatOf(rawLine) { const search = $("ses-search"); if (search) search.value = ""; ["ses-protocol", "ses-client", "ses-state"].forEach((id) => { const el = $(id); if (el) el.value = ""; }); + const childrenEl = $("ses-children"); + if (childrenEl) childrenEl.checked = false; return refreshSessions(false, 1); } function renderSessionTable() { @@ -2735,7 +2746,7 @@ function changelogCatOf(rawLine) { return plain.length > 48 ? plain.slice(0, 48) + "…" : plain || b.blockId; } function detailBadges(d) { - const live = d.live && !d.restored; + const live = d.live; let html = ""; if (live) html = '' + t("common.live") + ""; if (d.protocol) html += (html ? " " : "") + protoBadge(d.protocol); @@ -5743,6 +5754,8 @@ if (d.keepalive) kv(parts, t("det.keepalive"), d.keepalive.tierLabel + " · " + const el = $(id); if (el) el.addEventListener("change", () => refreshSessions(false, 1)); }); + const sesChildren = $("ses-children"); + if (sesChildren) sesChildren.addEventListener("change", () => refreshSessions(false, 1)); const reset = $("ses-reset-filters"); if (reset) reset.addEventListener("click", resetSessionFilters); const prev = $("ses-prev"); diff --git a/src/web/i18n.ts b/src/web/i18n.ts index 45d66a429b..da7a57bcd0 100644 --- a/src/web/i18n.ts +++ b/src/web/i18n.ts @@ -65,7 +65,7 @@ export const MESSAGES: Record> = { "common.live": "运行中", "common.sessions": "会话", "common.copied_hint": "已复制 ✓", - "ses.badge_live_tip": "当前进程正在处理的会话(实时数据)", + "ses.badge_live_tip": "最近 10 分钟内有活动的会话(在内存中且最近使用)", "ses.slow_short": "长会话", "ses.slow_tip": "已处理 {n} 次模型请求——宿主侧对话历史只增不减(压缩只缩发给模型的量,不缩宿主自己的文件),步耗时会随之变慢。建议开一个新会话继续。", "common.requests": "请求", @@ -352,6 +352,10 @@ export const MESSAGES: Record> = { "ses.filter_state_all": "全部状态", "ses.filter_state_live": "运行中", "ses.filter_state_history": "历史会话", + "ses.filter_children": "显示 side/sub 会话", + "ses.filter_children_tip": "客户端辅助调用(:side:/:sub:)默认隐藏,勾选后显示", + "ses.badge_child": "side", + "ses.badge_child_tip": "客户端辅助调用(一次性 side/sub 请求),默认隐藏", "ses.filter_unknown": "未知", "ses.reset_filters": "重置筛选", "ses.prev_page": "上一页", @@ -868,7 +872,7 @@ export const MESSAGES: Record> = { "common.live": "live", "common.sessions": "sessions", "common.copied_hint": "Copied ✓", - "ses.badge_live_tip": "Session being processed by the current daemon (live data)", + "ses.badge_live_tip": "Active in the last 10 minutes (in memory and recently used)", "ses.slow_short": "slow", "ses.slow_tip": "{n} requests so far — the host-side history only grows (compression shrinks what is sent to the model, not the host's own file), so each step gets slower over time. Consider starting a new session.", "common.requests": "requests", @@ -1152,6 +1156,10 @@ export const MESSAGES: Record> = { "ses.filter_state_all": "All states", "ses.filter_state_live": "Live", "ses.filter_state_history": "History", + "ses.filter_children": "Show side/sub sessions", + "ses.filter_children_tip": "Client auxiliary calls (:side:/:sub:) are hidden by default; check to show them", + "ses.badge_child": "side", + "ses.badge_child_tip": "Client auxiliary call (one-shot side/sub request), hidden by default", "ses.filter_unknown": "Unknown", "ses.reset_filters": "Reset filters", "ses.prev_page": "Previous", diff --git a/src/web/page.ts b/src/web/page.ts index 45fba31d2d..b8159d22ee 100644 --- a/src/web/page.ts +++ b/src/web/page.ts @@ -75,7 +75,7 @@ export function renderPage(origin: string, version: string, embed = false, theme