Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some multiline code in R console not working a #4901

Closed
jonvanausdeln opened this issue Oct 4, 2024 · 5 comments
Closed

Some multiline code in R console not working a #4901

jonvanausdeln opened this issue Oct 4, 2024 · 5 comments
Labels
area: console Issues related to Console category. lang: r

Comments

@jonvanausdeln
Copy link
Contributor

System details:

Windows, Ubuntu 22

Positron and OS details:

Dev build after ARK bumped to 0.1.143

Interpreter details:

R 4.4.1

Describe the issue:

Found in our automated ConsoleInput tests. This appears to be happening after the latest ARK version bump

Steps to reproduce the issue:

  1. Start and R Console
  2. Paste the following into the console
val <- readline(prompt = "Enter your name: ")
cat(sprintf('Hello %s!\n', val))

Results in
Image

Expected or desired behavior:

Image

Were there any error messages in the UI, Output panel, or Developer Tools console?

@DavisVaughan
Copy link
Contributor

DavisVaughan commented Oct 4, 2024

A little more info, looks like we need to recognize if we are in a readline state and pause on sending pending lines if we detect that

(To be clear, to reproduce you have to select both lines at once and send them all over)

Image

@testlabauto
Copy link
Contributor

There may be a little extra diagnostic info on OSX. Here is what I see with that test:

Image

[R] /Users/christophermead/posit/positron/extensions/positron-r/resources/ark/ark --connection_file /var/folders/rc/l24758015ggb5438npy04wtc0000gn/T/kernel-yfbhov/connection.json --log /var/folders/rc/l24758015ggb5438npy04wtc0000gn/T/kernel-yfbhov/kernel.log --startup-file /Users/christophermead/posit/positron/extensions/positron-r/resources/scripts/startup.R --session-mode console -- --interactive --no-restore-data
[R]   2024-10-04T17:46:02.111723Z ERROR  Panic! In file 'crates/ark/src/interface.rs' at line 686: internal error: entered unreachable code: Incomplete input in `ReadConsole` handler
[R] 
[R] Backtrace:
[R]    0: std::backtrace::Backtrace::create
[R]    1: ark::main::{{closure}}::{{closure}}
[R]    2: ark::main::{{closure}}
[R]    3: std::panicking::rust_panic_with_hook
[R]    4: std::panicking::begin_panic_handler::{{closure}}
[R]    5: std::sys::backtrace::__rust_end_short_backtrace
[R]    6: _rust_begin_unwind
[R]    7: core::panicking::panic_fmt
[R]    8: ark::interface::RMain::read_console
[R]    9: harp::exec::try_catch::callback
[R]   10: R_withCallingErrorHandler
[R]              at /Volumes/Builds/R4/R-4.3.3/src/main/errors.c:2613:16
[R]   11: harp::exec::top_level_exec::callback
[R]   12: R_ToplevelExec
[R]              at /Volumes/Builds/R4/R-4.3.3/src/main/context.c:799:2
[R]   13: harp::exec::r_sandbox
[R]   14: _r_read_console
[R]   15: Rf_ReplIteration
[R]              at /Volumes/Builds/R4/R-4.3.3/src/main/main.c:210:10
[R]   16: R_ReplConsole
[R]              at /Volumes/Builds/R4/R-4.3.3/src/main/main.c:314:11
[R]   17: run_Rmainloop
[R]              at /Volumes/Builds/R4/R-4.3.3/src/main/main.c:1200:5
[R]   18: ark::interface::RMain::start
[R]   19: ark::main
[R]   20: std::sys::backtrace::__rust_begin_short_backtrace
[R]   21: std::rt::lang_start::{{closure}}
[R]   22: std::rt::lang_start_internal
[R]   23: _main
[R] 
[R]     at crates/ark/src/main.rs:279
[R] 
[R] 
[R] *** Log started at Fri Oct  4 11:46:02 MDT 2024
[R] *** Command line:
[R] /Users/christophermead/posit/positron/extensions/positron-r/resources/ark/ark --connection_file /var/folders/rc/l24758015ggb5438npy04wtc0000gn/T/kernel-OLvWNf/connection.json --log /var/folders/rc/l24758015ggb5438npy04wtc0000gn/T/kernel-OLvWNf/kernel.log --startup-file /Users/christophermead/posit/positron/extensions/positron-r/resources/scripts/startup.R --session-mode console -- --interactive --no-restore-data

@jonvanausdeln
Copy link
Contributor Author

QA Note: we are skipping the automated test (see #4902 ) and it will need to be re-enabled after this is fixed.

@lionel-
Copy link
Contributor

lionel- commented Oct 7, 2024

I think we had decided not to maintain any internal stacks of pending inputs in the case of nested prompts, in particular debug prompts, because doing so would be incompatible with the frontend-side expression splitting (#1326). Also we thought it'd be fine because this is the RStudio behaviour.

But now that I think of it, since in the Jupyter protocol readline prompts are nested in execute-request prompts, the frontend-side splitting will not result in pending expressions being sent to readline prompts. So there's a fundamental distinction between browser and readline prompts and I agree the behaviour change highlighted here should be fixed.

Worth noting that we have plans for browser prompts to become readline prompts in notebook-mode, because right now the behaviour is confusing (posit-dev/ark#572). I wonder if we should do the same for browser prompts in console mode to benefit from the same nested structure.

@juliasilge juliasilge added the area: console Issues related to Console category. label Oct 7, 2024
@juliasilge juliasilge added this to the 2024.11.0 Pre-Release milestone Oct 7, 2024
@jonvanausdeln
Copy link
Contributor Author

Verified Fixed

Positron Version(s) : 2024.11.0-49
OS Version(s) : Windows 11

Test scenario(s)

Input now works as expected.

Link(s) to TestRail test cases run or created:

R- User Input
R - User Input can use Menu
R - ESC dismisses autocomplete

jonvanausdeln added a commit that referenced this issue Oct 15, 2024
### Intent

Turn cnosole input test again as #4901 has been fixed in `main`

### Approach

Removed `skip`. Also note that these tests will now run as part of the PR jobs as requested by dev.

## QA Notes

Tests pass in CI
isabelizimm pushed a commit that referenced this issue Oct 16, 2024
Skipping R console input test due to
#4901
isabelizimm pushed a commit that referenced this issue Oct 16, 2024
Skipping R console input test due to
#4901
isabelizimm pushed a commit that referenced this issue Oct 18, 2024
### Intent

Turn cnosole input test again as #4901 has been fixed in `main`

### Approach

Removed `skip`. Also note that these tests will now run as part of the PR jobs as requested by dev.

## QA Notes

Tests pass in CI
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: console Issues related to Console category. lang: r
Projects
None yet
Development

No branches or pull requests

5 participants