Skip to content

Conversation

@duckduckhero
Copy link
Contributor

@duckduckhero duckduckhero commented Aug 10, 2025

Summary by cubic

Improved event notification reliability by catching panics when showing notifications and adding more logging for better debugging.

  • Bug Fixes
    • Wrapped notification display in a panic handler to prevent worker crashes.
    • Added logs for notification execution, success, and errors.

@coderabbitai
Copy link

coderabbitai bot commented Aug 10, 2025

📝 Walkthrough

Walkthrough

The function responsible for event notifications now includes additional logging at key steps and wraps the notification display call in a panic-catching block. This ensures that any panics during notification display are logged as errors, while successful notifications are logged as informational messages. No public interfaces or function signatures were changed.

Changes

Cohort / File(s) Change Summary
Notification Worker Logging & Error Handling
plugins/notification/src/worker.rs
Added info logs before checking for events and before showing notifications; wrapped notification display in catch_unwind to log panics as errors; logs success or error accordingly.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ffba7c9 and 0fe2d52.

📒 Files selected for processing (1)
  • plugins/notification/src/worker.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • plugins/notification/src/worker.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci (windows, windows-latest)
  • GitHub Check: ci (macos, macos-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch notification-fix-2

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic analysis

No issues found across 1 file. Review in cubic

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
plugins/notification/src/worker.rs (2)

25-25: Consider lowering to debug to reduce noise

This runs every minute; “checking for events” at info level may be too chatty. Suggest using debug, or include structured fields if you need it at info.


42-42: Add structured context and consider deduping notifications

Include event_id (and maybe event start time) as structured fields for traceability. Also, given this job runs every minute with a 5‑minute window, you may re-notify the same event multiple times. Consider a de-duplication guard.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cb4a3f and ffba7c9.

📒 Files selected for processing (1)
  • plugins/notification/src/worker.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,ts,tsx,rs}

⚙️ CodeRabbit Configuration File

