()
| 228 | } |
| 229 | |
| 230 | // Always persist the ops to our journal — undo works regardless of git status. |
| 231 | this.journal.persistOps( |
| 232 | this.id, |
| 233 | this.sessionId, |
| 234 | this.ops, |
| 235 | this.gitSha, |
| 236 | this.toolCallId, |
| 237 | summary, |
| 238 | gitStatus, |
| 239 | gitFailReason, |
| 240 | ); |
| 241 | this.gitStatus = gitStatus; |
| 242 | this.gitFailReason = gitFailReason; |
| 243 | this.status = 'committed'; |
| 244 | return this.gitSha; |
| 245 | } |
| 246 | |
| 247 | /** Information about whether git tracked this transaction. Surface to user after commit. */ |
| 248 | public gitStatus: 'committed' | 'skipped-not-a-repo' | 'skipped-gitignored' | 'failed' = 'skipped-not-a-repo'; |
| 249 | public gitFailReason: string | null = null; |
| 250 | |
| 251 | async rollback(): Promise<void> { |
| 252 | if (this.status === 'rolled-back') return; |
| 253 | |
| 254 | for (const op of [...this.ops].reverse()) { |
| 255 | try { |
no test coverage detected