(directory, sessionID, args = {})
| 1085 | const diff = await runProcess("git", ["diff", "--binary"], directory, 120_000) |
| 1086 | const staged = await runProcess("git", ["diff", "--cached", "--binary"], directory, 120_000) |
| 1087 | const prefix = `${timestamp}-${safeID(job.name || job.id)}` |
| 1088 | await fs.writeFile(path.join(checkpointDir, `${prefix}.status.txt`), status.stdout + status.stderr) |
| 1089 | await fs.writeFile(path.join(checkpointDir, `${prefix}.patch`), `${diff.stdout}\n${staged.stdout}`) |
| 1090 | if (job.gitCheckpoint) { |
| 1091 | await runProcess("git", ["add", "-A"], directory, 120_000) |
| 1092 | await runProcess("git", ["commit", "-m", `chore: opencode loop checkpoint ${timestamp}`], directory, 120_000) |
| 1093 | } |
| 1094 | await toast(client, `Loop checkpoint saved: ${prefix}`, "success") |
| 1095 | } |
| 1096 | |
| 1097 | function updateSessionStatusFromEvent(event) { |
| 1098 | const sessionID = event?.properties?.sessionID |
| 1099 | if (typeof sessionID !== "string") return undefined |
| 1100 | if (event?.type === "session.idle") { |
| 1101 | sessionStatuses.set(sessionID, "idle") |
| 1102 | sessionStatusSeenAt.set(sessionID, now()) |
| 1103 | return { sessionID, idle: true } |
no test coverage detected