Repository navigation
feat(interactive): support managed sessions on Windows - #1953
Conversation
Centralize local endpoint creation in a transport module that uses named pipes on Windows and keeps Unix sockets with mode 0600 elsewhere. Enable detached supervision on Windows, store sessions under LOCALAPPDATA, and confirm a launched agent with an authenticated probe. Interrupt is available on Windows through arf IPC, and Stop force-terminates there. Windows CI installs arf and runs the managed runtime tests.
The Rtools MSYS curl splits the newline in the write-out argument that mise-action uses to fetch the packslip bundle, so the download always fails once Rtools is first on PATH. Run mise-action before setup-r on Windows; Linux and macOS keep the existing order.
Running mise-action ahead of setup-r everywhere keeps one install location instead of a Windows-only step.
… on Windows The Windows extension host can start in the VS Code installation directory, so locate sess, R resources and the bundle from the test file. mclapply forks only on Unix.
Windows editor documents can submit CRLF line endings, which R's parser rejects. Normalize them to LF before parsing while keeping the submitted text in history. Extension tests now follow each document's EOL and VS Code's path normalization, and the bulk session suite closes earlier agents itself instead of relying on a Unix-only restart test.
renkun-ken
left a comment
There was a problem hiding this comment.
Reviewed 0d59c8845acd0e0f2c1086e2161a016ba6aab2e7. One Windows default-working-directory issue remains, described inline: creating a session without an open workspace can start R in the VS Code installation directory when HOME is unset. Please use the cross-platform home-directory fallback and cover that case.
Validation: the PR builds and its TypeScript/test compilation passes locally on macOS. All 59 focused protocol/backend/supervisor/transport tests and 8 focused real R/arf runtime tests passed, including CRLF history retention, interrupt, Stop during startup, and detached/auto launcher survival (R 4.6.1, arf 0.7.2-rc.1). All 14 executed hosted checks passed; Pages deployment was skipped. I also inspected the Windows CI logs: Node had 445 passing / 25 pending, and the Interactive editor suite had 57 passing / 6 pending, with the new runtime and default-VS-Code-runtime creation paths actually exercised. I did not run a native Windows session locally.
| const child = spawn(node, [agent, file], { | ||
| detached: true, | ||
| windowsHide: true, | ||
| cwd: config.directory, |
There was a problem hiding this comment.
[P2] Use the user's home for Windows sessions without a workspace
This newly enabled Windows path inherits config.directory from InteractiveManager.create(), whose final fallback is process.env.HOME ?? process.cwd() (manager.ts:1110–1116). With no workspace open and HOME unset, a Windows extension host started from the VS Code installation directory therefore starts arf/R there too. For example, with USERPROFILE=C:\Users\example and cwd=C:\Program Files\Microsoft VS Code, I reproduced the compiled create method selecting the latter directory. In a system installation, ordinary relative writes such as saveRDS(x, "x.rds") then fail because that directory is not user-writable, and the session/export defaults point at the installation directory. The editor-test comment added in this PR also recognizes this possible Windows cwd. Please change the no-workspace fallback to os.homedir() and add a case with HOME absent, rather than relying on the extension host's cwd.
Resolve the default working directory with os.homedir() instead of HOME or the extension host's cwd. On Windows, HOME is usually unset and the host can start in the VS Code installation directory, which is not user-writable.
…n reply On Windows, R's language server can close its connection before it answers the client's shutdown request. The client rejects the pending request with PendingResponseRejected after it has already stopped, so suite teardown failed. Treat it like the EPIPE case, and only when the client is stopped.
renkun-ken
left a comment
There was a problem hiding this comment.
Reviewed b5dbdff14ac0e76a6f961061b3c4070c7e821377. The previous P2 finding is resolved: sessions without a workspace now use os.homedir(), while workspace/adopted-session directories retain precedence. The new regression test covers an absent HOME. The language-client cleanup change is also appropriately restricted to completed shutdown, with real-socket coverage for a server closing before its reply and negative cases for unrelated failures. No additional findings.
Validation: the updated PR builds and its TypeScript/test compilation passes locally on macOS; all 60 focused protocol/backend/supervisor/transport tests passed. All 14 executed hosted checks passed on this head (Pages deployment skipped). Latest Windows logs show 446 passing / 25 pending Node tests and 58 passing / 6 pending Interactive editor tests, including the no-workspace regression and all three language-client cleanup cases. The cleanup behavior with the locked language-client dependency was verified through CI; I did not run a native Windows session locally.
Summary
R Interactive refused to start on Windows. The obstacle was not R or arf IPC but the Session Agent: its endpoints, launch and liveness checks assumed Unix sockets, chmod and POSIX processes. Since interrupt and Stop now go through arf IPC (#1950), Windows no longer needs signals for them.
This PR enables managed Interactive sessions on Windows and keeps the Unix behavior unchanged. Discovering and adopting an existing arf process on Windows is left for a follow-up.
Changes
transport.tscreates and listens on local endpoints for the agent control channel and the sess bridge. Windows uses named pipes; Unix keeps sockets with mode 0600.autoanddetached;tmuxandsystemdare rejected with an actionable error. The agent is spawned detached and hidden, without editor-owned stdio, logging toagent.log.%LOCALAPPDATA%\vscode-r\interactive.Notes for reviewers
%LOCALAPPDATA%and the per-user%TEMP%. The extension does not rewrite ACLs. Named pipes keep their default security descriptor, under which other users cannot open them for writing. Securing a custom or shared storage path is documented as the user's responsibility.Follow-ups
node/arfexecutables are POSIX shell scripts. The product spawns executables without a shell, so.cmdwrappers cannot replace them either; they need a Node-based fake that Windows can launch as an.exe.