Skip to content

Use Claude Code, Codex, VSCode, Pi, and OpenCode (and 6 other harnesses) for free (1.3B+ free tokens) from your terminal, app, IDE, or phone, and now from the browser with native browser sessions (multi-harness + multi-model) like OpenClaw (voice supported + ToS friendly)

Python

Fix get_queue_snapshot corrupting queue _unfinished_tasks

Cursor Agent253fdac48c7f
diff --git a/messaging/tree_data.py b/messaging/tree_data.py
index 1a4a966a..7d136597 100644
--- a/messaging/tree_data.py
+++ b/messaging/tree_data.py
@@ -263,16 +263,9 @@ class MessageTree:
List of node IDs in FIFO order.
"""
async with self._lock:
- # Drain queue, copy items, then put them back to preserve order.
- items: List[str] = []
- while True:
- try:
- items.append(self._queue.get_nowait())
- except asyncio.QueueEmpty:
- break
- for item in items:
- self._queue.put_nowait(item)
- return items
+ # Read internal deque directly to avoid mutating queue state.
+ # Drain/put approach would inflate _unfinished_tasks without task_done().
+ return list(self._queue._queue) # type: ignore[attr-defined]
def get_queue_size(self) -> int:
"""Get number of messages waiting in queue."""