(event)
| 779 | const timestamp = new Date().toISOString().replace(/[:.]/g, "-") |
| 780 | const checkpointDir = path.join(stateDir(directory), "checkpoints", safeID(sessionID)) |
| 781 | await ensureDir(checkpointDir) |
| 782 | const diff = await runProcess("git", ["diff", "--binary"], directory, 120_000) |
| 783 | const staged = await runProcess("git", ["diff", "--cached", "--binary"], directory, 120_000) |
| 784 | const prefix = `${timestamp}-${safeID(job.name || job.id)}` |
| 785 | await fs.writeFile(path.join(checkpointDir, `${prefix}.status.txt`), status.stdout + status.stderr) |
| 786 | await fs.writeFile(path.join(checkpointDir, `${prefix}.patch`), `${diff.stdout}\n${staged.stdout}`) |
| 787 | if (job.gitCheckpoint) { |
| 788 | await runProcess("git", ["add", "-A"], directory, 120_000) |
| 789 | await runProcess("git", ["commit", "-m", `chore: opencode loop checkpoint ${timestamp}`], directory, 120_000) |
| 790 | } |
| 791 | await toast(client, `Loop checkpoint saved: ${prefix}`, "success") |
| 792 | } |
| 793 | |
| 794 | function updateSessionStatusFromEvent(event) { |
| 795 | const sessionID = event?.properties?.sessionID |
| 796 | if (typeof sessionID !== "string") return undefined |
| 797 | if (event?.type === "session.idle") { |
| 798 | sessionStatuses.set(sessionID, "idle") |
| 799 | sessionStatusSeenAt.set(sessionID, now()) |
| 800 | return { sessionID, idle: true } |
| 801 | } |
| 802 | if (event?.type === "session.status") { |
no test coverage detected