Skip to content

Quit or close project soon after a session restart prompts to save the workspace with save_workspace set to never #18784

Closed

Description

@gtritchie

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 to SaveAction.saveAsk() and only corrected when a save_action_changed client event arrived. The action was not part of SessionInfo, so there was nothing else to fall back on.
  • On the session side, s_lastSaveAction starts at r::session::kSaveActionAsk (SessionDirty.cpp), and onClientInit published that placeholder as-is. Only the first onDetectChanges pass 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

  1. Set save_workspace to never.
  2. Open a project (or restart the session).
  3. 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 saveChanges from SAVEASK != NOSAVE, so a restart can write .RData even with save_workspace set to never. 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 on window.rstudio.project.isActive() === false while 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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions