Add iOS flag colours to mail_flag and the read rows #70

Merged
svc-agent-writer merged 1 commit from feat/flag-colours into main 2026-11-01 00:32:00 +00:00

Closes #68. Parent: #51 (Phase 6). Decision: ADR 0004 §1, amended here; ADR 0006 §10.

Changes

  • Write side. mail_flag gains color: red, orange, yellow, green, blue, purple or grey.
    • A colour sets \Flagged and the bits of Apple's 3-bit index in $MailFlagBit0, $MailFlagBit1 and $MailFlagBit2. It clears the other bits.
    • Clearing \Flagged also clears every bit, as iOS Mail does. A plain \Flagged keeps the colour.
    • A colour never changes \Seen. Marking a message read stays an explicit add=["seen"].
    • IMAP: a colour needs a mailbox whose PERMANENTFLAGS keep keywords (\*, or the three bits). Otherwise the action is refused with unsupported.
    • JMAP: the same Email/set patch with ifInState (#57). A keyword is removed in the spelling the server holds, because a server may lowercase it.
  • Undo. The undo of a flag change restores only the flags that its action changed. The inverse records them as changed. A flag the owner changed since then stays as the owner set it. An action applied before this change has no changed and restores both flags, as before.
  • Read side.
    • A row shows !(blue) for a flagged message with a colour other than red. A plain flag stays !, so most rows do not change.
    • mail_search gains a flag_color filter. Keyword case does not matter.
  • Docs. ADR 0004 §1 and §3 are amended. README, SECURITY.md and CLAUDE.md are updated.

Checks

  • make check: 199 passed. Ruff, mypy and pip-audit are clean.
  • make test-integration: 16 passed.
    • GreenMail: set blue, change to green, clear, then undo each step back to the start.
    • Stalwart over JMAP: purple is set, IMAP (which iOS Mail uses) reads \Flagged with bits 0 and 2 and no \Seen, and undo removes it.
    • Stalwart over IMAP: yellow is set.

Not in this PR

  • The live check that iOS Mail shows an agent's colour, on one iCloud account and on Fastmail, waits on the write token (ADR 0004 §9, starbase #271).

🤖 Generated with Claude Code

Closes #68. Parent: #51 (Phase 6). Decision: ADR 0004 §1, amended here; ADR 0006 §10. ## Changes - **Write side.** `mail_flag` gains `color`: red, orange, yellow, green, blue, purple or grey. - A colour sets `\Flagged` and the bits of Apple's 3-bit index in `$MailFlagBit0`, `$MailFlagBit1` and `$MailFlagBit2`. It clears the other bits. - Clearing `\Flagged` also clears every bit, as iOS Mail does. A plain `\Flagged` keeps the colour. - A colour never changes `\Seen`. Marking a message read stays an explicit `add=["seen"]`. - IMAP: a colour needs a mailbox whose PERMANENTFLAGS keep keywords (`\*`, or the three bits). Otherwise the action is refused with `unsupported`. - JMAP: the same `Email/set` patch with `ifInState` (#57). A keyword is removed in the spelling the server holds, because a server may lowercase it. - **Undo.** The undo of a flag change restores only the flags that its action changed. The inverse records them as `changed`. A flag the owner changed since then stays as the owner set it. An action applied before this change has no `changed` and restores both flags, as before. - **Read side.** - A row shows `!(blue)` for a flagged message with a colour other than red. A plain flag stays `!`, so most rows do not change. - `mail_search` gains a `flag_color` filter. Keyword case does not matter. - **Docs.** ADR 0004 §1 and §3 are amended. README, SECURITY.md and CLAUDE.md are updated. ## Checks - `make check`: 199 passed. Ruff, mypy and pip-audit are clean. - `make test-integration`: 16 passed. - GreenMail: set blue, change to green, clear, then undo each step back to the start. - Stalwart over JMAP: purple is set, IMAP (which iOS Mail uses) reads `\Flagged` with bits 0 and 2 and no `\Seen`, and undo removes it. - Stalwart over IMAP: yellow is set. ## Not in this PR - The live check that iOS Mail shows an agent's colour, on one iCloud account and on Fastmail, waits on the write token (ADR 0004 §9, starbase #271). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mail_flag takes a color. A colour sets \Flagged and Apple's three
$MailFlagBit keywords and clears the other bits; clearing \Flagged
clears them all. A colour never changes \Seen. Rows show !(colour) for
a colour other than red, and mail_search filters on flag_color.

An undo of a flag change now restores only the flags the action
changed, recorded as changed in the inverse, so a flag the owner set
since stays. ADR 0004 is amended for the colour keywords.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.