Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

threadPresentation.ts

44 lines1.4 KB

1import type { StatusTone } from "../../components/StatusPill";
2import { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
3​
4export function threadSortValue(thread: EnvironmentThreadShell): number {
5 const candidate = Date.parse(thread.updatedAt ?? thread.createdAt);
6 return Number.isNaN(candidate) ? 0 : candidate;
7}
8​
9export function threadStatusTone(thread: EnvironmentThreadShell): 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 };