Mail workspace
The standalone mail workspace at /mail provides a mailbox-oriented email desk alongside the mail destination in the dashboard content and communication views. It combines a dedicated sidebar with an inbox list and a message view. It is one of the collaboration workspaces and follows a different message flow from the chat workspace.
Workspace composition
The route-level layout gives mail its own full-height work area. It places the mail sidebar beside the page content, then the page loads the mailbox data and the saved desktop panel arrangement into the mail surface.
References: src/…/layout.tsx• L1-15 src/…/page.tsx• L1-25
The workspace changes shape by screen size. Large screens show the inbox and message view as two resizable panels. Smaller screens show the inbox first and open the selected message in a drawer. The selected message stays the link between these views.
References: src/…/mail.tsx• L21-88
The main mail flow moves from mailbox navigation to inbox triage and then to message reading or reply composition.
flowchart LR
A[Mailbox sidebar] --> B[Inbox]
B --> C[Mail list]
C --> D[Selected message]
D --> E[Message details]
E --> F[Reply composer]
Mailbox navigation
The sidebar gives the user a mailbox context before the user works with a message. It supports account selection and presents entry points for the inbox, priority mail, drafts, sent mail, archive, and trash. Footer items provide help and keyboard shortcut access.
References: src/…/mail-sidebar.tsx• L118-131 src/…/data.tsx• L410-468
The sidebar provides a new-email entry point and changes its account controls when collapsed. In the expanded state, users can switch accounts directly. In the collapsed state, the same choice is available from a menu. The account choice is a local workspace choice, while the navigation labels and counts come from the mail navigation data.
References: src/…/mail-sidebar.tsx• L39-116 src/…/data.tsx• L470-481
Mailbox data
The mailbox data defines the information needed to connect list triage with message reading. A mail item has sender and recipient details, subject, body, received time, folder, read state, pin state, priority state, labels, and optional attachments or thread count.
References: src/…/data.tsx• L18-46
The route passes a fixed set of mail items into the workspace. The inbox surface uses the pin state to split those items into Pinned and Inbox groups. The same item then supplies the sender, subject, preview, time, body, recipients, and attachments shown in the message view.
References: src/…/page.tsx• L5-23 src/…/mail-inbox.tsx• L18-71 src/…/data.tsx• L62-408
Inbox list
The inbox is the workspace's triage surface. It provides the Inbox heading, search and mailbox toolbar controls, then presents grouped mail rows inside a scrollable list. Each row shows sender identity, read state, subject, a short body preview, and a relative or calendar date.
References: src/…/mail-inbox.tsx• L18-73 src/…/mail-list.tsx• L12-113
Each row is the selection point for the workflow. Selecting a row writes its stable mail ID to the shared state and can notify the surrounding inbox surface through an optional selection callback. On small screens, the surrounding workspace also opens the message drawer. On large screens, the same selection changes the message shown in the detail panel.
References: src/…/mail-list.tsx• L18-54 src/…/mail.tsx• L47-85
Message view
The message view turns the selected mail item into a readable message record. It shows the subject, received time, sender, recipients, optional carbon-copy recipients, body, and expandable attachments. When no item is selected, it shows an empty-state message instead.
References: src/…/mail-view.tsx• L43-54 src/…/mail-view.tsx• L163-239 src/…/mail-view.tsx• L262-264
The message header exposes controls for common mail actions such as pinning, archiving, replying, moving to trash, and marking as unread. The lower composer presents a reply field with emoji, attachment, and send affordances. These controls define the intended message workflow, while the route currently focuses on the workspace presentation rather than a server-backed mail operation.
References: src/…/mail-view.tsx• L56-157 src/…/mail-view.tsx• L241-260
Selection state
The useMail hook is the shared selection point for the inbox and message view. Its state holds one selected mail ID or null, and it starts with the first supplied mail item. The list writes the ID when a user selects a row. The message view clears it when the user closes the message.
References: src/…/use-mail.ts• L5-25 src/…/mail-list.tsx• L23-54 src/…/mail-view.tsx• L48-54
Desktop panel sizes are a separate workspace preference. The page reads the saved layout before rendering and uses a default list/detail split when no saved value exists. A desktop resize writes the new two-panel proportions for later visits.
References: src/…/page.tsx• L18-25 src/…/mail.tsx• L67-86 src/…/mail-layout-config.ts• L1-6
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the mail item ID used by
useMailvalid for the data passed from the route so list selection and detail rendering stay aligned. - Keep the Pinned and Inbox group rules consistent with the
isPinnedfield when mailbox data or folder behavior changes. - Keep the desktop panel IDs, saved cookie shape, and default layout proportions consistent when changing the responsive workspace split.
- Keep the mobile drawer close path and the desktop empty state consistent with the shared
selectedvalue. - Keep account choices, navigation labels, and mailbox filtering aligned if account-aware mail data is added.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The selected mail ID is not present in the route data | The message pane shows No email selected even when the list contains other mail | Preserve valid IDs when changing the data set or selection rules |
| A mail item is changed without preserving its ID | The selected row and message detail lose their shared link | Treat the mail ID as the stable identity across list and detail views |
| The saved panel cookie contains invalid JSON or the wrong shape | The mail route can fail while reading the layout or render an unusable desktop split | Keep the cookie as a two-number layout value and validate it when changing persistence |
| Mobile selection changes without opening or closing the drawer | The user can select a message but not reach its detail view or return to the list | Keep list selection and drawer visibility in the same interaction flow |
| Account selection is treated as mailbox filtering without adding that rule to the data flow | The sidebar account and visible messages can describe different mailboxes | Add account-aware filtering at the workspace boundary before relying on the account choice |
Key files
| File | Why to read it |
|---|---|
| src/…/page.tsx | Shows the standalone mail route entry point, its email-client purpose, and the saved layout passed into the workspace. |
| src/…/layout.tsx | Shows the dedicated layout that places the sidebar around the route content. |
| src/…/mail.tsx | Explains the desktop split, mobile drawer, and relationship between inbox and message view. |
| src/…/mail-sidebar.tsx | Explains account controls, mailbox navigation, and the new-email entry point. |
| src/…/mail-inbox.tsx | Explains inbox grouping and the list-level controls. |
| src/…/mail-list.tsx | Explains row presentation, date display, and shared mail selection. |
| src/…/mail-view.tsx | Explains message details, attachments, actions, and reply composition. |
| src/…/use-mail.ts | Defines the selected-mail state shared across the workflow. |
| src/…/data.tsx | Defines the mail item, navigation, account, and sample mailbox data used by the route. |
| src/…/mail-layout-config.ts | Defines the desktop panel persistence contract. |