Skip to content

fix: configure pager, browser, and graphics device for headless mode#122

Merged
eitsupi merged 8 commits intomainfrom
fix/headless-pager-and-graphics
Mar 20, 2026
Merged

fix: configure pager, browser, and graphics device for headless mode#122
eitsupi merged 8 commits intomainfrom
fix/headless-pager-and-graphics

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Mar 20, 2026

Summary

  • Configure R options at headless startup to prevent interactive programs from blocking or corrupting the server:
    • Custom pager function that dumps help text to stdout (captured by evaluate_with_capture) instead of spawning less/more
    • help_type="text" to force text-based help output
    • Custom browser function that prints URLs to stdout instead of opening a browser
    • File-based graphics device (png with pdf fallback) instead of X11/quartz
  • png()/pdf() use fixed defaults (no ... forwarding) to avoid unit mismatch between inches and pixels
  • The approach is based on mcp-repl (Apache-2.0)

Test plan

  • test_headless_help_does_not_hang?mean completes without hanging and captures help text
  • test_headless_plot_does_not_hangplot(1:10) completes without hanging, device is file-based (png/pdf)
  • test_headless_browse_url_does_not_hangbrowseURL() prints URL to stdout
  • All 17 headless tests pass
  • cargo fmt and cargo clippy clean

🤖 Generated with Claude Code

eitsupi and others added 2 commits March 20, 2026 05:09
Set R options at headless startup to prevent interactive programs from
blocking or corrupting the server:
- Custom pager function that dumps help text to stdout (captured by
  evaluate_with_capture) instead of spawning less/more
- help_type="text" to avoid HTML help opening a browser
- Custom browser function that prints URLs to stdout
- File-based graphics device (png with pdf fallback) instead of X11

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- pdf() uses inches while png() uses pixels, so forwarding ...
  could create absurdly large files
- Test now verifies the graphics device is actually file-based
  (png or pdf) rather than just checking success

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
macOS uses quartz which works headlessly (unlike X11), so the test
should accept quartz_off_screen alongside png/pdf.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens arf headless startup by configuring R options to avoid spawning interactive pagers/browsers/GUI graphics devices that can hang or corrupt a headless server session.

Changes:

  • Configure headless-only R options (text help, stdout pager, URL-printing browser, file-based graphics device).
  • Add integration tests ensuring ?mean and plot() complete without hanging in headless mode.
  • Document the fix in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/arf-console/src/main.rs Adds headless R option configuration (pager/browser/device) during run_headless() startup.
crates/arf-console/tests/headless_tests.rs Adds end-to-end tests verifying help and plotting don’t hang and use the expected headless behaviors.
CHANGELOG.md Notes the headless startup fix in Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

If the pager/browser/graphics options fail to apply, headless mode
would regress to spawning interactive programs that hang the server.
Return an error instead of logging a warning.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…test

- Update comments and log message to mention all configured options
  (pager, help_type, browser, graphics device)
- Add trailing newline after each pager file to prevent output merging
- Add test for browseURL() printing URL to stdout

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dev.new() passes width/height in inches but png() interprets them as
pixels. Use sensible defaults for both png and pdf fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

eitsupi and others added 2 commits March 20, 2026 06:18
Add attribution in doc comment and README Acknowledgements section.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The IPC server design was heavily informed by these Julia MCP server
implementations, particularly the shared REPL pattern and agent code
visibility approach.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@eitsupi eitsupi merged commit bc42dec into main Mar 20, 2026
10 checks passed
@eitsupi eitsupi deleted the fix/headless-pager-and-graphics branch March 20, 2026 06:38
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