@siddu-k
Summary
Once a script starts executing via /api/scripts/run, there is no way
to stop it from the UI or API. The only option is to kill the entire
DevShell process. This is a critical gap for long-running or hung scripts.
Current Behavior
/api/scripts/run spawns a subprocess and streams output via SSE
- No process registry exists to track active run IDs
- No
/api/scripts/kill endpoint exists
proc.wait(timeout=10) in run_script() will silently throw
subprocess.TimeoutExpired for any script that produces no output
for 10+ seconds, crashing the stream unexpectedly
Expected Behavior
- Each script execution gets a unique
run_id (already generated but unused for kill)
- A
POST /api/scripts/kill endpoint accepts { "run_id": "..." } and
terminates the process gracefully (proc.terminate() → proc.kill() fallback)
- Active terminal tabs in the UI show an Abort button while a script is running
- SSE stream sends a final
{ "type": "aborted" } event on kill
Proposed Fix
Backend (app.py):
# Global registry for active processes
active_processes = {}
# In run_script(), register the process:
active_processes[run_id] = proc
# New endpoint:
@app.route('/api/scripts/kill', methods=['POST'])
def kill_script():
data = request.json
run_id = data.get('run_id', '')
proc = active_processes.get(run_id)
if not proc:
return jsonify({'error': 'Process not found'}), 404
proc.terminate()
try:
proc.wait(timeout=3)
except subprocess.TimeoutExpired:
proc.kill()
active_processes.pop(run_id, None)
return jsonify({'success': True, 'run_id': run_id})
I noticed this issue
Could u please assign this to me, i would like to work upon this
@siddu-k
Summary
Once a script starts executing via
/api/scripts/run, there is no wayto stop it from the UI or API. The only option is to kill the entire
DevShell process. This is a critical gap for long-running or hung scripts.
Current Behavior
/api/scripts/runspawns a subprocess and streams output via SSE/api/scripts/killendpoint existsproc.wait(timeout=10)inrun_script()will silently throwsubprocess.TimeoutExpiredfor any script that produces no outputfor 10+ seconds, crashing the stream unexpectedly
Expected Behavior
run_id(already generated but unused for kill)POST /api/scripts/killendpoint accepts{ "run_id": "..." }andterminates the process gracefully (
proc.terminate()→proc.kill()fallback){ "type": "aborted" }event on killProposed Fix
Backend (
app.py):