-
Notifications
You must be signed in to change notification settings - Fork 415
Different way of notif #1408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Different way of notif #1408
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughReplaces the old notification2 crate with a split interface/macos implementation, rewires the notification crate to re-export the new macOS backend, updates the Tauri plugin to expose a show_notification command and new bindings, adjusts permissions, and simplifies the desktop UI to directly trigger test notifications without permission flows. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant UI as Desktop UI (React)
participant JS as Plugin JS (bindings.gen.ts)
participant Tauri as Tauri Commands (Rust)
participant Ext as Plugin Ext
participant Notif as hypr_notification
participant Mac as hypr_notification_macos (Rust)
participant Swift as Swift _show_notification
UI->>JS: showNotification(Notification)
JS->>Tauri: plugin:notification|show_notification { v }
Tauri->>Ext: commands::show_notification(app, v)
Ext->>Notif: show(&Notification)
Note over Notif,Mac: macOS only path
Notif->>Mac: show(&Notification)
Mac->>Swift: _show_notification(title, message, url, has_url, timeout)
Swift-->>UI: Displays macOS notification (async)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (29)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8 issues found across 30 files
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| } | ||
| } | ||
| // Also a local monitor to handle when app is active (faster updates) | ||
| NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved, .leftMouseDragged, .rightMouseDragged]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local NSEvent monitor is never removed; store the returned token and remove it when no notifications remain.
Prompt for AI agents
Address the following comment on crates/notification-macos/swift-lib/src/lib.swift at line 681:
<comment>Local NSEvent monitor is never removed; store the returned token and remove it when no notifications remain.</comment>
<file context>
@@ -0,0 +1,735 @@
+import AVFoundation
+import Cocoa
+import SwiftRs
+
+// MARK: - Notification Instance
+class NotificationInstance {
+ let id = UUID()
+ let panel: NSPanel
+ let clickableView: ClickableView
</file context>
|
|
||
| private func manageNotificationLimit() { | ||
| // Remove oldest notifications if we exceed the limit | ||
| while activeNotifications.count >= maxNotifications { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infinite loop: using while here spins because dismiss() updates activeNotifications asynchronously after animation; count never decreases during the loop.
Prompt for AI agents
Address the following comment on crates/notification-macos/swift-lib/src/lib.swift at line 313:
<comment>Infinite loop: using while here spins because dismiss() updates activeNotifications asynchronously after animation; count never decreases during the loop.</comment>
<file context>
@@ -0,0 +1,735 @@
+import AVFoundation
+import Cocoa
+import SwiftRs
+
+// MARK: - Notification Instance
+class NotificationInstance {
+ let id = UUID()
+ let panel: NSPanel
+ let clickableView: ClickableView
</file context>
| title: "Meeting detected".to_string(), | ||
| message: "Click here to start writing a note".to_string(), | ||
| url: Some("hypr://hyprnote.com/notification".to_string()), | ||
| // let notif = hypr_notification2::Notification { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stale comment references hypr_notification2; update to hypr_notification (or remove) to avoid confusion.
Prompt for AI agents
Address the following comment on plugins/notification/src/ext.rs at line 105:
<comment>Stale comment references `hypr_notification2`; update to `hypr_notification` (or remove) to avoid confusion.</comment>
<file context>
@@ -101,14 +102,19 @@ impl<R: tauri::Runtime, T: tauri::Manager<R>> NotificationPluginExt<R> for T {
#[tracing::instrument(skip(self))]
fn start_detect_notification(&self) -> Result<(), Error> {
let cb = hypr_detect::new_callback(move |bundle_id| {
- let notif = hypr_notification2::Notification {
- title: "Meeting detected".to_string(),
- message: "Click here to start writing a note".to_string(),
- url: Some("hypr://hyprnote.com/notification".to_string()),
+ // let notif = hypr_notification2::Notification {
+ // title: "Meeting detected".to_string(),
</file context>
| // let notif = hypr_notification2::Notification { | |
| // let notif = hypr_notification::Notification { |
| @@ -0,0 +1,13 @@ | |||
| fn main() { | |||
| #[cfg(target_os = "macos")] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using #[cfg(target_os = "macos")] in a build.rs checks the host OS, not the Cargo target; this can misbehave during cross-compilation. Prefer branching on CARGO_CFG_TARGET_OS to make the build script target-aware.
Prompt for AI agents
Address the following comment on crates/notification-macos/build.rs at line 2:
<comment>Using #[cfg(target_os = "macos")] in a build.rs checks the host OS, not the Cargo target; this can misbehave during cross-compilation. Prefer branching on CARGO_CFG_TARGET_OS to make the build script target-aware.</comment>
<file context>
@@ -0,0 +1,13 @@
+fn main() {
+ #[cfg(target_os = "macos")]
+ {
+ swift_rs::SwiftLinker::new("14.2")
</file context>
| @@ -1,2 +1,2 @@ | |||
| #[cfg(target_os = "macos")] | |||
| pub mod macos; | |||
| pub use hypr_notification_macos::*; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-exporting the entire external crate at the root breaks the previous notification::macos::... API and pollutes the root namespace; alias the crate to preserve the module path.
Prompt for AI agents
Address the following comment on crates/notification/src/lib.rs at line 2:
<comment>Re-exporting the entire external crate at the root breaks the previous `notification::macos::...` API and pollutes the root namespace; alias the crate to preserve the module path.</comment>
<file context>
@@ -1,2 +1,2 @@
#[cfg(target_os = "macos")]
-pub mod macos;
+pub use hypr_notification_macos::*;
</file context>
| pub use hypr_notification_macos::*; | |
| pub use hypr_notification_macos as macos; |
| pub struct Notification { | ||
| pub title: String, | ||
| pub message: String, | ||
| pub url: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a typed URL (e.g., url::Url) instead of String to validate and prevent malformed URLs in the public interface.
Prompt for AI agents
Address the following comment on crates/notification-interface/src/lib.rs at line 5:
<comment>Use a typed URL (e.g., url::Url) instead of String to validate and prevent malformed URLs in the public interface.</comment>
<file context>
@@ -0,0 +1,7 @@
+#[derive(Debug, serde::Serialize, serde::Deserialize, specta::Type)]
+pub struct Notification {
+ pub title: String,
+ pub message: String,
+ pub url: Option<String>,
+ pub timeout: Option<std::time::Duration>,
+}
</file context>
| pub title: String, | ||
| pub message: String, | ||
| pub url: Option<String>, | ||
| pub timeout: Option<std::time::Duration>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Represent duration with a primitive (e.g., milliseconds as u64) to avoid interop ambiguity when exporting to TS/JSON via specta.
Prompt for AI agents
Address the following comment on crates/notification-interface/src/lib.rs at line 6:
<comment>Represent duration with a primitive (e.g., milliseconds as u64) to avoid interop ambiguity when exporting to TS/JSON via specta.</comment>
<file context>
@@ -0,0 +1,7 @@
+#[derive(Debug, serde::Serialize, serde::Deserialize, specta::Type)]
+pub struct Notification {
+ pub title: String,
+ pub message: String,
+ pub url: Option<String>,
+ pub timeout: Option<std::time::Duration>,
+}
</file context>
| } | ||
|
|
||
| #[tracing::instrument(skip(self))] | ||
| fn show_notification(&self, v: hypr_notification::Notification) -> Result<(), Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instrumented function may log notification contents (potential PII). Add the parameter to skip list to avoid logging sensitive fields.
Prompt for AI agents
Address the following comment on plugins/notification/src/ext.rs at line 29:
<comment>Instrumented function may log notification contents (potential PII). Add the parameter to skip list to avoid logging sensitive fields.</comment>
<file context>
@@ -18,19 +19,19 @@ pub trait NotificationPluginExt<R: tauri::Runtime> {
fn start_detect_notification(&self) -> Result<(), Error>;
fn stop_detect_notification(&self) -> Result<(), Error>;
-
- fn open_notification_settings(&self) -> Result<(), Error>;
- fn request_notification_permission(&self) -> Result<(), Error>;
- fn check_notification_permission(
- &self,
- ) -> impl Future<Output = Result<hypr_notification2::NotificationPermission, Error>>;
</file context>
| #[tracing::instrument(skip(self))] | |
| #[tracing::instrument(skip(self, v))] |
Summary by cubic
Replaced the wezterm-based notification path with a native macOS implementation using Swift, and introduced a small cross-crate interface. This adds a single show_notification command, removes permission-related flows, and simplifies dependencies.
New Features
Migration