| 169 | } |
| 170 | |
| 171 | export async function ensureBaseSnapshot(parent: Session.Info) { |
| 172 | if (!isParent(parent)) return undefined |
| 173 | if (parent.benchmark.baseSnapshot) return parent.benchmark.baseSnapshot |
| 174 | const snapshot = await Snapshot.track() |
| 175 | if (!snapshot) { |
| 176 | throw new SnapshotUnavailableError({ |
| 177 | message: "Benchmark mode requires snapshots (git) to be enabled.", |
| 178 | }) |
| 179 | } |
| 180 | await Session.update(parent.id, (draft) => { |
| 181 | if (draft.benchmark?.type === "parent") { |
| 182 | draft.benchmark.baseSnapshot = snapshot |
| 183 | } |
| 184 | }) |
| 185 | return snapshot |
| 186 | } |
| 187 | |
| 188 | export async function updateChildSnapshot(sessionID: string, snapshot?: string, error?: string) { |
| 189 | await Session.update(sessionID, (draft) => { |