Skip to content

Conversation

@agriyakhetarpal
Copy link
Member

@agriyakhetarpal agriyakhetarpal commented Jul 3, 2025

I think it is time now that we do this. This PR sets the storage to memoryStorageDriver (in-memory, non-persistent). Files uploaded to the Files widget and notebooks will not retain data if saved beforehand when reloaded because enableMemoryStorage is also true.

Reference: https://jupyterlite.readthedocs.io/en/latest/howto/configure/storage.html

@agriyakhetarpal agriyakhetarpal marked this pull request as ready for review August 11, 2025 21:11
@agriyakhetarpal agriyakhetarpal marked this pull request as draft August 11, 2025 21:20
@agriyakhetarpal
Copy link
Member Author

On second thought: we should exercise caution before merging this, as the mere act of reloading the page will cause users to lose all their code – we want to avoid this in any scenario. One way to mitigate this issue is by resolving #104, which involves sharing the notebook and generating a shareable URL on initial load (which should be better handled after merging #192). We also need to ensure that the shareable link is always included in the URL. The shareable link is also present in view-only notebooks, so we should be checking for a token that allows editing the notebook. To achieve this, we will require #105, and we should securely store the sharing service token in the browser.

Current scenario

  • User X authors a notebook
  • They accidentally reload the page
  • Their code and the sharing service token are lost

Expected scenario

  • User X authors a notebook (they authenticate with the sharing service, and we automatically save the notebook right from the start, creating a shareable URL linked to the token)
  • We securely store User X's sharing service authentication token in the browser
  • We append the shareable ID to the URL
  • If User X reloads the page, the notebook won't be present in the browser's storage (due to non-persistent storage), so we look for a saved sharing service token in the browser and load the page with the shareable URL (as the shareable ID will be present unless the user were to remove it themselves)
  • This prompts us to retrieve the notebook from the storage of the sharing service. At this point, it will be a view-only notebook, but we will use the token to authenticate and remove the view-only header.
  • The token's expiry will determine when the user has access to author the notebook. We can decide on an appropriate expiry time later (e.g., 1 day, 7 days, etc.). I'm not sure what the value is in CKHub right now.
    • We can check for the existing token before loading the notebook so as to bypass the momentary period in which the view-only header is visible to the user.

We have two options: we can either merge this PR now and I will create additional PRs for #104 and #105, or I can prepare those PRs first and then return to this one.

@krassowski krassowski marked this pull request as ready for review September 11, 2025 14:46
Copy link
Collaborator

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try this on staging, this will help to make a decision!

@agriyakhetarpal
Copy link
Member Author

Yes, going forward with this as discussed. Merging!

@agriyakhetarpal agriyakhetarpal merged commit b8a7f6d into JupyterEverywhere:main Sep 11, 2025
16 of 18 checks passed
@agriyakhetarpal agriyakhetarpal deleted the drop-persistence branch September 11, 2025 15:40
krassowski added a commit that referenced this pull request Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance This PR performs maintenance for the repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants