-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
During PR #2 review, CodeRabbit suggested adding notify-based file watching for the Whisper models directory and settings file. This would enable the app to reactively refresh when external changes occur.
Current State
- ✅ The app already uses
notifycrate for watching markdown files (lib.rs:88-109) - ✅
model_manager.rsowns the paths and I/O logic for settings and models - ❌ No auto-refresh when models are added/deleted externally
- ❌ No auto-refresh when settings change externally
Proposed Implementation
Add two watcher helper functions to whisper/model_manager.rs:
1. Watch Models Directory
pub fn watch_models_dir(
models_dir: &PathBuf,
tx: std::sync::mpsc::Sender<notify::Event>
) -> notify::Result<notify::RecommendedWatcher> {
let mut watcher = notify::recommended_watcher(move |res: Result<Event, notify::Error>| {
if let Ok(event) = res {
let _ = tx.send(event);
}
})?;
watcher.watch(models_dir, RecursiveMode::Recursive)?;
Ok(watcher)
}2. Watch Settings File
pub fn watch_settings_file(
settings_path: &PathBuf,
tx: std::sync::mpsc::Sender<notify::Event>
) -> notify::Result<notify::RecommendedWatcher> {
let mut watcher = notify::recommended_watcher(move |res: Result<Event, notify::Error>| {
if let Ok(event) = res {
let _ = tx.send(event);
}
})?;
watcher.watch(settings_path, RecursiveMode::NonRecursive)?;
Ok(watcher)
}Integration Points
Update lib.rs to:
- Create watchers in
setup()similar to markdown file watching - Store watchers in app state (e.g.,
WhisperWatcherState) - Emit events to frontend:
whisper:models-changed,whisper:settings-changed
Frontend Reactions
When events are received:
- models-changed: Refresh model list UI (
list_models()) - settings-changed: Reload settings, update active model/shortcut
Use Cases
- Model Management: User downloads model via CLI/script → UI auto-updates
- Settings Sync: Settings changed by another app instance → current instance reflects changes
- External Tools: Models managed by external tools → app stays in sync
Optional Enhancements
- Debounce rapid events using
notify-debouncer-mini - Add
#[tauri::command]to manually trigger refresh - Add toast notification when external changes detected
Testing Checklist
- Add model file manually → UI refreshes
- Delete model file → UI updates list
- Edit settings file externally → app reflects changes
- Verify no memory leaks with long-running watchers
- Test on macOS and Linux (different notify backends)
References
- Original PR: feat: add offline voice-to-text with Whisper and UI improvements #2
- CodeRabbit comment: feat: add offline voice-to-text with Whisper and UI improvements #2 (comment)
- Existing watcher implementation:
lib.rs:88-109 notifydocs: https://docs.rs/notify/latest/notify/
Notes
This aligns with the project's coding guidelines to use notify for file watching and improves UX by making the app reactive to external changes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request