Skip to content

Clean up completed response controllers #9

Description

@cubrift

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodexUse for codex-generated issues only.good first issueGood for newcomerswontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions