aegis-framework 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -118,7 +118,8 @@ class AegisWindow(Gtk.Window):
118
118
  print(f"[Aegis] Action: {action}, Payload: {payload}")
119
119
 
120
120
  # Check if this is an async action
121
- async_actions = {'run.async', 'download', 'copy.async'}
121
+ # 'run' is now async by default to prevent UI freezing
122
+ async_actions = {'run', 'run.async', 'download', 'copy.async'}
122
123
 
123
124
  if action in async_actions:
124
125
  # Handle in background thread - response sent via callback
@@ -241,35 +242,45 @@ class AegisWindow(Gtk.Window):
241
242
 
242
243
  return {'success': True, 'path': full_path}
243
244
 
244
- def _handle_run(self, payload):
245
- """Execute Python or shell commands"""
245
+ def _handle_run(self, payload, callback_id=None):
246
+ """Execute Python or shell commands (Thread-Safe)"""
246
247
  import subprocess
247
248
 
249
+ result = {'error': 'No command specified'}
250
+
248
251
  if 'py' in payload:
249
252
  # Execute Python code
250
253
  try:
251
- result = eval(payload['py'])
252
- return {'output': str(result), 'exitCode': 0}
254
+ res = eval(payload['py'])
255
+ result = {'output': str(res), 'exitCode': 0}
253
256
  except:
254
257
  exec_globals = {}
255
258
  exec(payload['py'], exec_globals)
256
- return {'output': '', 'exitCode': 0}
259
+ result = {'output': '', 'exitCode': 0}
257
260
 
258
261
  elif 'sh' in payload:
259
262
  # Execute shell command
260
- result = subprocess.run(
261
- payload['sh'],
262
- shell=True,
263
- capture_output=True,
264
- text=True
265
- )
266
- return {
267
- 'output': result.stdout,
268
- 'error': result.stderr,
269
- 'exitCode': result.returncode
270
- }
263
+ try:
264
+ # Ensure we wait here in the thread, not blocking UI
265
+ proc_res = subprocess.run(
266
+ payload['sh'],
267
+ shell=True,
268
+ capture_output=True,
269
+ text=True
270
+ )
271
+ result = {
272
+ 'output': proc_res.stdout,
273
+ 'error': proc_res.stderr,
274
+ 'exitCode': proc_res.returncode
275
+ }
276
+ except Exception as e:
277
+ result = {'error': str(e), 'exitCode': -1}
271
278
 
272
- return {'error': 'No command specified'}
279
+ # If running async (callback_id present), send response to main thread
280
+ if callback_id:
281
+ GLib.idle_add(self._send_response, callback_id, result)
282
+ else:
283
+ return result
273
284
 
274
285
  def _handle_exists(self, payload):
275
286
  """Check if path exists"""
@@ -610,6 +621,7 @@ class AegisWindow(Gtk.Window):
610
621
  def _process_async_action(self, action, payload, callback_id):
611
622
  """Process async actions in background threads"""
612
623
  handlers = {
624
+ 'run': self._handle_run, # Now supported in background thread
613
625
  'run.async': self._handle_run_async,
614
626
  'download': self._handle_download,
615
627
  'copy.async': self._handle_copy_async,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aegis-framework",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Lightweight AppImage framework using WebKit2GTK and Python - An alternative to Electron that creates ~200KB apps instead of 150MB!",
5
5
  "keywords": [
6
6
  "appimage",
@@ -48,4 +48,4 @@
48
48
  "engines": {
49
49
  "node": ">=14"
50
50
  }
51
- }
51
+ }