# PRD: Dead-Letter Queue Management UI

This PRD defines the stories required to build an administrative interface for managing the dead-letter queue (DLQ) created in GPM-066.

### GPM-067: Create DLQ Management UI Skeleton
**Goal:** Establish the basic UI structure for managing the dead-letter queue within the AIVA admin panel.
**Acceptance Criteria:**
- A new section labeled "Dead-Letter Queue" is accessible from the AIVA admin panel.
- The DLQ section contains a placeholder page with a title and a brief description of its purpose.
- Basic UI framework (e.g., using React, Vue, Angular, or similar) is set up and functional.
**Files:** `admin/src/components/DLQ/DLQManagement.jsx`, `admin/src/routes.js`, `admin/src/styles/dlq.css`
**Spawns:** Implement basic DLQ listing functionality.

### GPM-068: Implement DLQ Listing with Pagination
**Goal:** Display a paginated list of emails currently residing in the dead-letter queue.
**Acceptance Criteria:**
- The DLQ management page displays a table/list of emails from the DLQ.
- Each entry in the list shows relevant information: Timestamp of failure, Recipient Email Address, Subject Line (if available), and a truncated version of the error message.
- Pagination controls are implemented to navigate through the queue, displaying a reasonable number of entries per page (e.g., 20).
- Total number of emails in the DLQ is displayed.
**Files:** `admin/src/components/DLQ/DLQList.jsx`, `api/dlq/get_emails.py`
**Spawns:** Add filtering and searching to the DLQ listing.

### GPM-069: Add DLQ Filtering and Searching
**Goal:** Enable administrators to filter and search the DLQ to quickly find specific failed emails.
**Acceptance Criteria:**
- A filter dropdown is available, allowing filtering by failure date range (e.g., Today, Last Week, Last Month, Custom Range).
- A search bar is available, allowing searching by recipient email address and subject line.
- Filtering and searching are applied server-side for efficient data retrieval.
**Files:** `admin/src/components/DLQ/DLQFilters.jsx`, `api/dlq/get_emails.py` (updated to handle filters/search)
**Spawns:** Implement functionality to view the full details of a failed email.

### GPM-070: Implement DLQ Email Detail View
**Goal:** Allow administrators to view the complete details of a specific email within the DLQ.
**Acceptance Criteria:**
- Clicking on an entry in the DLQ list opens a detail view for that email.
- The detail view displays the full email content (to, from, subject, body – both HTML and text versions), the full error message, and the timestamp of the failure.
- The detail view includes a back button to return to the DLQ list.
**Files:** `admin/src/components/DLQ/DLQDetail.jsx`, `api/dlq/get_email.py`
**Spawns:** Add the ability to retry sending emails from the DLQ.

### GPM-071: Implement DLQ Email Retry Functionality
**Goal:** Allow administrators to retry sending emails directly from the DLQ.
**Acceptance Criteria:**
- The email detail view includes a "Retry Sending" button.
- Clicking the button triggers a retry attempt for the email.
- A success or failure message is displayed after the retry attempt.
- On successful retry, the email is removed from the DLQ.
- On retry failure, the email remains in the DLQ, and the error message is updated (if possible).
**Files:** `api/dlq/retry_email.py`, `admin/src/components/DLQ/DLQDetail.jsx` (updated to include retry logic)
**Spawns:** Add bulk retry and deletion capabilities.

### GPM-072: Implement Bulk Retry and Deletion Functionality
**Goal:** Enable administrators to perform bulk actions (retry and delete) on multiple emails in the DLQ.
**Acceptance Criteria:**
- Checkboxes are added to each entry in the DLQ list.
- "Retry Selected" and "Delete Selected" buttons are added above or below the list.
- Selecting emails and clicking "Retry Selected" attempts to resend all selected emails.
- Selecting emails and clicking "Delete Selected" removes all selected emails from the DLQ.
- Progress indicators or confirmation messages are displayed during bulk operations.
**Files:** `admin/src/components/DLQ/DLQList.jsx` (updated to include checkboxes and bulk action buttons), `api/dlq/bulk_retry_emails.py`, `api/dlq/bulk_delete_emails.py`
**Spawns:** Implement DLQ email content preview.
