1import type {
2 ModelSelection,
3 OrchestrationV2ThreadShell,
4 ProjectId,
5 RuntimeMode,
6 ThreadId,
7 ThreadLinkedPullRequest,
8 ThreadPullRequestLink,
9} from "@t3tools/contracts";
10import * as DateTime from "effect/DateTime";
11
12export interface PullRequestTestThread {
13 readonly id: ThreadId;
14 readonly projectId: ProjectId;
15 readonly title: string;
16 readonly modelSelection: ModelSelection;
17 readonly runtimeMode: RuntimeMode;
18 readonly interactionMode: OrchestrationV2ThreadShell["interactionMode"];
19 readonly branch: string | null;
20 readonly worktreePath: string | null;
21 readonly pullRequests: ReadonlyArray<ThreadPullRequestLink>;
22 readonly linkedPullRequest?: ThreadLinkedPullRequest | null;
23 readonly branchPullRequest?: ThreadLinkedPullRequest | null;
24 readonly latestUserMessageAt: string | null;
25 readonly lineage?: OrchestrationV2ThreadShell["lineage"];
26 readonly createdAt: string;
27 readonly updatedAt: string;
28 readonly archivedAt: string | null;
29 readonly settledOverride: OrchestrationV2ThreadShell["settledOverride"];
30 readonly settledAt: string | null;
31}
32
33export function v2PullRequestThread(thread: PullRequestTestThread): OrchestrationV2ThreadShell {
34 return {
35 id: thread.id,
36 projectId: thread.projectId,
37 title: thread.title,
38 providerInstanceId: thread.modelSelection.instanceId,
39 modelSelection: thread.modelSelection,
40 runtimeMode: thread.runtimeMode,
41 interactionMode: thread.interactionMode,
42 branch: thread.branch,
43 worktreePath: thread.worktreePath,
44 pullRequests: thread.pullRequests,
45 linkedPullRequest: thread.linkedPullRequest,
46 branchPullRequest: thread.branchPullRequest,
47 createdBy: "user",
48 creationSource: "web",
49 activeProviderThreadId: null,
50 lineage: thread.lineage ?? {
51 rootThreadId: thread.id,
52 parentThreadId: null,
53 relationshipToParent: null,
54 },
55 forkedFrom: null,
56 latestRunId: null,
57 activeRunId: null,
58 status: "idle",
59 pendingRuntimeRequest: null,
60 latestVisibleMessage: null,
61 latestUserMessageAt: thread.latestUserMessageAt
62 ? DateTime.makeUnsafe(thread.latestUserMessageAt)
63 : null,
64 hasActionableProposedPlan: false,
65 itemCount: 0,
66 visibleItemCount: 0,
67 createdAt: DateTime.makeUnsafe(thread.createdAt),
68 updatedAt: DateTime.makeUnsafe(thread.updatedAt),
69 archivedAt: thread.archivedAt ? DateTime.makeUnsafe(thread.archivedAt) : null,
70 settledOverride: thread.settledOverride,
71 settledAt: thread.settledAt ? DateTime.makeUnsafe(thread.settledAt) : null,
72 deletedAt: null,
73 };
74}