Skip to content

✨ feat: add batch processing, auto-sort, custom prompt, and debug mode#7

Open
rfiacne wants to merge 82 commits into
Nigel1992:mainfrom
rfiacne:main
Open

✨ feat: add batch processing, auto-sort, custom prompt, and debug mode#7
rfiacne wants to merge 82 commits into
Nigel1992:mainfrom
rfiacne:main

Conversation

@rfiacne
Copy link
Copy Markdown

@rfiacne rfiacne commented Apr 22, 2026

Summary

This PR adds several features to AutoSort+ Thunderbird extension for improved email sorting workflow (and it is all ai generated, if you didn't notice):

🚀 New Features

1. Batch Processing with Controls

  • Process multiple selected emails with progress tracking
  • Progress bar and status panel showing sorted/skipped/failed counts

2. Batch Chunk Processing

  • Configurable chunk size (1-20 emails per batch)
  • Process N emails, await all AI responses, then continue
  • Prevents overwhelming AI endpoints with too many simultaneous requests

3. Auto-Sort New Emails

  • Automatic sorting of incoming Inbox emails when they arrive
  • Single toggle control in General Settings
  • Works for all AI providers (Gemini, OpenAI, Ollama, etc.)

4. Custom Prompt Feature

  • Full prompt customization via text area in Options page
  • Two placeholders: {labels} for folder list, {email} for email content
  • Reset to Default button to restore hardcoded prompt
  • Graceful fallback to the original default prompt when placeholders missing

5. OpenAI-Compatible Provider

  • Support for custom endpoints (LM Studio, LocalAI, vLLM, Together AI, etc.)
  • Model dropdown populated from /v1/models endpoint
  • Optional API key for cloud providers
  • Direct fetch for local endpoints, tab injection for localhost

6. Debug Mode

  • Collapsible console groups for API request/response logging
  • Toggle in General Settings to enable/disable
  • Works for all providers (Gemini, OpenAI, Ollama, OpenAI-compatible)

🐛 Bug Fixes

  • Fixed async convertToPlainText not being awaited, causing [object Promise] in AI prompts

📁 Files Changed

  • background.js - Core processing logic, AI provider calls, event listeners
  • options.html - UI for all new settings and controls
  • options.js - Load/save logic for all settings
  • styles.css - Styling for batch progress panel and custom prompt textarea
  • manifest.json - Permissions cleanup

- Fix manual label menu to properly handle selected messages
- Use await with browser.tabs.sendMessage to get response
- Get full message objects from mailTabs.getSelectedMessages
- Process all selected messages instead of just getting response
- Fixed manual label menu to process all selected emails (not just 2)
- Added example email folder categories with collapsible spoiler
- Improved error handling for batch operations
- Better message routing for manual label application
- When a category folder is not found (null), skip to the next category
- Prevents early exit if a matching category prefix exists but folder not found
- Better fallback handling for direct folder match
- Multi-provider AI support (Gemini, OpenAI, Anthropic, Groq, Mistral)
- Fixed batch email processing (all selected emails now processed)
- Added example email folder categories with spoiler
- Skip null categories and try next one
- IMAP folder discovery with recursive traversal
- Professional UI with provider info cards
- Move history tracking (last 100 entries)
- All syntax errors fixed
- Create folder on the fly if a configured custom label folder is missing
- Skip auto-creation for imported/structured labels (contain / or \)
- Uses first account folder as parent; logs failures but continues
- Added prominent warning box in settings UI
- Updated README with detailed rate limit estimates per provider
- Updated release notes with API quota guidance
- Free tiers: 5-20 emails before hitting limits
- Groq and Gemini recommended for best free tier limits
- Paid plans recommended for daily email processing
- Free tier: 5 requests per minute (12 second delay between requests)
- Free tier: 20 requests per day limit
- Added 'Gemini paid plan' checkbox in settings to bypass limits
- Shows countdown timer during rate limiting
- Displays hours until daily reset when limit reached
- Tracks requests in browser storage
- Only applies to Gemini provider
- Paid plan users can disable rate limiting
- Shows current daily usage (X/20 requests)
- Displays last request time
- Shows time until daily limit resets
- Status indicator (Ready/Nearly Full/Limit Reached)
- Warning when approaching or at limit
- Alerts when to switch to new API key
- Reset counter button for new API keys
- Refresh usage button
- Auto-updates when switching providers
…hanced organization

- Added Privacy & Security section with feature table
- Converted Troubleshooting to collapsible details sections
- Added System Requirements table
- Enhanced Changelog with collapsible feature categories
- Created Roadmap & TODO priority table
- Added professional Support & Community section
- Expanded Contributing guidelines
- Included full MIT License text
- Enhanced Credits & Acknowledgments
- Added Star History chart
- Professional footer with navigation and badges
…eature showcase

index.md:
- Added centered header with badges and navigation
- Multi-provider comparison table
- Complete v1.2.0 feature showcase with gradient styling
- AI provider comparison with free tier details
- Quick start guide with step-by-step instructions
- Gemini rate limit management guides
- Privacy & security table
- Advanced configuration section
- System architecture diagram
- Enhanced troubleshooting with solutions
- Support & community section with table
- Contributing guidelines with dev setup
- Full credits and acknowledgments
- Star history chart integration

_config.yml:
- Enhanced SEO with jekyll-seo-tag
- Added sitemap plugin
- Improved metadata (title, description, author)
- Repository and URL configuration
- Social media integration ready
- Kramdown with syntax highlighting
- Collections setup for future expansion
- Better build settings and excludes
Nigel1992 and others added 15 commits April 3, 2026 23:18
OpenAI-compatible provider:
- Custom endpoint support with base URL + model selection
- Model dropdown with Fetch Models button
- API key optional for local endpoints (no auth required)
- max_tokens: 8192 for reasoning models (Qwen3 etc)

Debug mode:
- Toggle in General Settings (Ctrl+Shift+I to view logs)
- Colored console tags: [AutoSort+], [Gemini], [Ollama], [Custom]
- apiRequest/apiResponse collapsible groups
- Cross-context sync via browser.storage.local

Bug fixes:
- Provider switch: hide/show correct subsections
- Save button state updates on all input changes
- Input validation for Ollama and OpenAI-compatible configs
- Extract subject, author, attachments for better AI categorization

- Build folder Map to avoid N+1 recursion in batch processing

- Cache accounts to avoid N+1 fetching

- Parallel auto-sort with provider-based concurrency limit

- Gemini rate limit mutex for atomic operations

- Add shared tab fetch utility module

Bug fixes:

- pct undefined crash in batch progress

- error message lost in catch block

- missing return true for async message handler

- message.folder null pointer risk

- ollamaNumCtx setting ignored

- context menu stale after label changes
@rfiacne rfiacne force-pushed the main branch 2 times, most recently from 81385ab to b8820b8 Compare April 23, 2026 10:34
Add Thunderbird _locales/ based internationalization with en and zh_CN translations. All UI text, provider info, badges, and dynamic status messages are now localized.
@Nigel1992
Copy link
Copy Markdown
Owner

Wow, thanks for the major updates!
I will take a look very soon and merge if I think its suitable.
Sorry for the late response.

@rfiacne
Copy link
Copy Markdown
Author

rfiacne commented Apr 25, 2026

Thank you so much for the kind words! No worries at all about the response time — I really appreciate you taking a look. Please let me know if there’s anything you’d like me to adjust or improve. Looking forward to your feedback!

Wow, thanks for the major updates! I will take a look very soon and merge if I think its suitable. Sorry for the late response.

- Add full English and Simplified Chinese translations (1260+ message keys)
- Fix: autoSortEnabled defaults to true for backward compatibility with
  users upgrading from older versions (storage migration, guard fix,
  checkbox default). Auto-sort was silently disabled after update because
  the new setting key was undefined and treated as disabled.
- Add autoSortEnabled unit test suite (13 cases)
@rfiacne rfiacne force-pushed the main branch 3 times, most recently from 1bca749 to 1bef445 Compare May 12, 2026 03:21
browser.i18n.getMessage() only supports $1/$2 positional syntax, but
messages.json uses {key} format. Add manual {key}→value substitution
in i18n.get() with a placeholder mapping table for all 50 keys.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants