v0.18.1 e08f000

log.js RawHistoryFolder

1// log.js: the live log of a running job (page /<repo>/actions/runs/<id>/job/<id>).
2// The lines arrive as "ci-log" events (internal/adapters/web/actions.go,
3// logStream), each one the <li> of the lines of a batch, and are appended to the
4// list. The browser reconnects by itself with Last-Event-ID, the number of the
5// next line; "ci-end" closes the feed when the job is over. The page follows the
6// log (scrolls to its end) only while the reader is at the end already. A piece
7// that continues a line begun in an earlier batch (data-cont) is joined to the
8// last line of the list.
9window.ermiteLog = (() => {
10  const nearEnd = () => window.innerHeight + window.scrollY >= document.body.scrollHeight - 80;
11
12  // follow starts the feed of the box (#job-log) and returns the EventSource,
13  // or null when the box is not a running job's.
14  function follow(box) {
15    if (!box || !box.hasAttribute('data-follow') || !box.dataset.stream || !window.EventSource) return null;
16    const list = box.querySelector('ol.log');
17    if (!list) return null;
18    const es = new window.EventSource(box.dataset.stream + '?from=' + encodeURIComponent(box.dataset.next || '0'));
19    es.addEventListener('ci-log', (e) => {
20      const t = document.createElement('template');
21      t.innerHTML = e.data;
22      const atEnd = nearEnd();
23      for (const line of [...t.content.children]) {
24        const last = list.children[list.children.length - 1];
25        if (line.hasAttribute('data-cont') && last) {
26          const text = line.querySelector('.t');
27          const into = last.querySelector('.t');
28          if (text && into) into.textContent += text.textContent;
29        } else {
30          list.append(line);
31        }
32      }
33      if (atEnd) window.scrollTo(0, document.body.scrollHeight);
34    });
35    es.addEventListener('ci-end', () => es.close());
36    es.onerror = () => { if (es.readyState === window.EventSource.CLOSED) es.close(); };
37    return es;
38  }
39
40  return { follow };
41})();
42
43document.addEventListener('DOMContentLoaded', () => window.ermiteLog.follow(document.getElementById('job-log')));

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 45

↑↓ moveenter openesc close