Skip to content

Conversation

@oscartbeaumont
Copy link
Contributor

@oscartbeaumont oscartbeaumont commented Aug 6, 2025

Summary by CodeRabbit

  • Refactor
    • Streamlined cursor size and click shrink calculations for consistent and smooth cursor behavior.
    • Improved cursor aspect ratio handling to maintain visual accuracy.
    • Added clarifying comments to enhance understanding of cursor positioning.
    • Simplified cursor shape resolution by replacing hash-based identification with platform-specific cursor shape enums.
    • Enhanced cursor metadata by replacing hash identifiers with descriptive cursor shape information.
  • New Features
    • Introduced detailed cursor shape support for macOS and Windows with embedded SVG assets and hotspot data.
    • Enabled direct cursor shape resolution on macOS and Windows for improved cursor monitoring and display.
  • Chores
    • Updated Windows cursor monitoring to use direct cursor handle conversion, removing complex image processing.
    • Refined dependency management by adding and reorganizing cursor info crate dependencies.
    • Updated cursor metadata types in desktop and project crates to use cursor shape enums instead of hashes.
    • Increased medium toggle control height slightly for improved UI consistency.
    • Added comprehensive README documentation for the cursor info crate detailing features, usage, and supported platforms.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Warning

Rate limit exceeded

@oscartbeaumont has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 73065f7 and 648c7bc.

📒 Files selected for processing (2)
  • crates/cursor-info/src/windows.rs (1 hunks)
  • crates/recording/src/cursor.rs (6 hunks)

Walkthrough

The cursor size calculation logic in crates/rendering/src/layers/cursor.rs was refactored. The computation of base size, aspect ratio adjustments, and click shrink effects were consolidated and clarified. Redundant scaling was removed, and explanatory comments were added. No public interfaces or exported entities were changed. Additionally, Windows and macOS cursor monitoring code in crates/cursor-info/examples/cli.rs was simplified by removing manual bitmap extraction and hash-based identification, replacing it with direct cursor shape resolution via the new CursorShape abstraction. The cursor shape representation was refactored across multiple crates to replace hash-based identification with a platform-specific enum-based system, including new modules for macOS and Windows cursor shapes, serialization/deserialization, and conversion from platform handles. Dependency manifests were updated to add the new cap-cursor-info crate and adjust related dependencies. Minor type changes were made to cursor metadata types in desktop and project crates.

Changes

Cohort / File(s) Change Summary
Cursor Sizing Logic Refactor
crates/rendering/src/layers/cursor.rs
Simplified cursor size calculation by unifying base size, cursor size factor, and click shrink scale; computed aspect ratio after sizing; removed duplicate click scaling; improved comments and clarity.
Cursor Monitoring CLI Simplification
crates/cursor-info/examples/cli.rs
Removed manual cursor bitmap extraction and hash-based identification on macOS and Windows; replaced with direct cursor shape resolution using CursorShape enum; simplified control flow and output.
Cursor Shape Abstraction and Refactor
crates/cursor-info/src/lib.rs, crates/cursor-info/src/macos.rs, crates/cursor-info/src/windows.rs
Introduced CursorShape enum with platform-specific variants; implemented serialization, deserialization, display, and type traits; moved cursor hash-to-shape resolution to platform modules; added Windows handle conversion; removed old hash-based resolution.
Cursor Metadata and Usage Updates
apps/desktop/src/utils/tauri.ts, crates/project/src/meta.rs, crates/recording/src/cursor.rs, crates/recording/src/studio_recording.rs
Replaced optional hash fields with optional CursorShape fields in cursor metadata and recording structs; updated construction and propagation of cursor shape data; adjusted type definitions accordingly.
Dependency and Manifest Updates
crates/cursor-info/Cargo.toml, crates/project/Cargo.toml, crates/recording/Cargo.toml
Added cap-cursor-info as a local path dependency; reorganized and updated dependencies in cap-cursor-info crate; adjusted dev-dependencies and feature flags; no public API changes.
UI Style Adjustment
apps/desktop/src/components/Toggle.tsx
Increased height of medium size toggle control from 1.4rem to 1.5rem; no logic or interface changes.
Documentation Addition
crates/cursor-info/README.md
Added README documentation describing the cap-cursor-info crate, its features, supported platforms, usage examples, development tools, and contribution guidelines.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as Cursor CLI
    participant OS as Operating System
    participant CursorShape as CursorShape Enum

    CLI->>OS: Request current cursor info
    OS-->>CLI: Return cursor handle or hash
    CLI->>CursorShape: Convert handle/hash to CursorShape (platform-specific)
    CursorShape-->>CLI: Resolved cursor shape or Unknown
    CLI->>CLI: Print resolved cursor shape or unknown message
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

