Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Mobile restores both versions of a queued new-task prompt after an edit races with launch #47787

Closedvoltcrash(GitHub profile, opens in a new tab) opened this issue 1 comment

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/mobile

Steps to reproduce

  1. Start recovering an edited queued new-task launch into the thread composer.
  2. Pause recovery after the old prompt has been written into the composer draft.
  3. Save a newer revision of the queued prompt and let recovery continue.
  4. Run recovery again against the new revision.

This is deterministic in the existing race test in threadOutboxDelivery.test.ts. After its existing assertion that the newer queue entry survives, run recovery a second time and assert that the composer contains only the latest prompt.

Expected behavior

The composer contains the most recent edit once and preserves independent draft text.

Actual behavior

The first recovery merges the older text before checking the revision. The retry appends the edited text to it. The isolated test produced original queued text\n\nedited while recovery persisted the draft.

Recovery code

Impact

Occasional draft corruption. The user can inadvertently resend deleted text.

Version or commit

Reproduced at 57fbce7570. The affected source was unchanged at upstream main 9e0de5137b.

  1. tanstack-source added labelsbug

  2. I tried to reproduce this on the current build and could not.

    Commit ddb9d3ec86 (origin/main). I did not run the mobile app. The race happens between an awaited storage write and the revision check, and no one can hit that window by hand on a device. Instead I followed the reporter's steps in the module's own test file. In apps/mobile/src/state/threadOutboxDelivery.test.ts I added the test 'recovers only the latest edit after an edit races with the draft merge'. It enqueues a new-task message with the text 'original queued text' and starts recoverEditedCreationAfterDelivery. It pauses after mergeComposerDraftContent has written that text into the composer draft, then saves a newer revision with manager.update ('edited while recovery persisted the draft'). Then it lets recovery continue: it returns 'changed' and leaves the queue entry. Finally it runs recovery again against the newer entry. Result with vp test run src/state/threadOutboxDelivery.test.ts -t "creation recovery": the new test fails and the 4 existing tests pass. The draft text is 'original queued text\n\nedited while recovery persisted the draft' where only the edited text was expected. That matches the issue exactly. The test is on branch factory/repro-47787 (7a2b6ad54e). Search found no duplicate. #32313 is a different, closed lost-launch-reply bug.

    Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.

  3. juliusmarminge closed this

Sign in to join this conversation.