Skip to content

Conversation

@richiemcilroy
Copy link
Member

@richiemcilroy richiemcilroy commented Sep 27, 2025

  • Replace the raw cursor sample in ProjectUniforms::new with a velocity-aware auto_zoom_focus helper so auto mode reacts smoothly across slow and fast clips
  • Rebalance the focus constants (lookback, lookahead, follow strength, shift clamp) to soften fast motions while keeping slow pans steady
  • Add focused unit tests that cover empty data, gentle motion, and rapid movement so future tweaks stay within the expected envelope

Before:

Existing.Auto.Zoom.mp4

After:

Improved.Auto.Zoom.mp4

Summary by CodeRabbit

  • New Features
    • Smarter auto-zoom focus that centers more intelligently around the cursor with smoothing and lookahead for faster, more responsive navigation.
    • Reduced jitter and drift during slow movement; more stable view when the cursor moves gradually.
    • Sensible fallback to the center when no cursor data is available.
  • Tests
    • Expanded coverage to validate default behavior, stability under slow motion, and responsiveness during fast motion.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 27, 2025

Walkthrough

Adds ProjectUniforms::auto_zoom_focus to compute zoom center using cursor data, smoothing, velocity, speed factor, and lookahead with UV clamping and fallbacks. Integrates smoothing config in ProjectUniforms::new, replaces inline zoom logic with auto_zoom_focus, and updates InterpolatedZoom construction. Introduces tests validating defaults, stability, and velocity responsiveness.

Changes

Cohort / File(s) Summary of Changes
Rendering uniforms and zoom focus
crates/rendering/src/lib.rs
Added ProjectUniforms::auto_zoom_focus; integrated cursor smoothing config; replaced inline zoom center calculation with auto_zoom_focus; updated InterpolatedZoom::new to use zoom_focus; added tests for defaults, slow-motion stability, and fast-motion responsiveness (with duplicated scaffolding sections).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App/Frame Loop
  participant PU as ProjectUniforms::new
  participant AF as auto_zoom_focus
  participant IZ as InterpolatedZoom::new
  participant GPU as Renderer/GPU

  App->>PU: Build uniforms (cursor data, config)
  PU->>AF: Compute zoom_focus (cursor + smoothing + velocity)
  AF-->>PU: zoom_focus (clamped UV)
  PU->>IZ: Construct with zoom_focus
  IZ-->>PU: InterpolatedZoom
  PU-->>GPU: Submit uniforms for rendering
  note over AF,IZ: New centralized zoom-focus and smoothing flow
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my whiskers at the screen so bright,
New zoom focus finds the center right.
With gentle smoothing, swift as breeze,
I hop through frames with rabbit ease.
Velocity’s hint, a lookahead gleam—
Now pixels align like a carrot dream. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly conveys that the primary change is an enhancement to the auto zoom smoothing behavior specifically for fast cursor movement, which aligns directly with the introduced velocity-aware auto_zoom_focus logic and updated smoothing in ProjectUniforms.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch auto-zoom-smoothness

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 273f2db and 198c2db.

📒 Files selected for processing (1)
  • crates/rendering/src/lib.rs (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
crates/**/src/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

For desktop IPC, use tauri_specta derive/macros on Rust types/events; do not hand-roll bindings

Files:

  • crates/rendering/src/lib.rs
**/*.{ts,tsx,js,jsx,rs}

📄 CodeRabbit inference engine (CLAUDE.md)

Do not add inline, block, or docstring comments in any language; code must be self-explanatory

Files:

  • crates/rendering/src/lib.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Format Rust code using rustfmt and ensure all Rust code passes workspace-level clippy lints.
Rust modules should be named with snake_case, and crate directories should be in kebab-case.

Files:

  • crates/rendering/src/lib.rs
crates/*/src/**/*

📄 CodeRabbit inference engine (AGENTS.md)

Rust crates should place tests within the src/ and/or a sibling tests/ directory for each crate inside crates/*.

Files:

  • crates/rendering/src/lib.rs
🧬 Code graph analysis (1)
crates/rendering/src/lib.rs (2)
crates/rendering/src/zoom.rs (4)
  • new (16-45)
  • new (73-78)
  • new (93-98)
  • c (243-245)
crates/rendering/src/cursor_interpolation.rs (1)
  • interpolate_cursor (16-75)
⏰ 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). (4)
  • GitHub Check: Vercel Agent Review
  • GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (5)
crates/rendering/src/lib.rs (5)

525-621: LGTM! Well-designed velocity-aware zoom focus computation.

The auto_zoom_focus function provides a sophisticated solution for smooth auto zoom behavior. The implementation properly handles velocity computation, lookahead prediction, and various edge cases. The use of exp() is appropriate here despite its non-deterministic precision, as the smoothness benefit outweighs minor precision variations in this visual context.

Key strengths:

  • Robust velocity computation with fallback strategies
  • NaN protection for edge cases
  • Proper UV space clamping
  • Configurable constants for tuning behavior

642-652: LGTM! Clean cursor smoothing configuration.

The conditional smoothing configuration is well-structured and correctly uses the project.cursor.raw flag to determine when smoothing should be applied.


654-660: LGTM! Proper integration of the new auto zoom focus.

The replacement of inline zoom center computation with the centralized auto_zoom_focus call is a clean improvement that maintains the same interface while providing enhanced smoothing capabilities.


670-670: LGTM! Correct usage of the computed zoom focus.

The zoom_focus value is properly passed to InterpolatedZoom::new, replacing the previous inline interpolation approach with the new smoothed focus computation.


1179-1256: LGTM! Comprehensive and well-structured test coverage.

The test suite provides excellent coverage of the key scenarios:

  1. Fallback behavior: Verifies proper default to center when no cursor data is available
  2. Stability: Ensures minimal drift during slow cursor movements
  3. Responsiveness: Validates appropriate velocity-aware behavior for fast movements

The test implementation is clean with proper helper functions and reasonable assertions that account for the smoothing algorithms' inherent approximations.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@richiemcilroy richiemcilroy merged commit 80b2fd6 into main Sep 30, 2025
15 of 16 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.

2 participants