diff --git a/src/routers/incidents.py b/src/routers/incidents.py index 2353321..69d8ca6 100644 --- a/src/routers/incidents.py +++ b/src/routers/incidents.py @@ -150,8 +150,16 @@ async def get_refreshing_incidents( (tenant_id, current_user["id"]), ) rows = await cursor.fetchall() + + # Also include queued incidents from orchestrator + from agents.orchestrator import orchestrator + queued_ids = list(orchestrator._queued_ids) if hasattr(orchestrator, '_queued_ids') else [] + current_task = orchestrator._current_task if hasattr(orchestrator, '_current_task') else None + return { "refreshing": [row["incident_id"] for row in rows], + "queued": queued_ids, + "current": current_task, "details": {str(row["incident_id"]): {"started_at": row["started_at"]} for row in rows}, } diff --git a/src/static/js/app.js b/src/static/js/app.js index 1502b2d..28e09ef 100644 --- a/src/static/js/app.js +++ b/src/static/js/app.js @@ -574,14 +574,34 @@ const App = { // Laufende Refreshes wiederherstellen try { const data = await API.getRefreshingIncidents(); + const details = data.details || {}; + const currentTask = data.current; + const queuedIds = data.queued || []; + + // Restore running refreshes if (data.refreshing && data.refreshing.length > 0) { - data.refreshing.forEach(id => this._refreshingIncidents.add(id)); - // Sidebar-Dots aktualisieren data.refreshing.forEach(id => { - this._updateSidebarDot(id); - // Init progress state so sidebar renders correctly - UI.showProgress('researching', {}, id, false); + this._refreshingIncidents.add(id); + const d = details[String(id)] || {}; + const inc = this.incidents.find(i => i.id === id); + const isFirst = inc && !inc.summary; + const isCurrent = (id === currentTask); + // Use 'researching' as default step for the actively running task + UI.showProgress(isCurrent ? 'researching' : 'queued', { started_at: d.started_at }, id, isFirst); }); + } + + // Restore queued incidents + if (queuedIds.length > 0) { + queuedIds.forEach((id, idx) => { + this._refreshingIncidents.add(id); + const inc = this.incidents.find(i => i.id === id); + const isFirst = inc && !inc.summary; + UI.showProgress('queued', { queue_position: idx + 1 }, id, isFirst); + }); + } + + if (data.refreshing.length > 0 || queuedIds.length > 0) { this.renderSidebar(); } } catch (e) { /* Kein kritischer Fehler */ }