Files
tern-web/docs/webapp-client-spec.md
T
Mateusz PstruchaandClaude Opus 5 1145e31af6 Initial webapp scaffold
Vite + Svelte 5 + TypeScript with no other runtime dependencies, per the
client spec's speed-and-simplicity priority. Wires up the decided palette
with light/dark/system switching, a two-pane desktop shell, and a thin
API client against the sync server.

Deliberately no PWA/service worker, matching the spec's scope cut.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 19:01:07 +02:00

9.4 KiB

Tern — Webapp Client Design Doc

Companion to the server architecture spec and Android client design doc.


1. Philosophy

Fast and simple over feature-complete. The explicit priority order: speed and simplicity first, functionality second. Avoid becoming a "does everything" app — every feature added should justify its cost in complexity and page weight.

Target: desktop, Chrome + Firefox. Unlike the Android client, this isn't a touch/mobile-first design — it's built for a mouse-and-keyboard desktop session in current Chrome or Firefox. That changes several defaults from a typical "mobile-first PWA" doc (see §4).

Practical implications:

  • Prefer a lightweight framework (or none) over a heavy SPA framework with a large runtime. Whatever's chosen, keep the shipped JS bundle small and avoid pulling in a large component library for things that can be a few lines of CSS.
  • No client-side feature should require the server's out-of-scope items (§8 of the server doc) to exist — the UI shouldn't imply functionality the backend doesn't have.
  • MVP surface: inbox list, thread view, compose/reply, tag/folder management, rule management, search. Resist adding more until this is solid.
  • Server-side rendering is probably unnecessary — this is an authenticated, logged-in-only app, not something that needs to be crawlable or SEO-friendly.

2. No PWA — Plain Webapp (for now)

Decided: drop PWA entirely for the initial build. No web app manifest, no service worker, no installability, no offline app-shell caching. Just a regular webapp, opened in a browser tab, kept simple. This is a scope cut in line with §1's "fast and simple over feature-complete" priority — PWA infrastructure (manifest, service worker lifecycle, cache versioning, offline fallback states) is real complexity that isn't needed for a first version. See §8 for bringing it back later.

Practical effect: no offline app-shell, no "Install" affordance in either browser, no Web Push notifications (§3 below covers what replaces this for now).


3. Notifications (WebSocket + polling, no push)

