Skip to content

fix(work-panel): keep native tab menus above Browser - #1924

Merged
vastsa merged 5 commits into
mainfrom
fix/work-panel-native-tab-menu-publish
Oct 28, 2026
Merged

vastsa merged 5 commits into
mainfrom
fix/work-panel-native-tab-menu-publish

Conversation

@vastsa

@vastsa vastsa commented Oct 27, 2026

Copy link
Copy Markdown
Owner

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

  • Desktop typecheck passed.
  • Targeted work-panel/window-menu tests: 56 passed.
  • node scripts/check-style-tokens.mjs passed.
  • node scripts/e2e-work-panel-tab-close.mjs passed in Electron, including the Browser-menu visibility path.
  • electron-vite build passed.
  • PR-base check passed against current origin/main.

Specs

  • Updated docs/spec/04-ux/08-component-spec.md and E2E-056 in docs/spec/06-delivery/04-e2e-test-plan.md.

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.
Copilot AI balanced review requested due to automatic review settings October 27, 2026 13:56

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@vastsa

vastsa commented Oct 27, 2026

Copy link
Copy Markdown
Owner Author

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 muzimu217 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.

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:

  1. 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 Browser WebContentsView is still composited above the renderer — the menu opens downward from the strip into that area. The e2e only exercises the plugin-active direction (runPluginViewMenuLayerPath sets 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.

  2. 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 .then never runs. It is voided so nothing blocks, but window.once("closed", () => resolve(selected)) costs nothing.

  3. Coordinate units. event.clientX/Y are CSS pixels while menu.popup takes DIP; those agree at zoom 1 and diverge under Cmd +/- zoom, which would offset the menu from the pointer.

  4. closeAllTabsAndFocus is 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.
@vastsa
vastsa merged commit 24b7f4e into main Oct 28, 2026
5 of 6 checks passed

vastsa commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

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 24b7f4ee6b6232a361ecc1961f9923b54c42c6dc.

@vastsa
vastsa deleted the fix/work-panel-native-tab-menu-publish branch November 6, 2026 04:34
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.

3 participants