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

automaticServerUpdate.ts

26 lines800 Bytes

1export interface AutomaticServerUpdateThreadActivity {
2 readonly session?: {
3 readonly status?: string;
4 readonly activeTurnId?: unknown;
5 } | null;
6 readonly latestTurn?: { readonly state?: string } | null;
7 readonly backgroundLiveness?: unknown;
8}
9​
10export function isAutomaticServerUpdateThreadActive(
11 thread: AutomaticServerUpdateThreadActivity,
12): boolean {
13 return (
14 thread.session?.status === "starting" ||
15 thread.session?.status === "running" ||
16 thread.session?.activeTurnId != null ||
17 thread.latestTurn?.state === "running" ||
18 thread.backgroundLiveness != null
19 );
21​
22export function hasAutomaticServerUpdateActiveWork(
23 threads: ReadonlyArray<AutomaticServerUpdateThreadActivity>,
24): boolean {
25 return threads.some(isAutomaticServerUpdateThreadActive);