Skip to content

Add launcher support for Xircuits templates and user templates #398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rabea-al
Copy link
Contributor

@rabea-al rabea-al commented May 5, 2025

Description

This PR introduces the following enhancements to the Xircuits Launcher:


"Xircuits Templates" section

Adds a new section in the Launcher to display curated example templates like Agent and Service workflows. Each button:

  • Installs required component libraries via terminal
  • Opens a fresh copy of the workflow file (non-destructive)
  • Automatically refreshes the component list

registerTemplateButton helper

A reusable function to add example buttons to the Launcher with custom labels, paths, and ranks.


"User Templates" section

Automatically loads and displays all .xircuits files found in the .xircuits/templates/ folder.

  • Each template opens in a new untitled file
  • Section is hidden if the folder is missing or empty

Improved Launcher order

Ensures:

  • "Xircuits Templates" always appears first
  • "User Templates" appears second if available

Pull Request Type

  • Xircuits Core (Jupyterlab Related changes)
  • Xircuits Canvas (Custom RD Related changes)
  • Xircuits Component Library
  • Xircuits Project Template
  • Testing Automation
  • Documentation
  • Others (Please Specify)

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Tests

To verify the changes:

  1. Follow the setup steps described here:
    https://xircuits.io/docs/main/developer-guide/developing-xircuits-core-features/#rebuild

  2. Launch JupyterLab and confirm that:

    • A new section "Xircuits Templates" appears in the Launcher with example buttons (e.g., Agent, Service).
    • A "User Templates" section appears when .xircuits/templates contains .xircuits files.
    • Clicking any example opens a new copy and installs the required libraries automatically.

Tested on? Specify Version.

  • Windows
  • Linux (Fedora)
  • Mac
  • Others (State here -> xxx )

Copy link

github-actions bot commented May 5, 2025

Binder 👈 Launch a binder notebook on branch rabea-al/xircuits/master

Copy link
Member

@MFA-X-AI MFA-X-AI left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks great.
A few requests if you may:

  • have a confirmation alert before proceeding with the component library install. This is what happens when users install component libraries via sidebar context menu as well. Just in case, since one button does a lot of things.
  • Currently if users uses it, the workflow template is saved as untitled.xircuits. If it can preserve the workflow name when copying to root, that would be great. You can see how the copy to root function was implemented.

@rabea-al
Copy link
Contributor Author

rabea-al commented May 8, 2025

@MFA-X-AI Thanks for the feedback! I’ve addressed both points:

Added a confirmation prompt before installing any library, similar to the sidebar context menu behavior.

Preserved the original template filename when copying.
Instead of generating untitled.xircuits, the copied file keeps its original name.
If a file with the same name already exists, it now follows JupyterLab’s native logic by appending -Copy1, -Copy2, etc., using the contents.copy() API directly.

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.

3 participants