# Email App Improvement Specification
## Outlook + Gmail + Lotus Notes Best Features
## Current State Analysis
The Email app (`botui/ui/suite/mail/mail.html`) has:
- ✅ **3-panel layout**: Sidebar, List, Content
- ✅ **Folders**: Inbox, Starred, Sent, Scheduled, Drafts, Tracking, Spam, Trash
- ✅ **Compose modal**: Rich text editor with formatting toolbar
- ✅ **Features**: Templates, Signatures, Rules, Auto-responder, Multi-account
- ✅ **Scheduling**: Send later functionality
- ✅ **Tracking**: Email open tracking
- ✅ **Labels**: Color-coded labels
## 🎯 Best-of-Breed Improvements
### 1. Snooze Emails (Gmail)
**What:** Temporarily hide emails until a specific time
**Implementation:**
```html
```
### 2. Smart Compose (Gmail AI)
**What:** AI-powered sentence completion while typing
**Implementation:**
```javascript
let composeTimeout;
document.getElementById('compose-body').addEventListener('input', async (e) => {
clearTimeout(composeTimeout);
composeTimeout = setTimeout(async () => {
const text = e.target.textContent;
if (text.length < 10) return;
const response = await fetch('/api/email/smart-compose', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ context: text })
});
const { suggestion } = await response.json();
if (suggestion) showSuggestion(suggestion);
}, 500);
});
// Accept with Tab key
document.addEventListener('keydown', (e) => {
if (e.key === 'Tab' && hasSuggestion()) {
e.preventDefault();
acceptSuggestion();
}
});
```
### 3. Nudges (Gmail Reminder)
**What:** Remind to follow up on emails without replies
**Implementation:**
```html
You haven't replied to John Doe in 3 days
```
### 4. Conversation Threading (Outlook)
**What:** Group related emails together
**Implementation:**
```html
```
### 5. Follow-Up Flags (Lotus Notes)
**What:** Flag emails with specific follow-up dates
**Implementation:**
```html
```
### 6. To-Do Integration (Lotus Notes)
**What:** Convert emails to tasks
**Implementation:**
```html
```
### 7. Reading Pane Options (Outlook)
**What:** Toggle between right pane, bottom pane, or no pane
**Implementation:**
```html
```
### 8. Sweep and Clean Up (Outlook)
**What:** Bulk delete/archive emails from specific senders
**Implementation:**
```html
```
### 9. Replication Conflicts (Lotus Notes)
**What:** Show when email was modified in multiple places
**Implementation:**
```html
This email has conflicting versions
Version 1 (Local)
...
Version 2 (Server)
...
```
### 10. Offline Mode (Gmail + Lotus Notes)
**What:** Read and compose emails offline, sync when online
**Implementation:**
```javascript
// Service Worker for offline support
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw-email.js');
}
// Cache emails for offline access
async function cacheEmailsForOffline() {
const cache = await caches.open('email-cache-v1');
const emails = await fetch('/api/email/list?folder=inbox');
const data = await emails.json();
// Cache email list
await cache.put('/api/email/list?folder=inbox', new Response(JSON.stringify(data)));
// Cache individual emails
for (const email of data.emails) {
const response = await fetch(`/api/email/${email.id}`);
await cache.put(`/api/email/${email.id}`, response.clone());
}
}
// Queue actions when offline
const offlineQueue = [];
async function sendEmailOffline(emailData) {
if (navigator.onLine) {
return await fetch('/api/email/send', {
method: 'POST',
body: JSON.stringify(emailData)
});
} else {
offlineQueue.push({ action: 'send', data: emailData });
localStorage.setItem('email_offline_queue', JSON.stringify(offlineQueue));
showNotification('Email queued. Will send when online.');
}
}
// Sync when back online
window.addEventListener('online', async () => {
const queue = JSON.parse(localStorage.getItem('email_offline_queue') || '[]');
for (const item of queue) {
if (item.action === 'send') {
await fetch('/api/email/send', {
method: 'POST',
body: JSON.stringify(item.data)
});
}
}
localStorage.removeItem('email_offline_queue');
showNotification('Offline emails sent!');
});
```
## 🔧 Backend API Requirements
```
# Gmail Features
POST /api/email/snooze - Snooze emails
POST /api/email/smart-compose - Get AI suggestions
GET /api/email/nudges - Get follow-up reminders
# Outlook Features
GET /api/email/thread/:id - Get conversation thread
POST /api/email/sweep - Bulk delete/archive
# Lotus Notes Features
POST /api/email/flag - Flag for follow-up
POST /api/tasks/from-email - Convert email to task
GET /api/email/conflicts - Get replication conflicts
POST /api/email/resolve-conflict - Resolve conflict
# Offline Support
GET /api/email/offline-sync - Sync offline changes
```
## 📊 Database Schema
```sql
-- Snoozed emails
CREATE TABLE email_snooze (
id UUID PRIMARY KEY,
email_id UUID REFERENCES emails(id),
snooze_until TIMESTAMP,
created_at TIMESTAMP
);
-- Follow-up flags
CREATE TABLE email_flags (
id UUID PRIMARY KEY,
email_id UUID REFERENCES emails(id),
follow_up_date DATE,
flag_type VARCHAR(50),
completed BOOLEAN DEFAULT FALSE
);
-- Nudges
CREATE TABLE email_nudges (
id UUID PRIMARY KEY,
email_id UUID REFERENCES emails(id),
last_sent TIMESTAMP,
dismissed BOOLEAN DEFAULT FALSE
);
-- Offline queue
CREATE TABLE email_offline_queue (
id UUID PRIMARY KEY,
user_id UUID NOT NULL,
action VARCHAR(50),
data JSONB,
created_at TIMESTAMP
);
-- Threading
ALTER TABLE emails ADD COLUMN thread_id UUID;
ALTER TABLE emails ADD COLUMN in_reply_to UUID;
```
## ✅ Implementation Priority
### Phase 1: Gmail Features (Week 1)
1. Snooze emails
2. Smart compose
3. Nudges
### Phase 2: Outlook Features (Week 2)
4. Conversation threading
5. Reading pane options
6. Sweep and clean up
### Phase 3: Lotus Notes Features (Week 3)
7. Follow-up flags
8. To-do integration
9. Offline mode
## 🧪 Testing Checklist
- [ ] Snooze email until tomorrow
- [ ] Smart compose suggests text
- [ ] Nudge appears for old emails
- [ ] Thread groups related emails
- [ ] Reading pane switches layouts
- [ ] Sweep deletes all from sender
- [ ] Flag email for follow-up
- [ ] Convert email to task
- [ ] Compose email offline
- [ ] Sync offline emails when online