@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 24 lines 914 Bytes
Raw
1 import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
2 import { threadSupportsProviderHandoff } from "@t3tools/client-runtime/state/thread-workflows";
3 import type { ThreadStructure } from "@t3tools/client-runtime/state/models";
4
5 type ThreadStartMarkers = Pick<
6 EnvironmentThreadShell,
7 "latestRun" | "latestUserMessageAt" | "runtime"
8 >;
9
10 function threadShellHasStarted(thread: ThreadStartMarkers | null | undefined): boolean {
11 return Boolean(
12 thread &&
13 (thread.latestRun !== null || thread.latestUserMessageAt !== null || thread.runtime !== null),
14 );
15 }
16
17 export function threadAllowsProviderSwitch(input: {
18 readonly thread: ThreadStartMarkers | null | undefined;
19 readonly projection: ThreadStructure | null | undefined;
20 }): boolean {
21 return input.projection != null
22 ? threadSupportsProviderHandoff(input.projection)
23 : !threadShellHasStarted(input.thread);
24 }