feat(mma): add stream pruning with MAX_STREAM_SIZE (10KB)

This commit is contained in:
2026-03-07 10:35:35 -05:00
parent d591b257d4
commit 87bfc69257

View File

@@ -138,6 +138,7 @@ class AppController:
self.active_tickets: List[Dict[str, Any]] = [] self.active_tickets: List[Dict[str, Any]] = []
self.mma_streams: Dict[str, str] = {} self.mma_streams: Dict[str, str] = {}
self._worker_status: Dict[str, str] = {} # stream_id -> "running" | "completed" | "failed" | "killed" self._worker_status: Dict[str, str] = {} # stream_id -> "running" | "completed" | "failed" | "killed"
self.MAX_STREAM_SIZE: int = 10 * 1024 # 10KB max per stream
self._pending_patch_text: Optional[str] = None self._pending_patch_text: Optional[str] = None
self._pending_patch_files: List[str] = [] self._pending_patch_files: List[str] = []
self._show_patch_modal: bool = False self._show_patch_modal: bool = False
@@ -401,6 +402,8 @@ class AppController:
if stream_id not in self.mma_streams: self.mma_streams[stream_id] = "" if stream_id not in self.mma_streams: self.mma_streams[stream_id] = ""
if stream_id not in self._worker_status: self._worker_status[stream_id] = "running" if stream_id not in self._worker_status: self._worker_status[stream_id] = "running"
self.mma_streams[stream_id] += text self.mma_streams[stream_id] += text
if len(self.mma_streams[stream_id]) > self.MAX_STREAM_SIZE:
self.mma_streams[stream_id] = self.mma_streams[stream_id][-self.MAX_STREAM_SIZE:]
else: else:
self.mma_streams[stream_id] = text self.mma_streams[stream_id] = text
if stream_id in self._worker_status and self._worker_status[stream_id] == "running": if stream_id in self._worker_status and self._worker_status[stream_id] == "running":