MCPcopy
hub / github.com/Narcooo/inkos / getSessionLabel

Function getSessionLabel

packages/studio/src/components/Sidebar.tsx:711–721  ·  view source on GitHub ↗
(session: { sessionId: string; title: string | null; messages: ReadonlyArray<{ role: string; content: string }> })

Source from the content-addressed store, hash-verified

709}
710
711function getSessionLabel(session: { sessionId: string; title: string | null; messages: ReadonlyArray<{ role: string; content: string }> }): string {
712 if (session.title) return session.title;
713 // 后端会在第一条用户消息发送时立即把消息内容持久化为占位标题。
714 // 这里处理的是"已有消息但标题还没同步回来"的短暂中间态(乐观显示)。
715 const firstUserMsg = session.messages.find((m) => m.role === "user")?.content?.trim();
716 if (firstUserMsg) {
717 const oneLine = firstUserMsg.replace(/\s+/g, " ");
718 return oneLine.length > 20 ? `${oneLine.slice(0, 20)}…` : oneLine;
719 }
720 return "新会话";
721}
722
723function formatRelativeTime(sessionId: string): string {
724 const rawTs = Number(sessionId.split("-")[0]);

Callers 1

SidebarFunction · 0.85

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected