Skip to content

PyEditor kill switch #2295

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

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

WebReflection
Copy link
Contributor

Description

This MR would like to provide a way to kill the currently running editor in case it's stuck in an infinite loop or any other problem is happening.

The current kill switch is orchestrated via an explicit confirm dialog that is shown only while the code is currently executing.

Once confirmed, the current editor and its sibling node will be removed and replaced in place with a new script that contains the latest code present in the editor, the code will stop executing and that's it, you can move on from where you left.

Changes

  • provide a way to relate a script to its editor
  • clone the script with a fresh new type and content from the current editor text
  • test everything works as expected

Checklist

  • I have checked make build works locally.
  • I have created / updated documentation for this change (if applicable).

@WebReflection WebReflection requested a review from ntoll February 20, 2025 11:07
@WebReflection WebReflection force-pushed the py-editor-kill-switch branch 2 times, most recently from 97fbddc to 012f7a8 Compare February 20, 2025 15:05
@WebReflection
Copy link
Contributor Author

WebReflection commented Feb 20, 2025

To whom it might concern, this has been published on our npm dev channel as https://cdn.jsdelivr.net/npm/@pyscript/core@0.6.32/dist/core.js and https://cdn.jsdelivr.net/npm/@pyscript/core@0.6.32/dist/core.css counter-part, as CSS changes are needed to see this working properly.

@ntoll
Copy link
Member

ntoll commented Feb 25, 2025

This looks great except for a single nit pick.

When you run the code that you want to kill, the icon you need to click is still the green "play" button. Can this be flipped to a red "STOP" button that looks something like this: 🛑 ...?

Just noticed it as I was about to update the docs. Once fixed happy for this to be merged. These small details are what make PyScript great. ;-)

@WebReflection
Copy link
Contributor Author

@ntoll the red button is a square as in play / stop now ... I think I prefer this version and I'll demo it but most importantly, it took forever just to create those two minimalistic icons out of my already bad and surely rusty SVG and drawing skills

@ntoll
Copy link
Member

ntoll commented Feb 25, 2025

@WebReflection ask 🤖 to do it?

Hey, ChatGPT, make me small SVG icons that represent the play and stop images commonly found on music players.

😝

@WebReflection
Copy link
Contributor Author

WebReflection commented Feb 25, 2025

@ntoll fair enough ... in my defense, it was a classic case of "how long could it take to draw a triangle and a square" that failed miserably due document size, ratio, rounded border as outer stroke and stuff 🤦

I felt like that person that thinks "those stairs are not great, I could build better stairs in minutes myself" ... I hope at least it looks decent, I will demo that in today community call.

edit and merge it once we all say "cool" or something that sounds like an OK ;-)

@ntoll
Copy link
Member

ntoll commented Feb 25, 2025

Please update confirmation to: "Stop evaluating this code?" (no killing executions) ;-)

@WebReflection WebReflection merged commit 3ff2c17 into pyscript:main Feb 26, 2025
2 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