Skip to content

feat(interactive): connect to existing arf sessions on Windows - #1990

Draft
eitsupi wants to merge 3 commits into
feat/interactive-arf-ipc-discoveryfrom
feat/interactive-windows-arf-adoption
Draft

eitsupi wants to merge 3 commits into
feat/interactive-arf-ipc-discoveryfrom
feat/interactive-windows-arf-adoption

Conversation

@eitsupi

@eitsupi eitsupi commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Connecting to an existing arf session was not supported on Windows. With sessions listed through the arf CLI and a Stop that never signals an attached process, nothing Unix-specific remains, so this enables it and tests it on every platform.

  • The documentation no longer excludes Windows from connecting to an existing arf session. Its setup steps ask to enable IPC, with :ipc start in a running arf, which keeps its objects, or arf --with-ipc for a new one.
  • The runtime test that adopts a headless arf now also runs on Windows.
  • A new runtime test drives an arf that runs in a terminal through a pseudo-terminal with @microsoft/tui-test, on every platform. The session is found by its PID and adopted, evaluates and is interrupted through IPC, refuses Stop while staying alive and usable, and still evaluates in its terminal after the agent closes. arf keeps its default policy for silent evaluation, and quits at the end so that it removes its socket. On Windows, this test needs x64 Node, for which the pseudo-terminal package is published.
  • @microsoft/tui-test is a pinned devDependency, and koffi's install script is allowed for the native library that it uses.

@eitsupi
eitsupi added this pull request to stack #1989 November 22, 2026 02:34
@eitsupi
eitsupi requested a review from renkun-ken November 22, 2026 02:45
@eitsupi
eitsupi marked this pull request as ready for review November 22, 2026 02:45
@eitsupi
eitsupi force-pushed the feat/interactive-windows-arf-adoption branch from 320733e to a6736b1 Compare November 22, 2026 02:57

@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.

Both the terminal and headless adoption tests passed locally on macOS with arf 0.7.2. The Windows and Ubuntu CI logs also show both tests executed. The terminal test demonstrates that R can still use an object created through the editor after the agent closes.

Please update the setup guide so users can discover a terminal launched with default settings, and exercise the default silent-evaluation policy in the new test. I also left two smaller notes on test cleanup and Windows Arm64. Windows CI · Ubuntu CI

## Requirements and setup

Use **VS Code 1.101.0 or newer**. R Interactive supports Linux, macOS, and Windows. On Windows, [connecting to an existing arf session](#connect-to-an-existing-arf-session) is not yet supported. Existing R terminal workflows remain available.
Use **VS Code 1.101.0 or newer**. R Interactive supports Linux, macOS, and Windows, including [connecting to an existing arf session](#connect-to-an-existing-arf-session). Existing R terminal workflows remain available.

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.

Enable IPC before opening the picker. The linked guide’s first step says to start arf “as usual”. With the pinned arf 0.7.2, I started a plain arf and arf ipc list returned no sessions. After I typed :ipc start at the same R prompt, its PID appeared. Please update step 1 to cover both :ipc start in an existing terminal and arf --with-ipc when launching a new one. This also lets users keep objects they already have in an open terminal. arf IPC guide

arf,
[
'--with-ipc',
'--ipc-eval-unrestricted',

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.

Keep arf’s default silent-evaluation policy in this test. The fixture already permits visible editor submissions with :ipc send-policy allow. --ipc-eval-unrestricted additionally permits arbitrary silent evaluation, so a future change that sent bootstrap or cell code silently could pass here and fail against a normally configured terminal. I reran this test on macOS with only this argument removed. Adoption, execution, interrupt, Stop refusal, and terminal reuse all passed. Please drop the argument.

connection?.close();
await adopted?.close();
} finally {
await terminal.closeQuiet();

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.

Let arf exit normally on the successful path. On macOS I matched the socket to the PID written by this fixture. After a passing run, closeQuiet() had ended the process, but its <pid>.sock and containing directory still existed outside the suite’s temporary directory. Sending await terminal.submit("q('no')") after the final prompt assertion and then await terminal.waitExit({ timeout: 5000 }) let arf remove both. The existing finally can still close the PTY when an assertion fails.

}
this.skip();
}
const { TuiTest } = await import('@microsoft/tui-test');

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.

Windows Arm64 test prerequisite (minor). The pinned package selects its DLL using Node’s process.arch and publishes only win32-x64-msvc for Windows. A contributor using native Arm64 Node can run the x64 arf.exe under emulation and get past arf --version, then fail at this import because the Arm64 PTY package is missing. Please document x64 Node as the prerequisite for this test on Windows, or skip just the PTY case on that unsupported architecture. The headless adoption test can still run.

@eitsupi
eitsupi force-pushed the feat/interactive-windows-arf-adoption branch from a6736b1 to bc33715 Compare November 22, 2026 08:40
@eitsupi
eitsupi requested a review from renkun-ken November 22, 2026 08:42
With discovery through the arf CLI and a Stop that never signals an
adopted process, connecting to an existing arf session no longer has
Unix-only parts, so the documentation stops excluding Windows and the
adoption runtime test runs there as well.

Add a runtime test of an arf that runs in a terminal, driven through a
pseudo-terminal with @microsoft/tui-test on every platform. It is
discovered by its PID and adopted, evaluates and interrupts through IPC,
refuses Stop while staying alive and usable, and still evaluates in its
terminal after the agent closes. koffi's install script is allowed for
the native library that tui-test uses.
…default policy in the terminal adoption test

The guide said to start arf as usual, but a plain arf does not serve IPC,
so it was not listed. It now says to type `:ipc start` in a running arf,
which keeps its objects, or to start a new one with `arf --with-ipc`.

The terminal adoption test started arf with `--ipc-eval-unrestricted`,
which also permits silent evaluation, so code sent silently could pass
there and fail against a normally configured terminal. The test now
keeps arf's default policy. On success it quits R, so that arf removes
its socket and session registration, and it is skipped on Windows when
Node is not x64, for which the pseudo-terminal package is not published.
@eitsupi
eitsupi marked this pull request as draft November 22, 2026 09:00
@eitsupi
eitsupi force-pushed the feat/interactive-windows-arf-adoption branch from bc33715 to e706147 Compare November 22, 2026 09:27

This branch has not been deployed

No deployments
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