1import { presentThreadShell } from "@t3tools/client-runtime/state/shell";
2import type {
3 EnvironmentId,
4 ThreadId,
5 ProjectId,
6 ModelSelection,
7 RuntimeMode,
8 ProviderInteractionMode,
9} from "@t3tools/contracts";
10import * as DateTime from "effect/DateTime";
11
12export function draftThreadShell(input: {
13 readonly environmentId: EnvironmentId;
14 readonly threadId: ThreadId;
15 readonly projectId: ProjectId;
16 readonly modelSelection: ModelSelection;
17 readonly runtimeMode: RuntimeMode;
18 readonly interactionMode: ProviderInteractionMode;
19 readonly branch: string | null;
20 readonly worktreePath: string | null;
21 readonly createdAt: string;
22}) {
23 const timestamp = DateTime.makeUnsafe(input.createdAt);
24 return presentThreadShell(input.environmentId, {
25 id: input.threadId,
26 projectId: input.projectId,
27 title: "New thread",
28 providerInstanceId: input.modelSelection.instanceId,
29 modelSelection: input.modelSelection,
30 runtimeMode: input.runtimeMode,
31 interactionMode: input.interactionMode,
32 branch: input.branch,
33 pullRequests: [],
34 worktreePath: input.worktreePath,
35 linkedPullRequest: null,
36 branchPullRequest: null,
37 lineage: { rootThreadId: input.threadId, parentThreadId: null, relationshipToParent: null },
38 forkedFrom: null,
39 createdBy: "user",
40 creationSource: "mobile",
41 activeProviderThreadId: null,
42 latestRunId: null,
43 activeRunId: null,
44 status: "idle",
45 pendingRuntimeRequest: null,
46 latestVisibleMessage: null,
47 latestUserMessageAt: timestamp,
48 hasActionableProposedPlan: false,
49 itemCount: 0,
50 visibleItemCount: 0,
51 createdAt: timestamp,
52 updatedAt: timestamp,
53 archivedAt: null,
54 settledOverride: null,
55 settledAt: null,
56 unsettledAt: null,
57 snoozedUntil: null,
58 snoozedAt: null,
59 pinnedAt: null,
60 pinOrderKey: null,
61 activeOrderKey: null,
62 deletedAt: null,
63 });
64}