From c9aa50f93253ee2b0f0843edc1da54fdfd78d412 Mon Sep 17 00:00:00 2001 From: dailz Date: Thu, 9 Jul 2026 13:58:38 +0800 Subject: [PATCH] docs: refresh AGENTS.md for app/ module split and updated test counts Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- AGENTS.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 9e09175..02c0618 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -76,7 +76,15 @@ All ten modules are declared `pub` in `lib.rs` and re-exported as `log_viewer_co ## TUI Architecture - **`main.rs`** — clap CLI (`files: Vec`), `TerminalGuard` RAII for raw mode + alternate screen. **CRITICAL**: `Drop` does not run on `std::process::exit` or `panic = "abort"` — never call `process::exit` inside the guarded scope; return `Err` and use `?` instead. Event loop: poll indexer → poll watcher → draw → poll keys, 100ms timeout. -- **`app.rs`** — `App` struct (~4000 lines including ~135 inline tests, test mod starts at `#[cfg(test)] mod tests`). `AppLoadingState: Empty | Loading { reader, estimated_lines, progress_percent } | Ready { reader } | Error(String)`. `AppMode: Normal | Settings`. Viewport cache for scroll. All key handling. +- **`app/`** — module directory (split from the former monolithic `app.rs`). `mod.rs` (~3000 lines, inline `tests` mod at `#[cfg(test)] mod tests`) holds the `App` struct, `AppLoadingState: Empty | Loading { reader, estimated_lines, progress_percent } | Ready { reader } | Error(String)`, `AppMode: Normal | Settings`, `ViewportRenderRow`, and the main impl blocks. Per-concern helpers are split into submodules: + - `input.rs` — `handle_key` + Normal-mode key dispatch + - `settings.rs` — Settings-mode key dispatch (←/→ color cycle, j/k level select, Enter/Esc) + - `scroll.rs` — line/half/full-page scroll + VHI-aware sub-offset walk + - `viewport.rs` — viewport computation helpers + - `viewport_cache.rs` — on-demand viewport-sized render cache + - `loading.rs` — loading-state polling/progress helpers + - `watcher.rs` — file-watcher event polling + reload/reindex glue + - `query.rs` — query helpers - **`ui.rs`** — ratatui rendering: title bar, content area, status bar, settings popup - **`color.rs`** — `LogLevel` → ratatui `Color` via `ColorConfig` @@ -88,9 +96,9 @@ j/k scroll, Ctrl+d/u half-page, Ctrl+f/b full-page, G/gg jump end/top, Tab toggl All tests are inline (`#[cfg(test)] mod tests` blocks). No `tests/` directories, no integration tests, no async tests. -- **~450 tests total**: core 251, tui 136, bench 63, gui 0 +- **~470 tests total**: core 262, tui 142, bench 63, gui 0 - Temp-file helpers vary per module — check the local `tests` mod before assuming an API: - - `make_temp_file(content) -> PathBuf` — `tui/app.rs`, `tui/ui.rs` + - `make_temp_file(content) -> PathBuf` — `tui/app/mod.rs`, `tui/ui.rs` - `make_test_file(lines) -> NamedTempFile` — `core/io/index_cache.rs` - `make_file(data) -> NamedTempFile` — `core/io/read_cache.rs` - `struct TempFile { ... }` — `core/io/line_sampler.rs`