Open History to see the last commit
1import type { StatusTone } from "../../components/StatusPill";
2import { EnvironmentScopedThreadShell } from "@t3tools/client-runtime";
3
4export function threadSortValue(thread: EnvironmentScopedThreadShell): number {
5 const candidate = Date.parse(thread.updatedAt ?? thread.createdAt);
6 return Number.isNaN(candidate) ? 0 : candidate;
7}
8
9export function threadStatusTone(thread: EnvironmentScopedThreadShell): StatusTone {
10 const status = thread.session?.status;
11 if (status === "running") {
12 return {
13 label: "Running",
14 pillClassName: "bg-orange-500/12 dark:bg-orange-500/16",
15 textClassName: "text-orange-700 dark:text-orange-300",
16 };
17 }
18 if (status === "ready") {
19 return {
20 label: "Ready",
21 pillClassName: "bg-emerald-500/12 dark:bg-emerald-500/16",
22 textClassName: "text-emerald-700 dark:text-emerald-300",
23 };
24 }
25 if (status === "starting") {
26 return {
27 label: "Starting",
28 pillClassName: "bg-sky-500/12 dark:bg-sky-500/16",
29 textClassName: "text-sky-700 dark:text-sky-300",
30 };
31 }
32 if (status === "error") {
33 return {
34 label: "Error",
35 pillClassName: "bg-rose-500/12 dark:bg-rose-500/16",
36 textClassName: "text-rose-700 dark:text-rose-300",
37 };
38 }
39 return {
40 label: "Idle",
41 pillClassName: "bg-neutral-500/10 dark:bg-neutral-500/16",
42 textClassName: "text-neutral-600 dark:text-neutral-300",
43 };
44}
45
46export function messageImageUrl(httpBaseUrl: string | null, attachmentId: string): string | null {
47 if (!httpBaseUrl) {
48 return null;
49 }
50
51 const url = new URL(`/attachments/${encodeURIComponent(attachmentId)}`, httpBaseUrl);
52 return url.toString();
53}