Skip to content

mito-ai: add toolbar to .py file#2197

Merged
aarondr77 merged 5 commits intodevfrom
python-file-toolbar
Mar 5, 2026
Merged

mito-ai: add toolbar to .py file#2197
aarondr77 merged 5 commits intodevfrom
python-file-toolbar

Conversation

@aarondr77
Copy link
Member

@aarondr77 aarondr77 commented Mar 2, 2026

Description

Here is the workflow of a user I talked to last week:

  1. Create a notebook for some analysis
  2. Turn it into an app
  3. Make some change to the .py file manually
  4. Close Mito
  5. Reopen Mito and open the .py file
  6. You want to preview it as an app again, but there is no app mode button. So instead, you ask the agent to turn it into an app. Since you don't have a notebook open, the agent says "I don't have notebook to turn into an app"
  7. So instead, you copy and paste the .py file into a notebook and then ask it to create the app.

Now, if the .py file is a mito app (determined by the file name), then we inject an App Mode button into the .py file toolbar so you can open the preview. When you click the button, it searches for the notebook that has the associated name.

Testing

Steps:

  1. Create an app
  2. Close the notebook and preview
  3. Open the .py file and click the app mode button. Make sure the app appears!

Documentation

Note if any new documentation needs to addressed or reviewed.


Note

Medium Risk
Adds a new JupyterLab plugin that hooks into the file editor and opens notebooks via the contents API/doc manager, which could affect preview behavior and editor toolbar wiring. Dependency additions (@jupyterlab/fileeditor/@jupyterlab/docmanager) and metadata-based notebook lookup introduce some integration and edge-case risk.

Overview
Enables App Mode preview from the file editor by injecting an App Mode toolbar button when a user opens a mito-app-*.py file, and wiring the click to launch the existing Streamlit preview flow.

Adds helper logic to map an app file path to a notebook_id, locate an already-open notebook by metadata or scan/open a matching .ipynb in the same directory via the contents API, then call streamlitPreviewManager.openAppPreview.

Updates typings and dependencies to support IEditorTracker/IDocumentManager, exports MITO_NOTEBOOK_ID_KEY for metadata reads, and adjusts the UI test to run in Galata’s tmpPath.

Written by Cursor Bugbot for commit aa094e2. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monorepo Ready Ready Preview, Comment Mar 5, 2026 4:29am

Request Review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

} catch {
toolbar.addItem(MITO_APP_MODE_BUTTON_ID, appModeButton);
}
};
Copy link

Choose a reason for hiding this comment

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

Duplicated button creation logic across two handlers

Low Severity

The addAppModeButtonIfNeeded function and the widgetAdded callback contain ~30 lines of nearly identical logic: guard checks, ToolbarButton construction with the same configuration, and the same insertAfter/addItem fallback. This duplication means any future change (e.g., button label, class, or click behavior) needs to be updated in two places, risking inconsistency. A single helper like addButtonToWidget(widget) would eliminate this.

Additional Locations (1)

Fix in Cursor Fix in Web

@aarondr77 aarondr77 merged commit cf87127 into dev Mar 5, 2026
28 of 31 checks passed
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.

2 participants