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