Conversation
- Add send_chat_action() method to TelegramNotifier to send typing action - Display 'typing...' in Telegram chat while generating AI summary - Apply typing status in /ai command handler - Apply typing status in hybrid mode AI summary callback The typing status provides visual feedback to users that the bot is processing their request, improving user experience when waiting for LLM responses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When user clicks 'AI Summary' button in hybrid mode, delete the original message containing the button after generating and sending the summary. This keeps the chat cleaner and removes the now-redundant message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Hybrid mode now shows: - Summary button (always displayed) - Translate button (only when source_language != target_language) Changes: - Enhanced cache to store source_language for each email uid - Modified _send_hybrid to accept language parameters - Updated keyboard generation to conditionally show Translate button - Added _cb_translate callback handler for translation button - Pass user's language setting from manager to notifier When user clicks Translate button: - Show typing status - Generate translation via AI - Display translation as reply - Delete original button message Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Agent mode now follows sequence: 1. Send original email (RAW format) 2. Auto-send Summary as separate message 3. Auto-send Translation (only if source_language != target_language) Changes: - Modified send_with_mode Agent branch to send original only - Added _send_agent_summary() method for auto-summary messages - Added _send_agent_translation() method for auto-translation messages - Updated manager.py to trigger summary and translation in Agent mode - Conditional translation based on language detection This replaces the old _send_agent_card behavior with a sequence of individual messages for better clarity and control. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When user clicks AI Summary or Translate button: - Remove inline keyboard (buttons) using editMessageReplyMarkup - Keep the original message text intact - Cleaner UX that preserves message context Changes: - Added remove_message_keyboard() method to TelegramNotifier - Updated _cb_summary() to use remove_message_keyboard() instead of delete_message() - Updated _cb_translate() to use remove_message_keyboard() instead of delete_message() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously, AI analysis was only run in Agent mode, so Hybrid mode never had source_language information to decide whether to show the Translate button. Now both Hybrid and Agent modes run analyze_email() to get: - source_language for detecting translation need - summary and other AI analysis results This fixes the Translate button not appearing in Hybrid mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…control - Hybrid mode: display email preview with dynamic buttons (Summary, Original, Translate) - No AI analysis upfront (zero token cost unless user clicks) - Translate button only shown when source language differs from target - Language detection via heuristic method (no LLM call) - Agent mode: auto-run AI summary with Original/Translate buttons - Upfront token cost but provides immediate summary - Translate button shown conditionally based on source language - Add show original email button in both modes - Displays full email content via cached snapshot - Zero token cost (no AI analysis) - Token cost optimization: - Hybrid users can save 80-90% tokens by not using AI features - Agent users get automatic summaries at cost of upfront token usage - All buttons remain visible (no hiding after interaction) Changes: - core/ai.py: Add detect_language_simple() for heuristic language detection - core/manager.py: Differentiate AI analysis timing (Agent upfront, Hybrid on-demand) - core/notifiers/telegram.py: Dynamic button display based on language detection - core/bot.py: Implement callback handlers for Summary, Original, Translate buttons Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…eature - Updated README.md and README_ZH.md with operation modes explanation - Added comprehensive three-mode descriptions (Raw/Hybrid/Agent) with token cost details - Updated docs/en/configuration.md with mode specifications - Updated docs/zh/configuration.md (Chinese) with mode specifications - Bumped version from 1.0.0 to 1.1.1 in utils/helpers.py - Added callback handler pattern guidance to code-standards SKILL.md Features documented: - Hybrid mode: Zero token cost upfront, on-demand AI via buttons (80-90% savings) - Agent mode: Auto-summary with manual translation/original options - Raw mode: Simple forwarding without AI - Dynamic Translate button (appears only when language differs) - Show Original button for cached email content (no cost) - Language detection using heuristic method for button visibility Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- interface/menu.py: Enhanced _config_wizard() and _system_settings() with step-by-step comments
- Added detailed docstring with Args/Returns documentation
- 4 main steps clearly marked for account management flow
- 5 steps for system configuration (poll interval, retries, log level, proxy)
- Improved inline comments for clarity
- core/bot.py: Improved _handle_callback_query() and _cb_translate() documentation
- Expanded docstring for _handle_callback_query() listing all callback routing prefixes
- Added comprehensive docstring for _cb_translate() explaining cache, AI analysis, and fallback
- Clarified callback type routing (settings, language, mode, summary, original, translation, rules)
- core/manager.py: Enhanced _dispatch_notification() with mode-specific comments
- Added explicit comments explaining RAW, AGENT, and HYBRID mode differences
- Clarified token cost behavior per mode
- Noted non-Telegram notifier behavior
- core/ai.py: Added step-by-step comments to analyze_email() function
- 7 major steps documented: body truncation, prompt building, message formatting,
LLM parameters, socket proxy handling, response extraction, JSON parsing
- Rationale for socket proxy bypass explained
- Markdown fence handling clarity improved
- interface/wizard.py: Detailed step comments in ai_wizard() function
- 5 main configuration phases documented with sub-steps (2a-2d, 3a-3d)
- Clear labels for provider selection, API key, model, base URL, mode, language
- Improved understanding of multi-step configuration workflow
All modifications follow code-standards:
- Comments in English only
- PEP 257 docstring compliance
- No functional code changes
- Non-trivial logic adequately explained
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- core/bot.py: Added detailed docstring to TelegramBotHandler.__init__ - Explains initialization of thread-safe state (mode, language, AI settings) - Documents caching strategy for hybrid callback mode - Clarifies parameters and initialization sequence - core/manager.py: Added comprehensive docstring to ServiceManager.__init__ - Describes setup of IMAP fetchers and notification adapters - Explains callback mechanism and state management - Documents optional callbacks for status/email events Improves code maintainability for developers initializing these core components. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Summary
This PR introduces significant improvements to MailBot's email processing capabilities, particularly focusing on the Hybrid and Agent modes, alongside
comprehensive documentation and code quality enhancements.
🎯 Key Changes
Features & Optimization:
Documentation & Code Quality:
Modified Files:
💡 Benefits
✅ Testing