Skip to content
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

Add a "start" button similar to run/runall/restart/restartall #697

Open
5 tasks
kno10 opened this issue Nov 5, 2023 · 1 comment
Open
5 tasks

Add a "start" button similar to run/runall/restart/restartall #697

kno10 opened this issue Nov 5, 2023 · 1 comment

Comments

@kno10
Copy link
Contributor

kno10 commented Nov 5, 2023

Context

  • The current "activate" and "status" widgets are on a global level
  • With "requestKernel": false, the run/runall/restart/restartall buttons do not function

Proposal

  • add mountStartButton option similar to the other buttons, that requests a new kernel (and that disappears when the kernel is started?)
  • add kernel availability indicator (reuse current spinner, style differently via css?)
  • hide or disable run/runAll/restart/restartAll buttons when no kernel is available (makes most sense if a "start" button is available instead - little use in having start and restart at the same time)
  • add autoRequestKernel option to start a kernel when a run button is clicked
  • allow placing the busy indicator left of the buttons, to obtain a stable layout when right-aligned (as the indicator disappears and re-appears)

Tasks and updates

No response

@kno10
Copy link
Contributor Author

kno10 commented Feb 28, 2024

In particular with requestKernel: false, a custom launch button currently appears to be necessary.

FWIW, I currently use the following workaround:

    // Add a status indicator to each input box
    document.querySelectorAll('.thebe-controls').forEach((e) => {
      let start_button = document.createElement("button");
      start_button.classList.add('thebe-button', 'thebe-start-button')
      start_button.innerText = "start";
      start_button.setAttribute("title", "Start a Pyodide kernel in the browser.");
      start_button.onclick = async() => {
        if (!window.thebe.session) {
          await window.thebe.server.ready;
          const session = await window.thebe.server.startNewSession(window.thebe.notebook.rendermime);
          if (session != null) {
            window.thebe.notebook.attachSession(session);
            window.thebe.session = session;
          }
        }
      };
      e.prepend(start_button);
      let kernel_status = document.createElement("div");
      kernel_status.setAttribute("class", "thebe-status");
      e.append(kernel_status);
    });
    window.thebe.on("status", function(evt, data) {
      // Update status indicator
      document.querySelectorAll('.thebe-status').forEach((e) => {
        e.innerText = data["status"];
        if (data["status"] == "server-ready") e.innerText = "No session started.";
      });
      if (data["status"] == "attached") {
        document.querySelectorAll('.thebe-start-button').forEach((e) => { e.style.display = "none"; });
      }
    });

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

No branches or pull requests

1 participant