File size: 894 Bytes
c453128 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /** Strip the server-injected workspace context block from a stored user message. */
export function stripWorkspaceHeader(text: string | null | undefined): string {
if (!text) return "";
return text
.replace(/^\s*\[Workspace(?: paths)?:[\s\S]*?\]\s*/i, "")
.replace(/\[Attached (?:image|file): [^\]]*\]\s*/g, "")
.trim();
}
/** Best label for a desk card: LLM title, then cleaned task text, then fallback. */
export function deskDisplayTitle(
title: string | null | undefined,
titleSummary?: string | null,
taskContent?: string | null,
): string {
if (titleSummary?.trim()) return titleSummary.trim();
const cleaned = stripWorkspaceHeader(title);
if (cleaned) return cleaned.length > 80 ? `${cleaned.slice(0, 77)}…` : cleaned;
const task = taskContent?.trim();
if (task) return task.length > 80 ? `${task.slice(0, 77)}…` : task;
return "Untitled task";
}
|