# tern-web Desktop webapp client for [Tern](../) — see [`docs/webapp-client-spec.md`](docs/webapp-client-spec.md) and [`docs/branding-spec.md`](docs/branding-spec.md). **Status: mail client with organisation and spam handling** (build order phases 3–6). What's here: - Vite + Svelte 5 + TypeScript, no other runtime dependencies, per the spec's "fast and simple" priority (§1) and browser-API-only approach (§5). - The decided color palette wired up as CSS custom properties with `data-theme` light/dark/system switching (§4). - Two-pane desktop layout as the base case, not a breakpoint-unlocked extra (§4a): folders / thread list / reading pane. - **Thread-grouped list**, one row per conversation, with unread weighting, message counts and attachment markers. - **Thread view** with older messages collapsed and the newest expanded. - **Sandboxed HTML mail rendering with remote images blocked by default** (§6) — see below. - **Compose, reply and reply-all** in a native ``, with drafts. Replying to your own sent message addresses the people you wrote to, not yourself. `Ctrl+Enter` sends. - **Outbox** view for drafts, queued and failed messages, showing retry timing and the last error, with Retry/Delete for failures. - Opening a conversation marks it read. - **Views, folders and tags** in the sidebar (Inbox, All mail, Sent, Outbox, Junk, Trash, your folders, your tags), with tag chips on list rows. - **Conversation lists load older pages as you scroll** (or press `j` past the end), with a *Load older* button as a keyboard-reachable fallback. - **Spam** — *Report spam* / *Not spam* (`!`), each message's spam score shown as a badge, and an **Add spam filter** preset in Rules. - **Conversation actions** — archive, delete/restore, mark read/unread, move, tag — from a toolbar, a right-click context menu (native Popover API, §5), or the keyboard. Keyboard actions apply to the row under the cursor when nothing is open, so mail can be triaged straight from the list. - **Rules editor** — conditions and actions edited as the structured JSON they're stored as, so anything the API accepts the editor can show. Each rule can stop later rules when it matches, and **Run now** applies it to existing mail. Server validation errors (e.g. a bad regex) appear inline without losing the form. - **Trash** shows when each conversation will be permanently deleted. - **Keyboard shortcuts** (§4a): `j`/`k`, `Enter`/`o`, `u`/`Esc`, `g`/`G`, `e` archive, `#` delete/restore, `!` spam/not spam, `Shift+I`/`Shift+U` read/unread, `v`/`l` move/tag, `c`, `r`/`a`, `Shift+R`, `?`. - Polls `/events` while the tab is open, since WebSocket push is phase 7. - No PWA, no service worker, no offline cache — matches §2's explicit scope cut. ## How untrusted mail is rendered Two independent defences in `src/lib/MessageBody.svelte`: 1. **`sandbox` with neither `allow-scripts` nor `allow-same-origin`.** Scripts never run, and the frame gets an opaque origin, so even if something did execute it couldn't reach the app's DOM, cookies or storage. 2. **A CSP `` inside the frame**, which is what actually blocks remote loads. This is done with CSP rather than by rewriting `` because rewriting only catches what you remember to look for — it misses `srcset`, ``, CSS `background-image` and `@font-face`. `img-src` covers every image load however it was requested. Remote images stay blocked until the reader opts in per message, since loading them is what confirms to a sender that the mail was opened. Verified against a message containing a tracking pixel, a remote hero image, a CSS background image and an inline `