Problem
messages/ai/MessageAI.js stores an AbortController in activeGenerations for each chat, but completed generations are not consistently removed. The map is cleaned up when a newer message arrives or when a group message is ignored, but successful text responses and several early-return paths can leave controllers retained indefinitely.
Expected behavior
The map should track only generations that are still running. A completed or failed generation should release its controller without deleting a newer generation that replaced it.
Suggested direction
Use a guarded cleanup path, such as a finally block or a small helper that checks whether the stored controller is the same controller being completed.
Acceptance criteria
- Successful text responses remove their controller.
- Audio, aborted, ignored, and error paths do not leave stale controllers behind.
- Cleanup never removes a newer controller for the same chat.
- A focused test or reproducible verification demonstrates the map is empty after a completed generation.
Problem
messages/ai/MessageAI.jsstores anAbortControllerinactiveGenerationsfor each chat, but completed generations are not consistently removed. The map is cleaned up when a newer message arrives or when a group message is ignored, but successful text responses and several early-return paths can leave controllers retained indefinitely.Expected behavior
The map should track only generations that are still running. A completed or failed generation should release its controller without deleting a newer generation that replaced it.
Suggested direction
Use a guarded cleanup path, such as a
finallyblock or a small helper that checks whether the stored controller is the same controller being completed.Acceptance criteria