diff --git a/CLAUDE.md b/CLAUDE.md index 39fc92d..c53c74a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,8 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project Overview -This is a Rust terminal user interface (TUI) application built with Ratatui. -It will evolve to become a tui mail client +**Skim** is a TUI email client built with Rust and Ratatui. It connects to IMAP servers (including Gmail) and displays inbox messages with a split-pane interface: email list on top, message preview on the bottom. ## Build and Run Commands @@ -44,27 +43,34 @@ docker exec -it mailserver setup email add test@example.com password123 docker-compose down ``` -Connection details: localhost:143 (IMAP) or localhost:993 (IMAPS). See `MAIL_SERVER_SETUP.md` for detailed usage. +Connection details: localhost:143 (IMAP) or localhost:993 (IMAPS). See `MAIL_SERVER_SETUP.md` for detailed usage including Gmail configuration. ## Architecture -This is a single-file application (`src/main.rs`) following the standard terminal application lifecycle: +- **`src/main.rs`** — Terminal setup/teardown, delegates to `lib::main` +- **`src/lib.rs`** — Main event loop, UI rendering, worker thread coordination +- **`src/inbox.rs`** — IMAP inbox operations (refresh, fetch older, fetch body) +- **`src/connect.rs`** — IMAP connection handling (plain TCP and TLS) +- **`src/config.rs`** — Configuration loading from `config.toml` -1. **Terminal Setup**: Enable raw mode and enter alternate screen -2. **Event Loop**: - - Render UI using Ratatui's declarative widget system - - Poll for keyboard events (200ms timeout) - - Exit on 'q' or Escape key -3. **Cleanup**: Disable raw mode, leave alternate screen, restore cursor +### Key patterns + +- IMAP operations run in a **background worker thread** communicating via `mpsc` channels, keeping the UI responsive +- Emails are loaded in **batches of 50**, with lazy loading when scrolling past the end +- **Tab** switches focus between inbox list and preview pane +- Selection is **preserved across refreshes** by matching IMAP sequence numbers ## Key Dependencies -- **ratatui (0.29)**: TUI framework providing widgets, layouts, and rendering -- **crossterm (0.28)**: Cross-platform terminal manipulation (raw mode, events, alternate screen) +- **ratatui (0.30)**: TUI framework providing widgets, layouts, and rendering +- **crossterm (0.29)**: Cross-platform terminal manipulation (raw mode, events, alternate screen) +- **imap (2.4)**: IMAP protocol client +- **native-tls (0.2)**: TLS support for secure IMAP connections (Gmail) +- **chrono (0.4)**: Date parsing and timezone conversion ## Development Notes - Uses Rust edition 2024 -- The application uses a constraint-based layout system to center content - Terminal is set to raw mode to capture individual key presses - The alternate screen prevents terminal history pollution +- `config.toml` contains credentials and is gitignored — see `config.toml.example` for the format