Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review: empty-patch short-circuit + true debounce

[._.]/ Adam Eivy85c01f63384f
diff --git a/server/services/pipeline/series.js b/server/services/pipeline/series.js
index 24f25747ae..51d3b29f6f 100644
--- a/server/services/pipeline/series.js
+++ b/server/services/pipeline/series.js
@@ -269,6 +269,16 @@ export async function updateSeasonOnSeries(seriesId, seasonId, patchFn) {
}
const existing = seasons[seasonIdx];
const patched = patchFn(existing);
+ // No-op short-circuit: `patchFn` returning `null`/`undefined` (or an empty
+ // object) means "nothing changed" — typically a filename-hook racing a
+ // newer job. Without this guard, every late completion event bumps
+ // `season.updatedAt`, rewrites the series file, and re-broadcasts
+ // `recordUpdated('series', …)`, which schedules a share re-export and
+ // makes LWW comparisons noisy. Mirrors the empty-patch fast-path the
+ // issues-side `updateStageWithLatest` already has.
+ if (!patched || (typeof patched === 'object' && Object.keys(patched).length === 0)) {
+ return cur;
+ }
const nextSeasons = [...seasons];
// Force a fresh updatedAt on the touched season so LWW comparisons fire.
nextSeasons[seasonIdx] = { ...existing, ...patched, updatedAt: new Date().toISOString() };
diff --git a/server/services/sharing/annotationsSync.js b/server/services/sharing/annotationsSync.js
index e72ea5c73b..1167559449 100644
--- a/server/services/sharing/annotationsSync.js
+++ b/server/services/sharing/annotationsSync.js
@@ -105,7 +105,7 @@ function buildManifestForAnnotations({ senderInstanceId, sourceName, bucket, rec
}
async function flushAll() {
- pendingTimer = null;
+ // pendingTimer is already cleared by scheduleFlush's setTimeout callback.
const [buckets, senderInstanceId, sourceName, localAnnotations] = await Promise.all([
listBuckets().catch(() => []),
getInstanceId().catch(() => null),
@@ -127,8 +127,15 @@ async function flushAll() {
}
function scheduleFlush() {
- if (pendingTimer) return;
+ // True debounce: restart the timer on every call so a burst of rapid edits
+ // collapses into one flush 2s after the LAST change. The previous
+ // "if (pendingTimer) return" was a throttle — the first edit started the
+ // timer and subsequent edits within the window were absorbed but the
+ // flush still fired mid-burst (and the trailing edits then triggered
+ // another flush a moment later).
+ if (pendingTimer) clearTimeout(pendingTimer);
pendingTimer = setTimeout(() => {
+ pendingTimer = null;
flushAll().catch((err) => {
console.error(`⚠️ sharing.annotations: flushAll failed: ${err.message}`);
});