返回 DeepSeek-Reasonix
sessionTitles.ts
根目录 / desktop / frontend / src / lib / sessionTitles.ts
1 import type { TabMeta } from "./types";
2
3 export function tabWorkspaceTitle(tab?: TabMeta): string {
4 if (!tab) return "Global";
5 if (tab.scope === "project") return tab.workspaceName || tab.workspaceRoot || "Project";
6 if (tab.scope === "global") return tab.workspaceName || "Global";
7 return tab.workspaceName || tab.workspaceRoot || "Global";
8 }
9
10 export function topicTitle(tab?: TabMeta): string {
11 if (!tab) return "Global";
12 const workspaceTitle = tabWorkspaceTitle(tab);
13 const topic = tab.topicTitle || (tab.scope === "global" ? workspaceTitle : "Untitled");
14 return topic === workspaceTitle ? workspaceTitle : `${workspaceTitle} / ${topic}`;
15 }
16
17 export function topicDisplayTitle(tab?: TabMeta): string {
18 if (!tab) return "Global";
19 return tab.topicTitle || (tab.scope === "global" ? tabWorkspaceTitle(tab) : "Untitled");
20 }
21
22 export function safeFilename(name: string): string {
23 const cleaned = name.trim().replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " ").slice(0, 80);
24 return cleaned || "reasonix-session";
25 }
26
26 lines TYPESCRIPT