Skip to content

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

Merged
waleedlatif1 merged 3 commits into
stagingfrom
refactor/mothership-queue-hold-retry
Oct 7, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
refactor/mothership-queue-hold-retry

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

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 fix(mothership): send a late queue write to the chat a new-chat queue moved to #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)

…send

A queued message's wait is now hold ('user' or 'online') instead of
retryRequired plus heldUntilOnline, and its automatic retry is
retry: { attempt, notBefore } instead of sendRetries plus notBefore, which
folds ScheduledRetry away. Queues saved in the older shape are mapped when
the session restores them.
- one lookup instead of a hop loop: only a new-chat key moves, and only to
  its chat's key, which never does; liveQueueKey derives from
  liveQueuePosition
- migrate keeps the first record, so a repeat cannot rewrite what was ahead
- the history check drops its no-op forwarding: it never runs on a new-chat key
- the dead-key DOM test waits on the queue instead of a fixed sleep
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 7, 2026 11:46am UTC

Request Review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Refactors message queue retry and hold fields.

The PR appears safe to merge; the added test addresses the previous review's remaining concern.

Summary

Consolidates queued sends into one hold field and one retry field. Older saved queues are converted when restored.

  • Updates the send policy, queue store, and useChat to use the new fields.
  • Keeps the first queue move so late writes retain their original order.
  • Adds the repeated-move test requested in the previous review. The test addresses the unnumbered thread resolved by waleedlatif1.
  • No new actionable issues or confirmed rule violations were found. The only change since the previous review is the added test.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Queued["Queued send"] --> Hold{"hold set?"}
  Hold -->|user| User["Wait for user"]
  Hold -->|online| Online["Wait for browser online or user"]
  Hold -->|No| Retry{"retry.notBefore in future?"}
  Retry -->|Yes| Wait["Wait until retry time"]
  Retry -->|No| Send["Send when chat is ready"]
Loading

Reviews (2) · Last reviewed commit: "test(mothership): cover migrate keeping ..." · Reviewed by Greptile

Comment thread apps/sim/stores/mothership-queue/store.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 3899fde into staging Oct 7, 2026
35 of 36 checks passed
@waleedlatif1
waleedlatif1 deleted the refactor/mothership-queue-hold-retry branch October 7, 2026 16:32

This branch was previously deployed

1 inactive deployment
Preview — dc8c1029 Deployed Oct 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant