Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(updates-consent): preserve active receipts during overlapping opt-ins
Sebastian B1b940463704b
diff --git a/electron/updates-consent.mjs b/electron/updates-consent.mjsindex 48ee58ad56..4492e49f1d 100644--- a/electron/updates-consent.mjs+++ b/electron/updates-consent.mjs@@ -68,7 +68,7 @@ export function createUpdatesConsent({ prefs, account, available, now = Date.nowif (sameAnswer()) return save({ ...local, receipt, pending: false });const latest = prefs.updatesConsent();if (!latest) return;- if (!latest.account && latest.status !== "opted_in" && latest.email === local.email && !latest.receipt) save({ ...latest, receipt });+ if (!latest.account && latest.email === local.email && (latest.status === "opted_in" || !latest.receipt)) save({ ...latest, receipt });else save(withReplacedReceipts(latest, [receipt]));} else if (local.status !== "opted_in" && local.receipt) {await client().withdrawUpdatesConsent({ status: local.status, receipt: local.receipt });diff --git a/electron/updates-consent.node-test.mjs b/electron/updates-consent.node-test.mjsindex 006f367540..b58effc3fe 100644--- a/electron/updates-consent.node-test.mjs+++ b/electron/updates-consent.node-test.mjs@@ -221,6 +221,37 @@ test("signed out, the same email opts in again: a failed submission keeps the ac});});+test("signed out, an overlapping same-email opt-in keeps the active receipt when the final submission fails", async t => {+ for (const email of [" [email protected] ", undefined]) await t.test(email ?? "saved email", async t => {+ const f = await world(t);+ await f.consent.choose({ status: "opted_in", email: "[email protected]" });+ const repeated = Promise.withResolvers(), final = Promise.withResolvers();+ t.after(() => { repeated.resolve(); final.resolve(); });+ f.gate = repeated.promise;+ const sending = f.consent.choose({ status: "opted_in", email: "[email protected]" });+ await until(() => f.requests.length === 2);+ f.now++;+ const changing = f.consent.choose({ status: "opted_in", email });+ await until(() => f.saved.updatesConsent.at === f.now);+ f.gate = final.promise;+ repeated.resolve();+ await until(() => f.requests.length === 3);+ f.failOptIns = 1;+ f.gate = null;+ final.resolve();+ await Promise.all([sending, changing]);+ assert.equal(f.emails.get("[email protected]"), "opted_in");+ assert.deepEqual(f.saved.updatesConsent, { status: "opted_in", version: UPDATES_CONSENT_VERSION, at: f.now,+ email: "[email protected]", receipt: RECEIPT, pending: true });+ assert.deepEqual(f.requests.map(request => request.body.status), ["opted_in", "opted_in", "opted_in"]);+ f.launch();+ await f.consent.sync();+ assert.equal(f.saved.updatesConsent.pending, undefined);+ await f.consent.choose({ status: "withdrawn" });+ assert.equal(f.emails.get("[email protected]"), "withdrawn");+ });+});+test("signed out, opting back in to the same email retries a pending withdrawal before subscribing", async t => {const f = await world(t);await f.consent.choose({ status: "opted_in", email: "[email protected]" });