Skip to content

fix(mothership): keep any queued send the server may already hold from being edited - #8723

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/mothership-resumed-send-edit
Oct 7, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/mothership-resumed-send-edit

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #8717.

  • No queued send the server may already hold can be edited. fix(mothership): keep a withdrawn first message held at the queue head as written #8717 blocked edits only for a first message the unmount queued itself. Other entries carrying an earlier attempt's id stayed editable, and an edit dropped that id, so the edited text could go out as a second message:
    • a send another surface withdrew, handed over through the send event or the stored handoff, that lands in a busy chat's queue;
    • a queued follow-up re-queued after its dispatch got no answer.
  • One place enforces it. The queue store marks every message written with a resumeUserMessageId as admissionUnknown, unless the writer says the server is known not to have it. Queues restored from the session go through the same guard, so entries saved before this change are covered too. The existing edit guards (store, hook, Edit button) then apply.
  • Only the server refusing that id clears it. A busy 409 or a superseded 409 means the server doesn't have the id. It checks the send's id before it takes the chat lock, so it answers a retry of an admitted id as a duplicate, never as busy. A message held this way becomes editable again once the server refuses it.
  • A Send-now whose Stop never settles keeps the earlier uncertainty. Nothing was sent, which proves nothing about the earlier attempt the message resumes, so the message stays uneditable.
  • Moves a test doc comment back above its own test.

Type of Change

  • Bug fix

Testing

  • New DOM tests, each failing before its fix:
    • does not let a withdrawn send handed to a busy chat be edited
    • does not let a queued follow-up be edited after its send got no answer
    • lets a held message be edited again once the server refuses it as busy
    • keeps a resumed message uneditable when its Send-now Stop does not settle
  • Store tests: treats any message resuming an earlier attempt as possibly sent, unless told otherwise, and a rehydration test (store.dom.test.ts) for queues saved before the guard.
  • The existing held-Stop edit test now carries admissionUnknown: false: that entry was never sent and resumed no earlier attempt, so the server can't have it.
  • 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)

…m being edited

#8717 blocked edits only for a first message the unmount queued itself. A
send handed to another surface, or re-queued after its dispatch got no
answer, also carries an earlier attempt's id and was still editable; an edit
dropped that id and could send a second message. The queue store now marks
every message resuming an earlier attempt as admissionUnknown unless the
writer knows the server refused it or never got it (a busy refusal, a
superseded 409, a Stop that never settled), which also makes a held message
editable again once the server refuses it.
@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 5:05am 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.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Turn on auto-fix | Re-trigger cubic

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

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Prevents editing of queued messages that may already be sent.

The PR appears safe to merge; both previously reported edit-guard gaps are fixed.

What we checked:

  • Saved sends keep their guard: Saved entries pass through withAdmissionGuard. An earlier attempt ID gains admissionUnknown: true unless a writer already supplied the flag.
  • Failed Stop keeps earlier uncertainty: Stop failure returns neverSent. Queue restoration keeps the entry's previous admissionUnknown value rather than treating the earlier send as refused.

Summary

This PR prevents edits to queued messages the server may already hold.

  • Queue writes and saved queues apply the same edit guard.
  • A failed Stop preserves the earlier send's uncertainty instead of treating it as refused.
  • Both previous, unnumbered findings are fixed. New regression tests cover these paths.
  • No new actionable issues were found. Tests were inspected, not run.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Queue write or restore] --> B{Earlier attempt ID?}
  B -->|No| C[Editable]
  B -->|Yes| D{Known refused?}
  D -->|Yes| C
  D -->|No| E[Cannot edit]
  E --> F{Retry outcome}
  F -->|Server refuses ID| C
  F -->|Stop fails before send| E
Loading

Reviews (2) · Last reviewed commit: "fix(mothership): keep earlier-attempt un..." · Reviewed by Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts Outdated
Comment thread apps/sim/stores/mothership-queue/store.ts
…op and a reload

A Send-now whose Stop did not settle sent nothing, but was treated as proof
the server lacked the message, so a resumed message became editable. Only a
refusal of its id clears that now; an attempt that never left keeps the
earlier uncertainty. Queues saved before the guard are normalized when the
session restores them.
@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 6 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 2e7082f into staging Oct 7, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/mothership-resumed-send-edit branch October 7, 2026 05:48

This branch was previously deployed

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