# Working offline

> What keeps working when your Hub is down or the device is offline, what needs the Hub, how changes made offline sync back, and how conflicts are resolved.

Source: https://docs.posternmail.app/apps/offline/

The desktop and mobile apps are complete mail clients on their own. This page lists what works
while your Hub can't be reached, what doesn't, and what happens to your changes when the Hub is
back. It also covers the web app, which depends on the Hub.

Everything here applies to apps in direct mode, which is the default for the desktop and mobile
apps (see [Apps](https://docs.posternmail.app/apps/#direct-mode-and-through-your-hub)). The device needs the Hub once,
for its first sign-in: "The first start on this computer needs your Hub."

## What works without the Hub

| Works on a device in direct mode | Needs the Hub |
|---|---|
| Reading and searching your mail | Signing in a **new** device, and pairing |
| Receiving new mail (the device connects to your providers itself) | The web app |
| All mail actions: archive, delete, move, tag, star, mark as read, spam | Notifications on a phone while its app is closed or paused |
| Sending, including undo send and send later | Connecting or reconnecting a **Google** mailbox (Google's sign-in returns to the Hub) |
| Drafts, templates, signatures, tags, rules and settings: changing them | Your account, devices, the security log, invites and the admin area |
| Snooze, pin, mute and follow-up | Rule steps that send, delete permanently or call out (see [Rules](https://docs.posternmail.app/apps/offline/#rules)) |
| Adding or reconnecting password (IMAP), JMAP and Microsoft mailboxes | Mail on your other devices: they see your changes only after the Hub is back |
| Refreshing the sign-ins of Google and Microsoft mailboxes | |

Screens that need the Hub say so, for example "Connecting Google needs your Hub, which can't be
reached right now" or "The list of your devices is kept on your Hub".

## What you see

**Desktop app.** The sidebar and the top of **Settings** say **Hub offline**, with the number
of changes waiting ("Hub offline · 3 changes waiting"). The tooltip explains that mail keeps
working and that changes sync when the Hub is back. While the waiting changes are being sent,
it says **Syncing…**.

**iOS and Android.** A strip at the top says the Hub can't be reached and that mail still
works and changes sync later. **Settings → About** shows **Your Hub: Can't be reached · 3
changes waiting**, and **Last in step with your Hub**.

**No network at all.** The apps say **You're offline** and show the mail they have. Mail
actions and sends wait in the device's outbox until the network is back.

## Changes made while the Hub is away

When the Hub doesn't answer, the device does not wait for it:

1. It applies your change at once, on the device, so you see it right away.
2. It stores the change in a queue on the device, in the order you made it.
3. It checks for the Hub every 15 seconds, and reconnects as soon as it answers.
4. It sends the queued changes in their original order. The Hub's answer then becomes the
   final state on every device.

If you quit the app, the queue stays on disk and is sent at the next start.

### Conflicts

| Situation | What happens |
|---|---|
| You changed something on two devices | The change that reaches the Hub last wins. Settings are merged per setting, so changing two different settings on two devices keeps both. |
| You edited the same draft on two devices | Both versions are kept: the device's version becomes a new draft titled "(conflict) …" next to the other one. |
| The Hub rejects a queued change (for example, the item was deleted elsewhere) | The change is dropped and the Hub's version comes back. The device shows a notification "A change couldn't be saved: …". |
| The Hub fails with a server error | The change is tried again later. After 5 failed tries it is dropped, so it can't block the changes behind it. |
| The Hub can't be reached | The queue waits, in order, and is sent when the Hub is back. |

Per-message state (snooze, pin, mute, follow-up, screened) is stored per message, keyed by the
message's Message-ID, so the same message has the same state on every device.

## Sending without the Hub

- **Send now** (including the undo window): the device sends the message itself, through your
  provider, and files it in Sent. This needs no Hub, only a connection to your provider. If the
  provider can't be reached, the message stays in the outbox and is tried again later.
- **Send later**, Hub reachable: the device hands the message to the Hub, which sends it on
  time even when every device is off.
- **Send later**, Hub unreachable: the device keeps the message. The outbox shows "Sends from
  this device · Will be handed to your Hub when it's reachable". When the Hub is back before
  the send time, the device hands it over. If the send time comes while the Hub is still away
  and the app is running, the device sends it itself.

Only one side owns a scheduled message at a time, and both skip a message whose Message-ID is
already in Sent, so it is never sent twice.

## Notifications, snoozes and rules

The Hub normally does these for all devices. While it is unreachable, a running app takes over
part of the work:

| Job | While the Hub is away |
|---|---|
| New-mail notifications | The app shows its own notification for new inbox mail. When the Hub is reachable, only the Hub notifies, so you never get two. |
| Snooze and follow-up reminders | The app brings snoozed mail back and shows follow-up reminders itself. It checks every 15 seconds. |
| Rules | See below. |

This happens only while the app runs. A phone app paused by iOS or Android, or a closed desktop
app, does none of it.

### Rules

The Hub runs your [rules](https://docs.posternmail.app/rules/). While the Hub has been unreachable for more than 2
minutes, a running device runs them itself for new mail that arrives, using the copy of your
rules it got from the Hub. It runs only steps that are safe to repeat: moving, archiving,
tagging, marking and similar. It skips every step that sends, deletes for good or calls out:
redirect, forward, reply, capture, copy, webhook, message notifications and permanent delete.
Those run only on the Hub.

Rules run on a device are not recorded in **Rule activity**.

## When the Hub is back

- Queued changes go to the Hub in order (**Syncing…**).
- Scheduled sends kept by the device are handed over.
- Changes from your other devices arrive.
- Notifications and rules go back to the Hub.

You don't need to do anything. If the desktop app shows the Hub as offline for a long time,
check that the Hub runs and that the computer can reach it (VPN, Tailscale). See
[Troubleshooting](https://docs.posternmail.app/troubleshooting/).

## Mailbox sign-ins while offline

The device keeps its own encrypted copy of your mailbox sign-ins and refreshes Google and
Microsoft access tokens by itself. If you reconnect a password, JMAP or Microsoft mailbox while
the Hub is away (a new app password, for example), the device checks the new sign-in with the
provider, uses it at once, and passes it to the Hub when it is back. The Hub keeps the newest
sign-in and hands it to your other devices.

## The web app when the Hub is down

The web app gets everything from the Hub, so it can do much less without it:

- It starts from the browser's cache when the page is installed or was opened before (HTTPS
  only).
- It shows the conversations and messages it already loaded in this browser. Others say
  "You're offline and nothing from this list is saved on this device yet."
- Mail actions such as archive or mark as read are queued and sent when the Hub is back. A
  strip says **Can't reach your Hub. Changes are sent when it's back.**
- New mail, search across all mail and other Hub requests fail until the Hub answers.
- If nothing is saved in the browser yet, the page says **Can't reach your Hub.**, counts down
  to the next try and offers **Try again now**.

## Apps through your Hub when the Hub is down

**Desktop app with Don't keep mail on this computer:** the window shows an offline page and
retries after 5, 10 and 20 seconds, then every 30 seconds. See
[Desktop app](https://docs.posternmail.app/apps/desktop/#starting-restarting-and-being-offline).

**iOS and Android without the engine:** the app shows the mail it saved on the phone ("Showing
saved mail. Changes are sent when it's back.") and queues your changes.
