Externd/Override jupyterlab default error messages

Hi all,

I am trying to change the default messages returned by jupyterlab without any luck. I am not very experienced with jupyterlab but I have read tutorials and I have a good understanding on how to write an extension (e.g. GitHub - jupyterlab/extension-examples: JupyterLab Extensions by Examples) but I am not sure how to extend/override the default error messages. This is an example of what I would like to achieve.

I start the server and I create 2 notebooks. After killing the server I receive messages like:

As mentioned here

this the place where of one of the messages I would like to extend/override lives.

I have searched extensively but I couldn’t find any hints whether this is doable (and how this could be done if doable). I have managed to create a simple extension but I can’t see how to extend/override a default behaviour/widget.

Can we override/extend the default dialogue messages that appear in different occasions?

Many thanks,

George

1 Like

Hi, did you find the way to override handlers and messages? I am in that same situation trying to override connection lost handler
Thank you

The “Sever Connection Error” dialog can be overriden by creating a custom plugin providing IConnectionLost token. By default that dialog falls back to this implementation:

as seen here:

JupyterHub does that in the @jupyterlab/hub-extension:connectionlost plugin:

Other dialogs can be overriden by creating a custom plugin providing the ISessionContextDialogs token and disabling the default @jupyterlab/apputils-extension:sessionDialogs.

Hi krassowski,
Ok @jupyterlab/hub-extension:connectionlost this is the place I want to change/override with my implementation.
I am not sure how to do that correctly, can you please elaborate on that?
Thank you!

We are using docker and k8s, this is how we install jupyter:

# jupyter install
RUN jupyter serverextension enable --py jupyterlab && \
    jupyter nbextension enable --py --sys-prefix widgetsnbextension && \
    jupyter serverextension enable --py jupyterlab_templates && \
    jupyter labextension disable "@jupyterlab/apputils-extension:announcements" && \
    jupyter lab clean

I am not sure how to do that correctly, can you please elaborate on that?

I do not really understand what you are trying to achieve. You would need to be more specific.

We are using docker and k8s, this is how we install jupyter:

No, I did not mean disable the package via CLI, but create a JupyterLab extension which replaces the default plugin with a different one. JupyterLab is very modular and any component can be swapped out using the extension (plugin) architecture. For an overview of developing extensions see: Develop Extensions — JupyterLab 4.2.0a2 documentation

Sure thing, I want to change this prompt on disconnect with my custom prompt saying something like
“You have lost connection to your server, please make sure your network and VPN connected”
With two buttons “Save File” and “Cancel” , first will try to save currently open file or best option all open and changed files if possible.
Screenshot 2024-03-27 at 14.55.06

Background: Why do I need that? Some of the users complained their work is not being saved using auto-save, after some investigation I found that after more that 2 minutes browser being disconnected from server the auto-save feature stopping to work even if the connection being restored and notebooks behave like normal except not auto saving. So as for the solution saving the notebook once network is back , ensures changes are persisted and also it turns back auto-save feature if manual save is triggered. I am totally new to plugin overrides or some customization on Jupyter.
Maybe the way I am trying to do is not the best, will be happy to hear any other solutions for the problem