GeezerVison is showing github.com — fix(app): stop model selector flyout placement loop at fractional zoom by neriousy · Pull Request #65240 · anomalyco/opencode
Conversation
Issue for this PR
Fixes #65138
Type of change
- Bug fix
- New feature
- Refactor / code improvement
- Documentation
What does this PR do?
Opening the desktop model selector at non-100% zoom (zoomLevel != 1) caused an infinite synchronous placement loop (RangeError: Maximum call stack size exceeded) and a 1–2s UI freeze when hovering models.
Two issues combined to create the loop:
- The post-render
createEffect in packages/app/src/providers/models/select-dialog.tsx tracked flyout() directly, so every placed coordinate update re-triggered the effect.
measure() subtracted rect.left - parseFloat(rendered.style.left) with zero tolerance (x || y), and the placed transition compared coordinates with ===. Under fractional zoom, Chromium quantizes getBoundingClientRect() to device pixels / LayoutUnits, leaving sub-pixel residuals that never settled to 0 and bounced back and forth until the call stack overflowed.
Changes:
- Added
selectFlyoutPlacement in packages/app/src/providers/models/select-dialog-machine.ts and tracked it with a memo keyed on { attempt, id } (plus row/usage reactivity) so placed coordinate updates and menu highlights never re-trigger the post-render measurement effect.
- Added
FLYOUT_POSITION_EPSILON_PX = 0.5 and correctFlyoutPosition so sub-pixel rounding residuals are ignored while preserving containing-block offsets (e.g. contain: layout previews) and CSS zoom scaling.
- Updated the
placed state transition to treat positions within < 0.5px on both axes as unchanged.
- Added unit tests in
packages/app/src/providers/models/select-dialog-machine.test.ts and a Playwright regression test in packages/app/e2e/regression/mobile-model-pickers.spec.ts covering 90%, 100%, 110%, and 125% zoom.
How did you verify your code works?
- Reproduced the bug before the fix with the new Playwright test in
packages/app/e2e/regression/mobile-model-pickers.spec.ts (failed at 0.9 zoom with 15,347 getBoundingClientRect calls on [data-slot="model-dialog-flyout"]).
- After the fix:
bun test --conditions=solid --preload ../ui/test/solid-jsx.ts --preload ./happydom.ts src/providers/models/select-dialog-machine.test.ts --rerun-each 10 (330/330 passed)
bun run test in packages/app (2,850 unit + 378 browser tests passed)
- Built-mode Playwright regression test (
mobile-model-pickers.spec.ts, -g "fractional zoom" --repeat-each=10 --workers=5 --retries=0: 10/10 passed, and full mobile-model-pickers.spec.ts with PLAYWRIGHT_FULLY_PARALLEL=1 --workers=5 --retries=0: 19/19 passed)
bun typecheck and bun run typecheck:tsc in packages/app
bun run check at repository root (all 35 tasks passed)
Screenshots / recordings
No visual design change; bug fix for fractional zoom freeze/stack overflow.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I ran the new Playwright regression test against both checkouts in headless Chromium:
- Base: it loops, with 3,373
getBoundingClientRect reads on the flyout against the limit of 40.
- This PR: the whole
mobile-model-pickers.spec.ts file passes, 19 of 19.
The select-dialog-machine unit tests and typecheck:tsc pass. I couldn't test the Electron app's own zoom on Windows; the test simulates zoom with CSS zoom. The effect no longer depends on position, so the loop can't happen with either kind of zoom.
The public API is unchanged; the new exports stay inside packages/app.
I have no blocking concerns.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I verified 6b592430 in Chromium 156 on macOS with actual tab zoom at 90%, 100%, 110%, and 125%. Using the local workspace fixture, I hovered across two models and selected the second model’s max variant at each zoom level. Each run made nine flyout rectangle reads and reported zero page errors. Native Windows Desktop testing remains open.
AI-assisted verification.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 21, 2026
|
Independent verification of the placement-loop approach: I reproduced the issue with real production model names on macOS OpenCode Desktop 2.3.2, then tested an independently written, similar local patch that stops the post-render effect from reacting to its own coordinate writes. This comment is not a claim that I built this PR's exact commit or that an installed production build has been patched.
Two separate full Electron development processes (Electron 44.9.1, v2.3.2 source tree, stock 2.3.2 CLI, isolated HOME/config/database) were used to avoid hot-reload contamination: one kept the unpatched component, the other kept the local bounded-remeasurement component. No real account, credentials, or model-generation requests were used.
| Real-name catalog, 110% desktop zoom |
Unpatched |
Patched |
| Composer button open |
301.389 ms |
26.471 ms |
⌘ + ' open |
316.079 ms |
29.528 ms |
Layout / UpdateLayoutTree inside each dispatch |
3,075 / 3,080 |
3 / 3 |
The catalog has 125 names in 9 groups and 436 variants. Repeating it with every model name padded to 160, 320, and 640 characters did not introduce a new failure mode:
| Name length |
Unpatched mouse / shortcut |
Patched mouse / shortcut |
| 160 chars |
218.407 / 210.955 ms |
19.463 / 24.677 ms |
| 320 chars |
191.205 / 193.078 ms |
19.936 / 24.188 ms |
| 640 chars |
198.994 / 206.599 ms |
21.779 / 24.938 ms |
Patched runs had 3 layouts and no page errors. The unpatched padded-name runs each had 6 Maximum call stack size exceeded errors.
Additional interaction A/B, relevant to #64570:
- Four hover switches: 289.926–301.413 ms unpatched, 33.872–154.463 ms patched.
mousemove dispatch: 177.305–183.678 ms → 0.904–1.518 ms.
- Six successive wheel events, largest dispatch: 219.782 ms → 0.218 ms. Final scroll/thumb positions match the scroll ratio on both builds; the unpatched build delays those updates behind placement work.
- Three reverse-direction hovers: 38.825–54.449 ms to the correct flyout, 1.139–1.996 ms main-thread
mousemove, zero errors.
The 19 model-picker browser tests and 30 placement-state tests passed locally with the local patch; the regression case made 22 flyout rectangle reads before it and 1 after, including the 6px bottom clearance assertion. These measurements support the root-cause analysis in #65138 and #64570 and the approach of not letting position writes recursively trigger placement measurement. Packaged production installation and real Console sign-in remain unverified.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|