Fix stale conversation sync labels on mobile

This commit is contained in:
kris
2026-04-07 13:35:52 +08:00
parent a43bb92f3c
commit 6153e94000
7 changed files with 76 additions and 4 deletions

View File

@@ -180,6 +180,20 @@ export function formatTimestampLabel(value?: string, fallback = "刚刚") {
return shanghaiDayFormatter.format(date);
}
const STALE_CONTEXT_SYNC_LABEL = "待同步";
const STALE_CONTEXT_REPLY_THRESHOLD_MS = 7 * 24 * 60 * 60_000;
function formatConversationLatestReplyLabel(value: string, hasVisibleContext: boolean) {
if (hasVisibleContext && value.includes("T")) {
const date = new Date(value);
const diff = Date.now() - date.getTime();
if (!Number.isNaN(date.getTime()) && diff >= STALE_CONTEXT_REPLY_THRESHOLD_MS) {
return STALE_CONTEXT_SYNC_LABEL;
}
}
return formatTimestampLabel(value);
}
function compareSnapshots(a: ThreadContextSnapshot, b: ThreadContextSnapshot) {
if (a.mustFinishBeforeCompaction !== b.mustFinishBeforeCompaction) {
return a.mustFinishBeforeCompaction ? -1 : 1;
@@ -386,7 +400,10 @@ function buildConversationItem(state: BossState, project: Project): Conversation
topPinnedLabel,
manualPinned: Boolean(project.pinned && !project.systemPinned),
latestReplyAt: latestConversationActivityAt,
latestReplyLabel: formatTimestampLabel(latestConversationActivityAt),
latestReplyLabel: formatConversationLatestReplyLabel(
latestConversationActivityAt,
Boolean(topThread),
),
unreadCount: project.unreadCount,
riskLevel: project.riskLevel,
activeDeviceCount: devices.length,