Remove archive/restore from the session menu and drop archived=1 listing. PATCH still accepts archived_at from old bundles then ignores it. A forward migration clears archived_at without bumping updated_at. Delete stays unchanged.
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import type { SidebarSession } from "@/components/sidebar-session-row";
|
|
import type { ChartLibraryRecord, ChatSession } from "@/lib/home-types";
|
|
import { sessionChartLabel } from "@/lib/home-profile";
|
|
import { shanghaiDateTimeLabel } from "@/lib/session-shanghai-clock";
|
|
|
|
export function sessionSidebarTitle(session: ChatSession) {
|
|
return session.title?.trim() || "新对话";
|
|
}
|
|
|
|
export function sessionSidebarSubtitle(
|
|
session: ChatSession,
|
|
library: readonly ChartLibraryRecord[] = [],
|
|
): string {
|
|
const clock = Number.isFinite(session.updatedAt) ? shanghaiDateTimeLabel(new Date(session.updatedAt)) : "";
|
|
const parts: string[] = [];
|
|
if (clock) parts.push(clock);
|
|
if (session.chartProfileRole && session.chartProfileRole !== "self" && session.chartProfileId) {
|
|
parts.push(sessionChartLabel(session, library));
|
|
}
|
|
return parts.join(" · ");
|
|
}
|
|
|
|
export function toSidebarSessionRow(
|
|
session: ChatSession,
|
|
library: readonly ChartLibraryRecord[] = [],
|
|
): SidebarSession {
|
|
return {
|
|
id: session.id,
|
|
title: sessionSidebarTitle(session),
|
|
subtitle: sessionSidebarSubtitle(session, library) || null,
|
|
pinned: session.pinned,
|
|
updatedAt: session.updatedAt,
|
|
};
|
|
}
|