forge
Explore
Log in

Don't you dare go Hollow

CI in the shell reads at a glance and tells the truth about a cancel: the topbar strip is one pill, the single run or a summary ("28 running · 2 failed") that opens the list of your runs

Browse files at this commit

c0cdb72c620d2016d061f5e2a3dd47e48b1dea94Ahmet Kaan GümüşParent: a8c97c4
All checks have passed
Show checks
  • feat
    • CI in the shell reads at a glance and tells the truth about a cancel: the topbar strip is one pill, the single run or a summary ("28 running · 2 failed") that opens the list of your runs
    • the avatar ring is a full ember ring while a run goes, not a progress arc
    • the repo's CI card shows a heat bar and the current job with a live clock for a running run, and "passed · 4m 12s" or "clippy failed · 2m 3s" once done
    • a cancelled run is grey everywhere (badge "cancelled", not "error"
    • strip, not "failed")
    • a running job being cancelled shows "stopping" and the Cancel button "Stopping…" until its runner stops it, and the reaper marks such a job cancelled, not lost
Show full message
✨ feat: CI in the shell reads at a glance and tells the truth about a cancel: the topbar strip is one pill, the single run or a summary ("28 running · 2 failed") that opens the list of your runs; the avatar ring is a full ember ring while a run goes, not a progress arc; the repo's CI card shows a heat bar and the current job with a live clock for a running run, and "passed · 4m 12s" or "clippy failed · 2m 3s" once done; a cancelled run is grey everywhere (badge "cancelled", not "error"; strip, not "failed"); a running job being cancelled shows "stopping" and the Cancel button "Stopping…" until its runner stops it, and the reaper marks such a job cancelled, not lost
crates/forge-core/src/store/ci.rsmodified+30 -1
@@ -1486,7 +1486,10 @@ impl Store {
14861486 let mut runs: Vec<String> = Vec::new();
14871487 for job in &lost {
14881488 tx.execute(
1489- "UPDATE ci_jobs SET state = 'error', message = 'runner lost', finished_at = ?2 \
1489+ "UPDATE ci_jobs SET \
1490+ state = CASE WHEN cancel_requested = 1 THEN 'cancelled' ELSE 'error' END, \
1491+ message = CASE WHEN cancel_requested = 1 THEN 'cancelled' ELSE 'runner lost' END, \
1492+ finished_at = ?2 \
14901493 WHERE id = ?1 AND state = 'running'",
14911494 (job.id.clone(), now.clone()),
14921495 )
@@ -3288,6 +3291,32 @@ mod tests {
32883291 );
32893292 }
32903293
3294+ #[tokio::test]
3295+ async fn reap_lost_jobs_marks_a_cancelled_running_job_cancelled() {
3296+ let fx = fixture().await;
3297+ let run = create(
3298+ &fx.store,
3299+ &fx.repo.id,
3300+ &fx.tahinli.id,
3301+ &[job("a", &[], &[])],
3302+ false,
3303+ )
3304+ .await;
3305+ let claimed = fx
3306+ .store
3307+ .claim_job(&bare_runner(&[]))
3308+ .await
3309+ .unwrap()
3310+ .unwrap();
3311+ fx.store.request_cancel(&run.id).await.unwrap();
3312+ let future = stamp_after(Duration::from_secs(3600));
3313+ let reaped = fx.store.reap_lost_jobs(&future).await.unwrap();
3314+ assert_eq!(reaped.len(), 1);
3315+ assert_eq!(reaped[0].id, claimed.0.id);
3316+ assert_eq!(reaped[0].state, JobState::Cancelled);
3317+ assert_eq!(reaped[0].message.as_deref(), Some("cancelled"));
3318+ }
3319+
32913320 #[tokio::test]
32923321 async fn purge_old_returns_logs_and_artifacts_once() {
32933322 let fx = fixture().await;
crates/forge-core/src/store/shell_activity.rsmodified+5 -4
@@ -12,8 +12,9 @@ use crate::error::{Error, Result};
1212 use crate::notifications::Reason;
1313 use crate::time::stamp_ago;
1414
15-/// Most runs each of `ActorRuns::running` and `ActorRuns::finished` lists.
16-const MAX_ACTOR_RUNS: i64 = 5;
15+/// Most runs each of `ActorRuns::running` and `ActorRuns::finished` lists: enough for the strip's
16+/// counts and list, bounded when runs pile up in the queue with no runner online.
17+const MAX_ACTOR_RUNS: i64 = 100;
1718
1819 /// How far back a failing run still counts toward `ActorRuns::failing`.
1920 const FAILING_WINDOW: Duration = Duration::from_secs(7 * 24 * 60 * 60);
@@ -49,9 +50,9 @@ pub struct WaitingItem {
4950 /// The user's own CI runs, as the corner shows them.
5051 #[derive(Debug, Clone)]
5152 pub struct ActorRuns {
52- /// Queued or running runs, newest first, at most 5.
53+ /// Queued or running runs, newest first, at most 100.
5354 pub running: Vec<ActorRun>,
54- /// Runs that finished recently, newest first, at most 5.
55+ /// Runs that finished within the caller's window, newest first, at most 100.
5556 pub finished: Vec<ActorRun>,
5657 /// Refs whose newest run by this user failed within the last 7 days.
5758 pub failing: u64,
crates/forge-web/assets/nav.jsmodified+93 -38
@@ -623,7 +623,7 @@
623623
624624 // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone
625625 // popover, phone menu, profile corner). Inline disclosures are not listed: a click outside leaves them open.
626- var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle, details.corner';
626+ var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle, details.corner, details.strip-runs';
627627
628628 // Closes every open dropdown that does not contain `from` (pass null to close them all). The corner
629629 // sits inside the phone menu, so a click in the corner keeps the phone menu open too.
@@ -1315,53 +1315,108 @@
13151315 return typeof href === 'string' && href.charAt(0) === '/' && href.charAt(1) !== '/' ? href : '';
13161316 }
13171317
1318- // The live strip: running pills first, then finished ones, two at most and a "+N" for the rest.
1319- // The words "passed" and "failed" come from the strip's own data attributes.
1320- function drawStrip(strip, json) {
1321- var pills = [];
1318+ // The live strip, drawn from the same JSON as the server's render. One run is a pill. Two or more are
1319+ // a summary pill (the counts, joined with " · ") that opens a list of every run. The list's <details>
1320+ // is kept across a redraw and only its contents change, so an open list stays open.
1321+ var OUTCOMES = {
1322+ passed: { state: 'ok', word: 'data-passed' },
1323+ failed: { state: 'bad', word: 'data-failed' },
1324+ cancelled: { state: 'off', word: 'data-cancelled' }
1325+ };
1326+
1327+ // The strip's runs, running ones first, each with its state class and its text (the job or the word).
1328+ function stripRows(strip, json) {
1329+ var rows = [];
13221330 (json.running || []).forEach(function (run) {
1323- pills.push({ cls: 'pill hot', run: run, text: run.job ? ' ' + run.job : '' });
1331+ rows.push({ state: 'hot', run: run, text: run.job ? ' ' + run.job : '' });
13241332 });
13251333 (json.finished || []).forEach(function (run) {
1326- var word = run.ok ? strip.getAttribute('data-passed') : strip.getAttribute('data-failed');
1327- pills.push({ cls: run.ok ? 'pill ok' : 'pill bad', run: run, text: ' ' + (word || '') });
1334+ var o = OUTCOMES[run.outcome];
1335+ if (!o) { return; }
1336+ rows.push({ state: o.state, run: run, text: ' ' + (strip.getAttribute(o.word) || '') });
13281337 });
1329- var more = pills.length - 2;
1330- strip.textContent = '';
1331- pills.slice(0, 2).forEach(function (pill) {
1332- var a = document.createElement('a');
1333- a.className = pill.cls;
1334- a.setAttribute('href', localHref(pill.run.href));
1338+ return rows;
1339+ }
1340+
1341+ // A run's link: a dot, the run's label in bold, then its text. Used for the lone pill and each row.
1342+ function runLink(cls, row) {
1343+ var a = document.createElement('a');
1344+ a.className = cls;
1345+ a.setAttribute('href', localHref(row.run.href));
1346+ var dot = document.createElement('span');
1347+ dot.className = 'pill-dot';
1348+ var b = document.createElement('b');
1349+ b.textContent = String(row.run.label || '');
1350+ a.appendChild(dot);
1351+ a.appendChild(b);
1352+ a.appendChild(document.createTextNode(row.text));
1353+ return a;
1354+ }
1355+
1356+ // The summary's counts: the non-zero ones, each from its template (`{n}` is the count).
1357+ function stripSummary(strip, json) {
1358+ var running = (json.running || []).length;
1359+ var finished = json.finished || [];
1360+ var count = function (outcome) {
1361+ return finished.filter(function (run) { return run.outcome === outcome; }).length;
1362+ };
1363+ var failed = count('failed');
1364+ var passed = count('passed');
1365+ var cancelled = count('cancelled');
1366+ var parts = [
1367+ [running, 'data-count-running'],
1368+ [failed, 'data-count-failed'],
1369+ [passed, 'data-count-passed'],
1370+ [cancelled, 'data-count-cancelled']
1371+ ].filter(function (p) { return p[0] > 0; }).map(function (p) {
1372+ return (strip.getAttribute(p[1]) || '').split('{n}').join(String(p[0]));
1373+ });
1374+ var cls = running ? 'hot' : failed ? 'bad' : passed ? 'ok' : 'off';
1375+ return { cls: 'pill ' + cls, text: parts.join(' \u00b7 ') };
1376+ }
1377+
1378+ function drawStrip(strip, json) {
1379+ var rows = stripRows(strip, json);
1380+ if (rows.length === 0) { strip.textContent = ''; return; }
1381+ if (rows.length === 1) {
1382+ strip.textContent = '';
1383+ strip.appendChild(runLink('pill ' + rows[0].state, rows[0]));
1384+ return;
1385+ }
1386+ var details = strip.querySelector('details.strip-runs');
1387+ if (!details) {
1388+ strip.textContent = '';
1389+ details = document.createElement('details');
1390+ details.className = 'strip-runs';
1391+ details.id = 'strip-runs';
1392+ var summary = document.createElement('summary');
1393+ summary.setAttribute('aria-label', strip.getAttribute('data-runs-label') || '');
13351394 var dot = document.createElement('span');
13361395 dot.className = 'pill-dot';
1337- var b = document.createElement('b');
1338- b.textContent = String(pill.run.label || '');
1339- a.appendChild(dot);
1340- a.appendChild(b);
1341- a.appendChild(document.createTextNode(pill.text));
1342- strip.appendChild(a);
1343- });
1344- if (more > 0) {
1345- var rest = document.createElement('span');
1346- rest.className = 'pill more';
1347- rest.textContent = '+' + more;
1348- strip.appendChild(rest);
1396+ summary.appendChild(dot);
1397+ summary.appendChild(document.createTextNode(''));
1398+ details.appendChild(summary);
1399+ var list = document.createElement('ul');
1400+ list.className = 'strip-list';
1401+ details.appendChild(list);
1402+ strip.appendChild(details);
13491403 }
1404+ var head = stripSummary(strip, json);
1405+ var sum = details.querySelector('summary');
1406+ sum.className = head.cls;
1407+ sum.lastChild.nodeValue = head.text;
1408+ var rowsEl = details.querySelector('.strip-list');
1409+ rowsEl.textContent = '';
1410+ rows.forEach(function (row) {
1411+ var li = document.createElement('li');
1412+ li.appendChild(runLink('strip-row ' + row.state, row));
1413+ rowsEl.appendChild(li);
1414+ });
13501415 }
13511416
1352- // The heat ring: lit while a run is going, filled to the newest run's share of its jobs (at least 8%).
1417+ // The heat ring: a full ember ring while any of the viewer's runs is going, a plain ring otherwise.
13531418 function drawRing(ring, running) {
1354- if (!running.length) {
1355- ring.classList.remove('hot');
1356- ring.setAttribute('data-p', '0');
1357- return;
1358- }
1359- var run = running[0];
1360- var p = run.total ? Math.round(run.done / run.total * 100) : 0;
1361- p = Math.min(100, Math.max(8, p));
1362- ring.classList.add('hot');
1363- // In steps of 5, as the server renders it; the stylesheet maps each step to --p.
1364- ring.setAttribute('data-p', String(Math.round(p / 5) * 5));
1419+ if (running.length) { ring.classList.add('hot'); } else { ring.classList.remove('hot'); }
13651420 }
13661421
13671422 // The chips: one per non-zero count. The titles come from the chip box's templates, with `{n}`
crates/forge-web/src/i18n/misc.rsmodified+41 -0
@@ -176,6 +176,8 @@ pub enum K {
176176 AllNotifications,
177177 Passed,
178178 Failed,
179+ Cancelled,
180+ YourCiRuns,
179181 SearchPublicReposFor,
180182 }
181183
@@ -330,6 +332,8 @@ const ALL: &[K] = &[
330332 K::AllNotifications,
331333 K::Passed,
332334 K::Failed,
335+ K::Cancelled,
336+ K::YourCiRuns,
333337 K::SearchPublicReposFor,
334338 ];
335339
@@ -659,6 +663,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
659663 (Passed, Tr) => "geçti",
660664 (Failed, En) => "failed",
661665 (Failed, Tr) => "başarısız",
666+ (Cancelled, En) => "cancelled",
667+ (Cancelled, Tr) => "iptal edildi",
668+ (YourCiRuns, En) => "Your CI runs",
669+ (YourCiRuns, Tr) => "CI çalıştırmaların",
662670 (SearchPublicReposFor, En) => "Search public repositories for",
663671 (SearchPublicReposFor, Tr) => "Herkese açık depolarda ara:",
664672 }
@@ -713,6 +721,39 @@ pub fn failing_runs_count(lang: Lang, n: u64) -> String {
713721 }
714722 }
715723
724+/// `28 running` / `3 çalışıyor`: the live strip's counts. Each takes its number as `{n}` in the
725+/// strip's templates, so these phrases have no plural.
726+pub fn running_count(lang: Lang, n: u64) -> String {
727+ match lang {
728+ Lang::En => format!("{n} running"),
729+ Lang::Tr => format!("{n} çalışıyor"),
730+ }
731+}
732+
733+/// `2 failed` / `2 başarısız`.
734+pub fn failed_count(lang: Lang, n: u64) -> String {
735+ match lang {
736+ Lang::En => format!("{n} failed"),
737+ Lang::Tr => format!("{n} başarısız"),
738+ }
739+}
740+
741+/// `2 passed` / `2 başarılı`.
742+pub fn passed_count(lang: Lang, n: u64) -> String {
743+ match lang {
744+ Lang::En => format!("{n} passed"),
745+ Lang::Tr => format!("{n} başarılı"),
746+ }
747+}
748+
749+/// `2 cancelled` / `2 iptal edildi`.
750+pub fn cancelled_count(lang: Lang, n: u64) -> String {
751+ match lang {
752+ Lang::En => format!("{n} cancelled"),
753+ Lang::Tr => format!("{n} iptal edildi"),
754+ }
755+}
756+
716757 /// `1 contribution` / `3 contributions`, and `3 katkı` in Turkish.
717758 pub fn contributions_count(lang: Lang, n: u64) -> String {
718759 match lang {
crates/forge-web/src/i18n/releases_ci.rsmodified+11 -2
@@ -86,6 +86,9 @@ pub enum K {
8686 StateError,
8787 StateBlocked,
8888 StateSkipped,
89+ /// A running job whose cancel was requested, until its runner stops it.
90+ StateStopping,
91+ StoppingButton,
8992
9093 // Release notices, shown after a release action.
9194 RelSaved,
@@ -152,10 +155,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
152155 (CiNoticeStarted, En) => "Workflow run queued.",
153156 (CiNoticeStarted, Tr) => "İş akışı çalıştırması sıraya alındı.",
154157 (CiNoticeCancelled, En) => {
155- "Cancellation requested. Queued jobs were cancelled; running jobs stop at their next heartbeat."
158+ "Cancel requested. Queued jobs are cancelled; running jobs show as stopping until the runner stops them."
156159 }
157160 (CiNoticeCancelled, Tr) => {
158- "İptal istendi. Sıradaki işler iptal edildi; çalışan işler bir sonraki kalp atışında duracak."
161+ "İptal istendi. Sıradaki işler iptal edildi; çalışan işler, çalıştırıcı onları durdurana dek durduruluyor olarak görünür."
159162 }
160163 (CiNoticeApproved, En) => "Run approved. Its jobs are queued.",
161164 (CiNoticeApproved, Tr) => "Çalıştırma onaylandı. İşler sıraya alındı.",
@@ -317,6 +320,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
317320 (StateBlocked, Tr) => "engellendi",
318321 (StateSkipped, En) => "skipped",
319322 (StateSkipped, Tr) => "atlandı",
323+ (StateStopping, En) => "stopping",
324+ (StateStopping, Tr) => "durduruluyor",
325+ (StoppingButton, En) => "Stopping…",
326+ (StoppingButton, Tr) => "Durduruluyor…",
320327
321328 (RelSaved, En) => "Release saved.",
322329 (RelSaved, Tr) => "Sürüm kaydedildi.",
@@ -620,6 +627,8 @@ mod tests {
620627 K::StateError,
621628 K::StateBlocked,
622629 K::StateSkipped,
630+ K::StateStopping,
631+ K::StoppingButton,
623632 K::RelSaved,
624633 K::RelDeleted,
625634 K::RelAssetUploaded,
crates/forge-web/src/pages/activity.rsmodified+14 -3
@@ -37,6 +37,16 @@ fn run_json(run: &ActorRun) -> Value {
3737 })
3838 }
3939
40+/// How a finished run ended, as the activity JSON names it. None for any other state.
41+pub(crate) fn outcome_word(state: RunState) -> Option<&'static str> {
42+ match state {
43+ RunState::Success => Some("passed"),
44+ RunState::Failure | RunState::Error => Some("failed"),
45+ RunState::Cancelled => Some("cancelled"),
46+ _ => None,
47+ }
48+}
49+
4050 /// The viewer's activity as JSON. `reviews` and `mentions` count unread inbox rows, `failing` counts
4151 /// refs whose newest run failed, `running` and `finished` list the viewer's CI runs and `waiting`
4252 /// lists the newest review requests and mentions. Reads only; the caller decides how to send it.
@@ -49,10 +59,11 @@ pub(crate) async fn activity_json(state: &AppState, user: &User) -> Result<Value
4959 let finished: Vec<Value> = runs
5060 .finished
5161 .iter()
52- .map(|run| {
62+ .filter_map(|run| {
63+ let outcome = outcome_word(run.state)?;
5364 let mut item = run_json(run);
54- item["ok"] = json!(matches!(run.state, RunState::Success));
55- item
65+ item["outcome"] = json!(outcome);
66+ Some(item)
5667 })
5768 .collect();
5869 let waiting: Vec<Value> = waiting
crates/forge-web/src/pages/ci_badge.rsmodified+10 -4
@@ -41,6 +41,7 @@ pub enum BadgeStatus {
4141 Passing,
4242 Failing,
4343 Error,
44+ Cancelled,
4445 Running,
4546 Pending,
4647 Skipped,
@@ -54,6 +55,7 @@ impl BadgeStatus {
5455 BadgeStatus::Passing => "passing",
5556 BadgeStatus::Failing => "failing",
5657 BadgeStatus::Error => "error",
58+ BadgeStatus::Cancelled => "cancelled",
5759 BadgeStatus::Running => "running",
5860 BadgeStatus::Pending => "pending",
5961 BadgeStatus::Skipped => "skipped",
@@ -68,7 +70,7 @@ impl BadgeStatus {
6870 BadgeStatus::Failing => "#e05d44",
6971 BadgeStatus::Error => "#9a5b5b",
7072 BadgeStatus::Running | BadgeStatus::Pending => "#dfb317",
71- BadgeStatus::Skipped | BadgeStatus::NoStatus => GREY,
73+ BadgeStatus::Cancelled | BadgeStatus::Skipped | BadgeStatus::NoStatus => GREY,
7274 }
7375 }
7476 }
@@ -78,7 +80,8 @@ pub fn status_of_run(state: RunState) -> BadgeStatus {
7880 match state {
7981 RunState::Success => BadgeStatus::Passing,
8082 RunState::Failure => BadgeStatus::Failing,
81- RunState::Error | RunState::Cancelled => BadgeStatus::Error,
83+ RunState::Error => BadgeStatus::Error,
84+ RunState::Cancelled => BadgeStatus::Cancelled,
8285 RunState::Queued | RunState::Running => BadgeStatus::Running,
8386 RunState::WaitingApproval => BadgeStatus::Pending,
8487 }
@@ -89,7 +92,8 @@ pub fn status_of_job(state: JobState) -> BadgeStatus {
8992 match state {
9093 JobState::Success => BadgeStatus::Passing,
9194 JobState::Failure => BadgeStatus::Failing,
92- JobState::Error | JobState::Cancelled => BadgeStatus::Error,
95+ JobState::Error => BadgeStatus::Error,
96+ JobState::Cancelled => BadgeStatus::Cancelled,
9397 JobState::Blocked | JobState::Queued | JobState::Running => BadgeStatus::Running,
9498 JobState::Skipped => BadgeStatus::Skipped,
9599 }
@@ -289,6 +293,7 @@ mod tests {
289293 (BadgeStatus::Error, "#9a5b5b", "error"),
290294 (BadgeStatus::Running, "#dfb317", "running"),
291295 (BadgeStatus::Pending, "#dfb317", "pending"),
296+ (BadgeStatus::Cancelled, "#9f9f9f", "cancelled"),
292297 (BadgeStatus::Skipped, "#9f9f9f", "skipped"),
293298 (BadgeStatus::NoStatus, "#9f9f9f", "no status"),
294299 ];
@@ -305,7 +310,7 @@ mod tests {
305310 fn run_and_job_states_map_to_badge_statuses() {
306311 assert_eq!(status_of_run(RunState::Success), BadgeStatus::Passing);
307312 assert_eq!(status_of_run(RunState::Failure), BadgeStatus::Failing);
308- assert_eq!(status_of_run(RunState::Cancelled), BadgeStatus::Error);
313+ assert_eq!(status_of_run(RunState::Cancelled), BadgeStatus::Cancelled);
309314 assert_eq!(status_of_run(RunState::Error), BadgeStatus::Error);
310315 assert_eq!(status_of_run(RunState::Queued), BadgeStatus::Running);
311316 assert_eq!(status_of_run(RunState::Running), BadgeStatus::Running);
@@ -314,6 +319,7 @@ mod tests {
314319 BadgeStatus::Pending
315320 );
316321 assert_eq!(status_of_job(JobState::Blocked), BadgeStatus::Running);
322+ assert_eq!(status_of_job(JobState::Cancelled), BadgeStatus::Cancelled);
317323 assert_eq!(status_of_job(JobState::Skipped), BadgeStatus::Skipped);
318324 }
319325
crates/forge-web/src/pages/ci_job.rsmodified+14 -4
@@ -11,7 +11,7 @@ use std::sync::Arc;
1111 use std::time::Duration;
1212
1313 use bytes::Bytes;
14-use forge_core::ci::{CiArtifact, CiJob, CiRun};
14+use forge_core::ci::{CiArtifact, CiJob, CiRun, JobState};
1515 use forge_core::{Store, User};
1616 use futures_util::{Stream, TryStreamExt};
1717 use http::header::{CONTENT_DISPOSITION, CONTENT_LENGTH, CONTENT_TYPE};
@@ -304,6 +304,16 @@ fn job_fingerprint(status: &str, artifact_ids: &[&str], log_kept: bool) -> Strin
304304 )
305305 }
306306
307+/// The status the job page shows and fingerprints: `stopping` for a running job with a cancel
308+/// request its runner has not acted on yet, else the job's state.
309+pub fn job_status(job: &CiJob) -> &'static str {
310+ if job.state == JobState::Running && job.cancel_requested {
311+ "stopping"
312+ } else {
313+ job.state.as_str()
314+ }
315+}
316+
307317 /// The job's fingerprint now. `None` when the job row is gone.
308318 async fn job_fingerprint_now(store: &Store, job_id: &str) -> Result<Option<String>> {
309319 let Some(job) = store.job_by_id(job_id).await? else {
@@ -312,7 +322,7 @@ async fn job_fingerprint_now(store: &Store, job_id: &str) -> Result<Option<Strin
312322 let artifacts = store.list_artifacts(job_id).await?;
313323 let ids: Vec<&str> = artifacts.iter().map(|artifact| artifact.id.as_str()).collect();
314324 Ok(Some(job_fingerprint(
315- job.state.as_str(),
325+ job_status(&job),
316326 &ids,
317327 job.log_bytes > 0,
318328 )))
@@ -422,7 +432,7 @@ async fn job_page(cx: &Cx) -> Result<impl View> {
422432 } = log_tail(&log_path(&state.config.data_dir, &job.id)).await?;
423433 let listed = state.store.list_artifacts(&job.id).await?;
424434 let ids: Vec<&str> = listed.iter().map(|artifact| artifact.id.as_str()).collect();
425- let fingerprint = job_fingerprint(job.state.as_str(), &ids, job.log_bytes > 0);
435+ let fingerprint = job_fingerprint(job_status(&job), &ids, job.log_bytes > 0);
426436 let artifacts = listed
427437 .into_iter()
428438 .map(|artifact| ArtifactRow {
@@ -451,7 +461,7 @@ async fn job_page(cx: &Cx) -> Result<impl View> {
451461 let view = JobView {
452462 name: job.name.clone(),
453463 fingerprint,
454- state: state_text(lang, job.state.as_str()),
464+ state: state_text(lang, job_status(&job)),
455465 state_class: format!("ci-state ci-{}", job.state.as_str()),
456466 runner,
457467 exit_code: job
crates/forge-web/src/pages/ci_runs.rsmodified+24 -3
@@ -202,7 +202,7 @@ pub(crate) fn duration_text(lang: Lang, started: Option<&str>, finished: Option<
202202
203203 /// The duration formats of `lang` with `{m}` and `{s}` where the numbers go, for the client ticker:
204204 /// the one with minutes and the seconds-only one.
205-fn duration_templates(lang: Lang) -> (String, String) {
205+pub(crate) fn duration_templates(lang: Lang) -> (String, String) {
206206 (
207207 g::duration_minutes(lang, 111_111, 222_222)
208208 .replace("111111", "{m}")
@@ -221,6 +221,7 @@ pub fn state_text(lang: Lang, state: &str) -> String {
221221 "success" => K::StateSuccess,
222222 "failure" => K::StateFailure,
223223 "cancelled" => K::StateCancelled,
224+ "stopping" => K::StateStopping,
224225 "error" => K::StateError,
225226 "blocked" => K::StateBlocked,
226227 "skipped" => K::StateSkipped,
@@ -282,10 +283,11 @@ pub(crate) async fn after_change(state: &AppState, run_id: &str, before: &[CiJob
282283 state.ci_live.bump_run(run_id);
283284 state.ci_live.bump_repo(&run.repo_id);
284285 for job in state.store.jobs_for_run(run_id).await? {
286+ // A cancel request on a running job changes no state, but its row shows "stopping".
285287 let changed = before
286288 .iter()
287289 .find(|old| old.id == job.id)
288- .is_none_or(|old| old.state != job.state);
290+ .is_none_or(|old| old.state != job.state || old.cancel_requested != job.cancel_requested);
289291 if changed {
290292 if job.state.is_terminal() {
291293 state.ci_live.close_job(&job.id);
@@ -395,6 +397,8 @@ struct JobLine {
395397 expanded: bool,
396398 /// The POST target that runs this job again. Set for a writer, once the job has finished.
397399 rerun: Option<String>,
400+ /// A running job whose cancel was requested: it shows as stopping until its runner stops it.
401+ stopping: bool,
398402 }
399403
400404 /// One artifact of the run: its download link, the job that made it, its name and size.
@@ -426,6 +430,8 @@ struct RunDetail {
426430 action_base: String,
427431 can_approve: bool,
428432 can_cancel: bool,
433+ /// A running job of the run has a cancel request: the run shows Stopping in place of Cancel.
434+ stopping: bool,
429435 /// A finished run with a failed, errored or cancelled job, for a writer.
430436 can_rerun_failed: bool,
431437 /// The config keys this forge ignored when it made the run.
@@ -606,9 +612,15 @@ struct Timing {
606612 queued: Option<i64>,
607613 started: Option<i64>,
608614 finished: Option<i64>,
615+ cancel_requested: bool,
609616 }
610617
611618 impl Timing {
619+ /// Whether the job runs and has a cancel request its runner has not yet acted on.
620+ fn stopping(&self) -> bool {
621+ self.cancel_requested && self.state == JobState::Running
622+ }
623+
612624 /// Where the job ends, in unix seconds: its finish, or `now` while it runs. None before it starts.
613625 fn end(&self, now: i64) -> Option<i64> {
614626 self.started?;
@@ -1112,6 +1124,7 @@ fn timing_of(job: &CiJob, runner: String, lang: Lang) -> Timing {
11121124 queued: job.queued_at.as_deref().and_then(unix_of),
11131125 started: job.started_at.as_deref().and_then(unix_of),
11141126 finished: job.finished_at.as_deref().and_then(unix_of),
1127+ cancel_requested: job.cancel_requested,
11151128 }
11161129 }
11171130
@@ -1535,6 +1548,7 @@ async fn run_detail(
15351548 since: (job.finished.is_none() && job.state == JobState::Running)
15361549 .then(|| job.started.map(|at| at.to_string()))
15371550 .flatten(),
1551+ stopping: job.stopping(),
15381552 });
15391553 }
15401554 let can_rerun_failed = writer
@@ -1572,6 +1586,7 @@ async fn run_detail(
15721586 action_base: run_href(title, run.number),
15731587 can_approve: header.writer_csrf.is_some() && run.state == RunState::WaitingApproval,
15741588 can_cancel: header.writer_csrf.is_some() && !run_finished(&run.state),
1589+ stopping: jobs.iter().any(Timing::stopping),
15751590 can_rerun_failed,
15761591 warnings,
15771592 artifacts,
@@ -1704,7 +1719,9 @@ async fn runs_body(
17041719 if run.can_approve {
17051720 action_button(action: format!("{}/approve", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::ApproveAndRun))
17061721 }
1707- if run.can_cancel {
1722+ if run.can_cancel && run.stopping {
1723+ <button type="button" class="ci-stopping" disabled="disabled">(g::t(lang, K::StoppingButton))</button>
1724+ } else if run.can_cancel {
17081725 action_button(action: format!("{}/cancel", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Cancel))
17091726 }
17101727 if run.can_rerun_failed {
@@ -1800,6 +1817,9 @@ async fn runs_body(
18001817 </span>
18011818 <span class="ci-job-runner">(job.runner.as_str())</span>
18021819 <span class="ci-job-dur" data-since=(job.since.as_deref())>(job.duration.as_str())</span>
1820+ if job.stopping {
1821+ <span class="ci-job-stopping muted small">(g::t(lang, K::StateStopping))</span>
1822+ }
18031823 <span class="ci-chev" aria-hidden="true"></span>
18041824 </a>
18051825 if let (Some(action), Some(csrf)) = (job.rerun.as_ref(), run.writer_csrf.as_ref()) {
@@ -2432,6 +2452,7 @@ mod tests {
24322452 queued,
24332453 started,
24342454 finished,
2455+ cancel_requested: false,
24352456 }
24362457 }
24372458
crates/forge-web/src/pages/repo_side.rsmodified+95 -56
@@ -10,22 +10,22 @@ use std::sync::{Mutex, OnceLock};
1010 use forge_core::ci::{JobState, RunState};
1111 use forge_core::{Repo, Visibility};
1212 use forge_git::{browse, history};
13+use time::OffsetDateTime;
14+use time::format_description::well_known::Rfc3339;
1315 use topcoat::Result;
1416 use topcoat::view::{View, component, view};
1517
1618 use crate::i18n::Lang;
1719 use crate::i18n::releases_ci as rc;
18-use crate::pages::ci_runs::{duration_text, run_href};
20+use crate::pages::ci_runs::{duration_templates, duration_text, run_href, state_text};
1921 use crate::pages::passkeys::s;
2022 use crate::pages::releases::LatestRelease;
2123 use crate::repo_stats::{LangShare, languages, license_file, license_id};
2224 use crate::state::AppState;
23-use crate::views::{human_size, rel_time, short_oid};
25+use crate::views::{human_size, now_unix, rel_time, short_oid};
2426
2527 /// CI runs the column lists.
2628 const RUNS_SHOWN: u32 = 3;
27-/// Jobs shown as pips; a run with more shows a count instead.
28-const MAX_PIPS: usize = 10;
2929 /// Languages listed before the rest fold into "Other".
3030 const TOP_LANGUAGES: usize = 4;
3131 /// Files the language count reads at most.
@@ -106,38 +106,38 @@ pub async fn tree_facts(
106106 Ok(facts)
107107 }
108108
109-/// One CI run as the column shows it.
109+/// One CI run as the column shows it: a link to the run, its dot, and one line of words. A run
110+/// still going has a bar of the jobs done and a clock that ticks.
110111 pub struct RunRow {
111112 pub href: String,
112113 pub number: i64,
113114 pub dot: &'static str,
114- pub meta: String,
115- /// Each job's pip class, or empty when the run has more jobs than pips.
116- pub pips: Vec<&'static str>,
117- /// "3/12" when the jobs do not fit as pips.
118- pub count: String,
115+ /// The bar's fill and its job count, for a run still going.
116+ pub bar: Option<(String, String)>,
117+ /// Unix seconds the run started, for the ticking clock of a run still going.
118+ pub since: Option<String>,
119+ /// The text before the clock: the current job's name.
120+ pub pre: Option<String>,
121+ /// The right-hand text, or the elapsed time of a run still going.
122+ pub label: String,
119123 pub title: String,
120124 }
121125
122-/// The dot of a run: green passed, red failed, amber in progress, grey otherwise.
126+/// The dot of a run: glowing while it goes, green passed, red failed, grey otherwise.
123127 fn run_dot(run: RunState) -> &'static str {
124128 match run {
125129 RunState::Success => "health-dot ok",
126130 RunState::Failure | RunState::Error => "health-dot bad",
127- RunState::Running | RunState::Queued => "health-dot warn",
131+ RunState::Running | RunState::Queued => "health-dot ember",
128132 RunState::Cancelled | RunState::WaitingApproval => "health-dot",
129133 }
130134 }
131135
132-/// The pip of a job: filled when it passed, red when it failed, accent while it runs.
133-fn job_pip(job: JobState) -> &'static str {
134- match job {
135- JobState::Success => "side-pip is-ok",
136- JobState::Failure | JobState::Error => "side-pip is-bad",
137- JobState::Running => "side-pip is-on",
138- JobState::Skipped | JobState::Cancelled => "side-pip is-off",
139- JobState::Blocked | JobState::Queued => "side-pip",
140- }
136+/// Unix seconds of an RFC 3339 stamp.
137+fn unix(stamp: &str) -> Option<i64> {
138+ OffsetDateTime::parse(stamp, &Rfc3339)
139+ .ok()
140+ .map(|at| at.unix_timestamp())
141141 }
142142
143143 /// The newest runs of the repo, with their jobs.
@@ -147,6 +147,7 @@ pub async fn run_rows(state: &AppState, lang: Lang, repo: &Repo) -> Result<Vec<R
147147 let mut rows = Vec::with_capacity(runs.len());
148148 for run in runs {
149149 let jobs = state.store.jobs_for_run(&run.id).await?;
150+ let total = jobs.len();
150151 let done = jobs
151152 .iter()
152153 .filter(|job| {
@@ -162,29 +163,66 @@ pub async fn run_rows(state: &AppState, lang: Lang, repo: &Repo) -> Result<Vec<R
162163 .strip_prefix("refs/heads/")
163164 .or_else(|| run.git_ref.strip_prefix("refs/tags/"))
164165 .unwrap_or(&run.git_ref);
165- let mut meta = vec![branch.to_owned(), short_oid(&run.commit_oid).to_owned()];
166- let took = duration_text(lang, started, run.finished_at.as_deref());
167- if !took.is_empty() {
168- meta.push(took);
169- }
170- let fits = jobs.len() <= MAX_PIPS;
166+ let (bar, since, pre, label) = if matches!(run.state, RunState::Running | RunState::Queued)
167+ {
168+ let current = jobs
169+ .iter()
170+ .find(|job| job.state == JobState::Running)
171+ .or_else(|| jobs.iter().find(|job| job.state == JobState::Queued))
172+ .map(|job| job.name.as_str())
173+ .unwrap_or("");
174+ let current = if current.is_empty() && run.state == RunState::Queued {
175+ s(lang, "queued", "sırada")
176+ } else {
177+ current
178+ };
179+ // A sliver shows even before the first job is done.
180+ let fill = if done == 0 { 0.2 } else { done as f64 };
181+ let since_stamp = started.unwrap_or(run.created_at.as_str());
182+ (
183+ Some((format!("{fill}"), total.max(1).to_string())),
184+ unix(since_stamp).map(|secs| secs.to_string()),
185+ (!current.is_empty()).then(|| format!("{current} \u{b7} ")),
186+ duration_text(lang, Some(since_stamp), None),
187+ )
188+ } else {
189+ let failed = jobs
190+ .iter()
191+ .find(|job| matches!(job.state, JobState::Failure | JobState::Error))
192+ .map(|job| job.name.as_str());
193+ let word = match run.state {
194+ RunState::Success => s(lang, "passed", "geçti").to_owned(),
195+ RunState::Failure | RunState::Error => match failed {
196+ Some(name) => format!("{name} {}", s(lang, "failed", "başarısız")),
197+ None => s(lang, "failed", "başarısız").to_owned(),
198+ },
199+ RunState::Cancelled => s(lang, "cancelled", "iptal edildi").to_owned(),
200+ RunState::WaitingApproval | RunState::Running | RunState::Queued => {
201+ state_text(lang, run.state.as_str())
202+ }
203+ };
204+ // The same words as the running clock and the CI pages: "4m 12s".
205+ let took = duration_text(lang, started, run.finished_at.as_deref());
206+ let label = if took.is_empty() || run.finished_at.is_none() {
207+ word
208+ } else {
209+ format!("{word} \u{b7} {took}")
210+ };
211+ (None, None, None, label)
212+ };
171213 rows.push(RunRow {
172214 href: run_href(&title, run.number),
173215 number: run.number,
174216 dot: run_dot(run.state),
175- meta: meta.join(" \u{b7} "),
176- pips: if fits {
177- jobs.iter().map(|job| job_pip(job.state)).collect()
178- } else {
179- Vec::new()
180- },
181- count: if fits {
182- String::new()
183- } else {
184- format!("{done}/{}", jobs.len())
185- },
186- title: s(lang, "Jobs passed", "Geçen işler").to_owned()
187- + &format!(": {done}/{}", jobs.len()),
217+ bar,
218+ since,
219+ pre,
220+ label,
221+ title: format!(
222+ "{}: {done}/{total} \u{b7} {branch} \u{b7} {}",
223+ s(lang, "Jobs passed", "Geçen işler"),
224+ short_oid(&run.commit_oid)
225+ ),
188226 });
189227 }
190228 Ok(rows)
@@ -227,6 +265,9 @@ pub async fn repo_side(
227265 let size = facts.as_ref().map(|f| human_size(lang, f.size));
228266 let license = facts.as_ref().and_then(|f| f.license.clone());
229267 let langs = facts.map(|f| f.languages).unwrap_or_default();
268+ // The CI rows' clock: the server's time and the duration words the page's ticker rewrites with.
269+ let now = now_unix();
270+ let (fm, fs) = duration_templates(lang);
230271 Ok(view! {
231272 <section class="side-sec">
232273 <h2>(s(lang, "About", "Hakkında"))</h2>
@@ -258,30 +299,28 @@ pub async fn repo_side(
258299 </dl>
259300 </section>
260301 if !runs.is_empty() {
261- <section class="side-sec">
302+ <section class="side-sec" data-now=(now.to_string()) data-fm=(fm.as_str()) data-fs=(fs.as_str())>
262303 <div class="side-h">
263304 <h2>"CI"</h2>
264305 <a class="small" href=(ci_href.as_str())>(s(lang, "All runs", "Tüm çalıştırmalar"))</a>
265306 </div>
266307 <ul class="side-rows">
267308 for run in runs.iter() {
268- <li class="side-row">
269- <div class="side-row-main">
270- <div class="side-row-title">
271- <span class=(run.dot)></span>
272- <a class="side-row-name" href=(run.href.as_str())>(format!("#{}", run.number))</a>
273- </div>
274- <div class="side-row-meta muted">(run.meta.as_str())</div>
275- </div>
276- if run.count.is_empty() {
277- <span class="side-pips" title=(run.title.as_str())>
278- for pip in run.pips.iter() {
279- <i class=(*pip)></i>
309+ <li class="side-run">
310+ <a class="side-run-link" href=(run.href.as_str()) title=(run.title.as_str())>
311+ <span class=(run.dot)></span>
312+ <span class="side-run-name">(format!("#{}", run.number))</span>
313+ if let Some((value, max)) = run.bar.as_ref() {
314+ <progress class="side-run-bar" value=(value.as_str()) max=(max.as_str())></progress>
315+ }
316+ <span class="side-run-text muted">
317+ if let Some(since) = run.since.as_deref() {
318+ <span data-since=(since) data-pre=(run.pre.as_deref())>(run.label.as_str())</span>
319+ } else {
320+ (run.label.as_str())
280321 }
281322 </span>
282- } else {
283- <span class="side-count muted" title=(run.title.as_str())>(run.count.as_str())</span>
284- }
323+ </a>
285324 </li>
286325 }
287326 </ul>
crates/forge-web/src/views/mod.rsmodified+129 -48
@@ -12,7 +12,7 @@ use std::sync::OnceLock;
1212 use forge_core::ci::RunState;
1313 use forge_core::store::RepoSort;
1414 use forge_core::store::repo_listing::RepoScope;
15-use forge_core::store::shell_activity::{ActorRuns, InboxKinds};
15+use forge_core::store::shell_activity::{ActorRun, ActorRuns, InboxKinds};
1616 use forge_core::{Error as CoreError, Session, User};
1717 use hex::encode;
1818 use http::header::{
@@ -208,44 +208,82 @@ struct PathCrumb {
208208 class: &'static str,
209209 }
210210
211-/// One pill of the live strip: a CI run of the viewer.
212-struct LivePill {
213- class: &'static str,
211+/// One run on the live strip: its pill when it is the only run, and its row in the dropdown otherwise.
212+struct StripRun {
213+ pill_class: String,
214+ row_class: String,
214215 label: String,
215- /// The current job's name (with a leading space) or the outcome word; empty when there is none.
216+ /// The current job's name or the outcome word, with a leading space; empty when there is none.
216217 text: String,
217218 href: String,
218219 }
219220
220-/// The live strip's pills, at most two, and how many runs are left over. Running runs come first,
221-/// then the finished ones that passed or failed.
222-fn live_pills(lang: Lang, runs: &ActorRuns) -> (Vec<LivePill>, usize) {
223- let mut pills = Vec::new();
221+/// The live strip: every run of the viewer, running ones first, and the pill it shows. With one run
222+/// that run's pill; with two or more a summary pill that opens the list of all of them.
223+struct LiveStrip {
224+ runs: Vec<StripRun>,
225+ summary_class: &'static str,
226+ summary: String,
227+}
228+
229+/// The live strip for the viewer's runs. A finished run that did not pass, fail or get cancelled is
230+/// left out.
231+fn live_strip(lang: Lang, runs: &ActorRuns) -> LiveStrip {
232+ let mut rows = Vec::new();
224233 for run in &runs.running {
225234 let job = run.current_job.as_deref().unwrap_or("");
226- pills.push(LivePill {
227- class: "pill hot",
228- label: format!("{} #{}", run.repo, run.number),
229- text: if job.is_empty() { String::new() } else { format!(" {job}") },
230- href: repo_href(&run.owner, &run.repo, "ci", &format!("runs/{}", run.number)),
231- });
235+ rows.push(strip_run("hot", run, if job.is_empty() { String::new() } else { format!(" {job}") }));
232236 }
233237 for run in &runs.finished {
234- let (class, word) = match run.state {
235- RunState::Success => ("pill ok", mi::t(lang, MK::Passed)),
236- RunState::Failure | RunState::Error => ("pill bad", mi::t(lang, MK::Failed)),
238+ let (state, word) = match run.state {
239+ RunState::Success => ("ok", mi::t(lang, MK::Passed)),
240+ RunState::Failure | RunState::Error => ("bad", mi::t(lang, MK::Failed)),
241+ RunState::Cancelled => ("off", mi::t(lang, MK::Cancelled)),
237242 _ => continue,
238243 };
239- pills.push(LivePill {
240- class,
241- label: format!("{} #{}", run.repo, run.number),
242- text: format!(" {word}"),
243- href: repo_href(&run.owner, &run.repo, "ci", &format!("runs/{}", run.number)),
244- });
244+ rows.push(strip_run(state, run, format!(" {word}")));
245+ }
246+ let count = |pred: fn(RunState) -> bool| runs.finished.iter().filter(|run| pred(run.state)).count() as u64;
247+ let running = runs.running.len() as u64;
248+ let failed = count(|state| matches!(state, RunState::Failure | RunState::Error));
249+ let passed = count(|state| matches!(state, RunState::Success));
250+ let cancelled = count(|state| matches!(state, RunState::Cancelled));
251+ let summary_class = if running > 0 {
252+ "pill hot"
253+ } else if failed > 0 {
254+ "pill bad"
255+ } else if passed > 0 {
256+ "pill ok"
257+ } else {
258+ "pill off"
259+ };
260+ let parts = [
261+ (running, mi::running_count as fn(Lang, u64) -> String),
262+ (failed, mi::failed_count),
263+ (passed, mi::passed_count),
264+ (cancelled, mi::cancelled_count),
265+ ];
266+ let summary = parts
267+ .iter()
268+ .filter(|(n, _)| *n > 0)
269+ .map(|(n, phrase)| phrase(lang, *n))
270+ .collect::<Vec<_>>()
271+ .join(" · ");
272+ LiveStrip {
273+ runs: rows,
274+ summary_class,
275+ summary,
276+ }
277+}
278+
279+fn strip_run(state: &str, run: &ActorRun, text: String) -> StripRun {
280+ StripRun {
281+ pill_class: format!("pill {state}"),
282+ row_class: format!("strip-row {state}"),
283+ label: format!("{} #{}", run.repo, run.number),
284+ text,
285+ href: repo_href(&run.owner, &run.repo, "ci", &format!("runs/{}", run.number)),
245286 }
246- let more = pills.len().saturating_sub(2);
247- pills.truncate(2);
248- (pills, more)
249287 }
250288
251289 /// A count's phrase with its number replaced by `{n}`, for nav.js to fill in again.
@@ -253,11 +291,6 @@ fn count_template(phrase: &str, n: u64) -> String {
253291 phrase.replacen(&n.to_string(), "{n}", 1)
254292 }
255293
256-/// The heat ring's fill: the share of a run's jobs that are done, at least 8%.
257-fn heat_percent(done: u64, total: u64) -> u64 {
258- (done * 100).checked_div(total).map_or(8, |p| p.clamp(8, 100))
259-}
260-
261294 /// The viewer's runs when there is no viewer or no app context: none.
262295 fn no_runs() -> ActorRuns {
263296 ActorRuns {
@@ -278,8 +311,8 @@ struct WaitingRow {
278311 dot_class: &'static str,
279312 }
280313
281-/// What the profile corner shows: the viewer, their inbox counts, the newest running run's heat
282-/// (`None` when nothing runs) and the items waiting on them.
314+/// What the profile corner shows: the viewer, their inbox counts, whether any of their runs is
315+/// going (the ring glows) and the items waiting on them.
283316 #[derive(Clone)]
284317 struct ProfileCorner {
285318 username: String,
@@ -291,7 +324,7 @@ struct ProfileCorner {
291324 reviews: u64,
292325 mentions: u64,
293326 failing: u64,
294- heat: Option<u64>,
327+ hot: bool,
295328 waiting: Vec<WaitingRow>,
296329 }
297330
@@ -300,9 +333,7 @@ struct ProfileCorner {
300333 /// and the profile, settings, admin and log out links.
301334 #[component]
302335 async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View> {
303- let ring_class = if corner.heat.is_some() { "heat-ring hot" } else { "heat-ring" };
304- // The fill in steps of 5 (the stylesheet maps each step to --p): the CSP refuses style attributes.
305- let ring_step = (corner.heat.unwrap_or(0).min(100) + 2) / 5 * 5;
336+ let ring_class = if corner.hot { "heat-ring hot" } else { "heat-ring" };
306337 let review_chip = (corner.reviews > 0).then(|| {
307338 (corner.reviews.to_string(), mi::review_requests_count(lang, corner.reviews))
308339 });
@@ -336,7 +367,7 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result<impl View>
336367 Ok(view! {
337368 <details class="corner" data-unread-stream="">
338369 <summary class="corner-btn" aria-label=(corner.username.as_str())>
339- <span class=(ring_class) data-p=(ring_step.to_string())><img class="avatar avatar-sm" src=(corner.avatar.as_str()) alt="" width="28" height="28"></span>
370+ <span class=(ring_class)><img class="avatar avatar-sm" src=(corner.avatar.as_str()) alt="" width="28" height="28"></span>
340371 <span class="corner-name">(corner.username.as_str())</span>
341372 <span class="corner-chips" data-review=(review_template.as_str()) data-review-one=(review_one.as_str()) data-mention=(mention_template.as_str()) data-mention-one=(mention_one.as_str()) data-failing=(failing_template.as_str()) data-failing-one=(failing_one.as_str())>
342373 if let Some((count, title)) = review_chip {
@@ -569,12 +600,17 @@ pub async fn shell(
569600 href,
570601 })
571602 .collect();
572- let (pills, more) = live_pills(lang, &runs);
573- let more_label = format!("+{more}");
603+ let strip = live_strip(lang, &runs);
604+ // The strip's count phrases, as templates for nav.js: `{n}` stands for the count.
605+ let running_tpl = count_template(&mi::running_count(lang, 2), 2);
606+ let failed_tpl = count_template(&mi::failed_count(lang, 2), 2);
607+ let passed_tpl = count_template(&mi::passed_count(lang, 2), 2);
608+ let cancelled_tpl = count_template(&mi::cancelled_count(lang, 2), 2);
609+ let runs_label = mi::t(lang, MK::YourCiRuns);
574610 let search_for_label = mi::t(lang, MK::SearchPublicReposFor);
575611 // The profile corner, the signed-in sidebar's account menu. The sidebar and the phone menu
576612 // each get their own copy.
577- let heat = runs.running.first().map(|run| heat_percent(run.jobs_done, run.jobs_total));
613+ let hot = !runs.running.is_empty();
578614 let waiting_rows: Vec<WaitingRow> = waiting
579615 .iter()
580616 .map(|item| WaitingRow {
@@ -603,7 +639,7 @@ pub async fn shell(
603639 reviews: inbox.reviews,
604640 mentions: inbox.mentions,
605641 failing: runs.failing,
606- heat,
642+ hot,
607643 waiting: waiting_rows,
608644 });
609645 let corner_panel = corner.clone();
@@ -678,12 +714,23 @@ pub async fn shell(
678714 }
679715 </nav>
680716 if signed_in {
681- <div class="live-strip" data-activity="/-/activity" data-passed=(mi::t(lang, MK::Passed)) data-failed=(mi::t(lang, MK::Failed)) aria-live="polite">
682- for pill in pills.iter() {
683- <a class=(pill.class) href=(pill.href.as_str())><span class="pill-dot"></span><b>(pill.label.as_str())</b>(pill.text.as_str())</a>
717+ <div class="live-strip" data-activity="/-/activity" data-passed=(mi::t(lang, MK::Passed)) data-failed=(mi::t(lang, MK::Failed)) data-cancelled=(mi::t(lang, MK::Cancelled))
718+ data-count-running=(running_tpl.as_str()) data-count-failed=(failed_tpl.as_str()) data-count-passed=(passed_tpl.as_str()) data-count-cancelled=(cancelled_tpl.as_str())
719+ data-runs-label=(runs_label) aria-live="polite">
720+ if strip.runs.len() == 1 {
721+ for run in strip.runs.iter() {
722+ <a class=(run.pill_class.as_str()) href=(run.href.as_str())><span class="pill-dot"></span><b>(run.label.as_str())</b>(run.text.as_str())</a>
723+ }
684724 }
685- if more > 0 {
686- <span class="pill more">(more_label.as_str())</span>
725+ if strip.runs.len() > 1 {
726+ <details class="strip-runs" id="strip-runs">
727+ <summary class=(strip.summary_class) aria-label=(runs_label)><span class="pill-dot"></span>(strip.summary.as_str())</summary>
728+ <ul class="strip-list">
729+ for run in strip.runs.iter() {
730+ <li><a class=(run.row_class.as_str()) href=(run.href.as_str())><span class="pill-dot"></span><b>(run.label.as_str())</b>(run.text.as_str())</a></li>
731+ }
732+ </ul>
733+ </details>
687734 }
688735 </div>
689736 } else {
@@ -1699,6 +1746,40 @@ mod tests {
16991746 assert_eq!(enc("a~b.c_d-e"), "a~b.c_d-e");
17001747 }
17011748
1749+ #[test]
1750+ fn live_strip_is_one_pill_for_one_run_and_a_summary_for_more() {
1751+ let run = |state, number| ActorRun {
1752+ owner: "tahinli".into(),
1753+ repo: "proj".into(),
1754+ number,
1755+ git_ref: "main".into(),
1756+ state,
1757+ created_at: String::new(),
1758+ finished_at: None,
1759+ jobs_total: 0,
1760+ jobs_done: 0,
1761+ current_job: None,
1762+ };
1763+ let many = ActorRuns {
1764+ running: vec![run(RunState::Running, 3)],
1765+ finished: vec![run(RunState::Failure, 2), run(RunState::Cancelled, 1)],
1766+ failing: 0,
1767+ };
1768+ let strip = live_strip(Lang::En, &many);
1769+ assert_eq!(strip.runs.len(), 3);
1770+ assert_eq!(strip.summary, "1 running · 1 failed · 1 cancelled");
1771+ assert_eq!(strip.summary_class, "pill hot");
1772+ let alone = ActorRuns {
1773+ running: Vec::new(),
1774+ finished: vec![run(RunState::Cancelled, 1)],
1775+ failing: 0,
1776+ };
1777+ let one = live_strip(Lang::En, &alone);
1778+ assert_eq!(one.runs.len(), 1);
1779+ assert_eq!(one.runs[0].pill_class, "pill off");
1780+ assert_eq!(one.runs[0].text, " cancelled");
1781+ }
1782+
17021783 #[test]
17031784 fn repo_href_builds_each_form() {
17041785 assert_eq!(repo_href("tahinli", "demo", "", ""), "/tahinli/demo");
style/_repo_side.scssmodified+68 -25
@@ -102,45 +102,88 @@
102102 white-space: nowrap;
103103 }
104104
105-// One pip per job, as on the runners list: filled when it passed, red when it failed, the accent
106-// while it runs, a hollow pip while it waits.
107-.side-pips {
108- display: inline-flex;
109- gap: 3px;
105+// One row per CI run, the whole row a link: an ember dot that glows while the run goes, the number,
106+// a slim heat bar of the jobs done (while it goes), and one muted line on the right: the current
107+// job and its clock, or the result and the total time.
108+.side-run + .side-run {
109+ border-top: 1px solid var(--border);
110110 }
111111
112-.side-pip {
113- box-sizing: border-box;
114- width: 12px;
115- height: 6px;
116- border-radius: 2px;
117- background: var(--surface-2);
118- box-shadow: inset 0 0 0 1px var(--border);
112+.side-run-link {
113+ display: flex;
114+ align-items: center;
115+ gap: 8px;
116+ min-width: 0;
117+ padding: 11px 0;
118+ color: inherit;
119+ text-decoration: none;
119120
120- &.is-ok {
121- background: var(--ok);
122- box-shadow: none;
121+ &:hover .side-run-name {
122+ text-decoration: underline;
123123 }
124+}
125+
126+.health-dot.ember {
127+ background: var(--heat-3);
128+ box-shadow: 0 0 6px var(--heat-glow);
129+ animation: ember-pulse 1.8s ease-in-out infinite;
124130
125- &.is-bad {
126- background: var(--bad);
127- box-shadow: none;
131+ @media (prefers-reduced-motion: reduce) {
132+ animation: none;
128133 }
134+}
129135
130- &.is-on {
131- background: var(--accent);
132- box-shadow: none;
136+@keyframes ember-pulse {
137+ 50% {
138+ box-shadow: 0 0 10px var(--heat-glow);
133139 }
140+}
141+
142+.side-run-name {
143+ flex: none;
144+ color: var(--text);
145+ font-size: 14px;
146+ font-weight: 600;
147+ font-variant-numeric: tabular-nums;
148+}
134149
135- &.is-off {
136- background: var(--border-strong);
137- box-shadow: none;
150+progress.side-run-bar {
151+ -webkit-appearance: none;
152+ appearance: none;
153+ flex: 1 1 auto;
154+ box-sizing: border-box;
155+ min-width: 24px;
156+ height: 4px;
157+ margin: 0;
158+ border: 0;
159+ border-radius: 2px;
160+ overflow: hidden;
161+ background: var(--border);
162+ color: var(--heat-3);
163+
164+ &::-webkit-progress-bar {
165+ background: var(--border);
166+ }
167+
168+ &::-webkit-progress-value {
169+ border-radius: 2px;
170+ background: linear-gradient(90deg, var(--heat-2), var(--heat-3), var(--heat-4));
171+ }
172+
173+ &::-moz-progress-bar {
174+ border-radius: 2px;
175+ background: linear-gradient(90deg, var(--heat-2), var(--heat-3), var(--heat-4));
138176 }
139177 }
140178
141-.side-count {
179+.side-run-text {
180+ min-width: 0;
181+ margin-left: auto;
182+ overflow: hidden;
142183 font-size: 12px;
143184 font-variant-numeric: tabular-nums;
185+ text-overflow: ellipsis;
186+ white-space: nowrap;
144187 }
145188
146189 // Languages: the name and what it is made of, a thin meter in the accent, the share on the right.
style/_shell.scssmodified+83 -22
@@ -333,9 +333,83 @@
333333 }
334334 }
335335
336-.pill.more {
337- color: var(--muted);
338- border-style: dashed;
336+// Two or more runs: the summary pill opens a list of all of them, right-aligned under it.
337+.strip-runs {
338+ position: relative;
339+
340+ > summary {
341+ list-style: none;
342+ cursor: pointer;
343+
344+ &::-webkit-details-marker {
345+ display: none;
346+ }
347+ }
348+}
349+
350+.strip-list {
351+ position: absolute;
352+ top: calc(100% + 6px);
353+ right: 0;
354+ z-index: 60;
355+ display: grid;
356+ gap: 2px;
357+ box-sizing: border-box;
358+ width: max-content;
359+ min-width: 240px;
360+ max-width: min(420px, 92vw);
361+ max-height: min(60vh, 420px);
362+ overflow-y: auto;
363+ margin: 0;
364+ padding: 6px;
365+ list-style: none;
366+ background: var(--surface);
367+ border: 1px solid var(--border);
368+ border-radius: var(--radius-md);
369+ box-shadow: var(--shadow);
370+
371+ li {
372+ min-width: 0;
373+ }
374+}
375+
376+.strip-row {
377+ display: flex;
378+ align-items: center;
379+ gap: 8px;
380+ min-width: 0;
381+ padding: 6px 8px;
382+ border-radius: var(--radius-md);
383+ color: var(--text-2);
384+ font-size: 12.5px;
385+ white-space: nowrap;
386+ text-decoration: none;
387+
388+ b {
389+ min-width: 0;
390+ overflow: hidden;
391+ font-weight: 600;
392+ color: var(--text);
393+ text-overflow: ellipsis;
394+ }
395+
396+ &:hover {
397+ background: var(--surface-2);
398+ text-decoration: none;
399+ }
400+
401+ &.ok .pill-dot {
402+ background: var(--ok);
403+ }
404+
405+ &.bad .pill-dot {
406+ background: var(--danger);
407+ }
408+
409+ &.hot .pill-dot {
410+ background: var(--heat-4);
411+ animation: pill-pulse 1.6s ease-out infinite;
412+ }
339413 }
340414
341415 @keyframes pill-pulse {
@@ -583,7 +657,8 @@
583657 white-space: nowrap;
584658 }
585659
586-// The avatar inside a ring: the ring fills with the running run's progress (--p), and glows while hot.
660+// The avatar inside a ring: a plain border ring when nothing runs, a full ember ring while a run
661+// of the viewer's is queued or running (.hot), glowing softly.
587662 .heat-ring {
588663 display: grid;
589664 flex: none;
@@ -591,18 +666,10 @@
591666 width: 34px;
592667 height: 34px;
593668 border-radius: 50%;
594- background: conic-gradient(
595- var(--heat-2) 0%,
596- var(--heat-3) calc(var(--p, 8%) * 0.6),
597- var(--heat-4) var(--p, 8%),
598- var(--border) var(--p, 8%)
599- );
600-
601- &:not(.hot) {
602- background: var(--border);
603- }
669+ background: var(--border);
604670
605671 &.hot {
672+ background: conic-gradient(var(--heat-2), var(--heat-3), var(--heat-4), var(--heat-2));
606673 filter: drop-shadow(0 0 5px var(--heat-glow));
607674 }
608675
@@ -615,13 +682,6 @@
615682 }
616683 }
617684
618-// The fill arrives as data-p in steps of 5: the CSP refuses style attributes.
619-@for $i from 0 through 20 {
620- .heat-ring[data-p="#{$i * 5}"] {
621- --p: #{$i * 5}%;
622- }
623-}
624-
625685 .corner-chips {
626686 display: flex;
627687 align-items: center;
@@ -1074,7 +1134,8 @@ html[aria-busy="true"] body::before {
10741134 opacity: 0.45;
10751135 }
10761136
1077- .pill.hot .pill-dot {
1137+ .pill.hot .pill-dot,
1138+ .strip-row.hot .pill-dot {
10781139 animation: none;
10791140 }
10801141 }
style/main.scssmodified+19 -0
@@ -6184,6 +6184,25 @@ html.js form.runner-load[data-dirty-form][data-dirty] .runner-save {
61846184 white-space: nowrap;
61856185 }
61866186
6187+// A running job being stopped: a small label tinted toward the heat colour, in its own grid track
6188+// (the row then has one more track, so the chevron keeps its place).
6189+.ci-job-line:has(.ci-job-stopping) {
6190+ grid-template-columns: 8px minmax(0, 1fr) auto auto auto 12px;
6191+}
6192+
6193+.ci-job-stopping {
6194+ font-size: 0.75rem;
6195+ color: color-mix(in srgb, var(--heat-3) 60%, var(--muted));
6196+ white-space: nowrap;
6197+}
6198+
6199+// Cancel's stand-in while the run is being stopped: disabled, so it reads as taken.
6200+button.ci-stopping {
6201+ cursor: not-allowed;
6202+ color: var(--muted);
6203+ opacity: 0.65;
6204+}
6205+
61876206 .ci-chev {
61886207 justify-self: end;
61896208 width: 6px;