Skip to content

Commit 3d74901

Browse files
committed
fix: preserve locally modified bookmark titles and folders during sync
Previously, locallyModifiedBookmarkIds protection only skipped index-only changes from cloud. Title and folder changes were allowed through, which caused local edits (e.g., renaming a bookmark label) to be overwritten by stale cloud data during the pull phase. By the time the push phase ran, the local change had already been reverted, so nothing got pushed. Now ALL cloud-driven updates are skipped for locally modified bookmarks, allowing local title, folder, and index changes to survive the pull phase and get pushed to cloud correctly.
1 parent ef00bf5 commit 3d74901

1 file changed

Lines changed: 15 additions & 29 deletions

File tree

apps/extension/src/background/index.js

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -492,26 +492,16 @@ function categorizeCloudBookmarks(cloudBookmarks, localBookmarks, tombstones) {
492492
if (!localBm) {
493493
toAdd.push(cloudBm);
494494
} else if (bookmarkNeedsUpdate(cloudBm, localBm)) {
495-
// If this bookmark was locally modified (e.g., user reordered it), skip
496-
// cloud-driven index/position updates. The local state takes priority and
497-
// will be pushed to cloud. This prevents the "reorder then Sync Now resets
498-
// order" bug where cloud's stale indices overwrite local changes.
499-
// We still allow title and folder changes from cloud (meaningful edits),
500-
// but skip index-only changes for locally modified bookmarks.
495+
// If this bookmark was locally modified (e.g., user renamed or reordered
496+
// it), skip ALL cloud-driven updates. The local state takes priority and
497+
// will be pushed to cloud in the push phase.
501498
if (locallyModifiedBookmarkIds.has(localBm.id)) {
502-
const cloudFolder = normalizeFolderPath(cloudBm.folderPath);
503-
const localFolder = normalizeFolderPath(localBm.folderPath);
504-
const titleChanged = (cloudBm.title ?? '') !== (localBm.title ?? '');
505-
const folderChanged = cloudFolder !== localFolder;
506-
507-
if (!titleChanged && !folderChanged) {
508-
// Only the index differs — this is a reorder conflict.
509-
// Local wins because the user just rearranged these bookmarks.
510-
skippedByLocalModification.push(cloudBm.url);
511-
continue;
512-
}
513-
// Title or folder changed in cloud — allow the update even for locally
514-
// modified bookmarks (meaningful edit from another browser).
499+
// Local wins for ALL changes (title, folder, index) when the bookmark
500+
// was locally modified. The local state will be pushed to cloud in the
501+
// push phase. Previously we only skipped index-only changes, which
502+
// caused local title/folder edits to be overwritten by stale cloud data.
503+
skippedByLocalModification.push(cloudBm.url);
504+
continue;
515505
}
516506
toUpdate.push({ cloud: cloudBm, local: localBm });
517507
} else {
@@ -2687,17 +2677,13 @@ async function updateLocalBookmarksFromCloud(bookmarksToUpdate) {
26872677
const indexChanged =
26882678
cloud.index !== undefined && local.index !== undefined && cloud.index !== local.index;
26892679

2690-
// Skip index-only moves for locally modified bookmarks.
2691-
// This prevents the "reorder then Sync Now resets order" bug where
2692-
// cloud's stale indices overwrite local changes the user just made.
2693-
if (
2694-
locallyModifiedBookmarkIds.has(local.id) &&
2695-
!titleChanged &&
2696-
!folderChanged &&
2697-
indexChanged
2698-
) {
2680+
// Skip ALL cloud-driven updates for locally modified bookmarks.
2681+
// Local state takes priority and will be pushed to cloud in the push phase.
2682+
// This prevents stale cloud data (title, folder, index) from overwriting
2683+
// local changes the user just made.
2684+
if (locallyModifiedBookmarkIds.has(local.id)) {
26992685
console.log(
2700-
`[MarkSyncr] 🏠 Skipping index-only update for locally modified bookmark: ${cloud.url} (local index ${local.index} vs cloud index ${cloud.index})`
2686+
`[MarkSyncr] 🏠 Skipping cloud update for locally modified bookmark: ${cloud.url} (title: "${local.title}" vs cloud "${cloud.title}", index: ${local.index} vs cloud ${cloud.index})`
27012687
);
27022688
continue;
27032689
}

0 commit comments

Comments
 (0)