Skip to content

Avoid repeated group metadata lookups during streamed replies #13

Description

@cubrift

Problem

While processing a streamed AI response, messages/ai/MessageAI.js calls sock.groupMetadata(jid) each time a completed response fragment needs mention detection. A single response can therefore fetch the same participant list repeatedly, adding avoidable network and processing overhead in active groups.

Expected behavior

One response should reuse group participant metadata when it is safe to do so, while still handling a newly started response or a changed group normally.

Suggested direction

Fetch the group metadata once per response and reuse the participant IDs for mention detection. Keep the change local to the response flow and avoid introducing a long-lived stale cache.

Acceptance criteria

  • A single response does not fetch identical group metadata for every fragment.
  • Mention detection produces the same results as before.
  • Direct-message handling remains unchanged.
  • A mocked test or instrumentation demonstrates the reduced lookup count.

Metadata

Metadata

Assignees

Labels

codexUse for codex-generated issues only.enhancementPerformance update or requestgood 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