Defining jupytext as the default viewer for text notebooks under jlab4

I’d like to revisit a discussion that we’ve had a while back already, but today in the context of jlab4

I’m trying to help @mwouts with the jupytext extension for jlab4, and it seems like an alpha version is in sight - https://github.com/mwouts/jupytext/issues/1054 - but at this point there is still the same issue addressed in the post above, namely that double clicking in a jupytext notebook in the file browser opens it in the editor and not as a notebook, and this despite the configuration that says

cat ~/.jupyter/labconfig/default_setting_overrides.json
{
  "@jupyterlab/docmanager-extension:plugin": {
    "defaultViewers": {
      "markdown": "Jupytext Notebook",
      "myst": "Jupytext Notebook",
      "r-markdown": "Jupytext Notebook",
      "quarto": "Jupytext Notebook",
      "julia": "Jupytext Notebook",
      "python": "Jupytext Notebook",
      "r": "Jupytext Notebook"
    }
  }
}

is this an expected result of using jlab4 and if so how can we get to enable the desired behaviour ?

here is where i set default viewers in jlab4:

~/ cat .jupyter/lab/user-settings/@jupyterlab/docmanager-extension/plugin.jupyterlab-settings
{
    "autosave": true,
    "autosaveInterval": 120,
    "confirmClosingDocument": false,
    "lastModifiedCheckMargin": 500,
    "renameUntitledFileOnSave": true,
    "defaultViewers": {
        "markdown": "Editor",
        "json": "Editor",
        "csv": "Editor",
        "tsv": "Editor"
    }
}

edit: also available under settings → document manager

Thanks for the tip, it’s helpful to at least know where the config should be located

However I’m still unable to get it to work
I can confirm the new config file gets loaded (after I made a stupid mistake in the json syntax), but I have tried to set the right-hand-side value to

  • "Jupytext Notebook" because this is what we had before
  • and then simply to "Notebook" because that is what I see in the Open with menu - and it does work fine when I go this road

but none of these settings result in the desired behaviour


could it mean that the jupytext extension should somehow expose a ‘viewer’ thing of some kind ?
the fact that the open-with menu works seems to suggest otherwise, but…

more generally how can I hope to troubleshoot that ?

thanks again for the tip in any case

So the right-click menu works?
I’d try reading this and working through that mp4 example renderer.
It’s not that much code ^^

I am not sure, but i guess the documentWidgetFactoryOptions in the mp4 renderer example might be the key to what is needed for the viewer to work.

turns out there was a missing field in the widget factory

as a result the ‘Jupytext Notebook’ viewer was not available

see also TypeError: t.currentWidget.context.model.metadata.has is not a function with JupyterLab 4 · Issue #1054 · mwouts/jupytext · GitHub
it’s all good now, thanks for your help @spookster