Skip to content

Keep the last project when the Dock opens a projectless window - #18807

Merged
gtritchie merged 3 commits into
mainfrom
bugfix/dock-new-window-keeps-last-project
Sep 13, 2026
Merged

gtritchie merged 3 commits into
mainfrom
bugfix/dock-new-window-keeps-last-project

Conversation

@gtritchie

@gtritchie gtritchie commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #18786. The Dock's "New RStudio Window" asks the session for no project with RS_INITIAL_PROJECT=none, and the session treated that like a --project none scope: it went through resolveProjectSwitch(), which also flushes the per-user last-project path. That record is shared by all windows, so the new empty window erased the project remembered for the window it was launched from. With "Restore most recently opened project at startup" on, the original project was not reopened on the next launch if that window crashed or the empty window was quit last.

The session now handles the desktop's env-var none as a plain projectless start and leaves the last project path alone. The command-line scope, used by Workbench, keeps its flush. The none env value is only ever sent by the Dock command, so no other startup path changes.

Also on the desktop side, from the review of #18786:

  • launchRStudio() builds the child's environment as a copy and passes it to spawn, instead of setting and unsetting variables in this process's own environment.
  • LaunchRStudioOptions is a union of the three launch intents (project file, working directory, no project), so callers can't combine them, and the function branches on the intent directly.

No NEWS entry: #18786 is unreleased.

Verification

Desktop unit tests cover the three launch intents and that an inherited project is not passed on. Lint and typecheck are clean. The session change needs a person:

  1. Turn on "Restore most recently opened project at startup". Open a project and wait 30 seconds so it is recorded.
  2. Right-click the Dock icon and choose "New RStudio Window". It opens with no project.
  3. Force-quit RStudio (or quit the empty window last), then relaunch: the project from step 1 reopens. Before this change it did not.

Addresses #15669

The Dock's "New RStudio Window" (#18786) asks the session for no project
by setting RS_INITIAL_PROJECT=none. The session handled that value the
same way as a "--project none" scope: through resolveProjectSwitch(),
which also flushes the per-user last-project path. That record is shared
by every window, so the new empty window erased the project remembered
for the window it was launched from. With "Restore most recently opened
project at startup" on, the original project was then not reopened on
the next launch if that window crashed or the empty window quit last.

Handle the desktop's env-var "none" as a plain projectless start and
leave the last project path alone. The command-line scope keeps its
flush.

Addresses #15669

Claude-Session: https://claude.ai/code/session_01HG3TvVKHo57As36tpZx2T8
launchRStudio() set RS_INITIAL_PROJECT and RS_INITIAL_WD in this
process's environment around the spawn call and unset them afterwards,
which also wiped whatever values this instance was started with. Build
the child's environment as a copy and hand it to spawn, leaving our own
untouched.

Make LaunchRStudioOptions a union of the three launch intents (a project
file, a working directory, or no project) so a caller can't combine
them, and branch on the intent directly rather than deriving the working
directory and project file through nested fallbacks.

Claude-Session: https://claude.ai/code/session_01HG3TvVKHo57As36tpZx2T8
@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
2915 0 186 10
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
✅ desktop-linux 732 0 38 3
✅ desktop-macos 737 0 33 4
✅ desktop-windows 737 0 41 1
✅ server-linux 679 0 44 2
✅ setup 28 0 20 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit d5d359f9c85c6498a4b73acb9a1ac0ee2a87747d - Run #990

@gtritchie
gtritchie merged commit cff728d into main Sep 13, 2026
34 checks passed
@gtritchie
gtritchie deleted the bugfix/dock-new-window-keeps-last-project branch September 13, 2026 21:29

This branch was previously deployed

1 inactive deployment
e2e-playwright — d5d359f9 Deployed Sep 13, 2026 by gtritchie via windows / e2e-desktop-windows (3) #990
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.

1 participant