The ask is to make the positron API executeCode call respect the RuntimeCodeExecutionMode and RuntimeErrorBehavior values being passes in. This PR only handles RuntimeCodeExecutionMode. The work for RuntimeErrorBehavior will be done in a separate PR.
The runtime session execute is already setup to work with RuntimeCodeExecutionMode, see workbench.action.executeCode.silently (https://github.com/posit-dev/positron/pull/2684) for an example of silent code execution via the session directly.
For code execution to work as expected, some changes were made in the PositronConsoleService to prevent data from being rendered in the console or added to history based off the RuntimeCodeExecutionMode.
QA Notes
We will want to verify that the three different values for RuntimeCodeExecutionMode are respected when positron.runtime.executeCode() is called and verify there aren't any regressions:
RuntimeCodeExecutionMode.Interactive means the code was entered interactively, and should be executed and stored in the runtime's history
We should verify that executing code via the console as a user would runs the code interactively.
We should verify that positron.runtime.executeCode() without a RuntimeCodeExecutionMode defaults to RuntimeCodeExecutionMode.Interactive
Verify the command workbench.action.executeCode.console runs the code interactively.
RuntimeCodeExecutionMode.Transient means the code should be executed (shown in console) but not stored in history
RuntimeCodeExecutionMode.Silent means the code should neither displayed to the user nor stored in history
Verify the command workbench.action.executeCode.silently runs the code interactively.
The PositronZedLanguageRuntime has a new command exec silent that can execute a code snippet in the language silently. The exec command now explicitly passes a RuntimeCodeExecutionMode of Interactive to make it clear what is happening.
Description
This partially addresses the ask from #4856.
The ask is to make the positron API
executeCode
call respect theRuntimeCodeExecutionMode
andRuntimeErrorBehavior
values being passes in. This PR only handlesRuntimeCodeExecutionMode
. The work forRuntimeErrorBehavior
will be done in a separate PR.The runtime session
execute
is already setup to work withRuntimeCodeExecutionMode
, seeworkbench.action.executeCode.silently
(https://github.com/posit-dev/positron/pull/2684) for an example of silent code execution via the session directly.For code execution to work as expected, some changes were made in the
PositronConsoleService
to prevent data from being rendered in the console or added to history based off theRuntimeCodeExecutionMode
.QA Notes
We will want to verify that the three different values for
RuntimeCodeExecutionMode
are respected whenpositron.runtime.executeCode()
is called and verify there aren't any regressions:RuntimeCodeExecutionMode.Interactive
means the code was entered interactively, and should be executed and stored in the runtime's historypositron.runtime.executeCode()
without aRuntimeCodeExecutionMode
defaults toRuntimeCodeExecutionMode.Interactive
workbench.action.executeCode.console
runs the code interactively.RuntimeCodeExecutionMode.Transient
means the code should be executed (shown in console) but not stored in historyRuntimeCodeExecutionMode.Silent
means the code should neither displayed to the user nor stored in historyworkbench.action.executeCode.silently
runs the code interactively.The
PositronZedLanguageRuntime
has a new commandexec silent
that can execute a code snippet in the language silently. Theexec
command now explicitly passes aRuntimeCodeExecutionMode
ofInteractive
to make it clear what is happening.Screenshot
Silent Code Execution - Print
https://github.com/user-attachments/assets/ce57bb56-bf72-40be-bce0-d134d34d560b
Silent Code Execution - Variable Assignment
https://github.com/user-attachments/assets/f792a7a8-bd46-45af-a8e5-3acadd6a608a
Interactive Code Execution - Print
https://github.com/user-attachments/assets/ec46d151-1df4-4ab2-badb-b60a71fcc4db
Interactive Code Execution - Variable Assignment
https://github.com/user-attachments/assets/b4146441-a288-4897-803f-d71146ffcfaa