(workspaceId: string, data: WorkspaceData)
| 420 | } |
| 421 | |
| 422 | private async loadFromDisk(workspaceId: string, data: WorkspaceData): Promise<void> { |
| 423 | const filePath = this.getSessionFilePath(workspaceId); |
| 424 | let raw = ""; |
| 425 | |
| 426 | try { |
| 427 | raw = await fs.readFile(filePath, "utf-8"); |
| 428 | } catch (error) { |
| 429 | if (isRecord(error) && error.code === "ENOENT") { |
| 430 | data.loaded = true; |
| 431 | return; |
| 432 | } |
| 433 | throw error; |
| 434 | } |
| 435 | |
| 436 | const lines = raw.split("\n"); |
| 437 | for (const line of lines) { |
| 438 | if (!line.trim()) { |
| 439 | continue; |
| 440 | } |
| 441 | |
| 442 | try { |
| 443 | const entry = JSON.parse(line) as DevToolsLogEntry; |
| 444 | switch (entry.type) { |
| 445 | case "run": { |
| 446 | data.runs.set(entry.run.id, entry.run); |
| 447 | break; |
| 448 | } |
| 449 | case "step": { |
| 450 | data.steps.set(entry.step.id, applyStepBackwardCompatibilityDefaults(entry.step)); |
| 451 | break; |
| 452 | } |
| 453 | case "step-update": { |
| 454 | const existing = data.steps.get(entry.stepId); |
| 455 | if (existing) { |
| 456 | data.steps.set( |
| 457 | entry.stepId, |
| 458 | applyStepBackwardCompatibilityDefaults({ |
| 459 | ...existing, |
| 460 | ...entry.update, |
| 461 | }) |
| 462 | ); |
| 463 | } |
| 464 | break; |
| 465 | } |
| 466 | default: { |
| 467 | log.warn("Skipping unknown devtools.jsonl entry type", { |
| 468 | workspaceId, |
| 469 | }); |
| 470 | } |
| 471 | } |
| 472 | } catch { |
| 473 | log.warn("Skipping corrupted devtools.jsonl line"); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | data.loaded = true; |
| 478 | await this.finalizeStaleStepsForLoadedWorkspace(workspaceId, data); |
| 479 | } |
no test coverage detected