Skip to content

bugfix: file.edit during in-flight closeAllSourceDocs silently dropped - #17740

Merged
kevinushey merged 1 commit into
mainfrom
bugfix/source-pane-open-during-close-race
May 22, 2026
Merged

kevinushey merged 1 commit into
mainfrom
bugfix/source-pane-open-during-close-race

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Intent

Addresses #17738.

Summary

  • WindowFrame.onEnsureVisible only fired the WindowStateChangeEvent(NORMAL) recovery when !isVisible(). During the HIDE animation kicked off by LastSourceDocClosedEvent -> PaneManager.closeSourceWindow, the WindowFrame is still mounted in the DOM and isVisible() returns true even though the logical state is already HIDE. The recovery never fired, the HIDE animation completed, and the file-open landed in an invisible pane.
  • Mirror the LogicalWindow's state onto its WindowFrame in transitionToState, and recover when that mirrored state is HIDE or MINIMIZE (in addition to !isVisible()).
  • Add a Playwright regression test that reproduces the issue's exact sequence (open, closeAllSourceDocs, immediate file.edit).
  • Drop the matching workaround from closeSourceAndDeleteFile -- the helper now waits only on the editor detach, so the regression test exercises the real behavior rather than the workaround.

Test plan

  • ant draft + repackage desktop, then run e2e/rstudio/tests/panes/editor/close_open_race.test.ts on macOS Desktop -- new test passes.
  • Re-run e2e/rstudio/tests/panes/editor/rmarkdown.test.ts to confirm the original symptom site is still healthy now that the helper no longer polls selectedTab.
  • Manual: maximize Source pane, click into other panes -- confirm ensureVisible still doesn't un-maximize unrelated layouts.
  • Manual: minimize Source pane via UI, then trigger a file.edit -- the pane should restore.

Addresses #17738.

WindowFrame.onEnsureVisible only fired the NORMAL state recovery when
!isVisible(). During the HIDE animation kicked off by
LastSourceDocClosedEvent -> PaneManager.closeSourceWindow, the WindowFrame
widget is still in the DOM, so isVisible() returns true even though the
logical state is HIDE. A file.edit arriving during that window silently
landed in a pane that finished hiding.

Mirror the LogicalWindow's state onto the WindowFrame in transitionToState,
and also recover when that mirrored state is HIDE or MINIMIZE.

Removes the matching workaround from the closeSourceAndDeleteFile helper
so the new Playwright regression test (close_open_race.test.ts) reflects
the real behavior.
@kevinushey kevinushey added this to the Blue Plumbago milestone May 22, 2026
@posit-snyk-bot

posit-snyk-bot commented May 22, 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.

@kevinushey
kevinushey merged commit 69be7fb into main May 22, 2026
1 of 5 checks passed
@kevinushey
kevinushey deleted the bugfix/source-pane-open-during-close-race branch May 22, 2026 07:14
kevinushey added a commit that referenced this pull request Jun 22, 2026
* resolve panmirror dependency from primary worktree in gwt build

Completes #18030: lib.dir and node.dir gained a ${git.main.worktree} fallback so a fresh git worktree can borrow the primary checkout's gitignored deps, but panmirror.dir did not. Add the same fallback so 'ant draft' (and the cmake-driven GWT build) work in a secondary worktree instead of failing with '${panmirror.dir} does not exist'.

* re-enable the View() close/open race playwright test

The View()/documentCloseAllNoSave variant of the source-pane open-during-close race (#17738) was left as test.fixme when #17740 landed, because the data viewer iframe failed to finish loading even with the WindowFrame HIDE-state recovery. The data-viewer mount path has since been reworked and the race no longer reproduces -- the test passes reliably (20/20 stress runs on macOS desktop).
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.

2 participants