A cursor hops across the screen,
Its shape now known, no hash unseen.
From Mac to Windows, clear and bright,
The code refines its graceful flight.
With simpler paths and enums tight,
A rabbit cheers this coding light! 🐇✨

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

🪧 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.
    • Explain this complex logic.
    • 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. 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.

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

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.

@oscartbeaumont oscartbeaumont marked this pull request as ready for review August 6, 2025 02:35
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: 4

🔭 Outside diff range comments (1)
crates/recording/src/cursor.rs (1)

581-584: Missing cursor shape resolution for Windows

The Windows implementation doesn't set the shape field in CursorData, which is inconsistent with the macOS implementation. The field will be uninitialized or need explicit initialization.

         Some(CursorData {
             image: png_data,
             hotspot: XY::new(hotspot_x, hotspot_y),
+            shape: None, // TODO: Implement Windows cursor shape resolution
         })
🧹 Nitpick comments (4)
crates/recording/src/cursor.rs (1)

268-274: Consider handling the shape resolution more explicitly

The current implementation silently returns None when CursorShapeMacOS::from_hash fails. Consider logging when an unknown cursor hash is encountered for debugging purposes.

-        let shape =
-            cap_cursor_info::CursorShapeMacOS::from_hash(&hex::encode(Sha256::digest(&image)));
-
+        let hash = hex::encode(Sha256::digest(&image));
+        let shape = cap_cursor_info::CursorShapeMacOS::from_hash(&hash);
+        if shape.is_none() {
+            tracing::debug!("Unknown cursor hash encountered: {}", hash);
+        }
+
crates/cursor-info/src/macos.rs (2)

44-44: Fix documentation typo for IBeamVerticalForVerticalLayout.

The documentation comment references "ibeamcursorforverticallayout" but should reference "iBeamCursorForVerticalLayout" to match Apple's actual documentation naming.

-    /// https://developer.apple.com/documentation/appkit/nscursor/ibeamcursorforverticallayout
+    /// https://developer.apple.com/documentation/appkit/nscursor/iBeamCursorForVerticalLayout

122-161: Consider documenting the hash generation process.

While the implementation is correct, the hardcoded SHA-256 hashes could become outdated if Apple updates their cursor assets. Consider adding a comment explaining how these hashes were generated and potentially create a utility script to regenerate them when needed.

Would you like me to help create a script that can extract and hash macOS cursor images to maintain these values?

crates/cursor-info/src/windows.rs (1)

139-151: Complete implementation for scroll cursor variants.

Several scroll cursor variants are currently unimplemented and will return None. This means these cursors won't be rendered properly.

Would you like me to help implement the missing scroll cursor variants or open an issue to track this work?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f603602 and eebc4cb.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (12)
  • apps/desktop/src/utils/tauri.ts (1 hunks)
  • crates/cursor-info/Cargo.toml (1 hunks)
  • crates/cursor-info/examples/cli.rs (3 hunks)
  • crates/cursor-info/src/lib.rs (2 hunks)
  • crates/cursor-info/src/macos.rs (1 hunks)
  • crates/cursor-info/src/windows.rs (1 hunks)
  • crates/project/Cargo.toml (1 hunks)
  • crates/project/src/meta.rs (1 hunks)
  • crates/recording/Cargo.toml (1 hunks)
  • crates/recording/src/cursor.rs (5 hunks)
  • crates/recording/src/studio_recording.rs (1 hunks)
  • crates/rendering/src/layers/cursor.rs (4 hunks)
