Files
archie/ui/src/chat/session.ts
T

17 lines
515 B
TypeScript

import type { ChatSession } from "./state";
const started = new Intl.DateTimeFormat(undefined, {
month: "short",
day: "numeric",
hour: "numeric",
minute: "2-digit",
});
// An untitled conversation is named by when it began, which tells two apart
// where a raw id cannot.
export function sessionTitle(session: ChatSession): string {
const named = session.title || session.branch_name;
if (named) return named;
return session.created_at ? started.format(new Date(session.created_at)) : "New chat";
}