fix(web): orchestrator dispatches eager-upload bubbles via pendingMessageStore subscribe

This commit is contained in:
Jannis Braun
2026-05-02 17:52:05 +02:00
parent b8da1c1778
commit 403c6e9075
@@ -52,6 +52,29 @@ export function startPendingMessageOrchestrator(): void {
} }
}); });
// 3b. Also re-check when pendingMessageStore mutates (e.g., new bubble appended
// AFTER boot, with all transfers already completed — eager-upload path).
// Without this, a bubble that becomes ready by virtue of pendingMessageStore
// changing — not transferStore — is never dispatched.
let lastBubblesSig = '';
usePendingMessageStore.subscribe((s) => {
const sig = Array.from(s.bubbles.values())
.flat()
.map((b) => `${b.clientId}|${b.state}|${b.retryCount}`)
.sort()
.join(',');
if (sig === lastBubblesSig) return;
lastBubblesSig = sig;
const fresh = usePendingMessageStore.getState().listReadyForDeferredSend();
for (const b of fresh) {
if (!sentClientIds.has(b.clientId)) {
sentClientIds.add(b.clientId);
void deferredSend(b);
}
}
});
// 4. Auto-retry on `online`: bump+resend bubbles that failed once with no // 4. Auto-retry on `online`: bump+resend bubbles that failed once with no
// prior retries (network-induced failure most likely). Uses the // prior retries (network-induced failure most likely). Uses the
// failed-retryable query — listReadyForDeferredSend gates state==='sending' // failed-retryable query — listReadyForDeferredSend gates state==='sending'