positron
positron copied to clipboard
`RRuntime` `execute()` requests don't populate the Console history correctly
Discovered while working on https://github.com/posit-dev/positron/pull/2007
It seems like the code sent through execute() isn't populated immediately in the console history, but is there after a restart of positron
https://github.com/posit-dev/positron/assets/19150088/aaa53e6e-3637-4ebe-8dde-fd8c1f0c73b9
Ah I wonder if the history issue is due to the fact that when you call a runtime's execute() method directly, this _onDidExecuteCodeEmitter event is not fired (it is called in the other "blessed" paths where runtime.execute() is called)
https://github.com/posit-dev/positron/blob/9ae3137d234058543f9f075e76cbada1b3289498/src/vs/workbench/services/positronConsole/browser/positronConsoleService.ts#L1830
It seems like it is highly related, and was a part of https://github.com/posit-dev/positron/pull/1663
My gut tells me that we need to move some of this behavior down into the kernel execute() method.
https://github.com/posit-dev/positron/blob/74f52bab1a5103425f5ddba6b462d0fbbb58a3f3/extensions/jupyter-adapter/src/JupyterKernel.ts#L897
Like, if store_history is TRUE, then we do some kind of signal to store the result in the execution history.
If the signal came from there and was propagated upward, that would be low enough that an RRuntime execute() call would trigger it, making that method safer to use.
I think ideally I'm looking for some solution that ensures a runtime's execute() method exactly matches what happens when a user types code interactively at the console (at least if the Interactive mode is set)
#2007 is now merged, so a simple reprex to reproduce this is:
Run
cli::cli_text("{.run rlang::abort('oh no')}")
Click the code hyperlink to automatically run the code
Press Up to go to the previous command in the History. It should be rlang::abort('oh no'), but is not
We talked at one point about whether it is a good idea at all to be able to execute with an RRuntime (for exactly the reasons you outline here) but we use it quite a bit now. 😬
Verified Fixed
Positron Version(s) : 2025.07.0-200
OS Version : OSX
Test scenario(s)
Code sent via execute is not immediately available in console history.
Link(s) to TestRail test cases run or created: