microsoft / microsoft/vscode-docs

API - How to create an "interactive"/REPL-style Notebook is not documented

Open
#8,530 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
Markdown
Stars
6.6k
Forks
5.8k
Avg merge
11h 43m
Merged PRs (30d)
123

Description

VSCode added support for "Interactive Notebooks" (REPL-style, where the CLI is at bottom, cell outputs get stacked on top). Python notebooks use it, and the [rest-api] example also does too. And, I wanted to add support for a Notebook extension I'm working on.

While the docs are pretty good at giving an overview and pointing at sample for details. The docs do not touch on the topic of "Interactive Notebooks". While I got it working, the mechanisms to enable REPL in notebook extension are pretty wonky - docs cannot fix that – but all the more reason it should be documented better ;).

It took unwinding this diff:
https://github.com/tanhakabir/rest-book/commit/c64a145725b31088245ec491221fda0bf3ea748b

Along with the only doc I could find that had a couple more clues:
https://github.com/microsoft/vscode/wiki/Interactive-Window-Documentation

which isn't written for an extension author's POV.

AFAIK, the steps are:

  • add onNotebook:interactive to package.json under activations along with the current notebook kernel, with "interactive" explicitly regardless of own extension naming.
  • subscriptions.push() a second instance of extension's notebook NotebookController/"kernel" in activate(), except with notebookType : "interactive" and some derivative metadata:
    notebooks.createNotebookController(
              isInteractive ? `${this.controllerId}-repl` : this.controllerId,
              isInteractive ? "interactive" : this.notebookType,
              isInteractive ? `${this.label} REPL`: this.label
          );
    
  • critically, to be able to get to you need add command (and file/open menu that invokes it) to extension for user to open it – with the command invoking the interactive.open command that provides the support (apparently):
    await commands.executeCommand('interactive.open',
      		undefined,
      		undefined,
      		`${exention-id}/${interactiveKernelControllerId}`,
      		undefined
      	);
    

It now looks simple, but this one took a while to unwind/figure out – thus the report. I missed that interactive.open was needed - the callback was off screen on a long line in rest-book example, and assumed it was called workspace.openNotebookDocument with the interactive type

Now I'm not sure that's the whole story on "Interactive Notebooks" - since it's not documented! So mere mention in docs would go a long way for the next person that tries to add a REPL notebook to an extension.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the rest-book commit diff, its package.json activation entry, and src/extension/commands.ts around the interactive.open call, then compare them with VS Code's Interactive Window Documentation. Document the confirmed steps and any additional requirements for extension authors so a reader can create and open an interactive notebook.

Written by the indexing model from the issue text.

Assessment

Tech stack
vscode
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.