Skip to content

feat(interactive): support managed sessions on Windows - #1953

Merged
eitsupi merged 10 commits into
mainfrom
feat/interactive-windows-managed
Nov 17, 2026
Merged

eitsupi merged 10 commits into
mainfrom
feat/interactive-windows-managed

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

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: a new transport.ts creates and listens on local endpoints for the agent control channel and the sess bridge. Windows uses named pipes; Unix keeps sockets with mode 0600.
  • Supervision: Windows uses detached supervision for auto and detached; tmux and systemd are rejected with an actionable error. The agent is spawned detached and hidden, without editor-owned stdio, logging to agent.log.
  • Readiness and liveness: a launch waits until the agent answers an authenticated probe for the expected session, not just until its manifest appears. The registry pre-filter still rejects stale entries by agent PID and, on Unix, by the socket file; on Windows it does not touch the pipe.
  • Storage: the default registry on Windows is %LOCALAPPDATA%\vscode-r\interactive.
  • Process control: Interrupt is available on Windows through arf IPC. Stop's fallback force-terminates on Windows, where Node signals already mean termination.
  • Line endings: code submitted from a CRLF editor document is normalized to LF before R parses it, since R rejects CR in source; history keeps the submitted text.
  • CI: Windows installs arf through mise, and the managed runtime, backend and protocol tests run there. Adopting an existing arf stays skipped on Windows.

Notes for reviewers

  • Security on Windows relies on the existing token authentication of the control and sess endpoints and on the user-profile ACL inherited by %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.
  • The detached-supervision runtime test checks that a session survives the termination of the process that launched it and keeps its objects. On Windows it does not walk the process tree.

Follow-ups

  • Editor tests on Windows: some Interactive editor tests are skipped on Windows because their fake node/arf executables are POSIX shell scripts. The product spawns executables without a shell, so .cmd wrappers cannot replace them either; they need a Node-based fake that Windows can launch as an .exe.
  • Multiplexer supervision on Windows: Windows currently supports only detached supervision. A multiplexer with Windows builds, such as zellij, could be evaluated as an additional supervisor, which would also let the supervisor-specific tests run there.

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.
@eitsupi
eitsupi marked this pull request as ready for review November 16, 2026 14:03

@renkun-ken renkun-ken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.
@eitsupi
eitsupi requested a review from renkun-ken November 16, 2026 22:52
…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 renkun-ken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@eitsupi
eitsupi merged commit 16e3b3f into main Nov 17, 2026
15 checks passed
@eitsupi
eitsupi deleted the feat/interactive-windows-managed branch November 17, 2026 00:49
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.

2 participants