Repository navigation
stabilize pane-layout e2e tests and fix sidebar zero-width squeeze - #17795
Conversation
Reduce cross-test flakiness traced to leaked modal dialogs, a close/delete race, unguarded sandbox paths, and pane animations. - reset: clear the whole GWT modal stack via dialogs.dismissAll at the start of resetForNextTest instead of clicking a single Don't Save button, so a leaked "Save File" error / "File Deleted" prompt can't block the next test. - resetSourcePaneState now waits for its async close chain to settle before returning. closeAndDeleteSandboxFiles relied on this implicitly and was deleting files while editors still held them open -- the source of the "system error 2" Save File dialogs that then leaked into later tests. - sandbox: assert a non-empty absolute path in createSandbox, createAndOpenProject, writeAndOpenFile, and closeAndDeleteSandboxFiles, so an unpopulated sandbox.dir fails loudly instead of building a root-relative "/<name>" path (the confusing "Error Opening Project" modal). Adds timeline logging and an empty-read guard in useSuiteSandbox for diagnosis. - animations: enable reduced_motion in automation prefs (base-prefs.jsonc and the server fixture) so pane minimize/maximize/zoom transitions apply synchronously and can't leave the Source pane stuck minimized. Animation tests override the pref per-suite. Validated locally (desktop-dev): the dialog-leak cascade is gone (0 PopupPanelGlass / Save File / File Deleted across the run) and reduced_motion cleared the findFromSelection, notebook-save, and layoutZoom failures.
…ditor A bare [class*=run_the_current_line_or_selection].first() also matched the hidden Untitled placeholder tab's button (kept by resetSourcePaneState), so .first() picked the hidden one and the click timed out as 'not visible'. Add SourcePane.runLineBtn scoped to the visible tabpanel (matching saveBtn et al.) and use it from the test.
Showing the sidebar takes its width from center_ (the fill column), so restoring a saved layout that no longer fits, or a first-time show, could squeeze the Source/Console column to ~0 and leave it invisible. Reclaim space by resetting the other columns to default widths once the post-show relayout reveals a sub-minimum center. A user can also deliberately collapse the center via the middle splitter. In that case restoring it near-zero on the next sidebar show is the correct, faithful restore, not a squeeze -- so record whether the center was already collapsed when the sidebar was hidden and skip the reclaim when restoring that state.
…ggle The sidebar-visibility preservation tests slept a fixed 300ms after re-showing the sidebar before reading column widths, which lost the race on slow CI. Settle on the sidebar's own width instead: it reveals in the same relayout pass as the columns, so once it stops animating the column widths are final.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Review SummaryA well-scoped PR: a real GWT product fix (sidebar show no longer collapses Source/Console to ~0) plus solid e2e stabilization work. The code is sound — no critical bugs found. Two issues are worth addressing before merge. Important Issues1. Comment-rot: "animation tests override 2. Suggestions
Recommended Action
The product fix itself is shippable as-is; the action items are about test coverage and doc/contract accuracy, not correctness of the fix. |
gtritchie
left a comment
There was a problem hiding this comment.
LGTM! Some non-blocking nitpicks re: tests, comments
Per PR #17795 review feedback: - reduced_motion: reword the base-prefs and server-fixture comments to forward-looking intent; no test currently overrides the pref, so the old "tests override this" wording described a convention that doesn't exist. - resetForNextTest: document the error-handling contract explicitly -- the debug-exit step is guarded/best-effort, while modal dismissal, source-pane reset, and console focus intentionally fail loud if the automation bridge is gone (guarding the source reset would silently leak buffers forward). - numModalsShowing: use a -1 sentinel on read failure instead of 0, so a failed count read warns rather than masquerading as "no modals left". - paths.ts: clarify that the screened input is an empty sandbox.dir; the root-relative path is the resulting symptom, not what the guard rejects.
Per PR #17795 review feedback: the existing suite exercised the reclaim branch (via "Sidebar show uses default widths after columns resized while hidden") but not the savedCenterCollapsed_ preserve branch deterministically. Add a test that deliberately collapses the center column below the minimum width via the middle splitter, hides and re-shows the sidebar, and asserts the center is restored as-is rather than reclaimed to a default width. Also add comments to both tests naming which MainSplitPanel branch each covers.
The worker-scoped session can be mid-relaunch or mid-reload when a spec starts (a prior test reloaded the page, or the session restarted), so window.rstudio may be installed while the workbench is still wiring up. Driving it then races init -- a command bridge call returns "markers not found", or an offsetWidth read returns 0 before layout (both seen as intermittent failures, e.g. create_projects and "Default quadrants"). Wait for window.rstudio.ready === true at the top of resetForNextTest -- the DeferredInitCompletedEvent signal openProject already relies on. It's independent of any leaked modal (a glass panel doesn't reset ready, and the dismissAll in step 1 clears it via the bridge regardless), and a genuinely dead session still fails loud here with a precise timeout.
ensureVisualMode clicked the toggle then slept a fixed 2s and returned,
gating the click on aria-pressed === 'false'. For a heavier document (an
R Markdown template with chunks/plots) the pandoc->ProseMirror conversion
outlasts 2s, so callers asserted against a still-source-mode editor and the
.ProseMirror lookup found nothing ("rmd templates display" failed here).
Detect mode via the .ProseMirror surface and wait for it to actually mount
instead of sleeping, so the helper returns only once visual mode is live.
For chunks with no visible output, the helper cat()'d a synthetic marker via the console right after dispatching executeCurrentChunk. But that command only dispatches -- the chunk feeds the console asynchronously -- so for a multi-line chunk the marker landed mid-continuation, corrupting R's input buffer (NotebookQueue raised "Incomplete expression") and silently skipping the chunk body. The patchwork #13470 test then passed vacuously: its registerS3method override never installed, so of course no output dumped. Drop the marker and bracket the chunk on R's busy state instead -- wait for the console to go busy (tolerating a chunk too fast to observe it) then idle. No input-buffer race, and no console-history pollution. The patchwork test now runs the override for real (8.0s vs 2.1s) and still passes. Adds waitForConsoleBusy alongside waitForConsoleIdle.
executeInConsole was fire-and-forget, so firing several commands in quick succession left the later ones queued (not yet in recall history) when a test started navigating. That made the console "arrow keys cycle" test flaky: a single ArrowUp recalled the only history entry. Wait for R to go idle by default (opt out with wait: false for the fire-and-forget pattern). Simplify ensurePackage/uninstallPackage to wait-for-idle instead of polling a done-marker, and read TRUE/FALSE via parens auto-print + a [1]-anchored regex instead of unique markers. Tag the flaky edit_suggestions "prefix-matched" test @ai to defer it.
.rs.api.showDialog/showPrompt/showQuestion block the R thread until the client dismisses the modal, so with executeInConsole now waiting for R idle by default these timed out. Submit them fire-and-forget (wait: false) and drive the dialog from the test as before.
Cases 4/5/6 (all useAir=true) require the Air binary; on a runner without it they fail with unformatted output. Add a beforeAll preflight that calls .rs.air.ensureAvailable() (mirroring the reformat path, autoinstall included) and skips those three cases when Air can't be resolved. The useAir=false cases keep running everywhere. Promote ConsolePaneActions.evalRLogical to a public state-probe helper so the preflight can read the availability boolean from R.
Rewrite the local waitForSessionRestart in create_projects to poll window.rstudio.ready (false->true across the restart) instead of echoing a cat() marker through the console. The marker loop was flaky: the marker could land in the old console moments before the in-place restart cleared it, and each inner executeInConsole idle-wait could consume the whole budget. closeCurrentProject and createProjectInNewDir now pre-reset the flag before triggering the restart so the wait sees a clean edge rather than the prior session's stale true. Also enrich openProject's active-project post-check: when ready flips true but the path never matches (a silently-failed open, since OpenProjectErrorEvent also sets ready=true), surface the actual active project instead of an opaque waitForFunction timeout.
The useSuiteSandbox beforeAll start/done bracket and the createSandbox workdir echo were timeline instrumentation added in #17795 to correlate "Error Opening Project" / empty-dir failures against sandbox creation. That failure mode has since been root-caused (module-scope hooks vs fixtures, #17955/#17956), so the three lines are now just per-suite log noise. The real diagnostics stay: the empty-dir read warning (with stack) and the not-under-PW_SANDBOX warning.
Summary
Stabilizes the pane-layout end-to-end tests, fixes an underlying
Source/Console zero-width bug uncovered while doing so, and folds in a set
of broader e2e reliability fixes surfaced by a full non-AI test run.
Product fix
sidebar takes its width from the center (fill) column, so restoring a
saved layout that no longer fits -- or a first-time show -- could squeeze
Source/Console to ~0. After the post-show relayout, if the center is
below a minimum width the other columns are reset to default widths to
reclaim space. A center the user deliberately collapsed via the middle
splitter is recorded at hide time and restored as-is, so the reclaim only
triggers on an involuntary squeeze.
Test stabilization
sleepafter re-showing the sidebar with awaitForStableWidthon the sidebar pane in the visibility-preservationtests, removing a slow-CI race.
deliberately-collapsed center" branch.
resetForNextTestnow waits forwindow.rstudio.ready === truebefore driving the IDE, fixing a class ofpost-relaunch/post-reload flakes (bridge "markers not found", offsetWidth
read of 0 before layout).
ensureVisualModenow waits for the.ProseMirrorsurface to mountinstead of a fixed 2s sleep, fixing the "rmd templates display" failure
(heavier templates convert slower than 2s).
than injecting a synthetic console marker that raced the chunk's
asynchronous console feed -- the old path corrupted multi-line chunks
("Incomplete expression") and made the patchwork patchwork plots cause internal data to be dumped into chunk outputs #13470 test pass
vacuously. Adds
waitForConsoleBusy.determinism; scope the
execute_from_editorrun-line button to thevisible editor; review-nit fixes to reset/fixture/path comments.
Testing
ant javacclean. Targeted desktop-dev runs: fullpanes.test.ts(21/21,incl. the new preserve test),
rmarkdown.test.ts+quarto.test.ts(visualmode), and
rmarkdown_chunks.test.ts(patchwork now runs for real, 8.0s).Known pre-existing failure (not addressed here)
rmarkdown_chunks.test.ts"saving an R Notebook creates an nb.html file"fails because saving an
html_notebooknever clears the document's dirtyflag (a plain
.Rmdsaves fine in the same sandbox). It is specific tonotebook saving on this build, unrelated to pane layout, and not a timing
issue -- tracked separately.