feat(ui): 会话徽标改显示 LLM 配置名

会话标题右侧的徽标原本显示模型 ID,改为显示配置名称;模型 ID 移到 hover
的 tooltip 里,并去掉其中的协议名(openai/anthropic 等)。

- 抽出 resolutionLabel(),徽标、aria-label、tooltip 共用一处取名逻辑;
  environment 来源的配置可能没有 name,按 name → model → 未命名配置 降级,
  避免渲染出空徽标
- 去掉 font-mono:等宽字体是为模型 ID 准备的,配置名多为中文
- tooltip 用 filter(Boolean).join(" / ") 拼接,模型名缺失时不留孤立斜杠

Claude-Session: https://claude.ai/code/session_01Q8nhYZfS4H8fsSCBJXxbSy
This commit is contained in:
Autumn-27 committed 2026-08-22 06:18:07 -04:00
1 parent adc8e3521d
commit 9b75afe9f1
1 file changed
+13 -4
@@ -59,6 +59,13 @@ import type {
} from "@/lib/types";
import { cn } from "@/lib/utils";
// resolutionLabel names the LLM a session runs on. The badge shows this alone and
// keeps the model id in its tooltip. Env-backed configs can arrive without a name,
// so fall back to the model id rather than rendering an empty badge.
function resolutionLabel(r: TaskLLMResolution): string {
return r.name || r.model || "未命名配置";
}
// fmtBytes renders a human file size for attachment chips (mirrors transcript.tsx).
function fmtBytes(n: number): string {
if (n >= 1 << 20) return `${(n / (1 << 20)).toFixed(1)} MB`;
@@ -1376,17 +1383,19 @@ export function SessionsTab({ taskId }: { taskId: string }) {
<TooltipTrigger asChild>
<Badge
variant="outline"
className="max-w-28 shrink-0 font-mono font-normal"
aria-label={activeResolution.available ? `当前模型:${activeResolution.model}` : "模型不可用"}
className="max-w-28 shrink-0 font-normal"
aria-label={
activeResolution.available ? `当前配置:${resolutionLabel(activeResolution)}` : "模型不可用"
}
>
<span className="truncate">
{activeResolution.available ? activeResolution.model : "模型不可用"}
{activeResolution.available ? resolutionLabel(activeResolution) : "模型不可用"}
</span>
</Badge>
</TooltipTrigger>
<TooltipContent side="bottom" className="max-w-xs [overflow-wrap:anywhere]">
{activeResolution.available
? `${activeResolution.name} / ${activeResolution.format} / ${activeResolution.model}`
? [resolutionLabel(activeResolution), activeResolution.model].filter(Boolean).join(" / ")
: activeResolution.reason || "没有可用的 LLM 配置"}
</TooltipContent>
</Tooltip>