MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / dispose

Method dispose

src/core/task/Task.ts:2233–2317  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2231 }
2232
2233 public dispose(): void {
2234 console.log(`[Task#dispose] disposing task ${this.taskId}.${this.instanceId}`)
2235
2236 // Cancel any in-progress HTTP request
2237 try {
2238 this.cancelCurrentRequest()
2239 } catch (error) {
2240 console.error("Error cancelling current request:", error)
2241 }
2242
2243 // Remove provider profile change listener
2244 try {
2245 if (this.providerProfileChangeListener) {
2246 const provider = this.providerRef.deref()
2247 if (provider) {
2248 provider.off(RooCodeEventName.ProviderProfileChanged, this.providerProfileChangeListener)
2249 }
2250 this.providerProfileChangeListener = undefined
2251 }
2252 } catch (error) {
2253 console.error("Error removing provider profile change listener:", error)
2254 }
2255
2256 // Dispose message queue and remove event listeners.
2257 try {
2258 if (this.messageQueueStateChangedHandler) {
2259 this.messageQueueService.removeListener("stateChanged", this.messageQueueStateChangedHandler)
2260 this.messageQueueStateChangedHandler = undefined
2261 }
2262
2263 this.messageQueueService.dispose()
2264 } catch (error) {
2265 console.error("Error disposing message queue:", error)
2266 }
2267
2268 // Remove all event listeners to prevent memory leaks.
2269 try {
2270 this.removeAllListeners()
2271 } catch (error) {
2272 console.error("Error removing event listeners:", error)
2273 }
2274
2275 // Release any terminals associated with this task.
2276 try {
2277 // Release any terminals associated with this task.
2278 TerminalRegistry.releaseTerminalsForTask(this.taskId)
2279 } catch (error) {
2280 console.error("Error releasing terminals:", error)
2281 }
2282
2283 // Cleanup command output artifacts
2284 getTaskDirectoryPath(this.globalStoragePath, this.taskId)
2285 .then((taskDir) => {
2286 const outputDir = path.join(taskDir, "command-output")
2287 return OutputInterceptor.cleanup(outputDir)
2288 })
2289 .catch((error) => {
2290 console.error("Error cleaning up command output artifacts:", error)

Callers 1

abortTaskMethod · 0.95

Calls 10

cancelCurrentRequestMethod · 0.95
getTaskDirectoryPathFunction · 0.90
revertChangesMethod · 0.80
logMethod · 0.65
errorMethod · 0.65
offMethod · 0.65
disposeMethod · 0.65
removeAllListenersMethod · 0.45
cleanupMethod · 0.45

Tested by

no test coverage detected