Tenant Unified Inbox
1. Purpose & Context (The âWhyâ)
-
Goal: Manage all replies from all campaigns and email accounts in a single interface.
-
Feature References:
-
User Journey: Daily workflow: Check Inbox â Reply/Archive/Mark Interested â Zero Inbox.
2. UI Patterns & Components (The âHowâ)
-
Core Components:
-
ThreePaneLayout: 1. Folders/Filters, 2. Thread List, 3. Conversation View. -
ThreadList: Virtualized list for performance. -
ConversationView: Chat-like interface for email threads. -
ReplyComposer: Rich text editor with template insertion.
-
-
Analytics Patterns: N/A.
-
Layout: Global Context (Full Height).
3. Route Specifications
| Route | Access | Purpose | State/Data Requirements |
|---|---|---|---|
/dashboard/inbox | Tenant | Inbox Root | Client Component. Fetches initial threads. Subscribes to real-time updates (WebSocket/Polling) for new messages. |
/dashboard/inbox/[threadId] | Tenant | Thread View | Client Component. Loads specific thread. Optimistic updates for âMark Readâ / âArchiveâ. |
Key Interactions
-
Filtering: Filter by âUnreadâ, âInterestedâ, âCampaignâ, âWorkspaceâ.
-
Quick Actions: Keyboard shortcuts for Archive (E), Reply (R), Mark Spam (!).
4. Detailed View Descriptions
/dashboard/inbox - Unified Inbox
User Story: âAs a busy entrepreneur, I want all campaign replies in one inbox with smart categorization, so I can respond quickly without switching between accounts.â
What Youâll Find:
Three-Pane Layout:
-
Left Panel: Folders & Filters (Collapsible)
-
Folders:
-
đ„ All Mail
-
đ„ Unread (badge with count)
-
â Interested
-
đ Archived
-
-
Filters:
-
By Campaign: Dropdown list of active campaigns.
-
By Workspace: For agency users.
-
By Status: âNeeds Replyâ, âAuto-replyâ, âBouncedâ.
-
-
-
Middle Panel: Thread List
-
Each Thread Item Shows:
-
Lead Name (bold if unread).
-
Subject Line (truncated).
-
Snippet: First line of last message.
-
Timestamp: â2 hours agoâ or âOct 15â.
-
Icons: đŹ (has reply), đ (attachment), â (interested).
-
-
Virtualized Scrolling: Smooth performance with 1000+ threads.
-
Select Multiple: Checkbox for bulk actions.
-
-
Right Panel: Conversation View
-
Thread Header:
-
Lead name + email.
-
Related campaign link.
-
Action Buttons: Mark Interested, Archive, Delete, More (âŻ).
-
-
Message Thread (Chat-style):
-
Sent messages (right-aligned, blue).
-
Received messages (left-aligned, gray).
-
Timestamps between messages.
-
-
Reply Composer (Bottom):
-
Rich text editor.
-
âInsert Templateâ Dropdown: Pre-written responses.
-
Attachment Button.
-
Send Button (Ctrl+Enter shortcut).
-
-
User Journey Context: Daily hub for managing prospect interactions. Must be fast and keyboard-friendly.
Related Documentation:
Technical Integration:
-
Real-time Updates:
-
WebSocket Connection: Receives new message events.
-
Fallback Polling: Every 30s if WebSocket fails.
-
-
Optimistic UI: Replies appear immediately, synced to backend asynchronously.
-
Thread Caching: Recently viewed threads cached in IndexedDB for offline access.
/dashboard/inbox/[threadId] - Thread Detail View
User Story: âAs a user who clicked a thread from elsewhere (e.g., email notification), I want to land directly in the thread view, so I can respond immediately.â
What Youâll Find:
-
Same Three-Pane Layout as root inbox.
-
Thread Automatically Selected in middle panel.
-
Right Panel: Shows full conversation for selected thread.
Behavior:
-
If accessed from external link (e.g., email notification), inbox loads with this thread pre-selected.
-
Mark as Read: Automatically triggered when thread opens.
User Journey Context: Deep-link entry point. Common from notification emails.
Related Documentation:
Keyboard Shortcuts (All Inbox Views)
User Story: âAs a power user processing 100+ emails daily, I want keyboard shortcuts, so I can manage my inbox without touching the mouse.â
Shortcuts:
-
j/k: Navigate down/up thread list. -
Enter: Open selected thread. -
r: Reply to thread. -
e: Archive thread. -
!: Mark as spam. -
*+a: Select all threads. -
Esc: Close conversation view (return to list).
Implementation:
-
Keyboard event listeners on inbox component.
-
Visual indicators: Shortcuts shown in tooltips.
Related Documentation:
Filters & Search
User Story: âAs a user with hundreds of threads, I want powerful search and filtering, so I can find specific conversations quickly.â
Search Bar (Top of Middle Panel):
-
Placeholder: âSearch by name, email, or subjectâ.
-
Real-time Search: Updates results as you type.
-
Advanced Filters (Dropdown):
-
Date range: âLast 7 daysâ, âLast 30 daysâ, âCustomâ.
-
Has attachment: Yes/No.
-
Campaign: Select from list.
-
Filter Persistence:
-
Active filters saved in URL query params.
-
âClear Filtersâ Button appears when active.
Related Documentation:
Reply Management
User Story: âAs a salesperson, I want template-based replies with personalization, so I can respond professionally without retyping common messages.â
Reply Composer Features:
-
Template Insertion:
-
Dropdown button: âInsert Templateâ.
-
Shows categorized templates (Follow-up, Meeting Request, etc.).
-
Click to insert, automatically personalizes with lead data.
-
-
Signature:
- Auto-appends user signature (configurable in settings).
-
Tracking:
- âTrack opensâ toggle (default ON).
-
Scheduled Send (Advanced):
-
âSend Laterâ option.
-
Time picker for delayed sending.
-
Validation:
-
Empty Subject Warning: âSubject line is empty. Continue?â
-
No Recipient Error: Cannot send without valid recipient.
Related Documentation:
Real-time Notifications
User Story: âAs a user with inbox open all day, I want non-intrusive notifications for new replies, so I can respond immediately.â
Notification Behavior:
-
New Message Toast (Top-right):
-
Shows sender name + subject.
-
Click to open thread.
-
Auto-dismiss after 5 seconds.
-
-
Browser Notification (if tab inactive):
-
Requires user permission.
-
Shows same info as toast.
-
-
Sound Alert (Optional):
-
Subtle âdingâ sound.
-
Configurable in settings (ON by default).
-
User Preference Controls:
- Toggle notifications in
/dashboard/settings/profile.
Related Documentation:
5. Related API Endpoints
| Route | Related API | Description |
|---|---|---|
/inbox | Inbox API | GET /api/v1/tenant/inbox/threads (List threads). |
/inbox/[threadId] | Inbox API | GET /api/v1/tenant/inbox/threads/{id} (Thread details). |
/inbox/[threadId]/reply | Inbox API | POST /api/v1/tenant/inbox/threads/{id}/reply (Send reply). |
/inbox/ws | Inbox API | WebSocket endpoint for real-time updates. |
6. Data Strategy
-
Fetching Method:
-
Initial Load: Client-side fetch (
useSWRorreact-query) to populate thread list. -
Real-time: WebSocket connection pushes
NEW_MESSAGEandTHREAD_UPDATEDevents.
-
-
Caching:
-
Thread List: Cached in memory (SWR cache).
-
Offline Support:
IndexedDBstores last 50 threads for offline viewing.
-
-
Optimistic Updates:
-
Sending Reply: Message appears in chat immediately with âSendingâŠâ status.
-
Archive/Delete: Thread removed from list immediately.
-
-
State Management:
- Unread Counts: Global context updated via WebSocket events.
7. Edge Cases & Error Handling
-
WebSocket Disconnect: Show âReconnectingâŠâ badge. Fallback to polling.
-
Send Failure: If reply fails, show red âFailed to sendâ icon with âRetryâ button.
-
Thread Not Found: If accessing deleted thread via URL, redirect to Inbox root.
-
Concurrent Reply: If another user replies to same thread, show new message immediately to avoid double-reply.
8. Component Architecture
Page Components
-
InboxLayout(Client)-
Manages split-pane layout (ThreadList ChatWindow). - Handles WebSocket connection context.
-
-
ThreadList(Client)-
Props:
initialThreads: Thread[] -
Features: Virtualized list (react-window), search filter, unread indicators.
-
-
ChatWindow(Client)-
Props:
activeThreadId: string -
Sub-components:
MessageBubble,ReplyComposer,LeadContextSidebar
-
Shared Components
-
ReplyComposer: Rich text input with âInsert Templateâ and âAI Assistâ actions. -
LeadContextSidebar: Reused from Lead Profile Drawer.
9. Implementation Status & MVP Gaps
Current Status
Documentation: Complete route specifications with comprehensive UI patterns and component architecture.
Implementation: Pending architecture spike completion.
Critical Blocker: Stalwart Integration
Problem: The inbox architecture proposes custom tables (inbox_threads, inbox_messages) without investigating how they integrate with Stalwart Mail Serverâs existing PostgreSQL schema.
Required Investigation (Q4 2025 - 3-5 days):
-
Can we extend Stalwartâs schema with custom fields?
-
Should inbox metadata live in OLTP, Content DB, or Stalwartâs database?
-
How does Stalwart store emails and can we add foreign keys?
Impact: This architectural decision blocks all inbox development.
MVP Gaps (Q1 2026 - Post-Spike)
Once the Stalwart investigation is complete, the following features need implementation:
-
Email Threading Algorithm (1-2 weeks)
-
Match replies using RFC 5322 headers (References, In-Reply-To)
-
Fallback to Subject + Contact matching
-
Handle edge cases (forwarded emails, subject changes)
-
-
Star/Favorite Feature (2-3 days)
-
Add star icon to thread list UI
-
Create âStarredâ folder view
-
Implement star/unstar API endpoint
-
-
Folder/View System (3-5 days)
-
Implement All, Starred, Sent, Archived, Trash views
-
Add âArchiveâ and âDeleteâ actions with bulk support
-
Implement soft delete (trash folder, permanent delete after 30 days)
-
-
Attachment Support (1-2 days documentation)
-
Document integration with existing Content DB attachments table
-
Add file upload UI specifications
-
Document file size limits (25 MB per attachment)
-
-
Browser Notifications (1-2 days integration)
-
Integrate with existing Notifications Database
-
Request browser notification permission on first inbox visit
-
Create notification when new reply arrives
-
Total MVP Effort: Unknown until Stalwart spike complete (estimated 2-4 weeks post-spike)
Post-MVP Enhancements (Q2-Q3 2026)
Q2 2026: AI Features
-
Smart Reply Suggestions (Gemini AI) - 1-2 weeks
-
Sentiment Analysis & Tone Detection - 3-5 days
-
Advanced Inbox Analytics - 3-4 weeks
-
Scheduled Sending - 3-5 days
-
Lead Context Sidebar - 2-3 weeks
Q3 2026: International Feature
-
Offline Support (IndexedDB) - 3-5 days
-
Multi-Language Support & Translation - 1-2 weeks
Related Documentation
-
Inbox Management Roadmap - Detailed timeline and roadmap items
-
Unified Inbox Overview - Feature specifications
-
Stalwart Investigation Spike - Internal task reference for architecture investigation
Last Updated: November 26, 2025 Status: Route specifications complete, awaiting Stalwart spike completion Next Review: After Stalwart spike (Q4 2025)