Compact imported folder conversation previews
This commit is contained in:
@@ -488,6 +488,33 @@ function buildFolderSearchAliases(items: ConversationItem[]) {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
function compactImportedThreadPreview(preview?: string) {
|
||||
const value = preview?.trim();
|
||||
if (!value) return "";
|
||||
if (/^已从设备.+导入线程《.+》[。.]?$/.test(value)) {
|
||||
return "已导入线程";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function trimLocalWorkspacePrefix(label?: string) {
|
||||
const value = label?.trim();
|
||||
if (!value) return "";
|
||||
const normalized = value.replaceAll("\\", "/");
|
||||
const patterns = [
|
||||
/^\/Users\/[^/]+\/code\/(.+)$/i,
|
||||
/^\/home\/[^/]+\/code\/(.+)$/i,
|
||||
/^[A-Za-z]:\/Users\/[^/]+\/code\/(.+)$/i,
|
||||
];
|
||||
for (const pattern of patterns) {
|
||||
const match = normalized.match(pattern);
|
||||
if (match?.[1]) {
|
||||
return match[1];
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function getConversationItems(state: BossState): ConversationItem[] {
|
||||
const conversations = state.projects.map((project) => buildConversationItem(state, project));
|
||||
|
||||
@@ -548,8 +575,12 @@ export function getConversationHomeItems(state: BossState): ConversationItem[] {
|
||||
}
|
||||
return b.latestReplyAt.localeCompare(a.latestReplyAt);
|
||||
})[0];
|
||||
const recentThreadLabel = latestItem.threadTitle.trim();
|
||||
const recentThreadLabel = trimLocalWorkspacePrefix(latestItem.threadTitle);
|
||||
const searchAliases = buildFolderSearchAliases(items);
|
||||
const latestPreview = compactImportedThreadPreview(latestItem.preview);
|
||||
const latestMessagePreview = compactImportedThreadPreview(
|
||||
latestItem.lastMessagePreview || latestItem.preview,
|
||||
);
|
||||
passthrough.push({
|
||||
conversationId: `folder-${folderKey}`,
|
||||
conversationType: "folder_archive",
|
||||
@@ -571,12 +602,11 @@ export function getConversationHomeItems(state: BossState): ConversationItem[] {
|
||||
searchTargetProjectIds: searchAliases.targetProjectIds,
|
||||
}
|
||||
: {}),
|
||||
preview:
|
||||
latestItem.preview || `包含 ${items.length} 个线程,最近活跃:《${latestItem.threadTitle}》`,
|
||||
preview: latestPreview || `包含 ${items.length} 个线程,最近活跃:《${recentThreadLabel || latestItem.threadTitle}》`,
|
||||
lastMessagePreview:
|
||||
latestItem.lastMessagePreview ||
|
||||
latestItem.preview ||
|
||||
`包含 ${items.length} 个线程,最近活跃:《${latestItem.threadTitle}》`,
|
||||
latestMessagePreview ||
|
||||
latestPreview ||
|
||||
`包含 ${items.length} 个线程,最近活跃:《${recentThreadLabel || latestItem.threadTitle}》`,
|
||||
activityIconCount: Math.max(0, Math.min(4, items.reduce((sum, entry) => sum + entry.activityIconCount, 0))),
|
||||
latestReplyAt: latestItem.latestReplyAt,
|
||||
latestReplyLabel: latestItem.latestReplyLabel,
|
||||
|
||||
Reference in New Issue
Block a user