Skip to content

Conversation

Brendonovich
Copy link
Member

@Brendonovich Brendonovich commented Aug 27, 2025

Summary by CodeRabbit

  • New Features

    • Added support for Continuity Camera on macOS 14+, enabling detection and use of these devices.
  • Bug Fixes

    • Improved stability during camera discovery by safely handling external and unknown devices, reducing the chance of crashes.
  • Chores

    • Updated macOS compatibility logic without changing any public APIs.

Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

Walkthrough

Updated AVFoundation camera device type collection to safely handle optional types and add macOS 14+ continuity camera support. Replaced unsafe unwrap with guarded checks for external and continuity_camera, and retained external_unknown for older paths. No public APIs changed.

Changes

Cohort / File(s) Summary of modifications
AVFoundation device type handling
crates/camera-avfoundation/src/lib.rs
- Replaced unsafe unwrap on external() with if let Some(...)
- Added conditional push for continuity_camera() on macOS 14+
- Kept fallback external_unknown() path (syntax cleanup)
- No exported/public signatures changed

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant Enumerator as DeviceEnumerator
    participant AVF as AVFoundation

    App->>Enumerator: enumerate_device_types()
    Enumerator->>AVF: query available device types
    alt macOS >= 14
        AVF-->>Enumerator: optional external()
        Note right of Enumerator: If Some, push external
        AVF-->>Enumerator: optional continuity_camera()
        Note right of Enumerator: If Some, push continuity_camera
    else macOS < 14 or not available
        Enumerator->>Enumerator: push external_unknown()
    end
    Enumerator-->>App: device types list
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at macOS fourteen’s light,
New cams hop in, when options feel right.
No panics now—just gentle checks,
External or continuity specs.
With safer hops through AV land,
I thump approval, carrot in hand. 🥕🐇

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.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch continuity-camera

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:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
Contributor

@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: 0

🧹 Nitpick comments (2)
crates/camera-avfoundation/src/lib.rs (2)

21-26: Good move replacing unwrap with guarded availability; add a fallback if both Option lookups fail on 14+

This prevents panics and properly probes weakly-linked symbols. To avoid returning no external devices on macOS 14+ if both calls unexpectedly return None (e.g., symbol resolution edge cases), add a local fallback to external_unknown() when neither were added. Also add a brief SAFETY note for future readers.

-        if let Some(typ) = unsafe { av::CaptureDeviceType::external() } {
-            device_types.push(typ);
-        }
-        if let Some(typ) = unsafe { av::CaptureDeviceType::continuity_camera() } {
-            device_types.push(typ);
-        }
+        // SAFETY: Calls are gated by macOS 14.0 availability; functions return None if the symbol
+        // is not present at runtime due to weak-linking.
+        let mut added_any = false;
+        if let Some(ty) = unsafe { av::CaptureDeviceType::external() } {
+            device_types.push(ty);
+            added_any = true;
+        }
+        if let Some(ty) = unsafe { av::CaptureDeviceType::continuity_camera() } {
+            device_types.push(ty);
+            added_any = true;
+        }
+        if !added_any {
+            device_types.push(av::CaptureDeviceType::external_unknown());
+        }

28-28: Pre-14 fallback looks right

Pushing external_unknown() for macOS < 14 keeps discovery working without relying on newer symbols. Consider a tiny comment to document why this branch doesn’t attempt external()/continuity_camera().

-        device_types.push(av::CaptureDeviceType::external_unknown());
+        // Pre-14: use the generic external type because newer symbols may not exist.
+        device_types.push(av::CaptureDeviceType::external_unknown());
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between afb7e0f and c29247d.

📒 Files selected for processing (1)
  • crates/camera-avfoundation/src/lib.rs (1 hunks)
⏰ 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). (3)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Analyze (rust)

@Brendonovich Brendonovich merged commit 845040b into main Sep 1, 2025
15 checks passed
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.

1 participant