Repository navigation
fix(work-panel): keep native tab menus above Browser - #1924
Conversation
Temporarily hide the composited plugin view while its tab menu is open, then restore it without changing bounds. This prevents Browser chrome from covering renderer menu items.
Use a Main-owned native popup over plugin WebContentsViews instead of hiding the entire Browser surface while a renderer menu is open. Preserve page visibility and validate selected actions against the originating session.
|
Thanks for handling the tricky Browser layering case — the visibility E2E is especially helpful. One small polish request: regular tabs use the app-styled context menu, while an active Browser/plugin view uses an OS-native popup, so the tab-menu experience can feel visually different depending on the active surface. Could you take another pass at the presentation consistency (at least labels, ordering, and enabled states) while keeping the menu above the native Browser view? If the platform-native styling is an intentional tradeoff, a brief note would help clarify it. |
muzimu217
left a comment
There was a problem hiding this comment.
Read the IPC path, the stale-selection guard, and the e2e. The security-relevant parts are solid, and the stale-selection handling is the right shape.
The main-side boundary is properly closed. assertMainWindowSender plus the window !== mainWindow check pins the caller; parseWorkPanelTabMenuRequest rejects non-objects, requires three sanitized labels (control characters collapsed, 256-char cap), a boolean and two finite non-negative coordinates, and clamps the point to getContentSize(). Most importantly the actions are fixed in main — the renderer supplies labels only, so a compromised renderer cannot turn this into an arbitrary command channel. Returning the action id instead of executing anything in main is the right split.
The stale-selection re-check is correct. openNativeTabMenu captures sessionId before the await and, after the menu resolves, re-reads the store and bails when activeSessionId changed or the tab no longer exists. That covers both "user switched conversation while the menu was open" and "tab closed underneath it".
Four things worth a look, none blocking:
-
The branch condition may leave the mirror case uncovered. The native path is chosen when
activeTab?.kind === "plugin", but the occlusion argument applies to whichever native view is on screen. With the Browser tab active and a plugin tab right-clicked, the code takes the HTML menu path while the BrowserWebContentsViewis still composited above the renderer — the menu opens downward from the strip into that area. The e2e only exercises the plugin-active direction (runPluginViewMenuLayerPathsets the active tab to a plugin view), so if the mirror case is actually fine, it is fine for a reason the test does not state. Either widen the condition to "a native view is visible" or add the mirror case to the probe. -
The promise can hang if the window goes away.
menu.popup's callback is the only resolver; if the window is destroyed while the menu is open, the callback may never fire and the renderer's.thennever runs. It isvoided so nothing blocks, butwindow.once("closed", () => resolve(selected))costs nothing. -
Coordinate units.
event.clientX/Yare CSS pixels whilemenu.popuptakes DIP; those agree at zoom 1 and diverge under Cmd +/- zoom, which would offset the menu from the pointer. -
closeAllTabsAndFocusis not guarded by the tab-existence check — correct for "close all", just noting the asymmetry is deliberate rather than an oversight.
The tab-strip changes (keeping the active tab's close control inside the strip after resize, revealing a partially visible tab before exposing its close action) are orthogonal to the menu work and read fine; they match the geometry probe that already exists in this script.
Integrate the contributor branch with the current main line so its native tab-menu behavior can be validated against the live work-panel lifecycle.
Native menu positions are renderer CSS pixels, so app zoom must be applied before Main clamps the popup to window DIPs. Resolve pending menu requests when the owning window closes to avoid retaining a dead renderer request. Exercise request validation, zoom conversion, window-close settlement, and the Browser-active sibling-tab path; document the native styling and IPC contract in both language specs.
|
Thanks for the Browser layering fix. I verified the native menu path and added the zoom-to-DIP coordinate conversion plus window-close settlement with regression coverage. The relevant tests and isolated Electron scenario passed, and the PR is now merged as |
Summary
Keep the Browser page visible while a work-panel tab context menu is open by using a Main-owned native popup for plugin-view tabs. Validate the IPC request and re-check the session/tab after the native menu returns so stale selections cannot affect a switched conversation. Also keep the active tab close control inside the scrollable strip after resize and reveal partially visible tabs before exposing their close action.
Validation
node scripts/check-style-tokens.mjspassed.node scripts/e2e-work-panel-tab-close.mjspassed in Electron, including the Browser-menu visibility path.electron-vite buildpassed.origin/main.Specs
docs/spec/04-ux/08-component-spec.mdand E2E-056 indocs/spec/06-delivery/04-e2e-test-plan.md.