trilium/apps/web-clipper-manifestv3/WORKING-STATUS.md
Octech2722 1f444ebc69 docs: add comprehensive development workflow documentation
Copilot Integration:
- Streamlined instructions (70% shorter than original)
- Task templates for common operations
- Three-tier usage strategy (free/strategic/manual)
- Optimized for GitHub Copilot Basic tier limits

Development Resources:
- Common task workflows with time estimates
- Feature parity checklist with priorities
- Debugging and troubleshooting guides
- Testing scenarios and checklists
- Code quality standards

Workflow Optimization:
- Efficient Copilot task budgeting
- Real-world implementation examples
- Performance and success metrics
- Project completion roadmap

Reduces repetitive context in prompts.
Maximizes limited Copilot task budget.
2025-10-18 12:21:13 -05:00

11 KiB
Raw Blame History

<EFBFBD> Trilium Web Clipper MV3 - Working Status

Extension Status: CORE FUNCTIONALITY WORKING
Last Updated: October 17, 2025
Build System: esbuild + IIFE
Target: Manifest V3 (Chrome/Edge/Brave)


🚀 Quick Start

# Make sure you are in the correct working directory
cd apps/web-clipper-manifestv3

# Build
npm run build

# Load in Chrome
chrome://extensions/ → Load unpacked → Select dist/

Implemented & Working

Core Functionality

  • Content script injection (declarative)
  • Save Selection to Trilium
  • Save Page to Trilium (with Readability + DOMPurify + Cheerio pipeline)
  • Save Link (basic - URL + title only)
  • Save Screenshot (full page capture, metadata stored)
  • Duplicate note detection with user choice (new/update/cancel)
  • HTML/Markdown/Both save formats
  • Context menus (Save Selection, Save Page, Save Link, Save Screenshot, Save Image)
  • Keyboard shortcuts (Ctrl+Shift+S for save, Ctrl+Shift+A for screenshot)

UI Components

  • Popup UI with theming (light/dark/auto)
  • Settings page with Trilium connection config
  • Logs page with filtering
  • Toast notifications (basic success/error)
  • Connection status indicator
  • System theme detection

Build System

  • esbuild bundling (IIFE format)
  • TypeScript compilation
  • HTML transformation (script refs fixed)
  • Asset copying (CSS, icons, manifest)
  • Type checking (npm run type-check)

🔴 Missing Features (vs MV2)

High Priority

1. Screenshot Cropping 🎯 NEXT UP

  • MV2: cropImage() function crops screenshot to selected area
  • MV3: Crop rectangle stored in metadata but NOT applied to image
  • Impact: Users get full-page screenshot instead of selected area
  • Solution: Use OffscreenCanvas API or content script canvas
  • Files: src/background/index.ts:504-560, need crop implementation

2. Image Processing (Full Page)

  • MV2: Downloads all external images, converts to base64, embeds in note
  • MV3: Only processes images for selection saves, not full page
  • Impact: External images in full-page clips may break/disappear
  • Solution: Apply postProcessImages() to all capture types
  • Files: src/background/index.ts:668-740

3. Screenshot Selection UI Verification

  • MV2: Overlay with drag-to-select, Escape to cancel, visual feedback
  • MV3: Likely exists in content script but needs testing against MV2
  • Impact: Unknown - need to verify feature parity
  • Files: Check src/content/ against apps/web-clipper/content.js:66-193

Medium Priority

4. Save Tabs (Bulk Save)

  • MV2: "Save tabs" context menu saves all open tabs as single note with links
  • MV3: Not implemented
  • Impact: Users can't bulk-save research sessions
  • Solution: Add context menu + background handler
  • Files: Reference apps/web-clipper/background.js:302-326

5. "Already Visited" Popup Detection

  • MV2: Popup shows if page already clipped, with link to existing note
  • MV3: Background has checkForExistingNote() but popup doesn't use it
  • Impact: Users don't know if they've already saved a page
  • Solution: Call checkForExistingNote() on popup open, show banner
  • Files: src/popup/, reference apps/web-clipper/popup/popup.js

Low Priority (Quality of Life)

  • MV2: Save link with custom text entry (textarea in popup)
  • MV3: Only saves URL + page title
  • Impact: Can't add context/thoughts when saving links
  • Solution: Add textarea to popup for "Save Link" action
  • Files: src/popup/index.ts, src/background/index.ts:562-592

7. Date Metadata Extraction

  • MV2: Extracts publishedDate/modifiedDate from meta tags
  • MV3: Not implemented
  • Impact: Lost temporal metadata for articles
  • Solution: Add meta tag parsing to content script
  • Files: Add to content script, reference apps/web-clipper/content.js:44-65

8. Interactive Toast Notifications

  • MV2: Toasts have "Open in Trilium" and "Close Tabs" buttons
  • MV3: Basic toasts with text only
  • Impact: Extra step to open saved notes
  • Solution: Add button elements to toast HTML
  • Files: src/content/toast.ts, reference apps/web-clipper/content.js:253-291

⚠️ Partially Implemented

Feature Status Gap
Screenshot capture Working No cropping applied
Image processing ⚠️ Selection only Full page clips missing
Save link Basic No custom note text
Toast notifications Basic No interactive buttons
Duplicate detection Working Not shown in popup proactively

📋 Feature Comparison Matrix

