Skip to content

fix(desktop): allow hotkeys to trigger in editable content - #3418

Merged
Kitenite merged 1 commit into
mainfrom
restore-cmd-w-close
Apr 13, 2026
Merged

Kitenite merged 1 commit into
mainfrom
restore-cmd-w-close

Conversation

@Kitenite

@Kitenite Kitenite commented Apr 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • react-hotkeys-hook skips keydown events whose target is contentEditable unless enableOnContentEditable is set. CodeMirror 6 (v1 file editor) uses a contenteditable editor area, so cmd+w never reached the CLOSE_TERMINAL handler at workspace/$workspaceId/page.tsx:220 while the editor was focused.
  • Default enableOnContentEditable: true in useHotkey, mirroring the existing enableOnFormTags: true default. Callers can still opt out via options.

Test plan

  • Focus a file in the v1 file editor, press cmd+w → pane closes.
  • Unsaved changes prompt still triggers on cmd+w in a dirty file editor.
  • Other app chords (cmd+s save, cmd+f find) still behave as before inside the editor.
  • cmd+w still closes terminal / chat / browser panes when those are focused.

Summary by cubic

Restore cmd+w to close the focused pane when the v1 file editor (CodeMirror) is focused by allowing app hotkeys to fire inside contentEditable editors.

  • Bug Fixes
    • Default enableOnContentEditable: true in useHotkey (mirrors enableOnFormTags: true); callers can override via options.
    • Addresses react-hotkeys-hook skipping keydown on contentEditable (CodeMirror), so cmd+w reaches the close handler again without changing other shortcuts.

Written for commit 45d877b. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Enabled hotkey handling on content-editable elements, allowing keyboard shortcuts to function properly in editable text areas.

…ditor)

react-hotkeys-hook skips events whose target is contentEditable unless
enableOnContentEditable is set. CodeMirror 6 renders its editor as a
contenteditable element, so app chords like cmd+w stopped firing when
focus was in the v1 file editor — meta+w never reached the CLOSE_TERMINAL
handler that closes the focused pane.

Default enableOnContentEditable: true in useHotkey, mirroring the existing
enableOnFormTags default. Callers can still opt out via options.
@coderabbitai

coderabbitai Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The hotkey hook configuration is extended to enable hotkey handling on contentEditable elements by adding enableOnContentEditable: true to the useHotkeys setup, alongside the existing enableOnFormTags: true setting.

Changes

Cohort / File(s) Summary
Hotkey Configuration Enhancement
apps/desktop/src/renderer/hotkeys/hooks/useHotkey/useHotkey.ts
Added enableOnContentEditable: true to the useHotkeys configuration to support hotkey handling on contentEditable elements.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A single line, so small and neat,
Makes contentEditable hotkeys sweet,
Now typing zones obey commands true,
One tiny change, so clean and new! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description covers the problem, solution, and test plan, but the author-provided section lacks the structured template (Bug fix checkbox, Related Issues, etc.) that is required. Complete the PR description using the template structure: fill in the Type of Change checkboxes, add Related Issues links, and ensure Testing section is detailed.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change—enabling hotkeys on contentEditable elements—which directly addresses the PR's core objective of restoring cmd+w functionality in the CodeMirror v1 file editor.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch restore-cmd-w-close

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.

@greptile-apps

greptile-apps Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes cmd+w not closing the pane when a v1 file editor (CodeMirror 6) was focused. CodeMirror 6 renders an editor area as a contenteditable div, and react-hotkeys-hook skips keydown events targeting contentEditable elements by default — so the CLOSE_TERMINAL handler never fired.

The fix adds enableOnContentEditable: true to the defaults in the shared useHotkey wrapper, mirroring the already-present enableOnFormTags: true. Because ...options is spread after the defaults, any individual call-site can still opt out by passing { enableOnContentEditable: false }.

Key observations:

  • The change is a single-line addition, minimal in scope.
  • The approach is consistent with the existing enableOnFormTags: true default, which already caused all globally-registered hotkeys to fire inside <input>, <textarea>, and <select> elements.
  • This is a desktop IDE-like application; workspace navigation shortcuts (close pane, switch tab, etc.) are expected to work regardless of which element has focus.
  • Chat shortcut registrations in ChatShortcuts already guard their activation with { enabled: isFocused }, so no regressions are expected there.
  • No currently-registered hotkeys overlap with standard editing operations (undo, copy, bold, etc.), so no text-editing conflicts are introduced.

Confidence Score: 5/5

