(isAbandoned = false)
| 2197 | } |
| 2198 | |
| 2199 | public async abortTask(isAbandoned = false) { |
| 2200 | // Aborting task |
| 2201 | |
| 2202 | // Will stop any autonomously running promises. |
| 2203 | if (isAbandoned) { |
| 2204 | this.abandoned = true |
| 2205 | } |
| 2206 | |
| 2207 | this.abort = true |
| 2208 | |
| 2209 | // Reset consecutive error counters on abort (manual intervention) |
| 2210 | this.consecutiveNoToolUseCount = 0 |
| 2211 | this.consecutiveNoAssistantMessagesCount = 0 |
| 2212 | |
| 2213 | // Force final token usage update before abort event |
| 2214 | this.emitFinalTokenUsageUpdate() |
| 2215 | |
| 2216 | this.emit(RooCodeEventName.TaskAborted) |
| 2217 | |
| 2218 | try { |
| 2219 | this.dispose() // Call the centralized dispose method |
| 2220 | } catch (error) { |
| 2221 | console.error(`Error during task ${this.taskId}.${this.instanceId} disposal:`, error) |
| 2222 | // Don't rethrow - we want abort to always succeed |
| 2223 | } |
| 2224 | // Save the countdown message in the automatic retry or other content. |
| 2225 | try { |
| 2226 | // Save the countdown message in the automatic retry or other content. |
| 2227 | await this.saveClineMessages() |
| 2228 | } catch (error) { |
| 2229 | console.error(`Error saving messages during abort for task ${this.taskId}.${this.instanceId}:`, error) |
| 2230 | } |
| 2231 | } |
| 2232 | |
| 2233 | public dispose(): void { |
| 2234 | console.log(`[Task#dispose] disposing task ${this.taskId}.${this.instanceId}`) |
no test coverage detected