Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

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.

Tighten the run page's logs and summary cards

8015a72b322328c3c5b8c3b5f8ca6fcd17c57695 · Keenan Nemetz · 17d ago · parent e653853a

Tighten the run page's logs and summary cards

Return the run page's step logs to a collapsible accordion. The tab bar
replaced a stack that already read well, and it hid every step's output behind
one shared pane. Each step now loads its own byte range when opened, the step a
reader should land on opens itself, and a record without per-step ranges falls
back to the attempt's full log instead of a stack of empty rows. Drop the
unused /runs/{id}/steps fragment and the tab-only view fields.

Stop stretching the summary cards to the tallest one, and trim their subtext:
the workflow card links the definition without repeating its path, "acted as"
and "reported by" lose their explanations, and only a successful run that does
not gate a branch explains why it is not a check.

server/web/static/app.js +29−100

@@ -575,58 +575,27 @@ const fitTextarea = (area) => {
575 575 });
576 576 })();
577 577
578 // Live step output. A running attempt reports each step's log range as a
579 // structured event, so the step tabs can change while the job is still going.
580 // The selected step is fetched from its own byte range; the running step is
581 // tailed, and a completed step stops at X-Step-Final. The step tab bar itself is
582 // refreshed by htmx, which is also how this learns that the next step started.
578 // Live CI job output. The server serves the attempt's file from a byte offset and
579 // says when the log is final; the page asks again only while the job is running.
580 // Chunks are decoded with a streaming TextDecoder because a multi-byte character
581 // can straddle two byte offsets.
583 582 (() => {
584 const pane = document.querySelector('pre[data-live-step-log]');
585 if (!pane) return;
586
587 let current = '';
588 let follow = true;
589 let generation = 0;
590
591 const list = () => document.getElementById('run-live-steps');
592 const buttons = () => Array.from(document.querySelectorAll('#run-live-steps [data-step-number]'));
593 const streamed = () => buttons().filter((button) => button.dataset.logUrl);
594 const running = () => buttons().find((button) => button.dataset.stepStatus === 'running');
595 const byNumber = (number) => buttons().find((button) => button.dataset.stepNumber === number);
596
597 const mark = (number) => {
598 buttons().forEach((button) => {
599 const active = button.dataset.stepNumber === number;
600 button.classList.toggle('active', active);
601 button.setAttribute('aria-selected', active ? 'true' : 'false');
602 });
603 };
604
605 const select = (button) => {
606 if (!button || !button.dataset.logUrl) return;
607 const number = button.dataset.stepNumber || '';
608 const changed = number !== current;
609 current = number;
610 mark(number);
611 if (changed) stream(button);
612 };
613
614 const stream = (button) => {
615 const url = button.dataset.logUrl;
616 let offset = Number(button.dataset.logOffset || 0);
617 const id = ++generation;
583 const follow = (pre) => {
584 if (pre.dataset.logStreaming) return;
585 pre.dataset.logStreaming = '1';
586 const url = pre.dataset.logUrl;
587 if (!url) return;
618 588 const decoder = new TextDecoder();
619 pane.textContent = '';
620
589 let offset = 0;
590 let stopped = false;
591 const finalOn404 = pre.dataset.logFinal === '1';
621 592 const schedule = () => {
622 if (id === generation) setTimeout(tick, 1000);
593 if (!stopped) setTimeout(tick, 1000);
623 594 };
624
625 595 const tick = async () => {
626 if (id !== generation) return;
627 596 let res;
628 597 try {
629 res = await fetch(url + '&after=' + offset, {
598 res = await fetch(url + (url.includes('?') ? '&' : '?') + 'after=' + offset, {
630 599 cache: 'no-store',
631 600 credentials: 'same-origin',
632 601 });
@@ -634,8 +603,8 @@ const fitTextarea = (area) => {
634 603 schedule();
635 604 return;
636 605 }
637 if (id !== generation) return;
638 606 if (res.status === 404) {
607 if (finalOn404 || res.headers.get('X-Log-Final') === '1') return;
639 608 schedule();
640 609 return;
641 610 }
@@ -650,70 +619,30 @@ const fitTextarea = (area) => {
650 619 schedule();
651 620 return;
652 621 }
653 if (id !== generation) return;
654 622 if (buf.byteLength) {
655 const stick = pane.scrollTop + pane.clientHeight >= pane.scrollHeight - 12;
656 pane.appendChild(document.createTextNode(decoder.decode(buf, { stream: true })));
623 const stick = pre.scrollTop + pre.clientHeight >= pre.scrollHeight - 12;
624 pre.appendChild(document.createTextNode(decoder.decode(buf, { stream: true })));
657 625 offset += buf.byteLength;
658 if (stick) pane.scrollTop = pane.scrollHeight;
626 if (stick) pre.scrollTop = pre.scrollHeight;
659 627 }
660 if (res.headers.get('X-Step-Final') === '1') {
661 pane.appendChild(document.createTextNode(decoder.decode()));
628 if (res.headers.get('X-Log-Final') === '1') {
629 pre.appendChild(document.createTextNode(decoder.decode()));
630 pre.dataset.logStreaming = 'done';
631 const state = pre.closest('details')?.querySelector('.run-log-state');
632 if (state) state.textContent = 'complete';
662 633 return;
663 634 }
664 635 schedule();
665 636 };
666
667 637 tick();
668 638 };
669 639
670 // A poll that brings a new running step should move the pane with it, unless
671 // the reader deliberately opened an earlier step.
672 const sync = () => {
673 if (!list()) return;
674 const active = running();
675 if (follow) {
676 if (active) {
677 if (active.dataset.stepNumber !== current) select(active);
678 else mark(current);
679 } else if (current) {
680 mark(current);
681 } else {
682 const started = streamed();
683 if (started.length) select(started[started.length - 1]);
684 }
685 return;
686 }
687 if (current) mark(current);
688 };
689
690 document.addEventListener('click', (event) => {
691 const button = event.target.closest('#run-live-steps [data-log-url]');
692 if (!button) return;
693 follow = button.dataset.stepStatus === 'running';
694 select(button);
695 });
696
697 document.body.addEventListener('htmx:afterSwap', () => {
698 if (list()) sync();
699 });
700
701 sync();
702 })();
703
704 // A finished run's output is one pane with the steps as tabs. HTMX replaces the
705 // pane's text; this only moves the selected marker so the reader can see which
706 // step is on screen.
707 (() => {
708 document.addEventListener('click', (event) => {
709 const step = event.target.closest('[data-log-step]');
710 if (!step) return;
711 const list = step.closest('.run-log-steps');
712 if (!list) return;
713 list.querySelectorAll('[data-log-step]').forEach((button) => {
714 const active = button === step;
715 button.classList.toggle('active', active);
716 button.setAttribute('aria-selected', active ? 'true' : 'false');
640 document.querySelectorAll('details').forEach((details) => {
641 const pre = details.querySelector('pre[data-log-stream]');
642 if (!pre) return;
643 if (details.open) follow(pre);
644 details.addEventListener('toggle', () => {
645 if (details.open) follow(pre);
717 646 });
718 647 });
719 648 })();