vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Refresh run status on focus and show one clock per job
aa38f6b2428795995009fbe14a0b5a82b83006c6 · Keenan Nemetz · 9d ago · parent 8ca8bbe0
Refresh run status on focus and show one clock per job A page in an unfocused window kept its durations moving while its status stopped changing. The clock is arithmetic from a start timestamp, so it jumps to the right value when the reader returns; the status is server-rendered HTML that only moves when something re-fetches it. The result was a page minutes behind that looked current. Hidden and unfocused windows are not being read, so the answer is not to keep polling them. The polls now skip a tick while the window is unfocused and mark their region stale; the repository header says how old the last answer is, and queued or running dots go hollow and stop pulsing. Returning to the window dispatches vole-refresh, which every poll answers immediately instead of waiting out its interval. The stale mark is cleared only by a refresh that succeeded. Finished statuses are never marked, because they cannot change. The overview's recent runs and the runs tab now poll too, and the run page keeps itself current while a run is queued as well as running, so a queued page picks up the start it was waiting for. A run row shows one clock: the queue wait while queued, the run time while running, and the total it took once finished. The run page keeps its separate duration and queue-wait cards, which is where both numbers belong. A running job's status dot pulses while the page is live. Fixes #367.
server/web/overview.go +38−4
| @@ -117,10 +117,7 @@ func (w *Web) Overview(rw http.ResponseWriter, r *http.Request) { | |||
| 117 | 117 | commits, languages, tags := w.overviewSummaries(memo, m, commit) | |
| 118 | 118 | contributors := w.overviewContributors(memo, m) | |
| 119 | 119 | ||
| 120 | var recentRuns []*runs.Run | ||
| 121 | if w.Runs != nil { | ||
| 122 | recentRuns, _ = w.Runs.Recent(m.Name, 5) | ||
| 123 | } | ||
| 120 | recentRuns, _ := w.overviewRecentRuns(m) | ||
| 124 | 121 | ||
| 125 | 122 | recentIssues, recentRequests := w.overviewRecent(memo, m) | |
| 126 | 123 | ||
| @@ -157,6 +154,43 @@ func (w *Web) Overview(rw http.ResponseWriter, r *http.Request) { | |||
| 157 | 154 | }, 0) | |
| 158 | 155 | } | |
| 159 | 156 | ||
| 157 | // overviewRunCount is how many jobs the overview's sidebar shows. The poll and | ||
| 158 | // the first render read the same number, so a refresh cannot change the shape of | ||
| 159 | // the section under the reader. | ||
| 160 | const overviewRunCount = 5 | ||
| 161 | |||
| 162 | // overviewRecentRuns is the overview's short list of jobs, newest first. | ||
| 163 | func (w *Web) overviewRecentRuns(m *repo.Meta) ([]*runs.Run, error) { | ||
| 164 | if w.Runs == nil { | ||
| 165 | return nil, nil | ||
| 166 | } | ||
| 167 | return w.Runs.Recent(m.Name, overviewRunCount) | ||
| 168 | } | ||
| 169 | |||
| 170 | // OverviewRuns answers the overview's poll: the recent run rows alone, so a job | ||
| 171 | // that starts or finishes arrives without re-rendering the README, the commit | ||
| 172 | // list, or the rest of the sidebar. | ||
| 173 | func (w *Web) OverviewRuns(rw http.ResponseWriter, r *http.Request) { | ||
| 174 | m, ok := w.open(rw, r) | ||
| 175 | if !ok { | ||
| 176 | return | ||
| 177 | } | ||
| 178 | if w.Runs == nil { | ||
| 179 | w.notFound(rw, r) | ||
| 180 | return | ||
| 181 | } | ||
| 182 | recent, err := w.overviewRecentRuns(m) | ||
| 183 | if err != nil { | ||
| 184 | w.Logger("overview runs %s: %v", m.Name, err) | ||
| 185 | w.serverError(rw, r, "cannot read the queue: "+err.Error()) | ||
| 186 | return | ||
| 187 | } | ||
| 188 | w.render(rw, "overview_runs", struct { | ||
| 189 | Name string | ||
| 190 | Runs []*runs.Run | ||
| 191 | }{Name: m.Name, Runs: recent}, 0) | ||
| 192 | } | ||
| 193 | |||
| 160 | 194 | // overviewSummaries returns the parts of the overview that describe the default | |
| 161 | 195 | // branch: its newest commits, its languages, and the repository's tags. When the | |
| 162 | 196 | // index has the summary for this exact tip they are rows; when it does not (no | |