Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix: finish logged reply cleanup across account changes

Amruth Pillai4c28631ac420
diff --git a/apps/mobile/scripts/workspace-reply-stage.test.mjs b/apps/mobile/scripts/workspace-reply-stage.test.mjs
index 2407dda24..83948a708 100644
--- a/apps/mobile/scripts/workspace-reply-stage.test.mjs
+++ b/apps/mobile/scripts/workspace-reply-stage.test.mjs
@@ -490,6 +490,37 @@ test("native reply completion clears its reminder after the view unmounts", asyn
assert.equal(h.env.invalidations, 1);
});
+for (const outcome of ["cancel", "replacement", "cancel-failure"]) {
+ test(`native confirmed reply completes captured reminder cleanup after account switch (${outcome})`, async () => {
+ const h = harness();
+ h.application.followUpAt = new Date("2030-03-15T09:00:00Z");
+ let finish;
+ h.env.logReply = () =>
+ new Promise((resolve) => {
+ finish = resolve;
+ });
+ buttonIn(h.replyTree(), "Copy and log as replied").props.onPress();
+ await new Promise(setImmediate);
+ assert.equal(h.env.logs.length, 1);
+ h.env.account = "acct-B";
+ h.unmount();
+ if (outcome === "replacement") h.env.reminderVersion++;
+ if (outcome === "cancel-failure")
+ h.env.cancel = async () => {
+ throw new Error("Notification service unavailable");
+ };
+ finish();
+ await new Promise(setImmediate);
+ assert.equal(h.env.cancelCalls.length, outcome === "replacement" ? 0 : 1);
+ assert.deepEqual(
+ h.env.clearedReminders,
+ outcome === "cancel" ? [{ kind: "follow-up", applicationId: "app-1" }] : [],
+ );
+ assert.equal(h.env.invalidations, 0);
+ assert.deepEqual(h.toasts, []);
+ });
+}
+
test("native cancellation failure offers scoped retry without logging the reply twice", async () => {
const h = harness();
h.application.followUpAt = new Date("2030-03-15T09:00:00Z");
diff --git a/apps/mobile/src/features/workspace/tabs/messages.tsx b/apps/mobile/src/features/workspace/tabs/messages.tsx
index 320cba1fe..ac10faee1 100644
--- a/apps/mobile/src/features/workspace/tabs/messages.tsx
+++ b/apps/mobile/src/features/workspace/tabs/messages.tsx
@@ -258,7 +258,11 @@ function ReplyCard({ reply, application, readOnly }: ReplyCardProps) {
{ id: application.id, expectedVersion: application.replyVersion },
{ context: { scope } },
);
- if (scope !== getAccountScope()) return;
+ if (scope !== getAccountScope()) {
+ // The confirmed write owns this captured notification, but no longer owns the account's UI.
+ await cancel().catch(() => undefined);
+ return;
+ }
const cleared = await clearFollowUpReminder(cancel, true);
if (scope !== getAccountScope()) return;
// Logging is confirmed; query refresh failure must not change its receipt or replace a reminder warning.