Skip to content

fix(ui): stop the reveal reflow from dismissing popovers - #10487

Merged
nwparker merged 2 commits into
mainfrom
nwparker/popover-viewport-guard
Jul 25, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/popover-viewport-guard

Conversation

@nwparker

@nwparker nwparker commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

forceRepaint runs on every window reveal, resume, and restore. Both paths it can take fire a real Chromium resize event at the renderer:

  • macOS 26 (reflowRendererViewport) — nudges the emulated device scale factor. innerWidth/innerHeight are unchanged; the resize is a phantom.
  • Pre-Tahoe (createMainWindow.ts:86,97) — setSize(width + 1, height) then back. A genuine 1px change.

Transient UI bound directly to resize treats the phantom as user intent. On macOS 26, the selected-text copy menu and the rich-markdown link bubble both dismiss on every window restore, with no user interaction.

Fix

addViewportSizeChangeListener caches innerWidth/innerHeight and invokes the callback only when they actually differ, rebasing the cache each time it fires. Wired into both consumers in place of their bare window.addEventListener('resize', …).

The guard compares actual dimensions rather than counting events, so it is indifferent to how many resizes a given reflow emits.

Verification

Measured in real Electron 43.1.0 on macOS 26.3.1 (Darwin 25.3.0):

trigger resize events dimensions
scale-factor reflow (macOS 26) 1 900×668 → 900×668 (unchanged)
setSize jiggle (pre-Tahoe) 2 901×668, then 900×668
invalidate() alone 0 —

Tests: 12 across three files — 5 unit (viewport-size-change-listener.test.ts), 4 component (SelectedTextCopyMenu.test.tsx), 3 component (RichMarkdownLinkBubble.render.test.tsx). Component tests render the real components under happy-dom and assert the menu/bubble survives a same-size resize but still dismisses on a real one.

Mutation-checked — each of these fails the suite:

  • revert either consumer to a bare resize listener → the same-size test fails
  • drop the listener entirely → both real-resize tests fail
  • remove the dimension guard from the hook → 3 unit failures

Typecheck clean (all three projects); 1182 tests pass across src/main/window/, the hook, and both component dirs.

Limits

This fixes the macOS 26 path only. Pre-Tahoe still dismisses these popovers on reveal, and deliberately so: the setSize jiggle is a real 1px viewport change, so no renderer-side dimension guard can filter it without also swallowing genuine user resizes. Closing that would mean changing forceRepaint's jiggle itself — out of scope here, and disclosed rather than papered over.

Related

Follow-up to #10473 and #10485, which fixed the main-thread deadlock and the terminal re-gridding respectively. This closes the last renderer-visible side effect of the reflow that I could reproduce.

Made with Orca 🐋

nwparker and others added 2 commits July 24, 2026 20:53
The main process reflows the renderer on every reveal, resume, and restore.
On macOS 26 that nudges the emulated device scale factor, and Chromium fires
a real window resize for it even though innerWidth/innerHeight are identical.
Anything bound directly to resize treated that as a user resize.

The selection copy menu and the markdown link bubble both dismiss on resize
unconditionally, so they closed on their own whenever the window was revealed
or restored. Gate both on an actual dimension change.

Only fixes the macOS 26 path: the pre-Tahoe repaint jiggles the native frame
by a real pixel, so the renderer sees a genuine dimension change and no
change-detection guard can — or should — filter it.

Co-authored-by: Orca <help@stably.ai>
Pins both halves of the wiring: a same-size resize must not dismiss, a real
one still must. Mutation-checked — reverting to a bare resize listener, or
dropping the listener entirely, each fails the suite.

Co-authored-by: Orca <help@stably.ai>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 89240646-9bb5-46ac-ace1-1ff0539087e3

📥 Commits

Reviewing files that changed from the base of the PR and between 4694278 and 3dbbba4.

📒 Files selected for processing (6)
  • src/renderer/src/components/SelectedTextCopyMenu.test.tsx
  • src/renderer/src/components/SelectedTextCopyMenu.tsx
  • src/renderer/src/components/editor/RichMarkdownLinkBubble.render.test.tsx
  • src/renderer/src/components/editor/RichMarkdownLinkBubble.tsx
  • src/renderer/src/hooks/viewport-size-change-listener.test.ts
  • src/renderer/src/hooks/viewport-size-change-listener.ts

📝 Walkthrough

Walkthrough

Adds addViewportSizeChangeListener, which filters resize events by comparing viewport width and height. SelectedTextCopyMenu and RichMarkdownLinkBubble now use it for dismissal handling and cleanup. New tests cover listener behavior, unchanged and changed viewport sizes, subsequent real resizes, and listener removal.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the problem, fix, verification, and scope, but it omits required template sections. Add the missing Screenshots, Testing checklist/results, AI Review Report, Security Audit, and Notes sections, or explicitly mark no visual change.
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 matches the main change: fixing popovers dismissed by reveal reflow resize behavior.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nwparker
nwparker merged commit cafa958 into main Jul 25, 2026
2 checks passed
@nwparker
nwparker deleted the nwparker/popover-viewport-guard branch July 25, 2026 04:12
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
)

* fix(ui): stop the reveal reflow from dismissing popovers

The main process reflows the renderer on every reveal, resume, and restore.
On macOS 26 that nudges the emulated device scale factor, and Chromium fires
a real window resize for it even though innerWidth/innerHeight are identical.
Anything bound directly to resize treated that as a user resize.

The selection copy menu and the markdown link bubble both dismiss on resize
unconditionally, so they closed on their own whenever the window was revealed
or restored. Gate both on an actual dimension change.

Only fixes the macOS 26 path: the pre-Tahoe repaint jiggles the native frame
by a real pixel, so the renderer sees a genuine dimension change and no
change-detection guard can — or should — filter it.

Co-authored-by: Orca <help@stably.ai>

* test(ui): cover the reveal-reflow guard at the component level

Pins both halves of the wiring: a same-size resize must not dismiss, a real
one still must. Mutation-checked — reverting to a bare resize listener, or
dropping the listener entirely, each fails the suite.

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
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