Safe to merge — minimal, targeted fix with no identified regressions.

Single-line change that mirrors an existing default (enableOnFormTags: true). The ...options spread preserves per-call-site opt-out. No registered hotkeys overlap with standard editing shortcuts, and existing call-sites that guard by focus ({ enabled: isFocused }) are unaffected. Test plan covers the primary bug path and adjacent cases.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/hotkeys/hooks/useHotkey/useHotkey.ts Adds enableOnContentEditable: true as a default alongside the existing enableOnFormTags: true, so all hotkeys registered via useHotkey now fire when focus is inside a contenteditable element (e.g. CodeMirror 6 editor). Callers can still opt out via options.

Sequence Diagram

sequenceDiagram
    participant User
    participant CodeMirror as CodeMirror 6 (contenteditable)
    participant RHKH as react-hotkeys-hook
    participant useHotkey
    participant Handler as CLOSE_TERMINAL handler

    Note over RHKH: Before fix: enableOnContentEditable defaults to false

    User->>CodeMirror: Focuses editor
    User->>CodeMirror: Presses cmd+w
    CodeMirror->>RHKH: keydown event (target=contenteditable)
    RHKH--xHandler: Skipped — contenteditable target

    Note over RHKH: After fix: enableOnContentEditable: true in useHotkey defaults

    User->>CodeMirror: Focuses editor
    User->>CodeMirror: Presses cmd+w
    CodeMirror->>RHKH: keydown event (target=contenteditable)
    RHKH->>useHotkey: Hotkey match — passes through
    useHotkey->>Handler: Calls CLOSE_TERMINAL callback
    Handler-->>User: Pane closes
Loading

Reviews (1): Last reviewed commit: "fix(desktop): let app hotkeys fire insid..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-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.

No issues found across 1 file

@Kitenite Kitenite changed the title fix(desktop): restore cmd+w close in v1 file editor fix(desktop): allow hotkeys to trigger in editable content Apr 13, 2026
@Kitenite
Kitenite merged commit b42a114 into main Apr 13, 2026
7 checks passed
@Kitenite
Kitenite deleted the restore-cmd-w-close branch April 13, 2026 20:50
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request Apr 14, 2026
…ditor) (ParadevAI#3418)

react-hotkeys-hook skips events whose target is contentEditable unless
enableOnContentEditable is set. CodeMirror 6 renders its editor as a
contenteditable element, so app chords like cmd+w stopped firing when
focus was in the v1 file editor — meta+w never reached the CLOSE_TERMINAL
handler that closes the focused pane.

Default enableOnContentEditable: true in useHotkey, mirroring the existing
enableOnFormTags default. Callers can still opt out via options.
MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request Apr 14, 2026
All 9 upstream commits have been individually cherry-picked via PR#159~#163:

| Upstream | Our PR | Description |
|---|---|---|
| d656b7e (ParadevAI#3415) | #159 (PR#1) | terminal clipboard handling |
| 31fcf19 (ParadevAI#3416) | #162 (PR#4) | v1 split pane startup sizing fix |
| 039edf2 (ParadevAI#3403) | #161 (PR#3) | Cmd+Alt+Arrow spatial pane focus |
| b18a00c (ParadevAI#3421) | #159 (PR#1) | v2 right sidebar toggle reactive |
| 3dd1de2 (ParadevAI#3420) | #161 (PR#3) | v2 diff viewer + tab title resolution |
| b42a114 (ParadevAI#3418) | #159 (PR#1) | CodeMirror hotkey enablement |
| c925f4d (ParadevAI#3422) | #160 (PR#2) | unbound defaults + restore prev/next tab/workspace |
| bb12c09 (ParadevAI#3419) | #163 (PR#5) | version bump 1.5.3 |
| 47efa73 (ParadevAI#3432) | #159 (PR#1) | pending/update-required error selectable |

Fork-specific features preserved:
- auto-updater (IS_FORK, GitHub Releases API)
- QuitMode/cleanupMainWindowResources lifecycle
- GitHubSyncService, SpreadsheetViewer
- BROWSER_RELOAD / BROWSER_HARD_RELOAD / SEARCH_IN_FILES hotkeys
- HotkeyCategory "Browser"
- v1 deep-link navigation (useSearch/WorkspaceSearchParams)
- v1 tRPC-based PREV/NEXT_WORKSPACE handlers
- v1 CLOSE_TERMINAL/CLOSE_TAB hotkey handlers
- v2 extra state (rightSidebarOpenViewWidth, showPresetsBar)
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