✅ Files skipped from review due to trivial changes (3)
  • crates/recording/Cargo.toml
  • crates/project/Cargo.toml
  • apps/desktop/src/utils/tauri.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/rendering/src/layers/cursor.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). (3)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Clippy
🔇 Additional comments (12)
crates/recording/src/studio_recording.rs (1)

528-528: LGTM!

The field update from hash to shape correctly aligns with the new cursor shape abstraction.

crates/project/src/meta.rs (1)

247-247: LGTM!

The type change to Option<cap_cursor_info::CursorShape> properly integrates the new cursor shape abstraction while maintaining backward compatibility with the optional field.

crates/cursor-info/Cargo.toml (1)

23-24: Confirm objc2-app-kit version downgrade

  • Verified on crates.io: both 0.3.1 and 0.3.0 exist and are not yanked.
  • No CHANGELOG or release notes in the repo mention differences between 0.3.1 and 0.3.0.

Please double-check that none of the features or fixes you rely on in 0.3.1 have been removed or altered in 0.3.0.

crates/cursor-info/examples/cli.rs (2)

72-77: Clean implementation of cursor shape resolution

Good use of the new CursorShapeMacOS::from_hash API with proper handling of unknown cursors.


95-111: Excellent simplification of Windows cursor monitoring

The refactored code is much cleaner and more maintainable than the previous manual bitmap extraction approach. Good use of the TryFrom trait for cursor shape conversion.

crates/cursor-info/src/macos.rs (2)

47-120: LGTM!

The resolve method implementation correctly maps each cursor variant to its corresponding SVG asset and hotspot coordinates. The explicit None return for DisappearingItem is appropriate.


164-168: LGTM!

The From trait implementation correctly wraps the macOS cursor shape in the generic CursorShape enum.

crates/cursor-info/src/windows.rs (1)

214-218: LGTM!

The From trait implementation correctly wraps the Windows cursor shape in the generic CursorShape enum.

crates/cursor-info/src/lib.rs (4)

3-11: LGTM!

The module structure and imports are well-organized, properly separating platform-specific implementations.


22-37: LGTM!

The CursorShape enum design with platform-specific variants and the delegation pattern in the resolve method are well-structured.


39-62: LGTM!

The Display and Serialize implementations correctly format the cursor shape as a platform-prefixed string.


97-104: LGTM!

The Type trait implementation correctly represents CursorShape as a string type for TypeScript bindings.

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 (1)
crates/cursor-info/src/windows.rs (1)

68-154: Cursor resolution implementation looks solid.

The method properly handles supported cursors with embedded SVG assets and normalized hotspot coordinates. The incomplete scroll cursor implementations are handled gracefully by returning None.

Would you like me to help implement the remaining scroll cursor variants or track this as a TODO item?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eebc4cb and ec76220.

📒 Files selected for processing (2)
  • crates/cursor-info/src/lib.rs (2 hunks)
  • crates/cursor-info/src/windows.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/cursor-info/src/lib.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). (3)
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Clippy
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
🔇 Additional comments (3)
crates/cursor-info/src/windows.rs (3)

6-66: Good implementation of Windows cursor shapes enum.

The enum is well-structured with comprehensive Windows cursor types and proper documentation. I notice the typo mentioned in previous reviews (ScrolNSScrollNS) has been fixed.


156-266: Excellent implementation of cursor caching optimization.

The cursor caching system directly addresses the previous review suggestion about avoiding repeated system calls. The implementation uses OnceLock for thread-safe lazy initialization and loads all cursors once into a HashMap for efficient lookups.


268-272: Clean conversion implementation.

Simple and correct implementation that enables ergonomic usage with the generic cursor shape system.

@oscartbeaumont oscartbeaumont merged commit 16da7ad into main Aug 6, 2025
6 of 7 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.

3 participants