@@ -157,6 +157,7 @@ def __init__(self, plugin: SimplyPrint) -> None:
157157 self ._last_ping_received : float = 0.
158158 self .gcode_terminal_enabled : bool = False
159159 self .cached_events : List [Tuple [Callable , Tuple [Any , ...]]] = []
160+ self ._current_job_id : Optional [int ] = None
160161
161162 # XXX: The call below is for dev, remove before release
162163 self ._setup_simplyprint_logging ()
@@ -586,6 +587,9 @@ def _process_demand(self, demand: str, args: Dict[str, Any]) -> None:
586587 file_id : Optional [str ] = args .get ("file_id" )
587588 file_name : Optional [str ] = args .get ("file_name" )
588589 start = bool (args .get ("auto_start" , 0 ))
590+ # Keep track of current job
591+ # Consider whether to persists this across restarts
592+ self ._current_job_id = int (args .get ("job_id" , 0 )) or None
589593
590594 if file_id != self .last_downloaded_file or self .file_manager .file_exists (FileDestinations .LOCAL , f"SimplyPrint/{ file_name } " ) is False :
591595 self .last_downloaded_file = file_id
@@ -1417,6 +1421,11 @@ def send_sp(
14171421 fut = self ._aioloop .create_future ()
14181422 fut .set_result (False )
14191423 return fut
1424+
1425+ # Include tracked job_id with some message types.
1426+ if evt_name in ("file_progress" , "job_info" ) and self ._current_job_id is not None and isinstance (data , dict ):
1427+ data .update ({"job_id" , self ._current_job_id })
1428+
14201429 packet = {"type" : evt_name , "data" : data }
14211430 if evt_name != "stream" :
14221431 self ._sock_logger .info (f"sent: { packet } " )
0 commit comments