Frontmatter
| id | 8121 |
| title | Fix popup window sizing: race condition, caching, and rounding |
| state | Closed |
| labels | bugairefactoring |
| assignees | tobiu |
| createdAt | Dec 16, 2025, 2:39 PM |
| updatedAt | Dec 16, 2025, 3:35 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8121 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 16, 2025, 3:35 PM |
Fix popup window sizing: race condition, caching, and rounding
tobiu assigned to @tobiu on Dec 16, 2025, 2:39 PM

tobiu
Dec 16, 2025, 3:33 PM
Input from Gemini:
✦ ### Final Resolution & Insights
We encountered a persistent issue where popup windows would resize unpredictably (e.g., jumping from 156px to 219px, or getting stuck at 156px) even up to 300ms after opening. This was caused by the browser attempting to adapt the window size to the content:
- The Problem: When requesting a window with
height=219, the browser interprets this as the inner height (viewport). However, due to browser chrome (headers/toolbars), the effective outer height becomes larger (e.g., ~282px). If the dragged content (219px) was then inserted into a window where the inner height was reduced by chrome (e.g., 156px), the browser would sometimes auto-expand the window to fit the content, causing layout shifts.- The Fix ("Give Size"): We implemented a strategy to immediately call
openedWindow.resizeTo(openedWindow.outerWidth, openedWindow.innerHeight)upon creation. This effectively forces the window's outer height to match the current inner height.
- This locks the dimensions, ensuring the popup's total footprint exactly matches the drag proxy.
- It prevents the browser from auto-resizing based on content insertion later in the lifecycle.
New Feature:
useTotalHeightWe added an optionaluseTotalHeightconfig toNeo.Main.windowOpen(defaults totrue).
- Concept: This acts similarly to
box-sizing: border-boxin CSS.- Behavior: It ensures the requested height is treated as the total outer height of the window, ignoring the size of browser header tools. This guarantees that a 219px drag proxy results in exactly a 219px popup window, preserving the visual continuity of the drag operation.
tobiu closed this issue on Dec 16, 2025, 3:35 PM
We encountered and fixed multiple issues related to drag-and-drop popup window sizing and management.
1. Race Condition in DragProxyContainer Sizing
DragProxyContainer(used inSortZone) was created withlayout: 'fit'but initially empty. Its DOM element would render with a default/minimal height (e.g., 155px) before the dragged content (e.g., 220px) was inserted.DragDropaddon would sometimes capture this initial "empty" height duringdrag:move, causingdragBoundaryExitevents to report incorrectproxyRectdimensions.src/draggable/DragZone.mjsto explicitly setconfig.heightandconfig.widthon theDragProxyContainerat creation time, matching the dragged element's dimensions.2. Browser Window Dimension Caching
window.namecaused browsers (like Chrome) to ignore the newwindowFeatures(height/width) and instead reuse the cached dimensions from the previous session. This persisted the incorrect "155px" height even after the race condition was fixed.src/Main.mjsto usecrypto.randomUUID()for the actual browser window target name. This ensures everywindowOpencall creates a fresh window context, bypassing the cache. We also enhanced the internalopenWindowsmap to store{win, targetName}to maintain correct logical references.3. Fractional Window Dimensions
219.5px) were being passed towindow.open.windowFeatures. Passing floats can lead to parsing errors or unpredictable fallback behaviors.apps/agentos/view/StrategyPanelController.mjsto round all calculated dimensions (height,width,left,top) usingMath.round()before passing them towindowOpen.Changes:
src/draggable/DragZone.mjs: Explicitly set container proxy height.src/Main.mjs: Implemented UUID-based window targeting and refactoredopenWindowsmap.apps/agentos/view/StrategyPanelController.mjs: Added rounding to window feature calculations.