Skip to content

refactor(mothership): keep a queued send's reused id in one field - #8746

Merged
waleedlatif1 merged 1 commit into
stagingfrom
refactor/mothership-one-reused-id
Oct 7, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
refactor/mothership-one-reused-id

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

Fifth step of the chat send-queue consolidation (after #8744). A queued send's reused request id now lives in one field. No behaviour change.

  • resumeUserMessageId is the only id a queue entry goes out under. Before, the Stop-handoff seed (QueuedSendHandoffSeed.userMessageId) carried a copy that was always equal to it. The seed drops that copy, and reusedRequestId goes away. These now read resumeUserMessageId directly:
    • the edit guard;
    • needsResendCheck / resendVerdict;
    • the accepted-message effect;
    • the id startSendMessage picks.
  • The stored handoff record (QueuedSendHandoffState) keeps its userMessageId, as the transport record. It is converted at the two points where it meets the queue:
    • when a stored handoff is restored into the queue, its id becomes the entry's resumeUserMessageId;
    • when a dispatch puts a send back in the queue, the entry takes the withdrawal's id, or failing that the stored record's.
  • Saved queues are mapped on restore. An entry saved with the id on its seed has it moved to resumeUserMessageId; if the entry already had one, that one wins. The copy is dropped from the seed, and the admission guard then applies to the entry as before.
  • replaceAt no longer needs to clear a seed id when an entry is edited.

Type of Change

  • Improvement (refactor)

Testing

  • New store.dom.test.ts test, moves the reused id a saved Stop handoff carried onto the entry. It covers an entry saved with the id only on its seed, and one saved as never sent. It fails on staging.
  • The existing DOM and store tests that set or checked the seed's id now use resumeUserMessageId. What they test is unchanged.
  • The targeted suite passes 1072/1072. 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)

resumeUserMessageId is the only id a queue entry goes out under; the Stop
handoff seed no longer carries a copy and reusedRequestId is gone. The
stored handoff record keeps its userMessageId and is converted where it
enters and leaves the queue. Queues saved with the id on the seed move it
to resumeUserMessageId on rehydrate.
@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 2:41pm 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 7 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

@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 7 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 where queued message IDs are stored in the queue state.

This PR appears safe to merge; no actionable issues were found.

What we checked:

  • Saved sends keep their ids: Old seed ids move onto the entry before the admission guard runs. An existing entry id wins.
  • Retried sends reuse their ids: Dispatch passes the live entry’s id to startSendMessage, which uses it instead of creating a new one.

Summary

This PR makes resumeUserMessageId the single reused request id on a queued message.

  • Converts old saved seed ids and stored handoff ids into the entry field.
  • Updates send, resend, edit protection, and accepted-message cleanup to use that field.
  • Adds a saved-queue regression test and updates existing expectations.
  • No actionable issues found. Tests were not run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Saved["Saved seed userMessageId"] --> Restore["Convert saved entry"]
  Stored["Stored handoff userMessageId"] --> Queue["Queue entry resumeUserMessageId"]
  Restore --> Queue
  Queue --> Check["Check whether already accepted"]
  Check -->|Not accepted| Send["Send using the same id"]
  Check -->|Accepted| Drop["Remove queued entry"]
Loading

Reviews (1) · Last reviewed commit: "refactor(mothership): keep a queued send..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 merged commit 9e953d1 into staging Oct 7, 2026
35 checks passed
@waleedlatif1
waleedlatif1 deleted the refactor/mothership-one-reused-id branch October 7, 2026 16:32

This branch was previously deployed

1 inactive deployment
Preview — 0b920afe 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