fix: separate window-blur from screenshot in integrity monitor - #143
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
barunaniket
left a comment
There was a problem hiding this comment.
Hi @vaibhavtulsian, thanks for opening this PR!
A few issues were identified during review:
Missing Feature Code: The PR contains no code changes for the screenshot flag / issue points mentioned in the commit message.
Dependency Downgrade: drizzle-kit was downgraded from ^0.31.10 to ^0.18.1, which causes breaking incompatibilities with our current Drizzle ORM setup and introduces ~8,500 lines of lockfile churn.
Typecheck Exclusion: "drizzle.config.ts" should not be excluded from tsconfig.json.
Please revert the dependency changes in package.json, package-lock.json, and tsconfig.json, and ensure your actual implementation commits are included in the branch before requesting review again.
Problem
useIntegrityMonitor records a "screenshot" flag on any window.blur while the tab stays visible (
useIntegrityMonitor.ts:134–138
), lumping it together with actual PrintScreen key presses. This means:
Alt-tabbing to another app
Clicking the address bar
Focusing undocked DevTools
Moving to a second monitor
…all count as "screen capture" and eat into the 5-flag cap that drops a solver's score to base points. Legitimate multitasking gets penalized, and the "screenshot" bucket conflates real captures with generic focus loss.
Fix
Split "screenshot" into two distinct event types:
"screenshot" — only fires on PrintScreen keyup (actual screen capture)
"window-blur" — fires on window focus loss while tab is visible
Exclude window-blur from the flag total used for scoring — it's still recorded in the per-category breakdown for server-side review, but doesn't count toward the 5-flag cap
Update user-facing messages to honestly label each signal ("You left the window" vs "Screen capture detected")
Update the API route to accept the new event type without incrementing the penalty counter
Affected area
Arena solve workspace (/cp-arena/solve/) — ranked solves only (practice is unaffected).