Skip to content

Conversation

6cobi
Copy link
Contributor

@6cobi 6cobi commented Mar 15, 2025

Description:
This PR addresses Issue #22, where the DevTools window was detaching instead of docking to the right panel when inspecting elements. The issue was caused by webContents.openDevTools({ mode: "right" }) not applying correctly.

Changes Made:

  • Explicitly ensure that webContents is correctly targeted for the main browser window and webviews.
  • Ensure that DevTools open only if they are not already open.

Steps to Test:

  1. Run the application.
  2. Right-click on any element and select "Inspect".
  3. Verify that DevTools open in the right panel instead of detaching.
  4. Test the behavior in both the main window and any webview instances.

Screenshot
Screenshot 2025-03-14 at 11 42 27 PM

Copy link
Member

@akhileshthite akhileshthite left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.
Screenshot 2025-03-14 at 10 22 32 PM

DevTools incorrectly target the main Electron window (file://) instead of the webview's content (e.g., https://peersky.p2plabs.xyz).

Ensure DevTools open for the webview's webContents instead of the main window index.html.

@6cobi
Copy link
Contributor Author

6cobi commented Mar 15, 2025

Hi,

I've spent a couple more hours trying to resolve this.
I looked at PRs from other projects, such as:
electron/electron#17168
Here, I tried reloading, adding a timeout/delay, and closing DevTools before opening them, but none of these approaches worked.

I also checked the demo of the Electron Documentation using devtool for webview but failed to:
https://github.com/electron/electron/blob/00fc8066de5c6617769567ec0369f10a271426f8/docs/api/web-contents.md

Additionally, I logged the method that checks if DevTools are open, and it returns false, even though DevTools aren’t actually opening. I also tried using a preload script, but I still couldn’t see the actual DevTools.

From what I’ve tested, this seems to be a known issue with webviews in Electron. Based on responses from some developers who had similar issues and AI tools, most people end up using either "undocked" or "detach" mode as a workaround.
I've also posted a question in Electron's Discord help forum and hope to get some guidance soon.

I would really appreciate any help or insights you could provide. Thank you in advance!

@akhileshthite akhileshthite added the help wanted Extra attention is needed label Mar 16, 2025
@akhileshthite
Copy link
Member

Hi,

I've spent a couple more hours trying to resolve this. I looked at PRs from other projects, such as: electron/electron#17168 Here, I tried reloading, adding a timeout/delay, and closing DevTools before opening them, but none of these approaches worked.

I also checked the demo of the Electron Documentation using devtool for webview but failed to: https://github.com/electron/electron/blob/00fc8066de5c6617769567ec0369f10a271426f8/docs/api/web-contents.md

Additionally, I logged the method that checks if DevTools are open, and it returns false, even though DevTools aren’t actually opening. I also tried using a preload script, but I still couldn’t see the actual DevTools.

From what I’ve tested, this seems to be a known issue with webviews in Electron. Based on responses from some developers who had similar issues and AI tools, most people end up using either "undocked" or "detach" mode as a workaround. I've also posted a question in Electron's Discord help forum and hope to get some guidance soon.

I would really appreciate any help or insights you could provide. Thank you in advance!

Ah, I see.
Thanks for your efforts, I truly appreciate it.

It might be worth checking how Agregore is handling DevTools:
https://github.com/AgregoreWeb/agregore-browser/blob/617e9f6968694ca6d72c0edaa79067fa5c186f16/app/actions.js#L113

https://github.com/AgregoreWeb/agregore-browser/blob/617e9f6968694ca6d72c0edaa79067fa5c186f16/app/actions.js#L160

@akhileshthite akhileshthite added the bug Something isn't working label Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants