fix(desktop): retain confirmed aborts across refresh failures

Signed-off-by: Codex <noreply@openai.com>
This commit is contained in:
Codex
2026-09-30 22:02:45 +00:00
parent e5f56aa67b
commit e2d23ca8cf
4 changed files with 166 additions and 48 deletions

View File

@@ -27,7 +27,7 @@ type RefreshContext = {
export async function refreshAcceptedCommunityDeletions(
context: RefreshContext,
): Promise<void> {
if (!context.isCurrent()) return;
if (!context.isCurrent() || context.identityMismatch) return;
let auth = await invoke<BuilderlabAuth | null>("get_builderlab_auth");
if (!context.isCurrent()) return;
context.setAuth(auth);
@@ -40,39 +40,47 @@ export async function refreshAcceptedCommunityDeletions(
if (auth.canDeleteBuzzCommunities !== true) return;
let restored = false;
for (const [communityId, envelope] of [...context.accepted.entries()]) {
if (!listed.some((community) => community.id === communityId)) continue;
const stillEligible = () =>
context.isCurrent() &&
context.ownerPubkey() === envelope.bound_owner_pubkey &&
envelope.backend_origin === BUILDERLAB_BACKEND_ORIGIN &&
context.accepted.get(communityId) === envelope &&
!context.identityMismatch;
if (!stillEligible()) return;
auth = await invoke<BuilderlabAuth | null>("get_builderlab_auth");
if (!stillEligible()) return;
context.setAuth(auth);
if (!auth) {
context.clearAccount();
return;
}
if (auth.canDeleteBuzzCommunities !== true) return;
const request = publicDeletionRequest(envelope);
if (!stillEligible()) return;
const response = await invoke<CommunityDeletionTransport>(
"delete_builderlab_community",
{
communityId: request.community_id,
host: request.host,
requestId: request.request_id,
acknowledgementVersion: request.acknowledgement_version,
},
);
if (!stillEligible()) return;
if (deletionResponseDisposition(response, envelope, "check") === "abort") {
context.accepted.delete(communityId);
restored = true;
try {
for (const [communityId, envelope] of [...context.accepted.entries()]) {
if (!listed.some((community) => community.id === communityId)) continue;
const stillEligible = () =>
context.isCurrent() &&
context.ownerPubkey() === envelope.bound_owner_pubkey &&
envelope.backend_origin === BUILDERLAB_BACKEND_ORIGIN &&
context.accepted.get(communityId) === envelope;
if (!stillEligible()) return;
auth = await invoke<BuilderlabAuth | null>("get_builderlab_auth");
if (!stillEligible()) return;
context.setAuth(auth);
if (!auth) {
context.clearAccount();
return;
}
if (auth.canDeleteBuzzCommunities !== true) return;
const request = publicDeletionRequest(envelope);
const response = await invoke<CommunityDeletionTransport>(
"delete_builderlab_community",
{
communityId: request.community_id,
host: request.host,
requestId: request.request_id,
acknowledgementVersion: request.acknowledgement_version,
},
);
if (!stillEligible()) return;
const disposition = deletionResponseDisposition(
response,
envelope,
"check",
);
if (disposition === "abort") {
context.accepted.delete(communityId);
restored = true;
} else if (disposition !== "accept") {
throw new Error("Couldn't check deletion status.");
}
}
} finally {
if (restored && context.isCurrent()) context.restoreListed(listed);
}
if (restored && context.isCurrent()) context.restoreListed(listed);
}

View File

@@ -265,6 +265,7 @@ type E2eConfig = {
code: string;
message?: string;
} | null>;
builderlabDeletionRejectSequence?: boolean[];
builderlabDeletionStatusSequence?: string[];
builderlabDeletionHttpStatusSequence?: number[];
builderlabDeletionBodyStatus?: number;
@@ -12664,6 +12665,16 @@ export function maybeInstallE2eTauriMocks() {
heldBuilderlabDeletionReleases.push(resolve);
});
}
const rejectSequence =
activeConfig?.mock?.builderlabDeletionRejectSequence;
if (
rejectSequence?.length &&
(rejectSequence.length > 1
? rejectSequence.shift()
: rejectSequence[0])
) {
throw new Error("Mock deletion transport failure");
}
const sequence = activeConfig?.mock?.builderlabDeletionErrorSequence;
const deletionError = sequence?.length
? sequence.length > 1