# Patch and Reply

This page covers the high-level patch workflow in the TUI:
detecting patch series,
applying or exporting them,
opening the reply panel,
and sending replies through the preview-confirm-send flow.

## Patch workflow

CRIEW detects patch series from thread subjects such as `[PATCH vN M/N]`.
Inside the TUI:

- `a` applies the current patch series through `b4`
- `d` exports the current patch series
- `u` undoes the most recent successful apply from the current session

Patch handling becomes more useful when a kernel tree is configured in `[kernel]`.

## Reply panel

Open the reply panel with `r` or `e`.
CRIEW fills these editable headers when the panel opens:

- `From`
- `To`
- `Cc`
- `Subject`

CRIEW also injects the thread headers needed for mail threading:

- `In-Reply-To`
- `References`

The body starts from a kernel-style quoted template.

## Send flow

CRIEW uses a fixed send sequence:

1. Open `Send Preview`.
2. Review the rendered headers and body.
3. Confirm the send.
4. Let CRIEW deliver the reply through `git send-email`.

If the draft contains only quoted text and generated scaffolding,
`Send Preview` still opens,
but it shows a warning before the user confirms the send.
Authored reply lines stand out from quoted lines in the preview.

## Source of truth

This page is a summary.
The detailed reply rules live in:
[docs/specs/reply-format-spec.md](https://github.com/ChenMiaoi/CRIEW/blob/develop/docs/specs/reply-format-spec.md)

That spec defines:

- subject normalization to a single `Re: ...`
- `To` and `Cc` inheritance and self-address filtering
- `From` resolution from git mail identity
- quoting format
- `Send Preview -> Confirm -> Send`

## Verify the result

Success means:

- the selected thread resolves to a patch series when expected
- apply or export finishes with a visible result instead of a silent no-op
- the reply panel opens with populated headers
- preview and send do not lose the current draft

## See also

- [Configuration](Configuration.md)
- [Sync and TUI](Sync-and-TUI.md)
