(input: string)
| 56 | |
| 57 | /** A run dir resolves to its recording; a file stands for itself. */ |
| 58 | const resolveArtifact = (input: string): Artifact => { |
| 59 | const path = resolve(input); |
| 60 | if (!existsSync(path)) throw new Error(`no such path: ${input}`); |
| 61 | if (!statSync(path).isDirectory()) { |
| 62 | return { |
| 63 | path, |
| 64 | label: basename(path), |
| 65 | slug: basename(path).replace(/\.[^.]+$/, ""), |
| 66 | }; |
| 67 | } |
| 68 | // film.mp4 (scripts/film.ts) is the whole session — terminal chat AND the |
| 69 | // browser hop, cut in time order; the bare browser session.mp4 is only the |
| 70 | // hop, so it must never win when a film exists. |
| 71 | const recording = ["film.mp4", "session.mp4", "terminal.cast"] |
| 72 | .map((name) => join(path, name)) |
| 73 | .find(existsSync); |
| 74 | if (!recording) throw new Error(`${input} has no film.mp4, session.mp4, or terminal.cast`); |
| 75 | let label = basename(path); |
| 76 | try { |
| 77 | const result = JSON.parse(readFileSync(join(path, "result.json"), "utf8")) as { |
| 78 | scenario?: string; |
| 79 | target?: string; |
| 80 | }; |
| 81 | if (result.scenario) label = `${result.scenario} (${result.target ?? "e2e"})`; |
| 82 | } catch { |
| 83 | // skipped/partial runs still have a recording worth showing |
| 84 | } |
| 85 | return { path: recording, label, slug: basename(path), runDir: path }; |
| 86 | }; |
| 87 | |
| 88 | const videoDuration = (file: string): number => |
| 89 | Number( |
no test coverage detected