Move runtime log and events modal

This commit is contained in:
2026-05-11 00:02:45 +08:00
parent 77c2e37b95
commit be70f4356b
5 changed files with 150 additions and 29 deletions
+3
View File
@@ -30,3 +30,6 @@ class EventBus:
def list_for_task(self, task_id: str) -> list[RuntimeEvent]:
return self._store.list_for_task(task_id)
def list_recent(self, limit: int = 500) -> list[RuntimeEvent]:
return self._store.list_recent(limit=limit)
+28
View File
@@ -65,6 +65,34 @@ class SQLiteEventStore:
for row in rows
]
def list_recent(self, limit: int = 500) -> list[RuntimeEvent]:
with sqlite3.connect(self._db_path) as conn:
rows = conn.execute(
"""
SELECT event_id, task_id, session_id, sequence, type, timestamp,
payload_json, causation_id, correlation_id
FROM events
ORDER BY timestamp DESC, task_id DESC, sequence DESC
LIMIT ?
""",
(limit,),
).fetchall()
events = [
RuntimeEvent(
event_id=row[0],
task_id=row[1],
session_id=row[2],
sequence=row[3],
type=row[4],
timestamp=row[5],
payload=json.loads(row[6]),
causation_id=row[7],
correlation_id=row[8],
)
for row in rows
]
return list(reversed(events))
def get_latest_sequence(self, task_id: str) -> int:
with sqlite3.connect(self._db_path) as conn:
row = conn.execute(