experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(page): toggleMaximize captures window bounds for exact restore

+49 -3
+49 -3
app/page/page.js
··· 129 129 // --- Maximize state --- 130 130 let isMaximized = false; 131 131 let preMaximizeBounds = null; // { x, y, width, height } screen bounds before maximize 132 + // Raw WINDOW bounds captured before maximize (used to restore to the exact same 133 + // window rect, bypassing computeWindowBounds margin math which may differ from 134 + // how the window was originally sized — e.g., in headless test mode where the 135 + // canvas margin adjustment in ipc.ts window-open is skipped). 136 + let preMaximizeWindowBounds = null; 132 137 133 138 // NOTE: The window always includes navbar space (NAVBAR_HEIGHT) to avoid 134 139 // visual jumps on show/hide. Navbar visibility is CSS-only — no window resize. ··· 501 506 } 502 507 503 508 if (isMaximized) { 504 - // Restore from maximize 509 + // Restore from maximize. Use the saved WINDOW bounds directly — they 510 + // were captured from the live window before maximize, so restoring with 511 + // them guarantees byte-for-byte bounds equivalence regardless of any 512 + // canvas margin adjustments (which may or may not be applied in 513 + // headless/test environments). 505 514 isMaximized = false; 506 515 document.body.classList.remove('maximized'); 507 516 517 + const restoreWindowBounds = preMaximizeWindowBounds; 508 518 if (preMaximizeBounds) { 509 519 screenBounds.x = preMaximizeBounds.x; 510 520 screenBounds.y = preMaximizeBounds.y; ··· 512 522 screenBounds.height = preMaximizeBounds.height; 513 523 preMaximizeBounds = null; 514 524 } 525 + preMaximizeWindowBounds = null; 515 526 516 527 updatePositions(); 517 528 centerColumn.style.opacity = '0'; 518 - await api.window.setBounds(computeWindowBounds(screenBounds)); 529 + if (restoreWindowBounds) { 530 + await api.window.setBounds(restoreWindowBounds); 531 + } else { 532 + await api.window.setBounds(computeWindowBounds(screenBounds)); 533 + } 519 534 centerColumn.style.opacity = '1'; 520 535 updateUrlParams(); 521 536 return; ··· 537 552 width: screenBounds.width, 538 553 height: screenBounds.height, 539 554 }; 555 + // Also capture the live WINDOW bounds — restoring via these bypasses 556 + // any computeWindowBounds margin math so the restored window matches 557 + // exactly what the user had before maximizing. 558 + try { 559 + const windowBoundsResult = await api.window.getBounds(); 560 + if (windowBoundsResult && windowBoundsResult.success !== false) { 561 + preMaximizeWindowBounds = { 562 + x: windowBoundsResult.x, 563 + y: windowBoundsResult.y, 564 + width: windowBoundsResult.width, 565 + height: windowBoundsResult.height, 566 + }; 567 + } 568 + } catch { 569 + preMaximizeWindowBounds = null; 570 + } 540 571 541 572 isMaximized = true; 542 573 document.body.classList.add('maximized'); ··· 811 842 if (isMaximized && preMaximizeBounds) { 812 843 const restoreW = preMaximizeBounds.width; 813 844 const restoreH = preMaximizeBounds.height; 845 + const savedWindowBounds = preMaximizeWindowBounds; 814 846 isMaximized = false; 815 847 document.body.classList.remove('maximized'); 816 848 ··· 820 852 screenBounds.width = restoreW; 821 853 screenBounds.height = restoreH; 822 854 preMaximizeBounds = null; 855 + preMaximizeWindowBounds = null; 823 856 824 857 updatePositions(); 825 - api.window.setBounds(computeWindowBounds(screenBounds)); 858 + // If we captured raw window bounds before maximize, restore to those exact 859 + // dimensions so the window matches its pre-maximize size byte-for-byte. 860 + // Only override position (centered on cursor); keep saved width/height. 861 + if (savedWindowBounds) { 862 + const computed = computeWindowBounds(screenBounds); 863 + api.window.setBounds({ 864 + x: computed.x, 865 + y: computed.y, 866 + width: savedWindowBounds.width, 867 + height: savedWindowBounds.height, 868 + }); 869 + } else { 870 + api.window.setBounds(computeWindowBounds(screenBounds)); 871 + } 826 872 } 827 873 isDragging = true; 828 874 dragStartScreenX = screenX;