Repository navigation
Description
Describe the bug
A quit, project close, or project switch issued shortly after a session restart prompts "Save workspace image to <path>/.RData?" even when save_workspace is set to never.
The client learns the session's save action two ways, and before this fix both started at "ask":
ApplicationQuit.saveAction_was initialized toSaveAction.saveAsk()and only corrected when asave_action_changedclient event arrived. The action was not part ofSessionInfo, so there was nothing else to fall back on.- On the session side,
s_lastSaveActionstarts atr::session::kSaveActionAsk(SessionDirty.cpp), andonClientInitpublished that placeholder as-is. Only the firstonDetectChangespass recomputed it and emitted the corrected value.
So a close issued before the new session's first event batch reached the client used "ask" and prompted. Every session emitted save_action_changed {action: -1} followed by {action: 0}, which is directly visible in CI event-stream payloads.
Steps to reproduce
- Set
save_workspacetonever. - Open a project (or restart the session).
- Within roughly a second of the new session becoming interactive, close the project or quit.
The prompt appears in that window. Outside it, the corrected save action has arrived and the close proceeds without prompting.
Expected behavior
With save_workspace set to never, no close or quit prompts to save the workspace image, regardless of when it is issued relative to a session restart.
Impact
For an interactive user this is one dismissible prompt, and every path that reaches it is user-initiated (quit, restart/update RStudio, switch R version, new project, close project, switch projects) -- nothing background can trigger it.
Two secondary effects:
- Inside the same window, Restart R derives
saveChangesfromSAVEASK != NOSAVE, so a restart can write.RDataeven withsave_workspaceset tonever. This one is silent rather than dismissible. - Unattended automation cannot answer the modal, so the close never completes. This blocked
e2e/rstudio/tests/panes/posit-assistant-chat/restart-under-agent.test.ts, which timed out after 30s waiting onwindow.rstudio.project.isActive() === falsewhile the prompt sat unanswered.
How it was found
Six consecutive failures of the above test on the Windows shard of the Posit Assistant release gate. In the failing trace the new session's first get_events took 1940ms, of which only 6.7ms was server think-time -- the rest was connection establishment. The close was clicked 1.64s before that batch was delivered, so the client held no save action for the session at all.
Not a regression
Both defaults are long-standing: saveAction_ = SaveAction.saveAsk() dates to 2011 (4993b7e7e3d) and s_lastSaveAction = kSaveActionAsk to 2013 (57a301581a1). Both are present unchanged on rel-autumn-hawkbit. What changed was the timing of the first event batch, not RStudio.
System details
- RStudio Edition: Desktop
- RStudio Version: 2026.10.0-daily+39 (also affects earlier releases)
- OS Version: Windows Server 2025 (observed); platform-independent by inspection
- R Version: 4.6.1
Activity
Make close_project_after_open assert the save prompt did not appear
Don't prompt to save the workspace right after a session restart (#18785