Skip to content

fix(desktop): deny new window creation on shift-click - #384

Merged
Astro-Han merged 1 commit into
devfrom
pawwork/fix-shift-click-new-window
May 2, 2026
Merged

fix(desktop): deny new window creation on shift-click#384
Astro-Han merged 1 commit into
devfrom
pawwork/fix-shift-click-new-window

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add webContents.setWindowOpenHandler({ action: 'deny' }) in createMainWindow() to prevent Electron from spawning new windows on shift+click or window.open() calls.
  • Root cause: SolidJS Router intentionally skips preventDefault() when shiftKey is pressed, letting the browser/Electron handle the click — which defaults to opening a new window.
  • Fix is at the Electron layer so it covers all <a> tag shift+clicks, not just sidebar conversation items.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the desktop application's window management to prevent new windows or tabs from being opened when triggered from within the application. This change enhances application stability and ensures a more consistent and predictable user experience during regular usage and interaction with the application.

@coderabbitai

coderabbitai Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7d164141-ba99-4e41-95f2-bb4f895a9e84

📥 Commits

Reviewing files that changed from the base of the PR and between 8bf85c1 and d9f0825.

📒 Files selected for processing (1)
  • packages/desktop-electron/src/main/windows.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-electron/src/main/windows.ts

📝 Walkthrough

Walkthrough

The PR adds a window open handler to the Electron main window that denies any renderer-initiated attempts to open new windows or tabs, preventing uncontrolled window creation from the renderer process.

Changes

Window Security Handler

Layer / File(s) Summary
Window Handler Installation
packages/desktop-electron/src/main/windows.ts
createMainWindow() registers setWindowOpenHandler to deny all renderer-initiated window/tab open requests before loading the window.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested labels

bug, P2, desktop

Poem

🐰 A window tries to knock upon the pane,
But the handler says "Not today, my friend!"
No popup tabs shall cause the renderer pain,
The open requests meet their swift end.
Security hops through, safe and sound! 🔐

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing multiple required template sections including Why, Related Issue, Review Focus, Risk Notes, How To Verify, and Checklist. Complete the PR description by adding the missing template sections: Why, Related Issue, Human Review Status, Review Focus, Risk Notes, How To Verify, Screenshots/Recordings, and the Checklist.
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.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preventing new window creation on shift-click at the Electron layer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 pawwork/fix-shift-click-new-window

Review rate limit: 8/10 reviews remaining, refill in 8 minutes and 29 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@Astro-Han
Astro-Han force-pushed the pawwork/fix-shift-click-new-window branch from 8bf85c1 to d9f0825 Compare May 2, 2026 12:41

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the version across multiple packages to 2026.5.2.2 and introduces a window opening handler in the Electron main process that denies all requests. Feedback points out that the versioning scheme is not compliant with Semantic Versioning (SemVer), which may interfere with update tools like electron-updater. Furthermore, the global denial of window opening is flagged as potentially disruptive to external links and authentication flows, with a recommendation to implement URL filtering instead.

I am having trouble creating individual review comments. Click here to see my feedback.

packages/desktop-electron/src/main/windows.ts (91)

high

Denying all window open requests via setWindowOpenHandler is a broad stroke that may break legitimate functionality. Specifically:

  1. External Links: Links to external websites (e.g., documentation, help pages) that use target="_blank" or are shift-clicked will now do nothing instead of opening in the system browser.
  2. OAuth/Authentication: If the application or any of its dependencies rely on window.open() for authentication flows (like GitLab or Poe auth), they will be blocked.

Consider filtering the URL and only denying internal navigation while allowing external URLs to open in the system browser using shell.openExternal(url) (which would require adding shell to the electron imports).

  win.webContents.setWindowOpenHandler(({ url }) => {
    // TODO: Handle external URLs (e.g., via shell.openExternal)
    return { action: "deny" }
  })

packages/desktop-electron/package.json (4)

high

The version 2026.5.2.2 is not a valid Semantic Version (SemVer). Since this package depends on electron-updater, using a non-standard version string may break update checks. Please ensure this format is intended for this specific release line, as workspace packages may follow different release lines.

References
  1. When performing a version bump, only update packages that belong to the specific release line being updated. Do not assume all workspace packages follow the same release line.

@Astro-Han
Astro-Han merged commit 6772f6e into dev May 2, 2026
27 checks passed
@Astro-Han
Astro-Han deleted the pawwork/fix-shift-click-new-window branch May 2, 2026 12:53
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