Open History to see the last commit
1export 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 pendingTaskId?: string | string[];
10 readonly draftId?: string | string[];
11 readonly incomingShareId?: string | string[];
12};
13
14export function isDraftThreadRoute(
15 route:
16 | {
17 readonly name: string;
18 readonly params?: object;
19 }
20 | undefined,
21) {
22 return (
23 route?.name === "Thread" && Boolean((route.params as { draft?: unknown } | undefined)?.draft)
24 );
25}
26
27export function submittedThreadParams(environmentId: string, threadId: string) {
28 return { draft: undefined, environmentId, threadId };
29}
30
31export function draftRouteIdentity(draft: NewTaskDraftRouteParams): string {
32 const first = (value: string | string[] | undefined) => (Array.isArray(value) ? value[0] : value);
33 return JSON.stringify([
34 draft.requestId,
35 first(draft.pendingTaskId),
36 first(draft.draftId),
37 first(draft.environmentId),
38 first(draft.projectId),
39 draft.branch ?? null,
40 draft.worktreePath ?? null,
41 first(draft.incomingShareId),
42 ]);
43}