diff --git a/.planning/phases/02-vault-core-and-rendering/02-03-PLAN.md b/.planning/phases/02-vault-core-and-rendering/02-03-PLAN.md index 13813d3..a9abe90 100644 --- a/.planning/phases/02-vault-core-and-rendering/02-03-PLAN.md +++ b/.planning/phases/02-vault-core-and-rendering/02-03-PLAN.md @@ -23,7 +23,7 @@ must_haves: - "When index.md is missing, user sees a BBS-style error screen with box-drawing border and helpful message" - "User can scroll content with j/k (one line), arrow keys (one line), PgUp/PgDn (full page)" - "Status bar at the bottom shows filename on the left and keyboard hints on the right in reverse video" - - "Terminal resize reflows the layout without crashing or corrupting display" + - "Terminal resize re-renders content at new width and reflows layout without crashing" - "Quit behavior from Phase 1 (q key, double Ctrl+C) is preserved" artifacts: - path: "src/app.rs" @@ -208,8 +208,13 @@ Helper methods: **IMPORTANT:** The scroll keys (j/k/arrows/PgUp/PgDn) must NOT trigger the quit prompt dismissal. Currently the `_ =>` branch dismisses the prompt. The scroll keys should be handled before the `_` catch-all, and only dismiss the prompt for truly unrelated keys. **Resize handling (NAV-09):** -- In `run_event_loop()`, add `Event::Resize(_, _) => {}` handling — ratatui handles the buffer resize automatically for `Viewport::Fullscreen`; we just need to ensure the event is consumed so it doesn't fall through -- `max_scroll()` recomputes on every draw based on `last_content_height`, so resize is handled naturally +- App needs to store the raw markdown content so it can re-render on resize. Add a `raw_content: Option` field to App (populated when document is loaded). +- In `run_event_loop()`, handle `Event::Resize(w, _h)`: + - If `raw_content` is Some, re-render: `let lines = renderer::render_markdown(&content, w); self.document = DocumentState::Loaded { filename, lines };` + - Clamp `scroll_offset` to new `max_scroll()` after re-render + - ratatui handles buffer resize automatically for `Viewport::Fullscreen` +- This ensures horizontal rules, code block borders, and table widths adapt to the new terminal width +- `max_scroll()` recomputes on every draw based on `last_content_height`, so vertical scroll is handled naturally **Preserve ALL Phase 1 behavior:** - Double Ctrl+C quit mechanism @@ -275,8 +280,8 @@ let initial_doc = match vault::load_document(&app_config.vault_path, "index.md") let mut app_state = app::App::new(is_login_shell, app_config, initial_doc); ``` -**Event loop resize re-rendering consideration:** -The initial render uses terminal width at startup. On resize, the content would ideally re-render. For Phase 2, accept the initial render width — re-rendering on resize can be added later if needed. The content still displays correctly; only horizontal rules and code block borders may not be pixel-perfect after resize. +**Pass raw content to App for resize re-rendering:** +When loading a Loaded document, also pass the raw markdown string to App so it can re-render on resize. Update `App::new()` signature to accept an optional raw content string, or store it alongside the DocumentState. **Remove the `#[allow(dead_code)]` on config field** in app.rs if it's now used (vault_path is accessed). Actually, config is passed at construction but vault loading happens in main.rs, so config may still appear unused inside App. Keep the allow if needed, or add a method to access vault_path for future use.