Add app:focusfollowscursor setting (off/on/term) for hover-based block focus#2908
Conversation
…low your cursor. Options are "off" (default), "on", or "term" to only have focus follow in term tabs.
|
Caution Review failedThe pull request is closed. WalkthroughAdds a new configuration key Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
Code Review SummaryStatus: No New Issues Found | Recommendation: Address existing comment before merge OverviewThis PR implements a "focus follows cursor" feature that allows blocks to automatically receive focus when the mouse pointer enters them. The implementation includes:
Technical Implementation✅ Well-structured changes:
Files Reviewed (10 files)
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/docs/config.mdx`:
- Line 46: The new config entry for app:focusfollowscursor is missing the
VersionBadge used for other v0.14 settings; update the docs line describing
app:focusfollowscursor to include the VersionBadge component (e.g. add
<VersionBadge version="v0.14" /> adjacent to the setting name) so it matches the
convention used for app:confirmquit, app:hideaibutton,
app:disablectrlshiftarrows and app:disablectrlshiftdisplay.
…iew. Added VersionBadge to the new config.mdx entry.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/app/block/block.tsx (1)
230-259: Hover-focus triggers theblockClickedlayout-effect path — minor redundant renders.When
focusFromPointerEntercallsnodeModel.focusNode(),isFocusedtransitions totrue, which triggersuseLayoutEffect(() => setBlockClicked(isFocused), [isFocused])(line 158). The second layout effect then runs but correctly skips all focus calls becausefocusedBlockId() == nodeModel.blockIdis already satisfied and!isFocusedis false. No correctness issue, but every hover-focus event incurs two extra React renders from theblockClickedstate mutation.This is inherited from the pre-existing click-focus architecture rather than a bug introduced here. If hover-focus paths become performance-sensitive (e.g., on systems with many open blocks), consider gating the
setBlockClicked(isFocused)effect with a ref flag to distinguish hover-triggeredisFocusedchanges from click-triggered ones.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/app/block/block.tsx` around lines 230 - 259, Hover-triggered focus causes an extra setBlockClicked update; add a ref flag (e.g., hoverFocusRef) to differentiate hover vs click: in focusFromPointerEnter set hoverFocusRef.current = true just before calling nodeModel.focusNode(), and ensure click handlers set hoverFocusRef.current = false; update the useLayoutEffect that runs setBlockClicked(isFocused) to bail out when hoverFocusRef.current is true (so it only sets blockClicked for click-initiated focuses), and clear hoverFocusRef.current after focus handling so future focus changes behave normally; reference symbols: focusFromPointerEnter, nodeModel.focusNode, isFocused, setBlockClicked, focusedBlockId, and the useLayoutEffect that updates blockClicked.
🤖 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/block/block.tsx`:
- Around line 230-259: Hover-triggered focus causes an extra setBlockClicked
update; add a ref flag (e.g., hoverFocusRef) to differentiate hover vs click: in
focusFromPointerEnter set hoverFocusRef.current = true just before calling
nodeModel.focusNode(), and ensure click handlers set hoverFocusRef.current =
false; update the useLayoutEffect that runs setBlockClicked(isFocused) to bail
out when hoverFocusRef.current is true (so it only sets blockClicked for
click-initiated focuses), and clear hoverFocusRef.current after focus handling
so future focus changes behave normally; reference symbols:
focusFromPointerEnter, nodeModel.focusNode, isFocused, setBlockClicked,
focusedBlockId, and the useLayoutEffect that updates blockClicked.
…k focus (wavetermdev#2908) This PR adds a new app setting to control whether block focus follows cursor movement: - `app:focusfollowscursor: "off" | "on" | "term"` - Default is `"off"` (no behavior change unless enabled) ## What changed - Added hover-focus behavior on block pointer enter. - Added guardrails so hover focus does not trigger when: - touch input is used - pointer buttons are pressed (drag/select scenarios) - modal is open - pointer events are disabled - block is resizing - Added config key plumbing across settings types and schema: - `pkg/wconfig/settingsconfig.go` - `pkg/wconfig/metaconsts.go` - `schema/settings.json` - `pkg/wconfig/defaultconfig/settings.json` -> `"app:focusfollowscursor": "off"` - Added docs for the new key and default example: - `docs/docs/config.mdx` ## Behavior - `"off"`: do not focus on cursor movement - `"on"`: focus follows cursor for all block types - `"term"`: focus follows cursor only for terminal blocks
This PR adds a new app setting to control whether block focus follows cursor movement:
app:focusfollowscursor: "off" | "on" | "term""off"(no behavior change unless enabled)What changed
pkg/wconfig/settingsconfig.gopkg/wconfig/metaconsts.goschema/settings.jsonpkg/wconfig/defaultconfig/settings.json->"app:focusfollowscursor": "off"docs/docs/config.mdxBehavior
"off": do not focus on cursor movement"on": focus follows cursor for all block types"term": focus follows cursor only for terminal blocks