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

Show list-field union summary in merge preview

Adam Eivy390ec4d6f7e1
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 7d2777939b..f5273eb4ec 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -16,6 +16,7 @@ TBD
## Fixed
+- **Merging duplicate universes now shows what's being combined.** When you fold two duplicate universes (or series) together, the merge dialog only ever asked you to resolve scalar conflicts like the starter prompt — the list-shaped fields (style prompt and negative prompt chips, categories, characters/places/objects, composite sheets, seasons) were silently unioned with no indication it happened. The dialog now lists each list field the folded copy contributes to, with a running "N total · +N folded in" count, so the no-data-loss combine is visible instead of feeling like those fields were ignored.
- **[peer-sync-per-category-version-gate] Machines on different PortOS versions keep syncing everything except the one changed data type.** When one federated machine updates to a version that changes how a single kind of data is stored (universes, comics, or media collections), the others used to refuse the *entire* sync until they caught up — silently stalling all data between them. Now only transfers of the changed data type wait for the lagging machine to update; every other kind keeps flowing.
- **Voice timers survive a restart and no longer double-fire.** A timer or reminder you set by voice ("remind me in 30 minutes to call mom") is now saved to disk, so it still goes off if PortOS restarts before it's due — any that came due while it was down fire as soon as it's back. A single request can no longer arm two timers, so you won't get the same reminder twice.
- **Federated media collections: a merged-away duplicate no longer survives on peers.** When a universe (or series) *merge* tombstones the loser's auto-collection, a receiving peer applies the universe tombstone first — and its cascade (`unlinkCollectionsForUniverse` / `unlinkCollectionsForSeries`) was stamping the linked collection's `updatedAt` to "now", which then defeated the collection's own (older) tombstone under Last-Writer-Wins and left a live duplicate "Universe: X" collection on the peer. The cascade unlink now **preserves `updatedAt`** (it's a derived side-effect of the owner's deletion, not a user edit), so the collection tombstone still wins and both machines converge to deleted. Items are never lost — they're always unioned on merge.
diff --git a/client/src/components/sharing/MergeModal.jsx b/client/src/components/sharing/MergeModal.jsx
index df1064af61..55f2cb6f23 100644
--- a/client/src/components/sharing/MergeModal.jsx
+++ b/client/src/components/sharing/MergeModal.jsx
@@ -27,6 +27,11 @@ export default function MergeModal({ merge, setMerge, onExecute, onRepreview, on
const { kind, records, survivorId, loserId, preview, choices, overrides = {}, busy, aiBusy } = merge;
const conflicts = preview?.conflicts || [];
const cascade = preview?.cascade || {};
+ // List-shaped fields (style/negative prompt chips, categories, canon, etc.)
+ // are unioned rather than conflict-resolved — show what's being combined so
+ // the no-data-loss fold isn't invisible. Only rows where the folded copy
+ // actually contributed new entries are worth calling out.
+ const unionSummary = (preview?.unionSummary || []).filter((r) => r.added > 0);
const multi = records.length > 2; // 3+ copies fold one pair at a time
const aiEligible = conflicts.some(isStringConflict);
@@ -129,10 +134,26 @@ export default function MergeModal({ merge, setMerge, onExecute, onRepreview, on
</div>
)}
- {preview && conflicts.length === 0 && (
+ {preview && conflicts.length === 0 && unionSummary.length === 0 && (
<div className="text-xs text-port-success">No conflicting fields — unique data from both will be unioned.</div>
)}
+ {preview && unionSummary.length > 0 && (
+ <div className="border border-port-border rounded p-3 bg-port-bg/40">
+ <p className="text-xs text-gray-400 mb-2">Combining list fields (no data loss — entries from both are kept):</p>
+ <ul className="space-y-1">
+ {unionSummary.map((r) => (
+ <li key={r.field} className="flex items-center justify-between text-xs text-gray-300">
+ <span>{r.field}</span>
+ <span className="font-mono text-[11px] text-gray-400">
+ {r.merged} total <span className="text-port-success">+{r.added} folded in</span>
+ </span>
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
+
{preview && (
<div className="text-xs text-gray-400 border-t border-port-border pt-3">
Cascade: {kind === 'universe'
diff --git a/server/services/recordMerge.js b/server/services/recordMerge.js
index dc9c947f20..f27cfadc1e 100644
--- a/server/services/recordMerge.js
+++ b/server/services/recordMerge.js
@@ -239,6 +239,44 @@ const SERIES_SCALARS = [
'writersRoomWorkId',
];
+// ---- union summary (preview only) ----
+//
+// List-shaped fields are unioned (no data loss) rather than surfaced as
+// survivor/loser conflicts — but that combine is otherwise invisible in the
+// merge modal. These helpers build a per-field summary the preview renders so
+// the user can SEE what's being folded together. `survivor` = entries kept
+// from the survivor, `added` = entries the folded copy contributed beyond
+// those (after dedupe), so `survivor + added === merged` always holds.
+const listLen = (a) => (Array.isArray(a) ? a.length : 0);
+// Categories are a keyed map of buckets; count the variations across all
+// buckets (the actual unioned leaf entries), not the bucket keys.
+const categoryVariationCount = (cats) =>
+ Object.values(cats && typeof cats === 'object' ? cats : {})
+ .reduce((n, b) => n + listLen(b?.variations), 0);
+
+const summaryRow = (field, survivorCount, mergedCount) => ({
+ field,
+ survivor: survivorCount,
+ merged: mergedCount,
+ added: Math.max(0, mergedCount - survivorCount),
+});
+const listRow = (field, survivorList, mergedList) => summaryRow(field, listLen(survivorList), listLen(mergedList));
+
+/** Per-list-field combine summary for a universe merge preview. */
+export const summarizeUniverseUnion = (survivor, loser, record) => [
+ listRow('Style prompt (embrace)', survivor.influences?.embrace, record.influences?.embrace),
+ listRow('Negative prompt (avoid)', survivor.influences?.avoid, record.influences?.avoid),
+ summaryRow('Categories', categoryVariationCount(survivor.categories), categoryVariationCount(record.categories)),
+ listRow('Composite sheets', survivor.compositeSheets, record.compositeSheets),
+ listRow('Characters', survivor.characters, record.characters),
+ listRow('Places', survivor.places, record.places),
+ listRow('Objects', survivor.objects, record.objects),
+].filter((r) => r.merged > 0);
+
+/** Per-list-field combine summary for a series merge preview. */
+export const summarizeSeriesUnion = (survivor, loser, record) =>
+ [listRow('Seasons', survivor.seasons, record.seasons)].filter((r) => r.merged > 0);
+
/** Build the unioned universe patch + conflict report from survivor + loser. */
export const buildUniverseUnion = (survivor, loser, fieldChoices = {}, fieldOverrides = {}) => {
const { values, conflicts, autoResolved } = resolveScalars(UNIVERSE_SCALARS, survivor, loser, fieldChoices, fieldOverrides);
@@ -251,7 +289,7 @@ export const buildUniverseUnion = (survivor, loser, fieldChoices = {}, fieldOver
places: mergeExtractedBible(survivor.places, loser.places, BIBLE_KIND.PLACE),
objects: mergeExtractedBible(survivor.objects, loser.objects, BIBLE_KIND.OBJECT),
};
- return { record, conflicts, autoResolved };
+ return { record, conflicts, autoResolved, unionSummary: summarizeUniverseUnion(survivor, loser, record) };
};
/** Build the unioned series patch + conflict report from survivor + loser. */
@@ -261,7 +299,7 @@ export const buildSeriesUnion = (survivor, loser, fieldChoices = {}, fieldOverri
...values,
seasons: unionSeasons(survivor.seasons, loser.seasons),
};
- return { record, conflicts, autoResolved };
+ return { record, conflicts, autoResolved, unionSummary: summarizeSeriesUnion(survivor, loser, record) };
};
const requireResolved = (conflicts) => {
@@ -287,7 +325,7 @@ export async function mergeUniverses(survivorId, loserId, fieldChoices = {}, { d
const survivor = await getUniverse(survivorId);
const loser = await getUniverse(loserId);
- const { record, conflicts, autoResolved } = buildUniverseUnion(survivor, loser, fieldChoices, fieldOverrides);
+ const { record, conflicts, autoResolved, unionSummary } = buildUniverseUnion(survivor, loser, fieldChoices, fieldOverrides);
// Cascade preview: which series re-point, how many collection items fold.
const childSeries = (await listSeries()).filter((s) => s.universeId === loserId);
@@ -298,7 +336,7 @@ export async function mergeUniverses(survivorId, loserId, fieldChoices = {}, { d
};
if (dryRun) {
- return { survivorId, loserId, preview: { ...survivor, ...record }, conflicts, autoResolved, cascade };
+ return { survivorId, loserId, preview: { ...survivor, ...record }, conflicts, autoResolved, unionSummary, cascade };
}
requireResolved(conflicts);
@@ -361,7 +399,7 @@ export async function mergeSeries(survivorId, loserId, fieldChoices = {}, { dryR
throw makeErr('Series can only be merged within the same universe', ERR_VALIDATION);
}
- const { record, conflicts, autoResolved } = buildSeriesUnion(survivor, loser, fieldChoices, fieldOverrides);
+ const { record, conflicts, autoResolved, unionSummary } = buildSeriesUnion(survivor, loser, fieldChoices, fieldOverrides);
const loserCollection = await findCollectionBySeriesId(loserId);
// Issues are reassigned to the survivor un-grouped; count for the preview.
@@ -372,7 +410,7 @@ export async function mergeSeries(survivorId, loserId, fieldChoices = {}, { dryR
};
if (dryRun) {
- return { survivorId, loserId, preview: { ...survivor, ...record }, conflicts, autoResolved, cascade };
+ return { survivorId, loserId, preview: { ...survivor, ...record }, conflicts, autoResolved, unionSummary, cascade };
}
requireResolved(conflicts);
diff --git a/server/services/recordMerge.test.js b/server/services/recordMerge.test.js
index 1f875ffc7e..d4f1b3033e 100644
--- a/server/services/recordMerge.test.js
+++ b/server/services/recordMerge.test.js
@@ -132,6 +132,21 @@ describe('recordMerge — pure union helpers', () => {
expect(record.starterPrompt).toBe('A + B unified');
});
+ it('buildUniverseUnion reports a union summary for list fields the folded copy adds to', () => {
+ const { unionSummary } = merge.buildUniverseUnion(
+ { name: 'Dup', starterPrompt: 'A', categories: {}, influences: { embrace: ['neon'], avoid: [] }, characters: [], places: [], objects: [] },
+ { name: 'Dup', starterPrompt: 'A', categories: {}, influences: { embrace: ['rain', 'NEON'], avoid: ['blur'] }, characters: [], places: [], objects: [] },
+ );
+ // embrace: survivor ['neon'] + loser ['rain','NEON'] → dedupe 'NEON' → ['neon','rain'] (2 total, +1)
+ const style = unionSummary.find((r) => r.field === 'Style prompt (embrace)');
+ expect(style).toEqual({ field: 'Style prompt (embrace)', survivor: 1, merged: 2, added: 1 });
+ // avoid: survivor [] + loser ['blur'] → ['blur'] (1 total, +1)
+ const neg = unionSummary.find((r) => r.field === 'Negative prompt (avoid)');
+ expect(neg).toEqual({ field: 'Negative prompt (avoid)', survivor: 0, merged: 1, added: 1 });
+ // Empty list fields (characters/places/objects/categories/sheets) are omitted.
+ expect(unionSummary.map((r) => r.field)).toEqual(['Style prompt (embrace)', 'Negative prompt (avoid)']);
+ });
+
it('buildUniverseUnion fieldOverrides honor empty-string clears', () => {
const { conflicts, record } = merge.buildUniverseUnion(
{ name: 'Dup', starterPrompt: 'A', categories: {}, influences: {}, characters: [], places: [], objects: [] },