Skip to content

Find the sidebar window when a sidebar tab raises itself - #19275

Merged
gtritchie merged 5 commits into
mainfrom
bugfix/sidebar-panes-stale-window
Oct 26, 2026
Merged

gtritchie merged 5 commits into
mainfrom
bugfix/sidebar-panes-stale-window

Conversation

@gtritchie

@gtritchie gtritchie commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

PaneManager.panes_ listed the sidebar's window only when the quadrants pref did, and kept the window showSidebar() had since replaced. getLogicalWindow() read only panes_, 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, and getLogicalWindow(), getParentLogicalWindow() and getFocusTargetIn() use it instead of each building that list. A hidden sidebar is left out: one hidden since page load has its window in HIDE, with no active widget, so a raise request routed to it during a zoom would fail in fullyMaximizeWindow(). That path needs a tab that raises itself without an ActivatePaneEvent (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 a getSidebarWindow() 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 a DualWindowLayoutPanel, so nothing handles its state-change events.

New e2e tests in zoom_inert.test.ts move Help to the sidebar, hide and reshow it, then call help() during an Environment zoom (the zoom moves to Help) and during a left-column zoom (the zoom ends and the sidebar reopens). Both fail against main and pass here. zoom_inert, focus_adjacent_pane, panes and viewer_maximize_zoom pass in test:server-dev.

Fixes #19202.

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 gtritchie added this to the 2026.11 (Montauk Daisy) milestone Oct 25, 2026

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

  1. getLogicalWindow() now finds the sidebar window while the sidebar is hidden. A hidden-at-startup sidebar can then crash fullyMaximizeWindow() during a zoom, for layouts saved from the Pane Layout dialog.
  2. The no-zoom path for a reshown sidebar changes as well: it now reopens a shut sidebar. Nothing tests that.
  3. Every lookup that needs all windows has to add the sidebar to panes_ by hand.
  4. 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);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, [

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@gtritchie

Copy link
Copy Markdown
Member Author

All four review findings are resolved:

  1. Hidden-sidebar lookup in getLogicalWindow(): 673d94a. getAllWindows() includes the sidebar only while it is shown.
  2. Untested reopen of a reshown sidebar: 82bd866 adds "help() ends a column zoom that shut the sidebar".
  3. Sidebar added by hand in each lookup: 01b1c67 (getSidebarWindow()) and 673d94a (getAllWindows()).
  4. Test pref write outside try: 2b8e6b0 moves setup to beforeEach and the restore to afterEach.

@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
4370 0 214 2
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 14 0
✅ desktop-linux 1092 0 42 2
✅ desktop-macos 1100 0 37 0
✅ desktop-windows 1093 0 49 0
✅ server-linux 1047 0 44 0
✅ setup 36 0 28 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 82bd86608b875f9d24275f2f213ade9a935451af - Run #1702

@gtritchie
gtritchie merged commit ad6e5ab into main Oct 26, 2026
41 checks passed
@gtritchie
gtritchie deleted the bugfix/sidebar-panes-stale-window branch October 26, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PaneManager.panes_ keeps a sidebar window that showSidebar() has replaced

1 participant