refactor(mothership): one hold field and one retry field on a queued send

Merged
WA
13d ago
+152-105

Summary

Third step of the chat send-queue consolidation (after #8740 and #8741): one wait field and one retry field on a queued send. No behaviour change.

  • hold?: 'user' | 'online' replaces retryRequired + heldUntilOnline. user means a failed dispatch waits for the user to send or edit it. online means it waits for the browser to come back online, or the user.
  • retry?: { attempt, notBefore } (SendRetry) replaces sendRetries + notBefore, and ScheduledRetry goes away. deferRetry takes the new shape.
  • The policy, store and hook use the new fields:
    • requeuedFields returns { hold } or { retry }, plus the chatless surface;
    • the online release clears only hold: 'online';
    • an edit strips hold, retry and heldSurface;
    • the drain skips any hold and waits out retry.notBefore.
  • Saved queues in the older shape are mapped on restore. retryRequired becomes hold: 'user' ('online' with heldUntilOnline), and sendRetries + notBefore become retry. Staging builds have persisted the old shape to session storage.
  • Tidy-ups from #8741's review:
    • liveQueuePosition does one lookup instead of a hop loop, since only a new-chat key moves and only once, and liveQueueKey derives from it;
    • migrate keeps the first record, so a repeat can't rewrite what was ahead;
    • the history check drops its no-op forwarding, since it never runs on a new-chat key;
    • the dead-key DOM test waits on the queue instead of a fixed sleep.

Type of Change

  • Improvement (refactor)

Testing

  • restores the hold and retry fields of a queue saved in their older shape (store.dom.test.ts) covers user, online, retrying and plain entries.
  • keeps the first move when the same new-chat queue is migrated again (store.test.ts) covers the migrate first-record guard; it fails without it.
  • The existing DOM, store and policy tests are updated to the new fields and pass. The full gate and integration tests ran on the CI runner.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)