Feature MV2 MV3 Priority
Content Capture
Save Selection -
Save Full Page -
Save Link ⚠️ Basic LOW
Save Screenshot ⚠️ No crop HIGH
Save Image -
Save Tabs MED
Content Processing
Readability extraction -
DOMPurify sanitization -
Cheerio cleanup -
Image downloading ⚠️ Partial HIGH
Date metadata LOW
Screenshot cropping HIGH
Save Formats
HTML -
Markdown -
Both (parent/child) -
UI Features
Popup -
Settings page -
Logs page -
Context menus -
Keyboard shortcuts -
Toast notifications ⚠️ Basic LOW
Already visited banner MED
Screenshot selection UI Unknown HIGH
Connection
HTTP/HTTPS servers -
Desktop app mode -
Connection testing -
Auto-reconnect -

🎯 Current Development Phase

Phase 1: Critical Features COMPLETE

  • Build system working
  • Content script injection
  • Basic save functionality
  • Settings & logs UI

Phase 2: Screenshot Features 🔄 IN PROGRESS

  • Task 2.1: Verify screenshot selection UI
  • Task 2.2: Implement screenshot cropping
  • Task 2.3: Test crop workflow end-to-end

Phase 3: Image Processing (Planned)

  • ⏸️ Apply image processing to full page captures
  • ⏸️ Test with various image formats
  • ⏸️ Handle CORS edge cases

Phase 4: Quality of Life (Planned)

  • ⏸️ Save tabs feature
  • ⏸️ Already visited detection
  • ⏸️ Link with custom note
  • ⏸️ Date metadata extraction
  • ⏸️ Interactive toasts

🛠️ Build System

Source: src/ (TypeScript)
Output: dist/ (IIFE JavaScript)
Config: build.mjs

Key Transformations

  • .ts.js (IIFE bundled)
  • HTML script refs fixed (.ts.js)
  • Paths rewritten for flat structure
  • CSS + icons copied
  • manifest.json validated

Common Commands

# Build for production
npm run build

# Type checking
npm run type-check

# Clean build
npm run clean && npm run build

📂 File Structure

dist/
├── background.js         # Service worker (IIFE)
├── content.js           # Content script (IIFE)
├── popup.js             # Popup UI logic (IIFE)
├── options.js           # Settings page (IIFE)
├── logs.js              # Logs page (IIFE)
├── *.html               # HTML files (script refs fixed)
├── *.css                # Styles (includes theme.css)
├── icons/               # Extension icons
├── shared/              # Shared assets (theme.css)
└── manifest.json        # Chrome extension manifest

🧪 Testing Checklist

Before Each Build

  • npm run type-check passes
  • npm run build completes without errors
  • No console errors in background service worker
  • No console errors in content script

Core Functionality

  • Popup displays correctly
  • Settings page accessible
  • Logs page accessible
  • Connection status shows correctly
  • Theme switching works (light/dark/auto)

Save Operations

  • Save Selection works
  • Save Page works
  • Save Link works
  • Save Screenshot works (full page)
  • Save Image works
  • Context menu items appear
  • Keyboard shortcuts work

Error Handling

  • Invalid Trilium URL shows error
  • Network errors handled gracefully
  • Restricted URLs (chrome://) blocked properly
  • Duplicate note dialog works

🎯 Next Steps

Immediate (This Session)

  1. Verify screenshot selection UI exists and works
  2. Implement screenshot cropping using OffscreenCanvas
  3. Test end-to-end screenshot workflow

Short Term (Next Session)

  1. Fix image processing for full page captures
  2. Add "already visited" detection to popup
  3. Implement "save tabs" feature

Long Term

  1. Add custom note text for links
  2. Extract date metadata
  3. Add interactive toast buttons
  4. Performance optimization
  5. Cross-browser testing (Firefox, Edge)

📚 Documentation

  • BUILD-MIGRATION-SUMMARY.md - Build system details
  • reference/dev_notes/TOAST-NOTIFICATION-IMPLEMENTATION.md - Toast system
  • reference/chrome_extension_docs/ - Chrome API docs
  • reference/Mozilla_Readability_docs/ - Readability docs
  • reference/cure53_DOMPurify_docs/ - DOMPurify docs
  • reference/cheerio_docs/ - Cheerio docs

🐛 Known Issues

  1. Screenshot cropping not applied - Crop rect stored but image not cropped
  2. Images not embedded in full page - Only works for selections
  3. No "already visited" indicator - Backend exists, UI doesn't use it
  4. Screenshot selection UI untested - Need to verify against MV2

💡 Support

Issue: Extension not loading?
Fix: Check chrome://extensions/ errors, rebuild with npm run build

Issue: Buttons not working?
Fix: Open DevTools, check console for errors, verify script paths in HTML

Issue: Missing styles?
Fix: Check dist/shared/theme.css exists after build

Issue: Content script not injecting?
Fix: Check URL isn't restricted (chrome://, about:, file://)

Issue: Can't connect to Trilium?
Fix: Verify URL in settings, check CORS headers, test with curl


🎨 Architecture Notes

Content Processing Pipeline

Raw HTML
  ↓
Phase 1: Readability (article extraction)
  ↓
Phase 2: DOMPurify (security sanitization)
  ↓
Phase 3: Cheerio (final polish)
  ↓
Clean HTML → Trilium

Save Format Options

  • HTML: Human-readable, rich formatting (default)
  • Markdown: AI/LLM-friendly, plain text with structure
  • Both: HTML parent note + Markdown child note

Message Flow

Content Script → Background → Trilium Server
     ↑              ↓
   Toast      Storage/State

🔒 Security

  • DOMPurify sanitization on all HTML
  • CSP compliant (no inline scripts/eval)
  • Restricted URL blocking
  • HTTPS recommended for Trilium connection
  • ⚠️ Auth token stored in chrome.storage.local (encrypted by browser)

Status: 🟢 Ready for Phase 2 Development
Next Task: Screenshot Selection UI Verification & Cropping Implementation

Ready to build! 🚀