Skip to content

Keep pane-zoom state in sync with the visible layout - #18454

Merged
gtritchie merged 13 commits into
mainfrom
bugfix/stale-pane-zoom-18444
Aug 7, 2026
Merged

gtritchie merged 13 commits into
mainfrom
bugfix/stale-pane-zoom-18444

Conversation

@gtritchie

@gtritchie gtritchie commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Note

The NEWS.md will need to be cleaned up before I merge this (once we've branched for release of 2026.08 and reset the NEWS file back to a clean state).

Fixes #18444.

PaneManager tracks a pane zoom in maximizedWindow_ and maximizedTab_. Only
restoreLayout() cleared them. Several routes changed the visible layout without
going through it, so the bookkeeping stayed live while the layout looked normal.

While it is live, the WindowEnsureVisibleEvent handler re-zooms the next pane that
raises itself: a new plot, a package-list refresh, a render, a ?help lookup. That
pane takes over the window and its neighbours disappear. An escape from that zoom
left the state live again, and the next raise repeated it.

View > Panes is a live readout of the tracked state. A check-marked Zoom <pane>
beside a normal-looking layout is the stale condition.
View > Panes > Show All Panes is the recovery.

What changed

One replaceable maximize action. Every frame-level maximize gesture now goes
through WindowFrame.maximize(), which reads a settable action. Three gestures come
here: the maximize button, a double-click on the Console title bar
(PrimaryWindowFrame), and a double-click on a tabset's tab bar
(ModuleTabLayoutPanel). PaneManager installs one action per pane. The action ends
the zoom with restoreLayout() when that pane is the zoomed one, and calls
maximizeDefault() otherwise. This replaces setMaximizeClickHandler, which covered
only the button.

The javadoc records the two paths that still bypass the frame: the button on
MinimizedWindowFrame, and EnsureHeightEvent.MAXIMIZED through
LogicalWindow.onEnsureHeight.

Sidebar. The sidebar maximizes by a zoom of its column, not its quadrant. But it
can still be the pane-zoomed window, because Zoom Chat goes through zoomTab and
fullyMaximizeWindow. It gets the same zoom-aware dispatch. The matching menu path
is covered too. The un-zoom branch of zoomColumn calls restoreLayout() when a
pane zoom is tracked, so View > Panes > Zoom Sidebar and its shortcut restore the
widths and clear the bookkeeping together.

Sidebar visibility. A sidebar show or hide lays out the columns again, which can
undraw a zoom. showSidebar therefore ends an active zoom when visibility changes.

Startup. MainSplitPanel discards zoomed column widths (#16688), so a replay of
a persisted zoom always desynced. ZoomedTabStateValue.onInit now undoes the
persisted zoom instead. That includes the quadrant half, which
DualWindowLayoutPanel restores from its own state. A source window that holds no
documents is HIDE, which is also the quadrant state a zoom gives the zoomed pane's
sibling. So the doc-count rule moved out of initPanes into
syncSourceWindowVisibility, and the undo re-asserts it afterwards. That keeps an
empty Source pane hidden.

getWindowForTab now returns null instead of dereferencing a missing tab panel.
Tab.SourceColumn names a quadrant, not a tabset member, but fullyMaximizeWindow
can still persist it. When the persisted tab does not resolve, the undo normalizes
every pane rather than leave a sibling hidden, and logs a warning that names the tab.

Tests

Nine Playwright tests in e2e/rstudio/tests/panes/layout/panes.test.ts. They cover
each clearing route, the reported consequence, and the non-zoomed maximize path
through the new indirection. Each one failed without its fix and passed with it. The
full tests/panes/layout/ suite is 53 passed on desktop.

Two of the waits needed care, because the obvious signal passes before the thing
under test can happen:

  • The pane-raising test waits for the Plots pane to be selected, not for the console
    prompt. The session queues the prompt event and wakes the event poller before it
    runs change detection, so at the prompt the plots event can be unqueued,
    undelivered, or not yet rendered.
  • The reload test waits for the set_client_state RPC that carries the zoom. Client
    state reaches the server on a passive 5s timer, so a reload otherwise outruns the
    save and there is nothing to replay. Its post-reload assertions then sample across
    a window instead of once, because expect.poll returns on its first passing
    sample and the pre-replay layout is the passing layout.

Manual verification

  • The Console title-bar double-click ends a zoom correctly. The default
    configuration does not render that header: ConsoleTabPanel.managePanels calls
    setFillWidget while any secondary console tab is visible. The gesture is live
    only with the Terminal and jobs tabs closed, which is why it is not automated.
  • The animated paths behave correctly with animations at the shipping default. The
    e2e suite runs with reduced_motion: true, so CI never exercises the 300ms
    restore. All four Zoom Chat escape routes were checked by hand.

Still not covered either way: a genuine session restart, as opposed to a UI reload,
and a window resize while zoomed.

Follow-up

#18448 collects five pre-existing routes in the same family that this PR leaves
alone. One is a two-click reproduction that hides a whole pane column.

PaneManager tracks pane zoom in maximizedWindow_/maximizedTab_, but only
restoreLayout() ever cleared them. Several routes changed the visible
layout without going through it, leaving the bookkeeping live while the
layout looked normal -- and while it is live, the WindowEnsureVisibleEvent
handler re-zooms whichever pane raises itself next (a new plot, a package
refresh, a render), collapsing the four-pane layout over and over.

Three routes are fixed:

- The pane header's maximize button reads as "restore" while the pane is
  EXCLUSIVE, but drove DualWindowLayoutPanel directly, so the vertical
  split returned while the collapsed columns and the bookkeeping did not.
  It now ends the zoom through restoreLayout().
- Showing or hiding the sidebar redistributes every column width, undrawing
  the zoom; it now ends the zoom first.
- A persisted zoom was replayed 200ms after startup even though
  MainSplitPanel deliberately discards zoomed column widths (#16688), a
  guaranteed desync. Startup now undoes the persisted zoom instead,
  including the quadrant state DualWindowLayoutPanel restores separately.

WindowFrame.maximize() becomes public so PaneManager can override the
maximize click handler and still delegate to the default action.

Addresses #18444
Intercepting the maximize button alone left two gestures bypassing the
zoom bookkeeping: double-clicking the Console title bar
(PrimaryWindowFrame) and double-clicking a tabset's tab bar
(ModuleTabLayoutPanel) both fired MAXIMIZE straight at the WindowFrame,
restoring the quadrant while leaving maximizedWindow_ and the collapsed
columns stale.

All three gestures now go through WindowFrame.maximize(), which consults
a single overridable action, so PaneManager intercepts the gesture in one
place instead of per route. setMaximizeClickHandler is replaced by
setMaximizeAction for the same reason -- it only covered the button.

Addresses #18444
Correctness:

- The sidebar can be the pane-zoomed window (Zoom Chat goes through zoomTab ->
  fullyMaximizeWindow) and zoomColumn's un-zoom branch does not clear the
  pane-zoom bookkeeping, so escaping that zoom via the sidebar's own button left
  exactly the stale state this fixes. Funnelling the maximize gestures together
  also routed a sidebar tab double-click into the same path. The sidebar now
  gets the same zoom-aware dispatch as the other tabsets.
- A source window holding no documents is HIDE, the same quadrant state a zoom
  gives the zoomed pane's sibling, so the startup undo revealed an empty Source
  pane. Extracted that doc-count rule out of initPanes as
  syncSourceWindowVisibility and re-assert it after normalizing quadrants.
- getWindowForTab dereferenced a null tab panel: Tab.SourceColumn names a
  quadrant, never a tabset member, yet it is persistable via fullyMaximizeWindow.
  It now returns null instead, the startup undo normalizes every pane when the
  tab does not resolve rather than leaving a sibling hidden, and the failure logs
  a warning naming the tab.

Comments: WindowFrame.maximize() no longer claims to be every route to
WindowState.MAXIMIZE (MinimizedWindowFrame and EnsureHeightEvent bypass the
frame); showSidebar and the test comments describe present behavior instead of
the pre-fix bug; MainSplitPanel.isZoomedColumnState notes what depends on it.

Tests: the pane-raising test now waits for Plots to actually be selected --
the session enqueues the console-prompt event before running change detection,
so it was measuring widths before the raise could happen. Added coverage for
the non-zoomed maximize path through the new indirection, for escaping a
sidebar pane zoom, and for hiding the sidebar while zoomed; assert every column
after a sidebar toggle; and repair a stuck hidden Source quadrant in afterEach
so a failure cannot poison later tests.

Addresses #18444
Escaping a sidebar pane zoom through the sidebar frame's own button was fixed,
but View > Panes > Zoom Sidebar (and its shortcut) calls zoomColumn directly and
bypasses the frame entirely. zoomColumn's un-zoom branch restores the saved
widths without clearing maximizedWindow_ / maximizedTab_, so a Chat zoom escaped
that way left the same stale state.

That branch now delegates to restoreLayout() when a pane zoom is tracked, which
restores the same saved widths and clears the bookkeeping with them. Guarded on
a recorded pre-zoom width so it can't reach resizeHorizontally with -1; without
one the existing fall-through to restoreColumnLayout already clears the state.

Addresses #18444
@posit-snyk-bot

posit-snyk-bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gtritchie

Copy link
Copy Markdown
Member Author

Manual verification on macOS Desktop, covering the paths the automated tests can't reach.

Console title-bar double-click (PrimaryWindowFrame) -- works correctly. This gesture
is only live when ConsoleTabPanel.managePanels() computes consoleOnly, since otherwise
setFillWidget removes the frame's header widget; reached by closing the Terminal and
Background Jobs tabs via their own close buttons, which fire EnsureHiddenEvent and
re-run managePanels() immediately. Zooming Console and double-clicking the title bar
fully un-zoomed it, left no check-marked Zoom ... item in View > Panes, and a
following plot(1:10) did not disturb the layout.

Animated paths -- work correctly. The e2e suite always runs with
reduced_motion: true, so resizeHorizontally uses duration 0 and CI never exercises the
300ms restore animating underneath a subsequent relayout. Re-ran the sidebar cases with
animations enabled (the shipping default): showing and hiding the sidebar while a pane was
zoomed both settled with every column visible and no stale check-mark, and escaping a
Zoom Chat via all four routes (the sidebar's own button, Zoom Sidebar, Zoom Chat
toggle-off, and Show All Panes) behaved correctly.

Still not covered, by automation or by hand: a genuine session restart as opposed to a UI
reload, and a window resize while zoomed.

Manual testing also confirmed a route this PR deliberately does not cover -- switching from
a pane zoom to a different column zoom -- which is now recorded as a reproduced item on
the #18448 follow-up.

@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
1520 1 284 5
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 6 0
❌ desktop-macos 504 1 87 2
✅ desktop-windows 507 0 90 2
✅ server-linux 489 0 95 1
✅ setup 18 0 6 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 680b0a0934ddeda006d26501718f737322545204 - Run #487

The post-reload half of the resurrect test asserted a must-not-happen
condition with expect.poll, which returns on its first passing sample. The
un-zoomed layout it checks for is also the layout that exists before the
replay would land, so the assertion's ability to catch a replay rested
entirely on the preceding fixed 300ms sleep having already carried past it.
window.rstudio.ready is not the anchor that sleep needs either: on this
re-join path Application.java sets it in initializeAgent(), immediately
before initializeWorkbench(), so it can be observed before PaneManager is
constructed -- the 300ms is racing workbench construction plus onInit's own
200ms timer, not just the timer.

Sample the assertions continuously across a 2s window instead, failing on
the first violation, so the layout has to stay un-zoomed rather than merely
be un-zoomed once.

Also assert the set_client_state gate actually succeeded. waitForResponse
resolves on a rejected response too, and a rejected RPC still returns HTTP
200 with an error member, so an unstored zoom would have left nothing for
the reload to replay and passed everything below vacuously.

Verified by simulating the regression (restoring the pre-fix replay in
ZoomedTabStateValue.onInit): the test fails on the intended assertion with
TabSet1 at width 0. The old form failed there too on this machine, so this
removes a timing dependence rather than a silent pass. Full
tests/panes/layout/ suite: 53 passed.
Comments only. The previous wording said window.rstudio.ready can be observed
before PaneManager is constructed. It cannot: Application.java calls
initializeAgent() and initializeWorkbench() in one task, and WorkbenchScreen
builds PaneManager synchronously (paneManager_ = pPaneManager.get()), so the
event loop never yields in between and an out-of-page observer cannot see the
gap.

What ready genuinely does not cover is startup work deferred to a later task,
which is what this assertion guards: ZoomedTabStateValue.onInit's 200ms Timer.
The hold-for-a-window assertion is unchanged and still correct -- only the
reason given for it was wrong.
expectHoldsFor set its deadline on entry, so a slow first sample could consume
the whole budget and return having checked the state once -- the single-sample
weakness the helper exists to avoid. The first sample can block for a while:
it is a locator read, and the element may not have attached yet.

Measure the window from the end of that first sample instead. The window can
only grow as a result, so the regression check behind the previous commit
(pre-fix replay restored in ZoomedTabStateValue.onInit, assertion fails with
TabSet1 at width 0) still holds.
Comments only, no code changes. Shorter sentences, one fact each, fewer nested
asides. The comments had accumulated long parenthetical chains that were hard to
read.

Two also carried claims that later review disproved, so they are corrected here
rather than left to contradict the skill doc:

- The console-prompt comment said executeInConsole resolves before the plots
  event is queued. Queueing the prompt wakes the event poller before
  onDetectChanges runs, so whether the poller drains first is a thread race. The
  event may be unqueued, undelivered, or merely unrendered, and the guidance
  holds in all three cases.
- The ready-flag comment said observing ready proves the panes were built.
  initializeWorkbench() can return early with a ReloadEvent on a cookie or pref
  mismatch, before it builds the workbench, so it proves no such thing.
"Any route that does not leaves ..." is correct -- "does not" stands in for
"does not end a zoom the same way" -- but the elided verb puts "not" next to
"leaves" and a reader has to backtrack. Say "does not do so" instead.
Comments only. The previous pass reflowed these into shorter sentences but kept
every word of the content, so they were still far longer than they needed to be.
This one deletes instead: 53 lines out of 28 blocks.

What went: product mechanism a reader can get from the code (call chains like
bringToFront -> EnsureVisibleEvent spelled out hop by hop), "before this fix"
narratives that the PR body already tells, restatements of the test title, and
the repetition of "a stale zoom re-zooms the next pane" in each test after the
describe-block header states it once.

What stayed: why a wait or selector is the one it is, since that is the part a
reader cannot recover from the code.
@gtritchie
gtritchie merged commit 8b3b385 into main Aug 7, 2026
6 of 11 checks passed
@gtritchie
gtritchie deleted the bugfix/stale-pane-zoom-18444 branch August 7, 2026 21:42
gtritchie added a commit that referenced this pull request Aug 10, 2026
* Resolve e2e daily builds per branch, not via /rstudio/latest

The e2e workflows installed the build named by
dailies.rstudio.com/rstudio/latest/index.json while running the tests from
the checked-out branch. Those are two different branches whenever the alias
lags a rollover, and its index.json does lag: after the 2026.08 branch cut
the /rstudio/latest/ page served Autumn Hawkbit (2026.09) while
/rstudio/latest/index.json still named a Yellow Yarrow (2026.08) build. CI
reads the JSON, so the scheduled rotation installed a 2026.08 binary and ran
main's tests against it. Every test covering behavior added after the cut
failed on every platform, with nothing wrong in either the test or the
product -- #18454 and #18470 both landed that way.

Resolve the manifest from version/RELEASE instead. The new
os-resolve-daily-manifest action turns it into the "flower" path segment the
same way docker/jenkins/publish-build.sh does when it writes the manifest, so
the reader and the writer stay in step, and a manifest named after its own
branch cannot be mis-pointed by an alias. It computes a URL and makes no
network request, so it is safe in the jobs that end up using an override URL
instead.

A missing platform key now fails with the branch and key named, and says a
source build is the way to test a branch with no daily. Autumn Hawkbit has no
Windows build yet, so the Windows engines take that path until one is
published; installing a 2026.08 .exe was never a valid substitute.

Addresses #18498

* Trigger PR e2e on resolver and version/RELEASE changes

The pull_request paths filter lists every composite action these workflows
use, but the new os-resolve-daily-manifest was missing, so a PR touching only
the resolver would not run the workflow that exercises it.

version/RELEASE joins it for the same reason one step further out: it selects
which branch's daily each platform resolves, so a change there changes the
binary under test. A flower with no daily yet falls through decide() to a
source build, so such a PR proves the transition works instead of leaving it
to the next cron rotation.

Addresses #18498
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.

Stale pane-zoom state re-zooms any pane that raises itself, breaking the four-pane layout

2 participants