fix(browser): strengthen contenteditable detection in annotation capture#300
fix(browser): strengthen contenteditable detection in annotation capture#300DeryFerd wants to merge 2 commits into
Conversation
- Improve contenteditable detection to properly handle all values - contenteditable='false' now correctly allows capture (not sensitive) - Add support for contenteditable='plaintext-only' detection - Add isContentEditable property fallback check - Add comprehensive test suite covering all edge cases Security improvement: prevents false positives where non-editable elements were incorrectly blocked from annotation capture.
|
Warning Review limit reached
More reviews will be available in 19 minutes and 36 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refines the ChangesRefined Sensitive Element Detection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/renderer/components/browser/annotation-sensitive-element.test.ts`:
- Around line 49-103: The test currently re-declares the isSensitiveElement
logic instead of using the production implementation, which risks drifting
tests; modify the production script (annotation-overlay.js) to expose the real
function in test runs by setting window.__termul_test_isSensitiveElement =
isSensitiveElement when window.__termul_test_mode is truthy, then in the test
set window.__termul_test_mode = true before injecting the overlay and remove the
duplicated testExposureScript so the test calls the real isSensitiveElement
implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5ee36aa0-3bec-4692-9440-dce5c2ed5fa3
📒 Files selected for processing (2)
src-tauri/resources/annotation-overlay.jssrc/renderer/components/browser/annotation-sensitive-element.test.ts
|
Hey @DeryFerd — triage update 🔁 CI green and mergeable ✅. One open CodeRabbit thread to consider: the test harness in |
… re-declaring logic - Modified annotation-overlay.js to expose isSensitiveElement in test mode - Removed duplicate test logic (60+ lines) from test file - Test now exercises production code directly, preventing drift - All 29 tests still pass
|
✅ Fixed - Test now uses production code Removed the test logic duplication issue identified by CodeRabbit. What changed:
Benefits:
All 29 tests still pass ✅ |
This fixes a false-positive in the browser annotation capture where
contenteditable="false"elements were incorrectly blocked from capture, even though they're explicitly non-editable.Background
The annotation overlay prevents capturing sensitive elements (form inputs, editable content) to protect user data. The contenteditable detection had a problem: it only checked whether the attribute existed, not what value it had. So
contenteditable="false"(which explicitly disables editing) was treated the same ascontenteditable="true".This meant legitimate static content got blocked. Code blocks or formatted text that use
contenteditable="false"to prevent accidental edits while keeping text selectable couldn't be captured.The fix
Updated
isSensitiveElement()to check the actual contenteditable value:true, empty string (which means true), orplaintext-only(all editable states)false(explicitly non-editable)element.isContentEditableproperty check as fallback for DOM-manipulated stateAlso added 29 tests in
annotation-sensitive-element.test.tscovering all contenteditable values, dynamic type changes, ARIA roles, nested editable elements, and the false-positive scenarios this fixes.Verification
All 29 new tests pass. TypeScript and Biome checks are clean. The fix maintains security (still blocks actual editable content and form inputs) while fixing the false positives.
Summary by CodeRabbit
Bug Fixes
Tests