# Sync and TUI

This page covers the common sync commands,
the main TUI navigation,
and the background sync behavior that runs while the TUI stays open.

## Prerequisites

- Install CRIEW and verify the environment with `criew doctor`.
- Configure `[imap]` only if you want real IMAP `INBOX` sync.
- Configure a kernel tree if you want code browsing and local patch review context.

## Workflow

### Check the environment

```bash
criew doctor
```

### Sync a lore mailbox

```bash
criew sync --mailbox io-uring
```

### Sync a real IMAP inbox

```bash
criew sync --mailbox INBOX
```

### Use local `.eml` fixtures

```bash
criew sync --mailbox test --fixture-dir ./fixtures
```

### Start the TUI

```bash
criew tui
```

## TUI actions

For the full key list,
including modal editors,
Send Preview,
and the inline code editor,
see [Keybindings](Keybindings.md).

- `:` opens the command palette.
- The header shows the active keymap scheme:
  `default`,
  `vim`,
  or `custom`.
- A numeric prefix repeats vertical movement:
  `count+i/k` for `default`,
  `count+j/k` for `vim`.
  For `custom`,
  the repeated movement keys follow the bindings shown by `:keymap`.
- `y` and `n` enable or disable the selected subscription.
- `Enter` opens the selected mailbox or thread
  and moves focus to threads or preview.
- `[` and `]` expand the focused mail pane left or right.
- `{` and `}` shrink the focused mail pane
  and persist the widths in `ui-state.toml`.
- `-` and `=` switch to the previous or next mail while preview stays focused.
- `Tab` switches between the mail page and the code browser.
- With `ui.keymap = "vim"`,
  `gg` jumps to the first line in the active pane,
  `G` jumps to the last line,
  and `qq` exits quickly.
- With `ui.keymap = "custom"`,
  the active main-page bindings come from `ui.keymap_base`
  plus any overrides from `[ui.custom_keymap]`.
  Use `:keymap` to inspect or edit them from inside the TUI.

## Command palette

Common commands are:

- `sync`
- `sync <mailbox>`
- `config`
- `keymap`
- `vim`
- `restart`
- `quit`
- `!<shell command>`

## Background sync

When IMAP is configured,
`My Inbox` joins startup sync
and continues periodic background sync while the TUI remains open.

Enabled mailing-list subscriptions also continue periodic background sync while the TUI remains open,
so Linux lore and QEMU archive mailboxes keep pulling new mail.

## Verify the result

Success means:

- the requested mailbox sync completes without transport errors
- thread lists populate after sync
- the TUI can open mailboxes,
  threads,
  and preview panes without falling back to empty-state errors

## See also

- [Configuration](Configuration.md)
- [Keybindings](Keybindings.md)
- [Patch and Reply](Patch-and-Reply.md)
