* Rewind conversation to a specific timestamp. * This is the SINGLE entry point for all message deletion operations. * * @param ts - The timestamp to rewind to * @param options - Rewind options * @throws Error if timestamp not found in clineMessages
(ts: number, options: RewindOptions = {})
| 46 | * @throws Error if timestamp not found in clineMessages |
| 47 | */ |
| 48 | async rewindToTimestamp(ts: number, options: RewindOptions = {}): Promise<void> { |
| 49 | const { includeTargetMessage = false, skipCleanup = false } = options |
| 50 | |
| 51 | // Find the index in clineMessages |
| 52 | const clineIndex = this.task.clineMessages.findIndex((m) => m.ts === ts) |
| 53 | if (clineIndex === -1) { |
| 54 | throw new Error(`Message with timestamp ${ts} not found in clineMessages`) |
| 55 | } |
| 56 | |
| 57 | // Calculate the actual cutoff index |
| 58 | const cutoffIndex = includeTargetMessage ? clineIndex + 1 : clineIndex |
| 59 | |
| 60 | await this.performRewind(cutoffIndex, ts, { skipCleanup }) |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Rewind conversation to a specific index in clineMessages. |
no test coverage detected