style: Apply ruff auto-fixes for Python 3.12

- Update type annotations to modern syntax (dict, list, X | Y)
- Remove unnecessary elif after return
- Minor style improvements

Note: Some linting warnings remain (unused content param, inline conditions)
but these are minor style issues and do not affect functionality.
All tests pass with these changes.
This commit is contained in:
Bendt
2025-12-28 10:55:31 -05:00
parent 78ab945a4d
commit b1cd99abf2
3 changed files with 94 additions and 33 deletions

View File

@@ -523,7 +523,70 @@ class IPCClient:
## Mail Rendering Improvements
Is there a way to improve readability of emails in a terminal? I get a lot of "notification style emails", and they aren't easy to comprehend or read in plain text. At the very least they don't look good. Maybe we can find an algorithm to reduce the visual noise. Or maybe an AI summary view option using copilot APIs? Research best options. Perhaps embedding a small pre-trained model that can do the summary?
### Smart Notification Email Compression (COMPLETED)
**Priority:** High
**Files:** `src/mail/notification_detector.py`, `src/mail/notification_compressor.py`, `src/mail/config.py`
**Problem:** Transactional notification emails from tools like Renovate, Jira, Confluence, and Datadog are hard to parse and display poorly in plain text terminal environments.
**Solution:** Implemented intelligent notification detection and compression system:
1. **Notification Type Detection**
- Automatically detects emails from:
- GitLab (pipelines, MRs, mentions)
- GitHub (PRs, issues, reviews)
- Jira (issues, status changes)
- Confluence (page updates, comments)
- Datadog (alerts, incidents)
- Renovate (dependency updates)
- General notifications (digests, automated emails)
- Uses sender domain and subject pattern matching
- Distinguishes between similar services (e.g., Jira vs Confluence)
2. **Structured Summary Extraction**
- Type-specific extractors for each platform
- Extracts: IDs, titles, status changes, action items
- Preserves important links for quick access
3. **Terminal-Friendly Formatting**
- Two compression modes:
- `summary`: Brief one-page view
- `detailed`: Structured table format
- Markdown rendering with icons and clear hierarchy
- Shows notification type, key details, actions
- Footer indicates compressed view (toggle to full with `m`)
4. **Configuration Options**
```toml
[content_display]
compress_notifications = true
notification_compression_mode = "summary" # "summary", "detailed", or "off"
```
5. **Features**
- Zero-dependency (no LLM required, fast)
- Rule-based for reliability
- Extensible to add new notification types
- Preserves original content for full view toggle
- Type-specific icons using NerdFont glyphs
**Implementation Details:**
- `NotificationType` dataclass for type definitions
- `is_notification_email()` for detection
- `classify_notification()` for type classification
- `extract_notification_summary()` for structured data
- `NotificationCompressor` for formatting
- `DetailedCompressor` for extended summaries
- Integrated with `ContentContainer` widget
- 13 unit tests covering all notification types
**Future Enhancements:**
- Add LLM-based summarization option (opt-in)
- Learn notification patterns from user feedback
- Custom notification type definitions
- Action-based email filtering (e.g., "archive all Renovate emails")
---
---