# `message read` Behavior Notes ## TUI vs Subprocess — Context-Dependent **Skill states** that `message read` hangs because it uses an interactive TUI. However, in practice (June 2026, cron job context): ```bash # This DID work and returned body content: himalaya message read 49830 --folder INBOX # Output: ~3000 chars of decoded email body # This also worked: himalaya message read 49826 --folder INBOX # Output: ~1100 chars ``` **When `message read` works from subprocess:** - Terminal-like environment (not truly headless — `TERM`/`STY`/`TMUX` may be set) - Email bodies are small-to-medium (< 10KB) - No special characters that trigger interactive prompts **When `message read` will likely fail:** - True headless environment with no TTY allocation - Large emails (> 20KB) that trigger pagination - Emails with HTML attachments that trigger rendering prompts **Safe default:** If `message read` works, use it. If it returns nothing or hangs, fall back to `message export --full` (see himalaya skill). ## `message export --full` as Fallback When `message read` fails: ```python result = subprocess.run( ["himalaya", "message", "export", msg_id, "--full"], capture_output=True, text=True, encoding="latin-1", timeout=30 ) ``` Output is raw MIME — parse headers by splitting on `\n\n`, then decode MIME-encoded headers with `email.header.decode_header()`. ## Email Classification Patterns (Order vs Invoice) | Signal | Likely Type | |--------|-------------| | Subject: "Bestellung erfolgreich", "Bestellung wurde bestätigt", "Your order is being processed" | Bestellbestätigung | | Subject: "Deine Bestellung wird bald eintreffen", "Order coming soon", "Wir packen Deine Bestellung" | Bestellbenachrichtigung (delivery, not invoice) | | Contains Bestellnummer/Order number + Artikel/Items + Preis but NO Rechnungsnummer/Gesamtbetrag/Steuern | Bestellbestätigung → `Bestellungen_jjjj_mm` | | Contains Rechnungsnummer, Gesamtbetrag, Steuern, Fälligkeitsdatum | Rechnung → `Rechnungen_jjjj_mm` | | Subject: "20 % Rabatt", "Sonderangebot", "Aktion" with discount code in body | Marketing/Newsletter → ignore | | Subject: "Sendung kommt heute", "Live verfolgen" with DHL/Paketdienst | Versandtracking → ignore | | Subject: "Bestellung hat einen lokalen Boost erhalten" with product recommendations | Marketing → ignore | | Subject: "Ihre Sendung kommt heute" with DHL/Paketdienst | Versandtracking → ignore | ## `folder create` vs `message move` for Nested Folders In practice (June 2026 cron session): - `himalaya folder create "Rechnungen_2026_06"` returned exit code 1 with empty stderr — appeared to silently fail or succeed - `himalaya folder create "Rechnungen_2026_06/Bestellungen_2026_06"` same behavior - `himalaya folder list` showed the folders existed after `message move` — suggesting `message move` auto-created them - Safe pattern: always use `message move "Parent/Child" ` for nested paths, and check `folder list` to confirm ## `imap_codec` Warnings During `message move`, `WARN imap_codec::response: Rectified missing text to "..."` may appear between the command and the success message. These are harmless IMAP protocol quirks. The actual output ends with `Message(s) successfully moved from INBOX to FolderName!`.