Repository navigation
Clear pane-zoom state on the remaining relayout routes - #18518
Merged
Merged
Conversation
Three routes re-lay-out the columns without going through the zoom machinery, leaving PaneManager's zoom bookkeeping live while the layout looks normal -- and a stale zoom re-zooms the next pane that raises itself (the #18444 cascade): - zoomColumn, asked for a *different* column while a pane zoom is tracked, fell through to the per-column branches, which never clear the pane-zoom bookkeeping. View > Panes then showed two checkmarks at once, and the next raised pane took over the window. The new guard ends the pane zoom first and re-applies the requested column zoom once the restore has settled. - showSidebar's zoom guard covered only maximizedWindow_, so hiding the sidebar while its *column* was zoomed handed the freed width to the center column and left the right column at 1px -- Environment / Plots / Help gone with nothing check-marked anywhere. - Adding a source column (newSourceColumn, openSourceDocNewColumn, and openFileInNewColumn) drives MainSplitPanel.addLeftWidget, which rebuilds the split panel and re-applies persisted widths, undrawing any active zoom. The shared guard keys on the zoom bookkeeping (widgetSizePriorToZoom_), not getZoomedColumn(): that method reads widths, so a splitter dragged to the edge by hand reads the same as a zoom command, and restoring would clobber the custom widths the user chose. The bookkeeping also covers the column zooms getZoomedColumn() misreads (collapsed columns hold 1px, not 0, while the sidebar is visible). The three new tests fail before this change and pass after it. Addresses #18448
restoreLayout cleared maximizedWindow_ only on the last line of restoreSavedLayout, but restorePaneStateToDefault runs first and its state changes call onBeforeShow on the panes they reveal. A tab that raises itself from there re-enters the WindowEnsureVisibleEvent handler, which would see the still-set maximizedWindow_ and start a new zoom in the middle of the restore. Snapshot the bookkeeping at the top of restoreLayout, clear it, and thread the snapshot through restoreSavedLayout / restorePaneLayout / restoreColumnLayout instead of re-reading the fields. The field clearing is split out of invalidateSavedLayoutState so the UI updates it also performs (splitter, menu checkmarks, ChatPaneActiveEvent) keep their current timing, after the restored widths are applied. Also remove isAnimating_: it guarded toggleWindowZoom against re-entrancy but nothing ever assigned it, so the guard could never fire. The hazard it looked like it covered is the one addressed above. The unused no-arg restorePaneLayout() overload goes too. Addresses #18448
LogicalWindow.onEnsureHeight converted EnsureHeightEvent.MAXIMIZED and NORMAL into WindowStateChangeEvents fired at the LogicalWindow, bypassing WindowFrame.maximize() -- the one place #18444 set up for an owner (PaneManager) to keep its zoom bookkeeping in sync with maximize gestures. So a height request arriving while a pane was zoomed drove the quadrant state machine directly, leaving the zoom bookkeeping stale or the quadrant state corrupted. The live producer is the Viewer's "maximize" height request (ToolbarPane.maximize, e.g. an R Notebook preview); Source fires the same events at the EventBus, where nothing subscribes. Now: - MAXIMIZED routes through the frame's maximize action, unless the window is EXCLUSIVE -- already full-window, so the request is satisfied (the maximize gesture would mean "restore" there). - NORMAL on an EXCLUSIVE window routes through the maximize action, which ends the zoom; on an unhooked frame the default action's MAXIMIZE is remapped to NORMAL by onWindowStateChange, preserving the old behavior. Unhooked frames (additional source columns) keep their previous behavior via the default action in both cases. The new tests guard the routing: the viewer maximize must still reach the quadrant when nothing is zoomed, and must not corrupt an active zoom. Addresses #18448
RStudio E2E - all platformsAll tests passed!
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
Routing the MAXIMIZED conversion through the frame's maximize action turned a vertical height request into whatever the owner's action does horizontally: the sidebar's action is layoutZoomSidebar, so a Viewer assigned to the sidebar collapsed every other column on a height = "maximize" request. Keep the direct WindowState.MAXIMIZE conversion for non-EXCLUSIVE windows; the substantive #18448 fix there was only the EXCLUSIVE guard (a zoomed window already fills the window, so the request is satisfied). The NORMAL-on-EXCLUSIVE conversion still routes through the maximize action, which is "restore" while zoomed. Found by roborev on 8be6f1a. Addresses #18448
WorkbenchTabPanel.add() registered ensure-visible and ensure-height handlers on each tab and never kept the registrations, so a pane-layout change that moved a tab to a different panel left the old panel forwarding the tab's events to its old quadrant's window. A Viewer moved to the sidebar still maximized the TabSet2 quadrant on a height = "maximize" request, hiding TabSet1. Retain the registrations and detach them whenever the tab set changes (setTabs / clear). Not detached on unload: a panel that a layout change detaches and re-attaches keeps its tabs and must keep forwarding their events. Also drop two unused locals in the ensure-visible handler. Addresses #18448
The column-zoom restore path (restoreColumnLayout, reached by Show All Panes and endZoomBeforeRelayout) resized the right and left columns but never the sidebar, so a zoomed sidebar kept nearly the whole panel and the center column could never reclaim it. Reset it to the same default width a fresh sidebar gets, only when it reads as zoomed -- a custom sidebar width must survive an unrelated restore. Hiding a zoomed sidebar had a quieter variant: the restored widths are applied on a later layout pass, so removeSidebarWidget could still read the zoomed width and save it as the width to restore on the next show, handing the sidebar the whole panel again. Discard a near-full-panel width instead, the same rule isZoomedColumnState applies to persisted state. The new test covers the roborev finding on 8be6f1a end to end: with Viewer assigned to the sidebar via the Pane Layout dialog, a height = "maximize" request must not move any column. It fails without this commit and the two before it. Addresses #18448
clearSidebarCache() dropped the old sidebar window without clearing its WorkbenchTabPanel, so the per-tab ensure-visible/height registrations made in add() survived every sidebar recreation. The tabs are long-lived singletons, so each recreation retained another abandoned panel and kept it forwarding tab events to its stale window. Call clear() on the outgoing panel -- which detaches the registrations -- before the replacement is created. Found by roborev on 371fa63. Addresses #18448
refreshSidebar() captures the sidebar width before its hide/show cycle ends the zoom and re-applies it after; for a zoomed sidebar that width is nearly the whole panel, so the relocated sidebar zoomed itself right back. The fix -- discard a captured width that reads as zoomed (isZoomedSidebarWidth, same 50px rule as isZoomedColumnState) -- landed with the previous commit (2989855), which bundled it alongside the sidebar-panel disposal; this adds the coverage. The test drives toggleSidebarLocation on a zoomed sidebar and holds its assertions across the deferred width re-apply. It fails without the refreshSidebar guard and passes with it. Found by roborev on 2143e32. Addresses #18448
createTabSet constructed a new SelectedTabStateValue on every sidebar recreation, and a ClientStateValue registers permanently on the event bus with no way to unregister. Each recreation therefore retained another abandoned panel, and a stale instance could persist its cleared panel's selected index (-1) over the live sidebar's. Keep one instance for the sidebar and repoint it at the replacement panel instead. Found by roborev on 2989855. Addresses #18448
Reusing the sidebar's SelectedTabStateValue skips the selection restore its constructor used to run through onInit, so recreating the sidebar (hide/show, location change) reset a non-first selected tab to the default and then persisted the reset. Capture the outgoing panel's selected tab in clearSidebarCache -- by tab rather than index, so a changed tab set degrades to no selection instead of the wrong one -- and re-select it on the replacement panel after the state value is repointed. The new test selects the second sidebar tab and toggles the sidebar location; it fails without this change and passes with it. Found by roborev on 44427dd. Addresses #18448
MainSplitPanel.removeLeftWidget rebuilds the split panel the same way addLeftWidget does, re-applying persisted or default column widths and undrawing any active zoom while the bookkeeping survived it. Addresses #18448
setWidgetSize records the restored column widths but leaves the layout pass to a deferred command, so a callback reading offsetWidth here saw the zoom-time geometry -- zoomColumn's re-entry recorded a near-full panel as the new zoom's prior width. Addresses #18448
Ending a tracked zoom normalizes every non-empty quadrant, untracked vertical maximizes included; the real difference from endZoomIfActive is that this is a no-op when no zoom is tracked. Addresses #18448
Only the recreation path detached the panel's per-tab event forwarding. A pane-layout change that replaces panesByName_ while the sidebar is hidden left the pre-hide panel registered on the tab singletons with nothing able to reach it again. Addresses #18448
MainSplitPanel now owns both formulas: isZoomedWidth, which the persisted state check and the sidebar-width discard share (the discard gains the panelWidth <= 0 guard it was missing), and getDefaultSidebarWidth. Addresses #18448
The viewer test now polls for the transferred zoom rather than sleeping past the prompt, and the three must-not-happen layout assertions hold over a window instead of sampling once. Addresses #18448
The client's source-column counter only climbs within a session, so the new column's pane id is whatever the tests before it left the counter at. Addresses #18448
The snippet now writes a unique temp file per invocation and lives in the viewer page object, so both layout specs use one copy; the renamed spec drops its local bridge wrapper for @utils/commands resetLayoutZoom.
Hiding the sidebar disposes its tab panel while the reused SelectedTabStateValue still references it, so the next client-state save recorded selected index -1; a reload while the sidebar was hidden then lost the remembered tab (the -1 clamps to the first tab on the next show). Remember the last non-negative selection in getValue() and keep reporting it when the panel reads -1, so an empty or disposed panel never poisons the persisted selection, whatever emptied it. Found by roborev on 7a9b034. Addresses #18448
lastSelected_ started at -1 and was only updated when a client-state save sampled a live selection, but saves are deferred (~5s passive timer), so a sidebar hidden between the startup restore and the first save still persisted -1 -- the one window the previous commit left open. Seed the fallback in onInit from the applied (clamped) selection. Found by roborev on 42f9301. Addresses #18448
The viewer maximize test failed deterministically on the ubuntu-server e2e runner: its browser window is only ~453px tall, so the maximized TabSet2 grew by 74px, below the test's fixed +100px margin, even though the maximize applied correctly (TabSet1 was minimized to its facsimile header strip). Assert that invariant instead -- the sibling's real tab element hides, as tabs.test.ts already verifies for maximizeTabSet2 -- plus strict growth, which holds at any window size. Addresses #18448
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses #18448.
What this does
PaneManager's zoom bookkeeping (maximizedWindow_/maximizedTab_and the saved pre-zoom widths) is only cleared byrestoreLayout(). #18454 fixed the routes the original reporter hit; this closes the five remaining routes that re-lay-out the panes while leaving the bookkeeping live, where a stale zoom re-zooms the next pane that raises itself.zoomColumnasked for a different column while a pane zoom is tracked (the manually-reproduced case): a new guard at the top ofzoomColumnends the pane zoom throughrestoreLayout(), then re-applies the requested column zoom once the restore settles, so the column zoom records the restored widths as its prior state.showSidebar's guard covered onlymaximizedWindow_. Hiding a zoomed sidebar handed its width to the center column and left the right column at 1px — Environment / Plots / Help invisible with no zoom check-marked. The guard now keys on the zoom bookkeeping (widgetSizePriorToZoom_) rather thangetZoomedColumn(), which is a width heuristic that misreads the 1px collapse and would also treat a splitter dragged to the edge by hand as a zoom, clobbering custom widths.MainSplitPanel.addLeftWidgetroutes (newSourceColumn,openSourceDocNewColumn,openFileInNewColumn) and theremoveLeftWidgetroute (closeSourceWindow— reached by reducing the column count or closing a column's last doc) now end an active zoom before the split panel is rebuilt.restoreLayoutnow snapshots and clears the bookkeeping beforerestorePaneStateToDefaultfires window state changes, so a tab raising itself fromonBeforeShowcan no longer re-enter theWindowEnsureVisibleEventhandler mid-restore and start a new zoom. The deadisAnimating_field and the guard it could never fire are removed.EnsureHeightEvent.MAXIMIZED/NORMAL(LogicalWindow.onEnsureHeight): a MAXIMIZED request on a zoomed (EXCLUSIVE) window is now absorbed — it already fills the window — instead of being fired at the quadrant state machine; a NORMAL request on a zoomed window routes throughWindowFrame.maximize(), whose action means "restore" while zoomed, so PaneManager ends the zoom properly. Non-zoomed windows keep the direct conversions: a height request is vertical, and an owner's maximize action may be horizontal (the sidebar's islayoutZoomSidebar).Review passes (roborev per commit, plus a whole-branch review) surfaced further defects in the same family, fixed here:
WorkbenchTabPanelnever detached the per-tab ensure-visible/ensure-height forwarding it registers, so a pane-layout change that moved a tab to another panel left the old panel forwarding the tab's events to its old quadrant's window; the sidebar's replaced panel is now disposed on both the show and hide paths.refreshSidebarre-applied a captured zoomed width after a location change. The zoomed-width and default-sidebar-width rules are consolidated inMainSplitPanel(isZoomedWidth,getDefaultSidebarWidth) with apanelWidth <= 0guard.SelectedTabStateValue(aClientStateValueregisters permanently on the event bus) and carries the selected tab across the recreation; the state value also keeps persisting the last real selection when its panel reads-1(a hidden sidebar's panel is disposed), seeded from the startup restore, so a reload while the sidebar is hidden no longer forgets the selected tab.restorePaneLayoutdefers its completion callback so re-entrant zooms read post-layout geometry instead of zoom-timeoffsetWidths.Tests
New coverage in
tests/panes/layout/(each bug-repro test verified to fail on the pre-fix build by stashing the fix and rerunning): switching columns while a pane is zoomed, closing the sidebar while its column is zoomed, adding a source column while zoomed, removing a source column while zoomed, moving a zoomed sidebar to the other side, sidebar recreation keeping the selected tab, a Viewer in the sidebar keepingheight = "maximize"vertical, andviewer_maximize_zoom.test.tsguarding theEnsureHeightEventhandling with and without an active zoom.Full
tests/panes/layout/suite: 62 passed, 0 failed.