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

main
ts 41 lines 1.19 KB
Raw
1 export type NewTaskDraftRouteParams = {
2 readonly requestId?: string;
3 readonly environmentId?: string | string[];
4 readonly projectId?: string | string[];
5 readonly branch?: string | null;
6 readonly worktreePath?: string | null;
7 readonly title?: string | string[];
8 readonly cloning?: string | string[];
9 readonly draftId?: string | string[];
10 readonly incomingShareId?: string | string[];
11 };
12
13 export function isDraftThreadRoute(
14 route:
15 | {
16 readonly name: string;
17 readonly params?: object;
18 }
19 | undefined,
20 ) {
21 return (
22 route?.name === "Thread" && Boolean((route.params as { draft?: unknown } | undefined)?.draft)
23 );
24 }
25
26 export function submittedThreadParams(environmentId: string, threadId: string) {
27 return { draft: undefined, environmentId, threadId };
28 }
29
30 export function draftRouteIdentity(draft: NewTaskDraftRouteParams): string {
31 const first = (value: string | string[] | undefined) => (Array.isArray(value) ? value[0] : value);
32 return JSON.stringify([
33 draft.requestId,
34 first(draft.draftId),
35 first(draft.environmentId),
36 first(draft.projectId),
37 draft.branch ?? null,
38 draft.worktreePath ?? null,
39 first(draft.incomingShareId),
40 ]);
41 }