Open petetronic opened 1 year ago
One example that generates this type of output is the iPython %less
magic. If you try to print the contents of a text file in your working directory, the content is returned on the shell channel in an execute_reply message, however we do not show this in the Console.
Truncated example of a reply to %less yourfile.txt
:
[Positron] RECV execute_reply from shell:
{
"header":
{
"msg_type": "execute_reply",
...
},
"parent_header":
{
"msg_type": "execute_request",
...
},
...
"content":
{
"status": "ok",
...
"payload":
[
{
"source": "page",
"data":
{
"text/plain": "Your text file content is returned here..."
}
}
]
}
}
We can discuss with the team if these output types are marked in some way different from those from execute_result.
Because this is file content, I've half a mind to have it hosted in an editor buffer instead of dumped into the Console. You said that some of these are decorated with ANSI escape sequences, though, right?
Right, so another example I've seen is "help" like information about a magic. For example, %colors?
tells you how to use the %colors magic. Its content describing the colors magic's options is sent in an execute_reply payload but it has ANSI control sequences to color items.
(As an aside, some other magics, like the %ls
alias, sends its output through the normal iopub execute_result, and that does show up in our Console today).
For reference, here are the magic commands I've found that use the page
payload type:
?
– entering a single question mark into the prompt is an alias for %pinfo
??
– alias for %pinfo2
%magic
%page
%quickref
%pycat
%pdoc
%psource
%pfile
%pinfo
%psearch
I agree that we could probably intercept these and either display the result in a new buffer, or in the help pane.
While the Jupyter specification mentions that the use of payloads is deprecated, a replacement has not been finalized. Some ipython output still makes use of the execute_reply message with a payload defined.
If the data in the payload is text/plain, we should at least consider showing this in the Positron Console REPL, even if it is not intended for Jupyter notebook cell output.
We may need a bit of plumbing in our runtime middleware to get these messages to the Console.