feat(group-chat): auto-retry member resolution 2s after CHAT_CHANGED

When onChatChanged detects partial group-member resolution (likely a
load-order race on large groups during startup), schedule one re-check
2 seconds later. If resolution recovers, log it and refresh the health
indicator (which clears the yellow warning). If not, log that the
unresolved avatars are likely genuinely missing. Captures groupId at
schedule time and bails if the user switched chats, to avoid mis-
attributing retry outcomes in the activity log.
This commit is contained in:
bal-spec 2026-04-23 16:58:41 -07:00
parent 9190be63a6
commit bc300e9992

View file

@ -3307,6 +3307,30 @@ async function onChatChanged() {
updateAllIndicators();
updateHealthIndicator();
// Retry member resolution after 2 seconds to recover from the load-order
// race on large groups (issue #17 / #18). If the initial resolution was
// incomplete, re-read and log the outcome; updateHealthIndicator() will
// clear the yellow warning if the retry succeeded.
if (isGroupChat()) {
const initial = getGroupMembersDetailed();
if (initial.unresolvedAvatars.length > 0) {
const initialGroupId = getContext().groupId;
setTimeout(() => {
// Bail if the user switched to a different chat (1:1 or a different group) —
// logging retry outcome against the wrong group would misattribute.
if (!isGroupChat() || getContext().groupId !== initialGroupId) return;
const retry = getGroupMembersDetailed();
if (retry.unresolvedAvatars.length < initial.unresolvedAvatars.length) {
const recovered = initial.unresolvedAvatars.length - retry.unresolvedAvatars.length;
logActivity(`Retry resolved ${recovered} previously-unresolved group members.`);
} else {
logActivity(`Retry did not resolve any additional group members (${retry.unresolvedAvatars.length} still unresolved).`, 'warning');
}
updateHealthIndicator();
}, 2000);
}
}
// Inject buttons on already-rendered messages (with a small delay to
// ensure the DOM has finished rendering the chat)
setTimeout(addButtonsToExistingMessages, 500);