| 1 | import type { EnvironmentId, ThreadId } from "@t3tools/contracts"; |
| 2 | |
| 3 | interface ThreadActivityFileContext { |
| 4 | readonly environmentId: EnvironmentId; |
| 5 | readonly currentThreadId: ThreadId; |
| 6 | readonly activitySourceThreadId: ThreadId; |
| 7 | readonly relativePath: string; |
| 8 | readonly line?: number | null; |
| 9 | } |
| 10 | |
| 11 | export function buildThreadActivityFileParams(input: ThreadActivityFileContext) { |
| 12 | // Activity provenance may come from a parent thread, but file routes stay scoped |
| 13 | // to the thread whose workspace is currently selected. |
| 14 | return { |
| 15 | environmentId: String(input.environmentId), |
| 16 | threadId: String(input.currentThreadId), |
| 17 | path: input.relativePath.split("/").filter((segment) => segment.length > 0), |
| 18 | ...(Number.isFinite(input.line) && Number(input.line) > 0 |
| 19 | ? { line: String(Math.floor(Number(input.line))) } |
| 20 | : {}), |
| 21 | }; |
| 22 | } |