()
| 92 | } |
| 93 | |
| 94 | async function refreshRuns() { |
| 95 | const response = await fetch("/api/runs", { cache: "no-store" }); |
| 96 | if (!response.ok) { |
| 97 | throw new Error(`Failed to load runs (${response.status})`); |
| 98 | } |
| 99 | |
| 100 | const payload = await response.json(); |
| 101 | state.runs = Array.isArray(payload.runs) ? payload.runs : []; |
| 102 | state.compareIds = state.compareIds.filter((id) => state.runs.some((run) => run.id === id)); |
| 103 | renderRunList(); |
| 104 | renderCompareButton(); |
| 105 | |
| 106 | if (state.compareMode) { |
| 107 | await renderCompareMode(); |
| 108 | return; |
| 109 | } |
| 110 | |
| 111 | if (state.selectedSource === "upload" && state.currentRun) { |
| 112 | renderDashboard(state.currentRun); |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | if (!state.runs.length) { |
| 117 | state.currentRun = null; |
| 118 | state.selectedId = null; |
| 119 | renderDashboard(null); |
| 120 | return; |
| 121 | } |
| 122 | |
| 123 | const nextId = state.selectedId && state.runs.some((run) => run.id === state.selectedId) |
| 124 | ? state.selectedId |
| 125 | : state.runs[0].id; |
| 126 | |
| 127 | await selectRun(nextId); |
| 128 | } |
| 129 | |
| 130 | async function selectRun(runId) { |
| 131 | state.selectedId = runId; |
no test coverage detected