# LinkSyncExtension - Implementation Tasks ## Phase 1: Project Setup ### Setup Tasks - [x] Create project directory structure - [x] Write README.md - [x] Write TODOs.txt - [x] Write design.md - [x] Write tasks.md - [x] Write AGENTS.md ### Initial Files - [x] Create manifest.json (v2, Firefox-compatible) - [x] Add icon files (48x48, 96x96) - [x] Create utils folder with all modules - [x] Create content folder for content script ## Phase 2: Core Development ### Background Script - [x] Create background.html - [x] Create background.js - [x] Implement init() on install/update - [x] Implement sync loop with interval (5 min) - [x] Add event handlers (message, install, bookmark changes) - [x] Implement sync mode switching - [x] Add collection mapping logic - [x] Implement auto-sync timer - [x] Add error handling and retries ### Popup Script - [x] Create popup.html with tabbed interface - [x] Create popup.css with full responsive styling - [x] Create popup.js with all functionality - [x] Implement bookmark form UI with auto-fill - [x] Add bookmark list view with search - [x] Add collection panel - [x] Implement settings modal - [x] Add sync button handler - [x] Implement query builder tab - [x] Add toast notifications ### Utility Modules - [x] Create utils/api.js - REST API client with Bearer token auth - Retry logic (3 attempts with backoff) - Timeout handling (10s) - Rate limit handling (429) - All endpoints: auth, links, collections, queries, sync, admin - [x] Create utils/sync.js - Bi-directional sync - Browser-authoritative sync - Server-authoritative sync - Deletions handling - Conflict detection - [x] Create utils/collection.js - List/create/update/delete collections - Add/remove links from collections - Execute queries - Parse queries - [x] Create utils/query-engine.js - Tokenizer for query expressions - Recursive descent parser - AST generation (TERM, TERM_SET, FIELD, AND, OR, XOR) - Query validation - Query string builder - [x] Create utils/bookmark.js - Parse Firefox bookmark data - Format bookmark for API - Handle field validation - Merge bookmarks for conflict resolution - Duplicate detection ### Content Script - [x] Create content/content.js - [x] Implement page title extraction - [x] Implement URL detection - [x] Implement meta description extraction - [x] Implement favicon extraction - [x] Handle browser.runtime.onMessage ### Options Page - [x] Create options.html - [x] Create options.js - [x] Server URL configuration - [x] API key input - [x] Sync mode dropdown - [x] Deletions checkbox - [x] Auto-sync checkbox - [x] Test connection button - [x] Sync now button ## Phase 3: Storage Management ### Storage Implementation - [x] Use browser.storage.local for all settings - [x] Store API key securely - [x] Implement storage helper functions - [x] Add sync timestamp tracking - [x] Add pending changes counter - [x] Add syncing state flag ### Storage Keys - [x] `linksync_server_url` - Server base URL - [x] `linksync_api_key` - JWT bearer token - [x] `linksync_sync_mode` - Sync mode string - [x] `linksync_deletions` - Boolean - [x] `linksync_auto_sync` - Boolean - [x] `linksync_last_sync` - ISO timestamp - [x] `linksync_syncing` - Boolean flag - [x] `linksync_pending` - Boolean flag ## Phase 4: Sync Logic ### Bi-directional Sync - [x] Push browser→server (new bookmarks) - [x] Push server→browser (new bookmarks) - [x] Handle deletions when enabled ### Browser Authoritative Sync - [x] Push browser→server (create + update) - [x] Overwrite server data on conflict - [x] Delete server bookmarks not in browser ### Server Authoritative Sync - [x] Download from server - [x] Overwrite local on conflict - [x] No push to server ### Deletions - [x] Implement deletions checkbox logic - [x] Delete on both sides if enabled ### Conflict Resolution - [x] Detect URL collision with different titles - [x] Conflict detection method available ## Phase 5: UI Components ### Bookmark Form - [x] URL input (auto-fill from active tab) - [x] Title input (auto-fill from active tab) - [x] Description textarea - [x] Notes textarea - [x] Tags input (comma-separated) - [x] Folder path input - [x] Add button ### Bookmark List - [x] Display synced bookmarks - [x] Search filter input - [x] Tag display ### Collections Panel - [x] Collection list display - [x] Collection type indicator ### Query Builder - [x] Query expression input - [x] Parse button - [x] Execute button - [x] Result display - [x] Syntax help ### Sync Status - [x] Last sync timestamp - [x] Sync indicator (syncing/synced/error) - [x] Manual sync trigger ### Settings Modal - [x] Server URL input - [x] API Key input (show/hide toggle) - [x] Sync mode dropdown - [x] Deletions checkbox - [x] Auto-sync checkbox - [x] Test connection button - [x] Save button ## Phase 6: Error Handling ### API Errors - [x] Handle 401 (unauthorized) - [x] Handle 429 (rate limited) with retry - [x] Handle 500 (server error) - [x] Handle timeout - [x] Show user-friendly messages via notifications ### Network Errors - [x] Offline detection (fetch errors) - [x] Retry with backoff (3 attempts) - [x] Request timeout (10s) ### UI Errors - [x] Form validation (required fields) - [x] Input sanitization (escapeHtml) - [x] Error notifications - [x] Empty state messages ## Phase 7: Testing ### Manual Testing - [x] Testing checklist (tests/README.md) - [ ] Test in Firefox (load temporary add-on) - [ ] Test all sync modes - [ ] Test conflict scenarios - [ ] Test offline scenarios ## Phase 8: Packaging ### Distribution - [x] All files present and valid - [x] manifest.json verified - [x] Icons present (48x48, 96x96) ## Phase 9: Documentation - [x] API reference (README.md) - [x] User guide (README.md) - [x] Troubleshooting guide (README.md) - [x] Query syntax reference (README.md) - [x] Architecture docs (AGENTS.md, design.md) ## Future Enhancements - [ ] Background sync notifications - [ ] Keyboard shortcuts - [ ] Dark theme toggle - [ ] Bookmark edit/delete from popup - [ ] Batch operations - [ ] Conflict resolution UI - [ ] Offline queue for pending changes - [ ] Auto-sync scheduler customization - [ ] Gesture controls - [ ] Mobile companion app