Skip to content

feat: default blur_active_element and hide_caret to true#161

Merged
pftg merged 1 commit into
masterfrom
fix/sensible-defaults
Apr 11, 2026
Merged

feat: default blur_active_element and hide_caret to true#161
pftg merged 1 commit into
masterfrom
fix/sensible-defaults

Conversation

@pftg

@pftg pftg commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Default blur_active_element to true (was nil)
  • Default hide_caret to true (was nil)

Both prevent flaky screenshots from blinking cursors and focused inputs. Every real-world app enables them. Users can still opt out with = false.

Note on :vips driver: The current :auto default already picks :vips first when available, falling back to :chunky_png. No change needed — it's effectively "vips by default."

Test plan

  • Full suite passes with CI=true (185 runs, 0 failures)
  • Verified blur/caret behavior unchanged for existing tests

🤖 Generated with Claude Code

Summary by Sourcery

Default key screenshot configuration options to reduce flakiness from focused elements and carets in captured images.

New Features:

  • Enable screenshot diffs to automatically blur the active element unless explicitly configured otherwise.
  • Enable screenshot diffs to automatically hide the text caret unless explicitly configured otherwise.

Summary by CodeRabbit

  • Chores
    • Active element blur is now enabled by default
    • Caret hiding is now enabled by default

@sourcery-ai

sourcery-ai Bot commented Apr 11, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Sets default values for screenshot-diff configuration options blur_active_element and hide_caret to true to reduce flaky visual test screenshots, while preserving the ability for users to override them.

Class diagram for updated Capybara_Screenshot configuration defaults

classDiagram
  class Capybara_Screenshot {
    <<module>>
    +add_driver_path
    +add_os_path
    +blur_active_element = true
    +enabled
    +hide_caret = true
    +root
    +stability_time_limit
    +window_size
  }
Loading

File-Level Changes

Change Details Files
Default blur_active_element configuration to true instead of nil.
  • Change mattr_accessor definition for blur_active_element to provide a default value block returning true
  • Ensure existing configuration can still override the default by explicitly setting false or another value at runtime
lib/capybara_screenshot_diff.rb
Default hide_caret configuration to true instead of nil.
  • Change mattr_accessor definition for hide_caret to provide a default value block returning true
  • Ensure existing configuration can still override the default by explicitly setting false or another value at runtime
lib/capybara_screenshot_diff.rb

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Apr 11, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@pftg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 8 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 25 minutes and 8 seconds.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7939ab00-441d-48f8-bb87-dbed06c6c03d

📥 Commits

Reviewing files that changed from the base of the PR and between 1d9bfa6 and 6c5840f.

📒 Files selected for processing (2)
  • lib/capybara_screenshot_diff.rb
  • test/test_helper.rb
📝 Walkthrough

Walkthrough

Two configuration flags in the Capybara::Screenshot module—blur_active_element and hide_caret—have been updated to default to true using a block syntax for mattr_accessor, rather than requiring explicit assignment afterward.

Changes

Cohort / File(s) Summary
Configuration Defaults
lib/capybara_screenshot_diff.rb
Updated blur_active_element and hide_caret flags to default to true via block-based mattr_accessor declarations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 With a twitch of my nose and a hop-skip-skip,
Two defaults now bloom, let screenshots not slip!
Hide the caret, blur the focus so bright,
Capybara stands taller—defaults done right!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: defaulting two configuration flags to true. It is specific, directly related to the changeset, and follows conventional commit format.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sensible-defaults

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.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Since blur_active_element and hide_caret now default to true instead of nil, double-check any internal conditionals that distinguish nil from false (e.g., if config.blur_active_element.nil?) to ensure they still behave correctly with the new default.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since `blur_active_element` and `hide_caret` now default to `true` instead of `nil`, double-check any internal conditionals that distinguish `nil` from `false` (e.g., `if config.blur_active_element.nil?`) to ensure they still behave correctly with the new default.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
lib/capybara_screenshot_diff.rb (1)

30-32: nil still disables these flags, which weakens the new default-true behavior.

On Line [30] and Line [32], defaults are now true, but downstream checks are truthy-based, so assigning nil still disables both features. Since current tests reset these flags to nil, this can silently opt out after a reset.

Consider treating only explicit false as disabled (e.g., != false in Screenshoter#prepare_page_for_screenshot) or normalizing nil back to true.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/capybara_screenshot_diff.rb` around lines 30 - 32, The new defaults for
mattr_accessor flags blur_active_element and hide_caret are true but downstream
checks treat any falsy value (including nil) as disabled; update the logic so
only an explicit false disables them by either normalizing the flags to true
(e.g., coerce nil to true after reset) or change the checks in
Screenshoter#prepare_page_for_screenshot to treat the flags as enabled unless
they are exactly false (use a `!= false` style check), ensuring the feature
remains enabled after tests reset them to nil; target the mattr_accessor
declarations (blur_active_element, hide_caret) and the conditionals inside
Screenshoter#prepare_page_for_screenshot when applying the fix.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/capybara_screenshot_diff.rb`:
- Around line 30-32: The new defaults for mattr_accessor flags
blur_active_element and hide_caret are true but downstream checks treat any
falsy value (including nil) as disabled; update the logic so only an explicit
false disables them by either normalizing the flags to true (e.g., coerce nil to
true after reset) or change the checks in
Screenshoter#prepare_page_for_screenshot to treat the flags as enabled unless
they are exactly false (use a `!= false` style check), ensuring the feature
remains enabled after tests reset them to nil; target the mattr_accessor
declarations (blur_active_element, hide_caret) and the conditionals inside
Screenshoter#prepare_page_for_screenshot when applying the fix.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4b47b40-e726-4e44-b82f-6218eb18a2d4

📥 Commits

Reviewing files that changed from the base of the PR and between c078dec and 1d9bfa6.

📒 Files selected for processing (1)
  • lib/capybara_screenshot_diff.rb

Every real-world app enables these to prevent flaky screenshots
from blinking cursors and focused input elements. Making them
default saves boilerplate and matches universal usage pattern.

Users can still set false to opt out.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pftg pftg force-pushed the fix/sensible-defaults branch from 1d9bfa6 to 6c5840f Compare April 11, 2026 23:38
@pftg pftg merged commit d60c30f into master Apr 11, 2026
7 checks passed
@pftg pftg deleted the fix/sensible-defaults branch April 11, 2026 23:43
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