How ophilar/tabtogether works
Project type and purpose
• TabTogether is a browser extension (Firefox Add-on) whose purpose is to let users define device “groups” and seamlessly send tabs between all members of a group by leveraging the Firefox Sync service.
Main architectural components
a. Browser Extension Container
• Popup UI (popup.html + popup.js + popup.css)
• Options UI (options.html + options.js + shared-ui.js + styles.css)
• Context-menu handler (registered in background.js)
• Background script (background.js + constants.js + utils.js + theme.js)
• Local storage module (browser.storage.local)
• Sync storage module (browser.storage.sync)
• Notification module (browser.notifications)
• Tests (jest + integration.test.js + utils.test.js)
b. External Service
• Firefox Sync (cloud-hosted key/value store and pub/sub mechanism for extension data)
Component relationships and data flow
• UI → Background
• popup.js and options.js send messages (browser.runtime.sendMessage) to background.js
• Background → Storage
• background.js writes group definitions and device subscriptions to browser.storage.local
• background.js writes “tab send” events into browser.storage.sync for distribution
• Firefox Sync → Background (on other devices)
• Storage.sync.onChanged events fire in background.js on all subscriber devices
• background.js responds by opening the incoming tab via browser.tabs.create
• Background → Notifications
• background.js uses browser.notifications to alert user of success or errors
• Context Menu → Background
• background.js registers a right-click menu (browser.contextMenus.create) and handles clicks to trigger the same “send tab” flow
Architectural patterns and design principles
• Event-driven messaging (UI ↔ background via runtime messages)
• Pub/Sub via storage.sync (leverages Firefox Sync as a distributed event bus)
• Separation of concerns:
• UI layer (popup/options)
• Orchestration layer (background)
• Persistence layer (local vs. sync storage)
• Reusable utilities (constants.js, utils.js) shared between background and UI
Detail and clarity
• Distinguish local vs. sync storage.
• Both UI-initiated flows (popup/options/context menu) and incoming flows from Sync.