Skip to content

Use official JupyterLite lifecycle instead of fragile log-based readiness detection#120

Open
mohab-elshamy wants to merge 1 commit intosoft-eng-practicum:developfrom
mohab-elshamy:fix-jupyterlab-integration
Open

Use official JupyterLite lifecycle instead of fragile log-based readiness detection#120
mohab-elshamy wants to merge 1 commit intosoft-eng-practicum:developfrom
mohab-elshamy:fix-jupyterlab-integration

Conversation

@mohab-elshamy
Copy link

Background

The current Analysim–JupyterLite integration detects readiness by intercepting an internal log message:

"Pyodide contents will be synced with Jupyter Contents"

This approach is fragile since it depends on undocumented logging behavior and may break with future JupyterLite updates.

Solution

This PR introduces a pure frontend JupyterLab extension that:

  • Uses the official plugin lifecycle
  • Waits for app.restored to ensure JupyterLite is fully initialized
  • Sends the readiness signal via:
window.parent.postMessage('jupyterlite-load', '*');

The extension is published on PyPI and added to requirements.txt, allowing anyone to install it easily:

analysim-jupyterlite-integration

Benefits

  • Removes fragile console interception hacks
  • Relies on stable, documented lifecycle APIs
  • Improves maintainability and upgrade resilience
  • Fully decouples Analysim from JupyterLite internals

Closes #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Less hacky way of integrating Jupyter Lite

1 participant