diff --git a/src/main.rs b/src/main.rs index 7dba136..189fb96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,6 +77,24 @@ fn main() { } }; + // 3c. Initialize filesystem watcher for live content refresh. + // Watch the parent directory of index.md (or vault root if index.md is at root). + // Watcher must be created before App::new() so it can be passed in. + let file_watcher = { + let watch_dir = app_config.vault_path.join("index.md") + .parent() + .map(|p| p.to_path_buf()) + .unwrap_or_else(|| app_config.vault_path.clone()); + match app::FileWatcher::new(&watch_dir) { + Ok(w) => Some(w), + Err(e) => { + // Non-fatal: live reload won't work but app is still usable + eprintln!("Warning: filesystem watcher unavailable: {}", e); + None + } + } + }; + // ── TERMINAL PHASE ──────────────────────────────────────────────────────── // Install safety envelope BEFORE terminal init so panics during init are caught. @@ -115,6 +133,7 @@ fn main() { raw_content, initial_link_records, "index.md".to_string(), + file_watcher, ); let shutdown_reason = app_state.run_event_loop(&mut term, &signal_flags);