Skip to content

Conversation

@bdbch
Copy link
Contributor

@bdbch bdbch commented Nov 12, 2025

Summary

This PR adds Firefox Sync support for Zen Browser's Pinned Tabs, Essential Tabs, and Tab Folders, allowing users to sync their customized tab setup across multiple devices.

What This Does

  • Syncs Pinned Tabs: All pinned tabs are synchronized across devices, including their URLs, positions, and container assignments
  • Syncs Essential Tabs: Essential tab status is preserved across devices
  • Syncs Folders: Tab folder structure, including nested folders, is maintained
  • Preserves Customizations: Custom tab titles, folder icons, and collapsed/expanded states are synced
  • Workspace Awareness: Tabs maintain their workspace assignments across devices

Implementation

New Sync Engine

Created ZenPinnedTabsSync.mjs that implements a Firefox Sync engine following the standard Weave sync architecture:

  • Store: Handles serialization/deserialization of pinned tab records
  • Tracker: Monitors local changes and marks records for upload
  • Engine: Coordinates sync operations with Firefox Sync infrastructure

Change Tracking

Enhanced ZenPinnedTabsStorage.mjs to track changes for sync:

  • Added zen_pins_changes table to track modified pins
  • Implemented timestamp-based change detection
  • Fixed updatePinTitle() to properly record title changes for sync

Auto-Refresh on Sync

Modified ZenPinnedTabManager.mjs to automatically apply synced changes:

  • Added observer for weave:engine:sync:finish events
  • Automatically refreshes pinned tabs when sync completes
  • Properly handles editedTitle flag to preserve custom tab names
  • Updates zen-has-static-label attribute to prevent title overwrites

UI Integration

  • Added sync preference checkbox in Settings → Sync
  • Added localization strings for the sync option
  • Integrated with Firefox's existing sync preferences system

Technical Details

Synced Properties:

  • uuid - Unique identifier
  • title - Tab title (original or custom)
  • url - Tab URL
  • editedTitle - Flag indicating custom title
  • containerTabId - Container tab assignment
  • workspaceUuid - Workspace assignment
  • position - Tab position in sidebar
  • isEssential - Essential tab status
  • isGroup - Folder indicator
  • parentUuid - Parent folder reference
  • folderIcon - Custom folder icon
  • isFolderCollapsed - Folder collapsed state

Testing Instructions

Initial Setup

  1. Build the browser
  2. Create a new Firefox profile (to avoid affecting your existing data):
    - Launch the browser
    - Go to about:profiles (or use Firefox's new profile manager)
    - Create a new profile and set it as default
  3. Enable Firefox Sync:
    - Go to Settings → Sync
    - Sign in with your Firefox Account
    - Enable "Pinned Tabs" and "Workspaces" in the sync options
  4. Create test data on Device 1:
    - Create several pinned tabs (at least 5-6)
    - Create a folder and add some tabs to it
    - Create a nested folder (folder inside a folder)
    - Rename some tabs to custom names (right-click → Rename)
    - Change some folder icons (right-click folder → Change Icon)
    - Mark some tabs as Essential
    - Assign tabs to different workspaces (if using workspaces)
    - Collapse/expand some folders
  5. Trigger a sync:
    - Go to Settings → Sync
    - Click "Sync Now" button
    - Wait for sync to complete
  6. Verify on Device 2:
    - Create another new profile (or use a different device)
    - Sign in with the same Firefox Account
    - Enable "Pinned Tabs" in sync options
    - Click "Sync Now"
    - Verify all tabs, folders, and customizations appear correctly:
    • ✓ All pinned tabs are present
    • ✓ Folder structure is preserved (including nested folders)
    • ✓ Custom tab names are maintained
    • ✓ Folder icons are preserved
    • ✓ Folder collapsed/expanded states match
    • ✓ Essential tabs are marked correctly
    • ✓ Workspace assignments are correct
  7. Test bidirectional sync:
    - On Device 2, make some changes (add tabs, rename something, create a folder)
    - Sync Device 2
    - Sync Device 1
    - Verify changes appear on Device 1
  8. Test conflict resolution:
    - Make different changes to the same tab on both devices (e.g., rename it differently)
    - Sync both devices
    - Verify no data loss occurs (last-write-wins strategy)

Additional notes

  • This uses Firefox's built-in Sync infrastructure, so no additional servers or configuration needed
  • Sync respects Firefox Account encryption - all data is encrypted end-to-end
  • Compatible with existing Firefox Sync data (bookmarks, history, etc.)
  • Follows Firefox Sync best practices for conflict resolution and error handling

@bdbch bdbch requested a review from mr-cheffy as a code owner November 12, 2025 08:03
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. Feature labels Nov 12, 2025
@mr-cheffy
Copy link
Member

I think this would be better implemented once we have #10034 merged. So we sync the entire "sidebar" object, not just pinned tabs.

@bdbch
Copy link
Contributor Author

bdbch commented Nov 12, 2025

Makes sense. Should I keep this open until #10034 is merged and we see how we can implement the sidebar sync with Firefox Sync?

@mr-cheffy
Copy link
Member

Sure, i'll mark is a draft though until it gets merged

@mr-cheffy mr-cheffy marked this pull request as draft November 12, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants