Notify on detected config drift#216
Conversation
📋 PR Overview
🔬 Coverage
|
There was a problem hiding this comment.
Pull request overview
Adds native-side drift notifications in the Tauri (Rust) app so that watcher-detected config drift can surface as a macOS notification while keeping the existing git:status-changed frontend event flow intact (ENG-514).
Changes:
- Emit a native drift notification when uncommitted config drift is detected (deduped).
- Emit a native drift notification when an external nix build changes the live store path.
- Introduce
state::drift_notificationsand hook it into the watcher loop.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/native/src-tauri/src/state/watcher.rs | Constructs a WatcherEvent, emits git:status-changed, and triggers native drift notifications. |
| apps/native/src-tauri/src/state/mod.rs | Exposes the new drift_notifications module. |
| apps/native/src-tauri/src/state/drift_notifications.rs | Implements deduping + macOS notification delivery and unit tests for notification selection. |
| let event = WatcherEvent { | ||
| git_status: Some(status.clone()), | ||
| change_map: Some(change_map), | ||
| evolve_state: evolve_state_updated, | ||
| error: None, | ||
| external_build_detected, | ||
| }; | ||
| // fire-and-forget: frontend event delivery; window may not be connected. | ||
| let _ = app_handle.emit( | ||
| "git:status-changed", | ||
| WatcherEvent { | ||
| git_status: Some(status.clone()), | ||
| change_map: Some(change_map), | ||
| evolve_state: evolve_state_updated, | ||
| error: None, | ||
| external_build_detected, | ||
| }, | ||
| ); | ||
| let _ = app_handle.emit("git:status-changed", event.clone()); | ||
| drift_notifications::maybe_notify(&event); |
| #[cfg(target_os = "macos")] | ||
| fn send_native_notification(title: &str, body: &str) -> Result<(), String> { | ||
| use cocoa::base::{id, nil}; | ||
| use cocoa::foundation::{NSAutoreleasePool, NSString}; | ||
| use objc::{class, msg_send, sel, sel_impl}; | ||
|
|
||
| unsafe { | ||
| let pool = NSAutoreleasePool::new(nil); | ||
| let notification: id = msg_send![class!(NSUserNotification), new]; | ||
| let title = NSString::alloc(nil).init_str(title); | ||
| let body = NSString::alloc(nil).init_str(body); | ||
|
|
||
| let _: () = msg_send![notification, setTitle: title]; | ||
| let _: () = msg_send![notification, setInformativeText: body]; | ||
|
|
||
| let center: id = msg_send![ | ||
| class!(NSUserNotificationCenter), | ||
| defaultUserNotificationCenter | ||
| ]; | ||
| let _: () = msg_send![center, deliverNotification: notification]; |
|
Copilot resolve the merge conflicts in this pull request |
Resolved and pushed. The PR now includes the conflict resolution merge from |
Head branch was pushed to by a user without write access
|
Copilot resolve the merge conflicts in this pull request |
Merge activity
|
dd48979 to
b0e662c
Compare
Head branch was pushed to by a user without write access
Resolved and pushed in merge commit |
Co-authored-by: cooper <czxtm@users.noreply.github.com>
Co-authored-by: cooper <czxtm@users.noreply.github.com>
Co-authored-by: cooper <czxtm@users.noreply.github.com>
Co-authored-by: cooper <czxtm@users.noreply.github.com>
Co-authored-by: cooper <czxtm@users.noreply.github.com>
Co-authored-by: cooper <czxtm@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
fea928a to
14a909e
Compare
…ypes The --theirs rebase onto develop left mixed architectures. Restore develop's queue_summarizer (SummarizerState/mpsc worker), watcher (per-slice GitState events), api.ts (drop duplicate devConfigs), and regenerated ipc/types.ts (GitState/ExportResult/ImportResult; drop removed WatcherEvent/SummarizerUpdateEvent). Re-add GitState specta registration. Adapt drift_notifications to take GitStatus directly instead of the removed WatcherEvent.
Summary
Adds a native macOS notification path for watcher-detected drift:
git_state_changedandchange_map_changedTest Plan
rustfmt --edition 2021 --check apps/native/src-tauri/src/state/watcher.rs apps/native/src-tauri/src/state/drift_notifications.rs apps/native/src-tauri/src/storage/credential_store.rs apps/native/src-tauri/src/summarize/queue_summarizer.rsbun -F native buildcargo test --manifest-path apps/native/src-tauri/Cargo.toml drift_notifications, but this runner is missing the systemglib-2.0.pcdependency required byglib-sys.Docs
No docs update needed.