Repository navigation
Find the sidebar window when a sidebar tab raises itself - #19275
Conversation
panes_ listed the sidebar only when the quadrants pref did, and kept the window showSidebar() had since replaced. getLogicalWindow() read only panes_, so a sidebar tab raising itself during a zoom was ignored once the sidebar had been shown after load. Leave the sidebar out of panes_ and look it up in panesByName_ wherever it is needed. Addresses #19202.
gtritchie
left a comment
There was a problem hiding this comment.
Four findings. The first is a possible crash I found by reading the code and haven't reproduced. The other three are about test coverage, the design, and test cleanup.
getLogicalWindow()now finds the sidebar window while the sidebar is hidden. A hidden-at-startup sidebar can then crashfullyMaximizeWindow()during a zoom, for layouts saved from the Pane Layout dialog.- The no-zoom path for a reshown sidebar changes as well: it now reopens a shut sidebar. Nothing tests that.
- Every lookup that needs all windows has to add the sidebar to
panes_by hand. - The test's pref write runs outside
try, so a failure there skips the cleanup.
| for (LogicalWindow window : panes_) | ||
| if (window.getNormal() == frame) | ||
| return window; | ||
| LogicalWindow sidebarWindow = panesByName_.get(UserPrefsAccessor.Panes.QUADRANTS_SIDEBAR); |
There was a problem hiding this comment.
This lookup also returns the sidebar window while the sidebar is hidden (sidebar_ == null), because the window stays in panesByName_.
If the sidebar was hidden at startup, its window is in HIDE (PaneManager.java:2141). The panel from initPanes() also still forwards its tabs' events, because showSidebar(false) only disposes it when sidebar_ != null (PaneManager.java:1280). A sidebar tab that raises itself with ensureVisible() instead of bringToFront() fires no ActivatePaneEvent, so nothing shows the sidebar first. One example is Build on build errors (BuildPane.java:443). During a pane zoom, the WindowEnsureVisibleEvent handler then calls fullyMaximizeWindow() on the hidden sidebar. That sets maximizedWindow_, disables the splitters and resets panes_ to NORMAL. It then throws at PaneManager.java:1542, because getActiveWidget() returns null in HIDE.
Before this PR the path was reachable only when quadrants lists "Sidebar". The Pane Layout dialog writes only the four visible quadrants (PaneLayoutPreferencesPane.java:868-872), so layouts saved there returned null here. Checking sidebar_ != null in this lookup would close both cases.
I traced this by reading the code and haven't reproduced it.
| return window; | ||
| LogicalWindow sidebarWindow = panesByName_.get(UserPrefsAccessor.Panes.QUADRANTS_SIDEBAR); | ||
| if (sidebarWindow != null && sidebarWindow.getNormal() == frame) | ||
| return sidebarWindow; |
There was a problem hiding this comment.
With no pane zoom active, a tab raising itself in a sidebar shown after page load now reaches reopenCollapsedColumn(window, lastSelectedTab_, true) (PaneManager.java:550). Before this PR the lookup returned null there.
So if a reshown sidebar is shut by a column zoom or a splitter drag, help("mean") now ends the column zoom and reopens the sidebar, where before the sidebar stayed shut. That's probably the intent, but neither the PR description nor a test covers it. The existing "Show Chat reopens a sidebar shut by a column zoom" test goes through activateChat, not this handler.
|
|
||
| // Do not include hiddenTabSet in panes since it should never be displayed | ||
| // Do not include hiddenTabSet in panes since it should never be displayed. | ||
| // Leave out the sidebar too: only some layouts list it, and showSidebar() |
There was a problem hiding this comment.
With the sidebar out of panes_, any code that needs every window has to add it from panesByName_ by hand. getLogicalWindow(), getParentLogicalWindow() and getFocusTargetIn() each build panes_ + sidebar + sourceLogicalWindows_ themselves, in three different orders. panesByName_.get(UserPrefsAccessor.Panes.QUADRANTS_SIDEBAR) appears 8 times. A future helper that loops over panes_, the obvious field, would skip the sidebar and bring #19202 back.
A getSidebarWindow() accessor (next to getSourceLogicalWindow() and getConsoleLogicalWindow()) plus one getAllWindows() used by those three lookups would keep this in one place.
| rstudioPage: page, | ||
| }) => { | ||
| await setSidebarVisible(page, false); | ||
| await executeInConsole(page, [ |
There was a problem hiding this comment.
This call writes the panes pref but runs before try {, so the finally that restores .rs.e2ePanes doesn't cover it. If it times out or fails after .rs.writeUiPref("panes", p) has landed, Help stays in the sidebar for the rest of the shared-session run, and later Help/TabSet2 assertions fail for an unrelated reason. Moving it inside the try fixes that (.rs.e2ePanes would then need a guard in the restore).
getLogicalWindow(), getParentLogicalWindow() and getFocusTargetIn() each built panes_ + sidebar + source columns by hand. getAllWindows() does it once, and adds the sidebar only while it is shown: a sidebar hidden since page load has its window in HIDE, so a raise request routed to it during a zoom would reach fullyMaximizeWindow() with no active widget. Addresses #19202.
The panes pref write ran before the try, so a failure once it had landed left Help in the sidebar for the rest of the shared-session run. Move the setup and restore into beforeEach/afterEach hooks, which also run after a failed beforeEach, and restore only when the saved value exists. Addresses #19202.
A tab raising itself in a sidebar shown after page load now reaches reopenCollapsedColumn(), which ends a column zoom that shut the sidebar. Before, the window lookup missed the reshown sidebar and it stayed shut. Addresses #19202.
|
All four review findings are resolved:
|
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 |
PaneManager.panes_listed the sidebar's window only when thequadrantspref did, and kept the windowshowSidebar()had since replaced.getLogicalWindow()read onlypanes_, so once the sidebar had been shown after page load, a tab raising itself in the sidebar (e.g. Help after?mean) was ignored. During a pane zoom the zoom stayed on the other pane, and a sidebar shut by a column zoom stayed shut.panes_now holds the quadrants only.getAllWindows()returns the quadrants, the sidebar while it is shown, and the source columns, andgetLogicalWindow(),getParentLogicalWindow()andgetFocusTargetIn()use it instead of each building that list. A hidden sidebar is left out: one hidden since page load has its window inHIDE, with no active widget, so a raise request routed to it during a zoom would fail infullyMaximizeWindow(). That path needs a tab that raises itself without anActivatePaneEvent(Build on build errors) while the sidebar is still hidden from page load; I traced it in the code but couldn't reproduce it, since every build raises Build at start and completion, which shows the sidebar first. The sidebar window is read through agetSidebarWindow()accessor, which still returns it while the sidebar is hidden, as the show/hide paths need.The zoom loops over
panes_(endZoomIfActive(),fullyMaximizeWindow(),restorePaneStateToDefault()) no longer reach the sidebar. Their behavior doesn't change: the sidebar window isn't in aDualWindowLayoutPanel, so nothing handles its state-change events.New e2e tests in
zoom_inert.test.tsmove Help to the sidebar, hide and reshow it, then callhelp()during an Environment zoom (the zoom moves to Help) and during a left-column zoom (the zoom ends and the sidebar reopens). Both fail againstmainand pass here.zoom_inert,focus_adjacent_pane,panesandviewer_maximize_zoompass intest:server-dev.Fixes #19202.