**/*.{js,ts,tsx,rs}: 1. No error handling.
2. No unused imports, variables, or functions.
3. For comments, keep it minimal. It should be about "Why", not "What".

Files:

  • plugins/notification/src/worker.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: ci (windows, windows-latest)

Comment on lines 44 to 58
if let Err(e) = std::panic::catch_unwind(|| {
hypr_notification2::show(hypr_notification2::Notification {
title: "Meeting starting in 5 minutes".to_string(),
message: event.name.clone(),
url: Some(format!(
"hypr://hyprnote.com/notification?event_id={}",
event.id
)),
timeout: Some(std::time::Duration::from_secs(10)),
});
}) {
tracing::error!(" Notification panic: {:?}", e);
} else {
tracing::info!(" Notification shown");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Fix compile error when logging panic payload; ensure unwind-safety; remove stray spaces; and justify the policy exception

  • Box<dyn Any + Send> from catch_unwind doesn’t implement Debug; {:?} won’t compile. Downcast to &str/String before logging.
  • Use AssertUnwindSafe if the closure captures non-UnwindSafe refs.
  • Remove leading whitespace in log messages.
  • Per org guideline “No error handling” for rs files: this introduces panic handling. If this is necessary (known FFI/UI panic), add a minimal “why” comment to justify the exception, or drop the catch_unwind entirely.

Proposed patch for this block:

-        if let Err(e) = std::panic::catch_unwind(|| {
-            hypr_notification2::show(hypr_notification2::Notification {
-                title: "Meeting starting in 5 minutes".to_string(),
-                message: event.name.clone(),
-                url: Some(format!(
-                    "hypr://hyprnote.com/notification?event_id={}",
-                    event.id
-                )),
-                timeout: Some(std::time::Duration::from_secs(10)),
-            });
-        }) {
-            tracing::error!(" Notification panic: {:?}", e);
-        } else {
-            tracing::info!(" Notification shown");
-        }
+        // Why: hypr_notification2::show has been observed to panic on some platforms;
+        // guard to keep the worker alive (exception to the "no error handling" guideline).
+        if let Err(panic_payload) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
+            hypr_notification2::show(hypr_notification2::Notification {
+                title: "Meeting starting in 5 minutes".to_string(),
+                message: event.name.clone(),
+                url: Some(format!("hypr://hyprnote.com/notification?event_id={}", event.id)),
+                timeout: Some(std::time::Duration::from_secs(10)),
+            });
+        })) {
+            let panic_msg = if let Some(s) = panic_payload.downcast_ref::<&str>() {
+                *s
+            } else if let Some(s) = panic_payload.downcast_ref::<String>() {
+                s.as_str()
+            } else {
+                "unknown panic payload"
+            };
+            tracing::error!(event_id = %event.id, panic_message = %panic_msg, "Notification panicked");
+        } else {
+            tracing::info!(event_id = %event.id, "Notification shown");
+        }

If the policy exception isn’t acceptable, remove the catch_unwind and let failures surface (or handle a Result from show if available).


Fix panic logging and enforce unwind-safety in the notification worker

The current use of catch_unwind won’t compile (Box<dyn Any + Send> isn’t Debug), and we should explicitly mark the closure as unwind-safe, remove stray spaces in the logs, and document why we’re breaking the “no error handling” guideline.

• File: plugins/notification/src/worker.rs (lines 44–58)
• Change logging of panic payload to a downcasted string
• Wrap the closure in AssertUnwindSafe
• Trim leading whitespace from log messages
• Add a brief comment justifying the catch_unwind usage

-        if let Err(e) = std::panic::catch_unwind(|| {
-            hypr_notification2::show(hypr_notification2::Notification {
-                title: "Meeting starting in 5 minutes".to_string(),
-                message: event.name.clone(),
-                url: Some(format!(
-                    "hypr://hyprnote.com/notification?event_id={}",
-                    event.id
-                )),
-                timeout: Some(std::time::Duration::from_secs(10)),
-            });
-        }) {
-            tracing::error!(" Notification panic: {:?}", e);
-        } else {
-            tracing::info!(" Notification shown");
-        }
+        // Rationale: `hypr_notification2::show` can panic (FFI/UI edge cases).
+        // We catch unwinds to keep the worker alive (exception to the “no error handling” policy).
+        if let Err(panic_payload) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
+            hypr_notification2::show(hypr_notification2::Notification {
+                title: "Meeting starting in 5 minutes".to_string(),
+                message: event.name.clone(),
+                url: Some(format!("hypr://hyprnote.com/notification?event_id={}", event.id)),
+                timeout: Some(std::time::Duration::from_secs(10)),
+            });
+        })) {
+            let panic_msg = if let Some(s) = panic_payload.downcast_ref::<&str>() {
+                *s
+            } else if let Some(s) = panic_payload.downcast_ref::<String>() {
+                s.as_str()
+            } else {
+                "unknown panic payload"
+            };
+            tracing::error!(event_id = %event.id, panic_message = %panic_msg, "Notification panicked");
+        } else {
+            tracing::info!(event_id = %event.id, "Notification shown");
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if let Err(e) = std::panic::catch_unwind(|| {
hypr_notification2::show(hypr_notification2::Notification {
title: "Meeting starting in 5 minutes".to_string(),
message: event.name.clone(),
url: Some(format!(
"hypr://hyprnote.com/notification?event_id={}",
event.id
)),
timeout: Some(std::time::Duration::from_secs(10)),
});
}) {
tracing::error!(" Notification panic: {:?}", e);
} else {
tracing::info!(" Notification shown");
}
// Rationale: `hypr_notification2::show` can panic (FFI/UI edge cases).
// We catch unwinds to keep the worker alive (exception to the “no error handling” policy).
if let Err(panic_payload) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
hypr_notification2::show(hypr_notification2::Notification {
title: "Meeting starting in 5 minutes".to_string(),
message: event.name.clone(),
url: Some(format!("hypr://hyprnote.com/notification?event_id={}", event.id)),
timeout: Some(std::time::Duration::from_secs(10)),
});
})) {
let panic_msg = if let Some(s) = panic_payload.downcast_ref::<&str>() {
*s
} else if let Some(s) = panic_payload.downcast_ref::<String>() {
s.as_str()
} else {
"unknown panic payload"
};
tracing::error!(event_id = %event.id, panic_message = %panic_msg, "Notification panicked");
} else {
tracing::info!(event_id = %event.id, "Notification shown");
}
🤖 Prompt for AI Agents
In plugins/notification/src/worker.rs lines 44 to 58, fix the panic logging by
downcasting the panic payload to a string for proper Debug output, wrap the
closure passed to catch_unwind with AssertUnwindSafe to enforce unwind-safety,
remove leading spaces from the tracing log messages, and add a brief comment
explaining why catch_unwind is used despite the usual no error handling
guideline.

@duckduckhero duckduckhero merged commit 5ffe0bb into main Aug 10, 2025
6 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants