special first click handling for macos. cancel the click but set block/waveai focus#3098
special first click handling for macos. cancel the click but set block/waveai focus#3098
Conversation
WalkthroughThis pull request introduces macOS first-click handling infrastructure by adding a new event handler component that listens to focus and mouse events, implementing logic to prevent and cancel the first click after a window focus event when occurring within a 50ms window. The changes include configuration updates for Electron on macOS, DOM attribute additions for component identification, a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
fix for #2982 |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Implementation NotesThe PR correctly implements special first-click handling for macOS:
The code follows existing patterns in the codebase and properly uses the existing Reviewed by minimax-m2.5-20260211 · 439,700 tokens |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/app/app.tsx (1)
207-282: Consider removing debug console.log statements before merge.The
MacOSFirstClickHandlerimplementation is correct for intercepting the macOS first-click behavior. A few observations:
Lines 248, 253, 257, 270: Multiple
console.logstatements appear to be debug artifacts. Consider removing or converting to the existingfocusLogdebug logger for consistency with the rest of the file.The 50ms timing window (line 240) and 10ms setTimeout delays (lines 247, 252) are reasonable for ensuring the focus event has fully propagated before applying custom focus logic.
The capture phase listeners (lines 273-274) correctly ensure this handler runs before other event handlers.
🧹 Suggested cleanup for console.log statements
const handleMouseDown = (e: MouseEvent) => { const timeDiff = Date.now() - windowFocusTime; if (windowFocusTime != null && timeDiff < 50) { e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); cancelNextClick = true; const blockId = getBlockIdFromTarget(e.target); if (blockId != null) { setTimeout(() => { - console.log("macos first-click, focusing block", blockId); + focusLog("macos first-click, focusing block", blockId); refocusNode(blockId); }, 10); } else if (isAIPanelTarget(e.target)) { setTimeout(() => { - console.log("macos first-click, focusing AI panel"); + focusLog("macos first-click, focusing AI panel"); FocusManager.getInstance().setWaveAIFocused(true); }, 10); } - console.log("macos first-click detected, canceled", timeDiff + "ms"); + focusLog("macos first-click detected, canceled", timeDiff + "ms"); return; } cancelNextClick = false; }; const handleClick = (e: MouseEvent) => { if (!cancelNextClick) { return; } cancelNextClick = false; e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); - console.log("macos first-click (click event) canceled"); + focusLog("macos first-click (click event) canceled"); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/app/app.tsx` around lines 207 - 282, Remove the debug console.log calls in MacOSFirstClickHandler: replace the console.log in the setTimeout inside handleMouseDown that logs "macos first-click, focusing block", the one that logs "macos first-click, focusing AI panel", the "macos first-click detected, canceled" in handleMouseDown, and the "macos first-click (click event) canceled" in handleClick with the project's debug logger (e.g., focusLog.debug or similar) or delete them if no logging is desired; update references in the setTimeout callbacks and both handlers (handleMouseDown, handleClick) so no console.log calls remain.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frontend/app/app.tsx`:
- Around line 207-282: Remove the debug console.log calls in
MacOSFirstClickHandler: replace the console.log in the setTimeout inside
handleMouseDown that logs "macos first-click, focusing block", the one that logs
"macos first-click, focusing AI panel", the "macos first-click detected,
canceled" in handleMouseDown, and the "macos first-click (click event) canceled"
in handleClick with the project's debug logger (e.g., focusLog.debug or similar)
or delete them if no logging is desired; update references in the setTimeout
callbacks and both handlers (handleMouseDown, handleClick) so no console.log
calls remain.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 5c938874-a2a3-4d67-a1d8-6c2f09d9288b
📒 Files selected for processing (5)
emain/emain-window.tsfrontend/app/aipanel/aipanel.tsxfrontend/app/app.tsxfrontend/app/store/focusManager.tsfrontend/app/store/global.ts
No description provided.