Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(release): format sidecar and preserve iOS delivery on draft advance

tianma-if3d64b6856f9f
diff --git a/crates/desktop-sidecar/src/memo.rs b/crates/desktop-sidecar/src/memo.rs
index d69427c7..33c1fbfc 100644
--- a/crates/desktop-sidecar/src/memo.rs
+++ b/crates/desktop-sidecar/src/memo.rs
@@ -620,7 +620,9 @@ pub(crate) fn delete_memo(database: &Connection, params: &Value) -> Result<Value
if !bool_param(params, "permanent", false) || !memo_id.starts_with("memo_local_") {
return Err("Only an unsynced local memo can be cancelled".to_owned());
}
- let tx = database.unchecked_transaction().map_err(|e| e.to_string())?;
+ let tx = database
+ .unchecked_transaction()
+ .map_err(|e| e.to_string())?;
let pending_create: i64 = tx.query_row(
"SELECT COUNT(*) FROM _edgeever_sidecar_outbox WHERE kind = 'memo.create' AND entity_id = ?1 AND status = 'pending'",
[&memo_id],
@@ -634,7 +636,9 @@ pub(crate) fn delete_memo(database: &Connection, params: &Value) -> Result<Value
if pending_create != 1 || other_changes != 0 {
return Err("Local memo cannot be cancelled after synchronization started".to_owned());
}
- let deleted = tx.execute("DELETE FROM memos WHERE id = ?1", [&memo_id]).map_err(|e| e.to_string())?;
+ let deleted = tx
+ .execute("DELETE FROM memos WHERE id = ?1", [&memo_id])
+ .map_err(|e| e.to_string())?;
if deleted != 1 {
return Err("Local memo no longer exists".to_owned());
}
diff --git a/scripts/release.mjs b/scripts/release.mjs
index 89b6f749..1962f049 100644
--- a/scripts/release.mjs
+++ b/scripts/release.mjs
@@ -730,7 +730,7 @@ export const checkpointRunIds = (checkpoint) => [...new Set([
...CHECKPOINT_RUN_FIELDS.map((field) => Number(checkpoint[field])),
].filter((runId) => Number.isInteger(runId) && runId > 0))];
-export const prepareReleaseCheckpoint = ({ storedState, releaseSha }) => {
+export const prepareReleaseCheckpoint = ({ storedState, releaseSha, preserveIosStoreRun = false }) => {
if (storedState.releaseSha === releaseSha) return storedState;
const legacyHistory = CHECKPOINT_RUN_FIELDS.flatMap((field) => {
const runId = Number(storedState[field]);
@@ -746,6 +746,9 @@ export const prepareReleaseCheckpoint = ({ storedState, releaseSha }) => {
releaseSha,
...(runHistory.length > 0 ? { runHistory } : {}),
...(storedState.playDelivery ? { playDelivery: storedState.playDelivery } : {}),
+ ...(preserveIosStoreRun && storedState.iosStoreRunId
+ ? { iosStoreRunId: storedState.iosStoreRunId }
+ : {}),
};
};
@@ -833,11 +836,12 @@ const viewWorkflowRun = ({ repository, runId }) => ghJson([
"status,conclusion,url,headSha,jobs",
]);
-const cancelSupersededCheckpointRuns = ({ repository, checkpoint, headSha }) => {
+const cancelSupersededCheckpointRuns = ({ repository, checkpoint, headSha, preserveIosStoreRun = false }) => {
const candidates = CHECKPOINT_RUN_FIELDS.flatMap((field) => checkpoint[field]
? [{ field, runId: checkpoint[field] }]
: []).filter(({ field }, index, entries) =>
CANCELLABLE_CHECKPOINT_RUN_FIELDS.has(field) &&
+ !(preserveIosStoreRun && field === "iosStoreRunId") &&
entries.findIndex((candidate) => Number(candidate.runId) === Number(entries[index].runId)) === index
);
for (const { field, runId } of candidates) {
@@ -1110,11 +1114,12 @@ const startIosStoreDelivery = async ({
headSha,
checkpoint,
persistCheckpoint,
+ allowPriorIosRun = false,
}) => {
let iosStoreRunId = checkpoint.iosStoreRunId;
if (iosStoreRunId) {
const existing = viewWorkflowRun({ repository, runId: iosStoreRunId });
- if (existing.headSha === headSha) {
+ if (existing.headSha === headSha || allowPriorIosRun) {
if (existing.status !== "completed") {
console.log(`[release] reusing App Store delivery: ${existing.url}`);
return iosStoreRunId;
@@ -1596,16 +1601,28 @@ const releaseMain = async (options) => {
tag,
});
let checkpointCommentId = storedCheckpoint.commentId;
+ const priorReleaseSha = storedCheckpoint.state.releaseSha;
+ const preserveIosStoreRun = Boolean(
+ storedCheckpoint.state.iosStoreRunId &&
+ priorReleaseSha &&
+ priorReleaseSha !== releaseSha &&
+ run("git", ["merge-base", "--is-ancestor", priorReleaseSha, releaseSha], {
+ allowFailure: true,
+ }).status === 0 &&
+ !planNativeRelease("ios", changedFilesBetween(priorReleaseSha, releaseSha)).rebuild
+ );
if (storedCheckpoint.state.releaseSha && storedCheckpoint.state.releaseSha !== releaseSha) {
cancelSupersededCheckpointRuns({
repository: options.repository,
checkpoint: storedCheckpoint.state,
headSha: releaseSha,
+ preserveIosStoreRun,
});
}
const checkpoint = prepareReleaseCheckpoint({
storedState: storedCheckpoint.state,
releaseSha,
+ preserveIosStoreRun,
});
const persistCheckpoint = () => {
checkpointCommentId = saveReleaseCheckpoint({
@@ -1679,6 +1696,7 @@ const releaseMain = async (options) => {
headSha: releaseSha,
checkpoint,
persistCheckpoint,
+ allowPriorIosRun: preserveIosStoreRun,
});
}
diff --git a/scripts/release.test.mjs b/scripts/release.test.mjs
index 10ef74bb..3acf9ad1 100644
--- a/scripts/release.test.mjs
+++ b/scripts/release.test.mjs
@@ -171,6 +171,26 @@ describe("release automation", () => {
expect(checkpointRunIds(checkpoint)).toEqual([11, 12, 13]);
});
+ test("keeps an active App Store delivery when a Draft advances without iOS changes", () => {
+ const storedState = {
+ releaseSha: "old",
+ desktopRunId: 11,
+ iosStoreRunId: 12,
+ };
+ const checkpoint = prepareReleaseCheckpoint({
+ storedState,
+ releaseSha: "new",
+ preserveIosStoreRun: true,
+ });
+ expect(checkpoint.iosStoreRunId).toBe(12);
+ expect(checkpoint.desktopRunId).toBeUndefined();
+ expect(checkpoint.runHistory).toContainEqual({
+ field: "iosStoreRunId",
+ runId: 12,
+ releaseSha: "old",
+ });
+ });
+
test("verifies an immutable Play delivery without uploading across mobile-compatible fixes", () => {
const playDelivery = { tag: "v1.42.0", releaseSha: "old" };
expect(playDeliveryResumeAction({