Repository navigation
Closed
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
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
- In the mobile app, start a new task on a connected host where task creation fails.
- While the task is starting, type a follow-up in its composer.
- Paste a large image into the same composer.
- When the task creation error appears, tap Edit task before image preparation finishes.
- Inspect the recovered task draft after preparation finishes.
Expected behavior
The recovered draft includes the follow-up and the image once preparation finishes.
Actual behavior
If image preparation finishes while the recovery draft is being saved, the image is cleared from the old composer without being added to the recovered draft.
Impact
Major degradation or frequent failure. Mobile users recovering a failed task can lose an image when its pending paste finishes during recovery; this requires the preparation and recovery saves to overlap.
Version or commit
main at 17c142588b. The cause is at apps/mobile/src/state/recover-failed-thread-draft.ts:33.
Environment
Linux x64, the repository's own tests.
Logs or stack traces
AssertionError: expected [] to deep equally containAutomated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/apps/mobile/src/state/threadOutboxDelivery.test.ts b/apps/mobile/src/state/threadOutboxDelivery.test.ts
index aa6e04c186..2e562a44ad 100644
--- a/apps/mobile/src/state/threadOutboxDelivery.test.ts
+++ b/apps/mobile/src/state/threadOutboxDelivery.test.ts
@@ -789,6 +789,60 @@ describe("thread outbox recovery rollback", () => {
);
});
+ it("keeps an attachment prepared while a failed task is being recovered", async () => {
+ const message: QueuedThreadMessage = {
+ ...queuedMessage({ messageId: "failed-late-attachment", text: "Original prompt" }),
+ modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.6-sol" },
+ creation: {
+ projectId: ProjectId.make("project-1"),
+ workspaceMode: "local",
+ branch: null,
+ worktreePath: null,
+ },
+ };
+ const sourceKey = `${message.environmentId}:${message.threadId}`;
+ const targetKey = "new-task:restored-failed-late-attachment";
+ await composerDrafts.waitForComposerDraftsLoaded();
+ appAtomRegistry.set(composerDrafts.composerDraftsAtom, {
+ [targetKey]: { text: message.text, attachments: [] },
+ [sourceKey]: { text: "Please include tests", attachments: [] },
+ });
+ const saving = Promise.withResolvers<void>();
+ const resume = Promise.withResolvers<void>();
+ const write = harness.draftFile.File.prototype.write;
+ const writeSpy = vi
+ .spyOn(harness.draftFile.File.prototype, "write")
+ .mockImplementationOnce(async function (value) {
+ write(value);
+ saving.resolve();
+ await resume.promise;
+ });
+ const attachment = {
+ id: "late-paste",
+ type: "image" as const,
+ name: "pasted.png",
+ mimeType: "image/png",
+ sizeBytes: 1,
+ dataUrl: "data:image/png;base64,AA==",
+ };
+ try {
+ const recovering = recoverFailedThreadDraft(message);
+ await saving.promise;
+ composerDrafts.appendComposerDraftAttachments(sourceKey, [attachment], {
+ appendReference: true,
+ });
+ resume.resolve();
+ await recovering;
+ expect(composerDrafts.getComposerDraftSnapshot(targetKey).attachments).toContainEqual(
+ attachment,
+ );
+ } finally {
+ resume.resolve();
+ writeSpy.mockRestore();
+ await composerDrafts.flushComposerDrafts();
+ }
+ });
+
it("keeps setup edits recoverable when saving their recovery draft fails", async () => {
const message = queuedMessage({ messageId: "failed-save", text: "Original prompt" });
const sourceKey = `${message.environmentId}:${message.threadId}`;cd apps/mobile && pnpm exec vp test run src/state/threadOutboxDelivery.test.tsWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Activity