Repository navigation
Conversation
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
Looks correct from reading the code. All app windows share one Electron session, so setting the permission handlers once per session and checking a set of open window ids fixes the case where only the newest window keeps clipboard and notification access. Embedded views and other web content are never added to the set, so they stay denied as before. Windows are removed from the set on closed, and a renderer crash or reload keeps the same webContents, so its id stays valid.
I couldn't run the desktop app here to reproduce it with two windows. Typecheck and bun test in packages/desktop pass (130 pass, 1 skip).
Public API: unchanged (desktop main-process internals only).
No blocking concerns.
Permission handlers live on the shared session, so registering one per window replaced the previous handler and only the newest window passed the webContents id check. Clipboard writes from older windows rejected with NotAllowedError. Keep the live webContents ids in one set and register the handlers once per session.
3fa6082 to
6d5b6f7
Compare
Issue for this PR
Closes #51748
Type of change
What does this PR do?
allowRendererPermissionsregistered the session permission handlers per window while keying them on that window'swebContents.id. The handlers live on the session, so opening another window replaced them and every older window then failed the id check. That breaksnavigator.clipboard.writeTextin all but the newest window, which is why the markdown code block copy button silently does nothing there.The handlers are now registered once per session and check the live
webContentsids kept in a set, adding ids on window creation and removing them on close. Every app window keeps clipboard and notification access.Also narrowed the unused
openExternalURLcallback return fromunknowntovoid, becauselint:changedlints the whole touched file and the repo disallowsunknownreturns.How did you verify your code works?
navigator.clipboard.writeTextwithNotAllowedError: Write permission denied; after the fix the permission check returns true for both windows and false for an unknownwebContents.bun testinpackages/desktop(130 pass, 1 skip).bun run typecheckinpackages/desktop.Screenshots / recordings
N/A, no UI change.
Checklist