Repository navigation
Spike: Investigate common ground between I.W. and Python REPL #23029
Description
This document intends to capture information that pertains to or intends to distinguish between I.W. and upcoming Python native REPL. For information that is focused more solely or in a broader spectrum towards native Python REPL can be tracked here: #22674
(More to be added) Conducting spike into learning more about the current state of Interactive Window that uses iPython kernel, including target users, complains about I.W, and how I.W and notebook components and attributes can be applied towards building VS Code native Python REPL experience.
This spike plans to display and document some of the finding that represent current state of Interactive Window, Notebook and plans in moving forward for move I.W. and native Python REPL experience.
We should also note of the positive and mutually inclusive components/design/feature we would want to potentially apply in designing and implementing VS Code Native REPL.
Components/design/features that may be present in notebook, interactive window, but rather should be avoided for native VS Code REPL experience should also be listed here.
- If in a case that the cell like structure is used to represent VS Code native REPL, we should not allow users to execute different cell components back and forth in a somewhat randomized way that is allowed in Jupyter notebook and Interactive Window without keeping the sole, uninterrupted history of execution order that is visible to users. We want to make it explicitly clear which exact order user has executed their commands, and index number per each cell is not sufficient to provide the full history of execution order.
- If in a case that the cell like structure is used, user should be able to clearly see which order they have executed their commands. On a instance where user wish to re-execute their previous command that they have previously executed in previous cell like structure, we may allow them to copy or re-execute in the promise of placing the re-execution to the very latest location of the REPL instance.
Questions that needs more research:
- If we decide to go with more of horizontal structure that still uses cell-like components that basically sends commands from the left side to the right, I'm not sure if
notebook editoror notebook API can be used since it ison top of builtin list/tree view renderer
- How does I.W. get IntelliSense, syntax highlighting? Is it via Pylance or other LSP.
- Presence and extent of debugging: What does debugging look like for I.W.? How should debugging look like in the upcoming native REPL?
- Since VS Code Native REPL won't be using iPython Kernel, what would it take to replace that with? Is it a custom interactive interpreter (custom REPL)? If so what should we keep in mind in building this other than the storage of command history?
- How generalized is Interactive Window and Notebook to outside of Python. How applicable is it for other languages?
- If in a case of using cell-like structure, how do I keep the state of each individual cell component to share same instance of my customized interactive interpreter?
- Do I need to build my own "kernel" if I use notebook structure/API?
- Explore a ways to embed variable view in the current interactive window vertical structure.
Actionable items going forward (more to be added):
- Build custom Python REPL (interactive interpreter)
- Build node.js application to that hooks up to custom interactive interpreter that can send message back and forth.
- Once I have package to launch/communicate with Python REPL then I would hook it up to VS Code API.
- Message would mean the Python command users are trying to execute, and also the result of those. This would be ideal to see if correct communication is happening between the TypeScript side and the Python side later when the code from the above node js project gets embedded inside Python extension repository; And also to be part of/connect to notebook controller, so then the custom Python REPL/interactive interpreter can be used as a kernel, and not have to require iPython kernel which were a overhead/complaints in users staying away from the current interactive window experience.
Activity
amunger commentedon Mar 7, 2024
From your mockup screenshot, I was initially thinking of this suggestion
To clarify what you were going with on that editor layout -
Are those two seperate tab groups? Is this in the editor area or the panel?
Is the left side one big input?
Would there still be the option to execute code from a .py file?
anthonykim1 commentedon Mar 7, 2024
It is sort of like a diff editor view. If we go with horizontal like view, it should be configurable into a verticle view if user also wants to view their content from Python file on side side of the VS Code, from feedback from Python standup today.
The link is surprisingly similar to my updated mockup as I was thinking more of:

after the screenshot above.
I was thinking left side should be chunked up and match with the output boxes on the rightside on 1:1 ratio for better readability.
Yes, there would be way to trigger from .py.
anthonykim1 commentedon Mar 12, 2024
Attaching meeting notes from March 7th, 2024 (feel free to add more):
compute. Interactive window talks to Jupyter kernel, which can generate both text output and rich output. iPython generate all text.amunger commentedon Mar 12, 2024
Should be "as a controller/kernel". To expand on this, the current categories that the jupyter extension provides are these:
Jupyter allows users to pick an interpreter to be used as a controller (in the python environments category) and we ensure that the required packages are installed - ipykernel/IPython.
If the REPL also uses that same kernel picker (rather than perhaps just forcing the user to use the active interpreter), it would likely provide the same list of interpreters that are in Jupyter's python environments category, but selecting them would be a different experience.
But I think the Python extension will have to select which controller to use when opening the IW anyway, so the user won't be in this situation unless they want to change it.
anthonykim1 commentedon May 1, 2024
MVP
intellisense - aaron
execute (enter/shift+enter/ctrl+enter) - aaron
add to python extension behind experiment - anthony
Jupyter's IW shouldn't break - aaron
handle interpreter not selected gracefully - anthony
interrupt - anthony
support input() - anthony
repl file association - anthony???
------------------------ Further Improvements ----------------------
re-add cell if executed in history - aaron
reduce padding in cells microsoft/vscode#175295 - aaron
variable provider - anthony
restart - anthony
IW/"repl notebook" with pure notebook model - aaron
Native IW API - aaron
Multiple REPLs - anthony
smart send - anthony
using core component for text output - aaron
recovering an active REPL on reload - anthony
anthonykim1 commentedon May 8, 2024
Adding issue that contains items needed for MVP: #23332
anthonykim1 commentedon May 10, 2024
Discussed May 9th:
We may need additional notebook API that resembles pre-execute handler of some kind.
If Python extension were to strive for "enter" to be the default execution mechanism for user trying to execute their Python command using IW UI (with REPL controller contributed from Python extension), we need to be able to get user's Python command inside user's text input box inside the IW UI BEFORE execute handler.
This is because cell output UI seem to already be attached by the time execute handler gets called, but we would need user's input before in order to figure out whether they have typed complete command or incomplete command and hence need to wait for more input.
Add Interactive REPL Experiment (#23235)
Add Interactive REPL Experiment (microsoft#23235)
Add Interactive REPL Experiment (#23235)