Repository navigation
Prompt to save on window close after a cancelled quit - #18820
Merged
Merged
Conversation
closeEvent() set quitConfirmed as soon as desktopHooks.quitR() returned, but quitR() only dispatches the quit sequence -- it resolves while the save prompts are still on screen. Cancelling left the flag set for the life of the session, so every later click of the window close button skipped the quit sequence entirely: no prompt for unsaved documents, and no workspace save. quit() already sets quitConfirmed on the confirmed-quit path, before it closes the window, so let it be the sole setter. Addresses #18818
The main process is never told whether a quit was cancelled or is still awaiting an answer, so closing again re-runs the quit sequence. Record that this is deliberate: suppressing the re-run would need a signal that ApplicationQuit's several cancel exits do not send, and a pending flag without one would leave the close button dead instead. Addresses #18818
closeEvent() recorded the window bounds on the first close attempt and set geometrySaved so later attempts skipped it. Cancelling that quit therefore froze the saved geometry at the cancel-time bounds, and every move or resize for the rest of the session was discarded. Save the bounds in the branch that lets the window close instead, which is the only point where the geometry is final, and drop the flag: the single remaining call site needs no guard, since that branch runs once per window. Addresses #18818
3 of 4 tasks
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:03 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:03 — with
GitHub Actions
Inactive
gtritchie
had a problem deploying
to
e2e-playwright
September 14, 2026 21:04 — with
GitHub Actions
Failure
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 21:04 — with
GitHub Actions
Inactive
…d-quit-disarms-close
gtritchie
had a problem deploying
to
e2e-playwright
September 14, 2026 22:23 — with
GitHub Actions
Failure
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:23 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:24 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:24 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:28 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:28 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:32 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:32 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:32 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:32 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:32 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 22:32 — with
GitHub Actions
Inactive
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 |
…d-quit-disarms-close
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:41 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:41 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:44 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:44 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:47 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:47 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:50 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:50 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:50 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:50 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:50 — with
GitHub Actions
Inactive
gtritchie
temporarily deployed
to
e2e-playwright
September 14, 2026 23:50 — with
GitHub Actions
Inactive
Collaborator
|
LGTM |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fixes #18818.
On RStudio Desktop, cancelling the quit that a window close triggers left the window's close button disarmed for the rest of the session: later closes exited immediately, with no prompt for unsaved documents and no workspace save.
MainWindow.closeEvent()setquitConfirmed = trueas soon asdesktopHooks.quitR()returned.quitR()isvoidand only dispatches the quit sequence — the promise resolves while the save prompts are still on screen, so the flag was set whatever the user answered. Nothing cleared it except a session restart, which is why a morning cancel persisted all afternoon.The assignment was also redundant: on a confirmed quit, GWT sets
PENDING_QUIT_AND_EXITand the session exits,SessionLauncher.onRSessionExited()callsMainWindow.quit(), andquit()setsquitConfirmed = truebeforewindow.close(). This change drops the assignment incloseEvent()and leavesquit()as the sole setter.closeEvent()held a second piece of state with the same problem. It recorded the window bounds on the first close attempt and setgeometrySavedso later attempts skipped it, so cancelling froze the saved geometry at the cancel-time bounds and every move or resize for the rest of the session was discarded. The bounds are now saved in the branch that lets the window close, which is the only point where the geometry is final, and the flag is gone.Desktop only.
quitConfirmedhas no server-side counterpart, and closing a browser tab in Server mode is not a quit.Approach
src/node/desktop/src/main/main-window.ts: remove the.then()that confirmed the quit on dispatch; move thesaveWindowBounds()call into the closing branch and deletegeometrySavedalong with its reset inonWorkbenchInitialized().src/node/desktop/test/unit/main/main-window.test.ts: four cases in the style of the existing crashed-renderer fake — acloseEventwhosequitR()resolves leavesquitConfirmedfalse; a secondcloseEventstill callspreventDefault()and re-runsquitR(); the closing pass saves the current bounds; the cancellable pass saves nothing. The options singleton is pointed at a temp directory so no test touches the real user config.The close-after-confirmed-quit routes were checked:
onSessionQuit(),onRSessionExited()(PendingQuitAndExit), thelaunchSession()failure dialog, andrunDiagnosticsall go throughquit(), which closes the window and so reaches the geometry save.SessionLauncher.onLaunchError()closes the window directly but is covered by the existing!this.sessionProcess || exitCode !== nullguard, and by the!!window.desktopHooksprobe when an error page is loaded.Two consequences worth naming. Clicking the close button repeatedly while the save prompt is up now dispatches the quit sequence again instead of closing the window, because the main process is never told whether a quit was cancelled or is still being answered. Suppressing that would need a signal
ApplicationQuitdoes not send — it abandons a quit at seven independent exits with no common funnel — and a pending flag without one would leave the close button dead, which is the same bug in a less visible form. Stacked prompts also replace what used to happen on that second click: the window closed with the prompt still on screen. Separately, geometry is no longer persisted for a cancelled close, so a session that is cancelled and then hard-killed keeps its previous bounds rather than the cancel-time ones.QA Notes
Open RStudio Desktop, click the window close button, cancel the prompt. Create a variable in the console and edit an open document, then click close again: the unsaved-documents and save-workspace prompts appear, and confirming writes
.RData. Before this change the second close exited silently.For the geometry half: cancel a close, then move and resize the window, then quit and restart. The window comes back where it was left, not where it sat when the close was cancelled.