feat: add experimental arf headless subcommand for terminal-free IPC operation#119
Merged
feat: add experimental arf headless subcommand for terminal-free IPC operation#119
arf headless subcommand for terminal-free IPC operation#119Conversation
Add a new `arf headless` subcommand that starts R with an IPC server but without the interactive REPL (reedline). This enables IPC testing on Windows CI where ConPTY cursor::position() is problematic, and supports AI-agent-only use cases where no terminal is needed. The headless mode: - Initializes R with the same flags as the REPL (vanilla, no-environ, etc.) - Starts the IPC server automatically (no --with-ipc flag needed) - Polls for IPC requests and R events in a simple loop - Exits on Ctrl+C Integration tests use `arf headless` + `arf ipc eval` end-to-end, requiring only std::process::Command (no PTY). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The headless handler was ignoring the visible parameter, always using silent capture. Now visible=true passes through to start_ipc_capture, so output is written to the headless process's stdout/stderr as well as being returned in the JSON-RPC response. Also add test verifying visible output appears on the server side and silent output does not. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…nput error handling - Extract shared R argument-building logic into RArgsBuilder struct, used by both Cli::r_args() (REPL) and run_headless(). Eliminates the duplicated headless_r_args static method. - Simplify run_headless() from 11 parameters to 4 by passing RArgsBuilder directly. Removes the clippy too_many_arguments allow. - Return accepted=false from headless user_input when eval_string fails, so IPC clients can detect evaluation failures. Addresses roborev review 419 findings. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add a `shutdown` JSON-RPC method that triggers graceful shutdown of headless mode. The method is handled directly on the server thread (no main thread round-trip needed) by setting the shared shutdown flag. In REPL mode, shutdown returns METHOD_NOT_FOUND since the REPL has its own exit mechanisms (:quit, Ctrl+D, q()). Also adds `arf ipc shutdown --pid <PID>` CLI subcommand and updates the headless help text to reference it. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a headless execution mode to arf-console so R + the IPC server can run without a terminal/REPL, enabling cross-platform (notably Windows CI) IPC integration testing and adding a graceful shutdown path for headless sessions.
Changes:
- Add
arf headlesssubcommand that runs R + IPC server without reedline/terminal. - Add JSON-RPC
shutdownmethod plusarf ipc shutdownclient command. - Refactor R init argument construction into a shared
RArgsBuilder, and add new headless end-to-end integration tests + updated CLI completion/help snapshots.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/arf-console/tests/headless_tests.rs | New terminal-free integration tests covering headless IPC behavior, including shutdown. |
| crates/arf-console/src/main.rs | Wires headless subcommand to a new run_headless event loop and hooks IPC shutdown + Ctrl+C. |
| crates/arf-console/src/cli.rs | Adds Headless subcommand, ipc shutdown, and introduces RArgsBuilder for shared R arg construction. |
| crates/arf-console/src/ipc/mod.rs | Adds headless shutdown flag + headless polling/processing path; updates capture call signature usage. |
| crates/arf-console/src/ipc/server.rs | Implements shutdown JSON-RPC method (headless-only) handled directly on the server thread. |
| crates/arf-console/src/ipc/client.rs | Adds cmd_shutdown for arf ipc shutdown. |
| crates/arf-console/src/ipc/protocol.rs | Introduces ShutdownResult protocol type. |
| crates/arf-console/src/ipc/capture.rs | Extends capture to optionally “tee” output to process stdout/stderr when visible is true. |
| crates/arf-console/src/snapshots/arf__cli__tests__help_long.snap | Updates CLI help snapshot to include headless. |
| crates/arf-console/src/snapshots/arf__cli__tests__completions_*.snap | Updates shell completion snapshots for headless and ipc shutdown. |
| crates/arf-console/Cargo.toml | Adds ctrlc dependency for headless Ctrl+C handling. |
| Cargo.toml | Adds workspace dependency entry for ctrlc. |
| Cargo.lock | Locks ctrlc and its transitive deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix headless_tests.rs module doc: "session file discovery" → actual stderr monitoring mechanism - Improve cmd_shutdown error handling: treat missing/non-accepted result as error with non-zero exit - Add test_ipc_shutdown_rejected_in_repl: verify shutdown returns METHOD_NOT_FOUND in REPL mode Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
arf headless subcommand for terminal-free IPC operationarf headless subcommand for terminal-free IPC operation
This was referenced Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
arf headlesssubcommand that starts R + IPC server without interactive REPL (no reedline/terminal needed)shutdownIPC method andarf ipc shutdownCLI for graceful headless terminationRArgsBuilderto deduplicate R argument-building logic between REPL and headless modesMotivation
Windows CI cannot run IPC tests because ConPTY's
cursor::position()is incompatible with reedline. Headless mode eliminates terminal dependency entirely, enabling cross-platform IPC testing with juststd::process::Command.Test plan
--vanillaflagcargo clippyclean (no warnings)🤖 Generated with Claude Code