Without a service worker (§2), Web Push isn't available, so notifications work only while the tab is open — which matches dropping PWA for now:

  • WebSocket: the primary path, as already scoped server-side — the server pushes events (new mail, flag change, rule action) to any open tab in real time.
  • Polling fallback: a simple GET /events?since=<cursor> for degraded connections or if a WebSocket connection drops and hasn't reconnected yet.
  • In-tab notifications only (a toast/badge inside the UI, or the Notification API for an OS-level notification while the tab is open — Notification.requestPermission() + new Notification(...) works without a service worker, it just can't fire when the tab/browser is fully closed).
  • The always-on, closed-tab notification experience ("just works" even when not looking at it) stays the Android app's job for now, via UnifiedPush — see the Android design doc. Bringing that same experience to the webapp is what PWA + Web Push (§8) would add back later.

4. Theming

No dynamic/system-extracted color for the webapp — decided against it. Palette is decided (same values as the branding doc — kept here too since it's what the CSS actually consumes):

:root[data-theme="light"] {
  --text: #0c0a10;
  --background: #f4f3f7;
  --primary: #988fa8;
  --secondary: #c3c7d5;
  --accent: #f39a39;
}
:root[data-theme="dark"] {
  --text: #f1eff5;
  --background: #09080c;
  --primary: #605770;
  --secondary: #2a2e3c;
  --accent: #c66c0c;
}
  • Let the user choose Light / Dark / Follow system in-app (stored preference — localStorage is fine given this is a desktop-only, per-browser app; no need to sync it to the account).
  • Use the light-dark() CSS function (Chrome/Edge 123+, Firefox 120+ — safely inside your desktop Chrome+Firefox target) to define both values in one place instead of duplicating rules inside @media (prefers-color-scheme: dark) blocks. Requires color-scheme: light dark; set on :root for it to activate. The data-theme attribute approach above (rather than relying on light-dark() alone) is what lets "Follow system" vs. an explicit user override both work cleanly — set data-theme from the resolved preference, and reference light-dark() and/or these custom properties inside the CSS either way.
  • Set <meta name="theme-color"> with a media attribute for light/dark variants, so the browser UI (address bar/tab color) matches your current theme immediately, before your CSS loads.

4a. Desktop-Specific Design Considerations

Since this isn't a touch/mobile design, several defaults flip compared to a typical PWA:

  • Two-pane layout by default, not single-pane-first: a list + reading pane (Gmail/Outlook-style) is the natural desktop layout and doesn't need to be "unlocked" at a breakpoint the way a mobile-first design would — design for it as the base case.
  • Hover states, not swipe gestures: reveal row actions (archive/tag/delete) on row hover rather than building touch-swipe interactions you don't need. Simpler to build and more discoverable on desktop anyway — fits the "simple" priority.
  • Keyboard shortcuts matter a lot here — arguably more than on mobile. Desktop mail power-users expect Gmail-style single-key navigation (e.g. j/k to move between messages, e to archive, / to focus search, c to compose). This is a cheap, high-value way to make the app feel "fast," which is your stated top priority — worth treating as core UX, not a stretch feature.
  • Right-click context menus are a natural fit for list-row actions (move to folder, apply tag, mark as spam) instead of needing an explicit "..." menu button on every row.
  • No safe-area-inset / gesture-nav handling needed — that's an Android-specific concern from the client design doc and doesn't apply here.
  • Mobile-oriented APIs (Web Share, touch-optimized tap targets) can be skipped entirely rather than "supported but untested" — this app isn't targeting a phone browser.

5. Modern Web Platform APIs (desktop Firefox + Chromium)

Decided: only build on APIs supported in both current desktop Chrome and Firefox. No Chromium-only features, even as an optional/feature-detected extra — keeps the codebase and testing surface simple, and avoids a two-tier experience between browsers.

  • light-dark() CSS function (§4)
  • CSS nesting (native, no preprocessor needed)
  • CSS :has() selector — useful for parent-aware styling (e.g. style a list row differently when it contains an unread indicator) without extra JS
  • Container queries (@container) — useful for component-level layout (e.g. a reading pane that reflows if the user resizes it), less critical than on a responsive mobile design but still handy
  • <dialog> element — native modals (compose window, confirmation dialogs) without a JS modal library
  • popover attribute / Popover API — native lightweight popovers/menus (Chrome 114+, Firefox 125+), good fit for a "simple over heavy" philosophy since it replaces a chunk of what a UI library would otherwise provide — especially useful for right-click context menus (§4a)
  • :focus-visible and :focus-within — keyboard-vs-pointer-aware focus styling, matters more here given the keyboard-shortcut-heavy interaction model (§4a)
  • IndexedDB — for the local cache

For things a Chromium-only API would otherwise cover (e.g. native save-file dialogs, a taskbar unread-count badge, background retry sync), use the plain cross-browser equivalent instead: a standard <a download> link, a favicon/title unread-count update, and an IndexedDB-backed retry queue driven by the online event, respectively.


6. Rendering Untrusted HTML Mail

Same constraint as noted in the server doc, restated here as a client concern:

  • Sandbox rendered HTML email (<iframe sandbox> with a strict CSP, or a strict sanitizer allow-list) — this is a real XSS surface, not optional polish.
  • Block remote image loading by default (tracking-pixel/read-receipt vector) with a per-message or per-sender "load images" action.

8. Future Plans (explicitly deferred, not designed yet)

  • PWA (manifest + service worker + installability + Web Push) — bring back what §2 drops, once the plain webapp is solid. This is what would let the webapp match the Android app's "leave it closed and it still notifies you" behavior. Design note for whenever this happens: keep it additive (the plain webapp keeps working with no manifest present) rather than a rewrite.
  • Desktop app — a native-feeling desktop wrapper (e.g. Tauri, which is lighter-weight than Electron and fits the "fast and simple" philosophy better) once the webapp UI is stable, for people who want a proper installed app with an OS taskbar/dock presence, unread badge, and native notifications without relying on Chrome's PWA install support (relevant given Firefox desktop has none — see the earlier discussion this doc was built on). Wrapping the same webapp UI means this stays low-cost rather than a second UI to maintain.

9. Open Items for Later

  • Exact keyboard shortcut scheme (§4a) — worth nailing down once the core list/thread UI exists, so shortcuts map to real actions rather than being designed in the abstract.
  • Whether an unread-count favicon/title update (§5) is worth adding now or waits for the future desktop app/PWA work, since it's cheap either way.