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

fix(publish): a replaced post starts with only the links its own draft carried

[._.]/ Adam Eivy8b6ef92e7668
diff --git a/server/lib/musicVideoCrossLinks.js b/server/lib/musicVideoCrossLinks.js
index c216f59f18..027da9dbf5 100644
--- a/server/lib/musicVideoCrossLinks.js
+++ b/server/lib/musicVideoCrossLinks.js
@@ -75,7 +75,7 @@ export function carriedLinks(kit, target) {
export function crossLinkBackfill(kit) {
const posts = kitOf(kit).posts || {};
return CROSS_LINK_EDIT_TARGETS.filter((target) => str(posts[target]?.url)).map((target) => {
- const exclude = [target, ...carriedLinks(kit, target), ...(target === 'stackerNews' ? ['youtube'] : [])];
+ const exclude = [target, ...carriedLinks(kit, target)];
const missing = releaseLinks(kit, { exclude });
return { target, url: str(posts[target].url), missing, text: missing.map((l) => `${l.label}: ${l.url}`).join('\n') };
});
diff --git a/server/lib/musicVideoCrossLinks.test.js b/server/lib/musicVideoCrossLinks.test.js
index 2391ef115a..5fb3176617 100644
--- a/server/lib/musicVideoCrossLinks.test.js
+++ b/server/lib/musicVideoCrossLinks.test.js
@@ -41,4 +41,14 @@ describe('cross-links between release posts', () => {
const reposted = { posts: { ...posts, youtube: { url: 'https://youtu.be/new', postedAt: '2026-01-04T00:00:00Z', links: [] } } };
expect(crossLinkBackfill(reposted).find((r) => r.target === 'x').missing.map((l) => l.url)).toContain('https://youtu.be/new');
});
+
+ it('offers a replaced YouTube video to a Stacker News post that linked the old one', () => {
+ const kit = { posts: {
+ youtube: { url: 'https://youtu.be/new', postedAt: '2026-01-04T00:00:00Z', links: [] },
+ stackerNews: { url: 'https://stacker.news/items/7', postedAt: '2026-01-02T00:00:00Z', links: ['youtube'] },
+ } };
+ expect(crossLinkBackfill(kit).find((r) => r.target === 'stackerNews').missing).toEqual([]);
+ const dropped = { posts: dropCarriedLink(kit, kit.posts, 'youtube') };
+ expect(crossLinkBackfill(dropped).find((r) => r.target === 'stackerNews').missing.map((l) => l.url)).toEqual(['https://youtu.be/new']);
+ });
});
diff --git a/server/services/musicVideo/publish/index.js b/server/services/musicVideo/publish/index.js
index ccc0b464c2..8c2fbd1e6f 100644
--- a/server/services/musicVideo/publish/index.js
+++ b/server/services/musicVideo/publish/index.js
@@ -313,11 +313,14 @@ export async function recordPublishPost(projectId, target, input = {}, deps = {}
const { project } = await mutateProjectRecord(projectId, (current) => {
const kit = current.publishKit && typeof current.publishKit === 'object' ? current.publishKit : {};
let posts = { ...(kit.posts || {}) };
- if (Array.isArray(input.links) && posts[target]) input = { ...input, links: mergeCarriedLinks(carriedLinks(kit, target), input.links) };
const before = posts[target];
+ const replaced = !!before?.url && typeof input.url === 'string' && input.url.trim() !== before.url;
+ // A replacement post starts over: only the links its own draft carried.
+ if (replaced) input = { ...input, links: mergeCarriedLinks([], input.links) };
+ else if (Array.isArray(input.links) && before) input = { ...input, links: mergeCarriedLinks(carriedLinks(kit, target), input.links) };
const next = normalizePost(before, input);
// Other posts that linked the old URL no longer link this post.
- if (before?.url && before.url !== next.url) posts = dropCarriedLink(kit, posts, target);
+ if (replaced) posts = dropCarriedLink(kit, posts, target);
posts[target] = next;
return { project: { ...current, publishKit: { ...kit, posts } } };
});