fix: clarify Workbench session title fallback

This commit is contained in:
root
2026-07-20 11:42:13 +02:00
parent f07669fe40
commit f4aaf55c48
3 changed files with 22 additions and 3 deletions
@@ -106,8 +106,8 @@ function formatSessionUpdatedTime(value: string | null | undefined): string {
<div v-if="!collapsed" class="session-list" id="session-tabs" :data-loading="showSessionListLoading">
<LoadingState v-if="showSessionListLoading" class="session-list-loading" label="加载中" />
<template v-else>
<button v-for="tab in workbench.sessionTabs" :key="tab.sessionId || tab.key" class="session-tab" :data-active="tab.active" :data-running="tab.running" :data-status="tab.status || undefined" :data-projection-health="tab.projectionHealth || undefined" :data-session-id="tab.sessionId || undefined" type="button" :title="tab.projectionDiagnosticText || tab.label || tab.sessionId || tab.key" @click="workbench.selectSession(tab)">
<span class="session-tab-title">{{ tab.label || tab.sessionId }}</span>
<button v-for="tab in workbench.sessionTabs" :key="tab.sessionId || tab.key" class="session-tab" :data-active="tab.active" :data-running="tab.running" :data-status="tab.status || undefined" :data-projection-health="tab.projectionHealth || undefined" :data-session-id="tab.sessionId || undefined" type="button" :title="tab.tooltip" @click="workbench.selectSession(tab)">
<span class="session-tab-title">{{ tab.label }}</span>
<span v-if="tab.projectionDiagnosticText" class="session-tab-diagnostic">状态更新异常</span>
<time class="session-tab-time" :datetime="tab.updatedAt || tab.startedAt || undefined">{{ formatSessionUpdatedTime(tab.updatedAt || tab.startedAt) }}</time>
</button>
@@ -165,3 +165,19 @@ test("session rail update time uses the last user send time instead of replay re
assert.equal(tab.updatedAt, "2026-07-20T00:00:00.000Z");
});
test("session rail uses a neutral label when Kafka has no user title event", () => {
const sessionId = "ses_session_rail_without_kafka_title";
const tab = sessionToSessionTab({ sessionId, messages: [] }, null);
assert.equal(tab.label, "新建会话");
assert.equal(tab.tooltip, `新建会话 · ${sessionId}`);
});
test("session rail keeps the Kafka user preview as its visible title", () => {
const sessionId = "ses_session_rail_with_kafka_title";
const tab = sessionToSessionTab({ sessionId, firstUserMessagePreview: "hi", messages: [] }, null);
assert.equal(tab.label, "hi");
assert.equal(tab.tooltip, `hi · ${sessionId}`);
});
@@ -18,6 +18,7 @@ export interface ComposerState {
export interface SessionTab extends WorkbenchSessionRecord {
key: string;
label: string;
tooltip: string;
subtitle: string;
active: boolean;
running: boolean;
@@ -162,10 +163,12 @@ export function sessionToSessionTab(session: WorkbenchSessionRecord, activeSessi
session.title,
session.name
);
const label = preview ?? "新建会话";
return {
...session,
key: sessionId,
label: preview ?? `Session ${shortToken(sessionId, 8)}`,
label,
tooltip: `${projectionText ?? label} · ${sessionId}`,
subtitle: `${projectionText ? "状态更新异常" : running ? "处理中" : trace ? `trace ${shortToken(trace, 8)}` : status === "unknown" ? "状态同步中" : "未开始"} · ${session.messageCount ?? session.messages?.length ?? 0}`,
lastTraceId: trace,
status,