(workspaceId: string, entry: DevToolsLogEntry)
| 573 | } |
| 574 | |
| 575 | private async appendToFile(workspaceId: string, entry: DevToolsLogEntry): Promise<void> { |
| 576 | return this.enqueueWrite(workspaceId, async () => { |
| 577 | // Defense-in-depth: skip stale writes after clear() by requiring current entities. |
| 578 | const data = this.workspaces.get(workspaceId); |
| 579 | if (!data) { |
| 580 | return; |
| 581 | } |
| 582 | if (entry.type === "run" && !data.runs.has(entry.run.id)) { |
| 583 | return; |
| 584 | } |
| 585 | if (entry.type === "step" && !data.steps.has(entry.step.id)) { |
| 586 | return; |
| 587 | } |
| 588 | if (entry.type === "step-update" && !data.steps.has(entry.stepId)) { |
| 589 | return; |
| 590 | } |
| 591 | |
| 592 | const filePath = this.getSessionFilePath(workspaceId); |
| 593 | await fs.mkdir(path.dirname(filePath), { recursive: true }); |
| 594 | await fs.appendFile(filePath, `${JSON.stringify(entry)}\n`, "utf-8"); |
| 595 | }); |
| 596 | } |
| 597 | } |
no test coverage detected