diff --git a/crates/forge-core/src/store/shell_activity.rs b/crates/forge-core/src/store/shell_activity.rs index ed23062..c92bba2 100644 --- a/crates/forge-core/src/store/shell_activity.rs +++ b/crates/forge-core/src/store/shell_activity.rs @@ -56,6 +56,8 @@ pub struct ActorRuns { pub finished: Vec, /// Refs whose newest run by this user failed within the last 7 days. pub failing: u64, + /// The newest of those failed runs as (owner, repo, run number), for a link straight to it. + pub newest_failing: Option<(String, String, i64)>, } /// One CI run of the user, with its job progress. @@ -221,33 +223,43 @@ impl Store { ) .await?; - // Newest run per (repo, ref) among this actor's runs, then count the ones that failed. + // Newest run per (repo, ref) among this actor's runs; the ones that failed are counted, and the + // newest of them is kept for its link. let mut params = vec![Value::Text(actor_id.to_string())]; params.extend(readable_params(actor_id)); params.push(Value::Text(stamp_ago(FAILING_WINDOW))); let failing = fetch_all( &conn, &format!( - "SELECT COUNT(*) FROM ( \ - SELECT ci_runs.state, ci_runs.created_at, ROW_NUMBER() OVER ( \ + "SELECT COUNT(*) OVER (), owner, name, number FROM ( \ + SELECT ci_runs.state, ci_runs.created_at, ci_runs.number, o.username AS owner, \ + r.name AS name, ROW_NUMBER() OVER ( \ PARTITION BY ci_runs.repo_id, ci_runs.git_ref ORDER BY ci_runs.number DESC) AS rn \ FROM ci_runs JOIN repos r ON r.id = ci_runs.repo_id \ + JOIN users o ON o.id = r.owner_id \ WHERE ci_runs.actor_id = ? AND {readable} \ - ) WHERE rn = 1 AND state IN ('failure', 'error') AND created_at >= ?" + ) WHERE rn = 1 AND state IN ('failure', 'error') AND created_at >= ? \ + ORDER BY created_at DESC LIMIT 1" ), params, - |row| col_int(row, 0), + |row| { + Ok(( + col_int(row, 0)?, + (col_text(row, 1)?, col_text(row, 2)?, col_int(row, 3)?), + )) + }, ) .await?; - let failing = match failing.first() { - Some(n) => count_from(*n)?, - None => 0, + let (failing, newest_failing) = match failing.into_iter().next() { + Some((n, run)) => (count_from(n)?, Some(run)), + None => (0, None), }; Ok(ActorRuns { running, finished, failing, + newest_failing, }) } } diff --git a/crates/forge-web/src/i18n/misc.rs b/crates/forge-web/src/i18n/misc.rs index eac882f..1dad1ae 100644 --- a/crates/forge-web/src/i18n/misc.rs +++ b/crates/forge-web/src/i18n/misc.rs @@ -172,7 +172,6 @@ pub enum K { YourProfile, EditProfile, // Profile corner, live strip and path bar search. - WaitingOnYou, AllNotifications, Passed, Failed, @@ -328,7 +327,6 @@ const ALL: &[K] = &[ K::RefLabel, K::YourProfile, K::EditProfile, - K::WaitingOnYou, K::AllNotifications, K::Passed, K::Failed, @@ -655,8 +653,6 @@ pub fn t(lang: Lang, key: K) -> &'static str { (YourProfile, Tr) => "Profilin", (EditProfile, En) => "Edit profile", (EditProfile, Tr) => "Profili düzenle", - (WaitingOnYou, En) => "Waiting on you", - (WaitingOnYou, Tr) => "Seni bekleyenler", (AllNotifications, En) => "All notifications", (AllNotifications, Tr) => "Tüm bildirimler", (Passed, En) => "passed", diff --git a/crates/forge-web/src/pages/activity.rs b/crates/forge-web/src/pages/activity.rs index 1e70a24..980c189 100644 --- a/crates/forge-web/src/pages/activity.rs +++ b/crates/forge-web/src/pages/activity.rs @@ -90,6 +90,10 @@ pub(crate) async fn activity_json(state: &AppState, user: &User) -> Result ActorRuns { running: Vec::new(), finished: Vec::new(), failing: 0, + newest_failing: None, } } -/// One item of the profile corner's waiting list. -#[derive(Clone)] -struct WaitingRow { - href: String, - title: String, - /// `owner/repo#number`. - repo: String, - /// `corner-dot review` or `corner-dot mention`. - dot_class: &'static str, -} - -/// What the profile corner shows: the viewer, their inbox counts, whether any of their runs is -/// going (the ring glows) and the items waiting on them. +/// What the profile corner shows: the viewer, their inbox counts with where each leads, and whether +/// any of their runs is going (the ring glows). #[derive(Clone)] struct ProfileCorner { username: String, + /// The display name when set, else the username. + name: String, avatar: String, csrf: String, back: String, @@ -325,7 +317,10 @@ struct ProfileCorner { mentions: u64, failing: u64, hot: bool, - waiting: Vec, + /// The newest waiting review request, mention and failed run, each chip's link. + review_href: String, + mention_href: String, + failing_href: String, } /// The account corner at the foot of the signed-in sidebar and in the phone menu. It opens upward: @@ -341,8 +336,7 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result .then(|| (corner.mentions.to_string(), mi::mentions_count(lang, corner.mentions))); let failing_chip = (corner.failing > 0) .then(|| (corner.failing.to_string(), mi::failing_runs_count(lang, corner.failing))); - let waiting_label = mi::t(lang, MK::WaitingOnYou); - let all_label = mi::t(lang, MK::AllNotifications); + let bell_label = mi::t(lang, MK::AllNotifications); let theme_label = mi::t(lang, MK::ThemeLabel); let match_label = mi::t(lang, MK::MatchSystem); let light_label = mi::t(lang, MK::Light); @@ -350,7 +344,6 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result let auto_pressed = if corner.theme == "auto" { "true" } else { "false" }; let light_pressed = if corner.theme == "light" { "true" } else { "false" }; let dark_pressed = if corner.theme == "dark" { "true" } else { "false" }; - let has_waiting = !corner.waiting.is_empty(); // The chips' titles as nav.js rebuilds them: the server's phrase with `{n}` for the count. The // singular and plural forms are separate, as English puts "request" and "requests" apart. let review_template = count_template(&mi::review_requests_count(lang, 2), 2); @@ -368,30 +361,21 @@ async fn profile_corner(lang: Lang, corner: ProfileCorner) -> Result
- (corner.username.as_str()) + (corner.name.as_str()) if let Some((count, title)) = review_chip { - (count.as_str()) + (count.as_str()) } if let Some((count, title)) = mention_chip { - (count.as_str()) + (count.as_str()) } if let Some((count, title)) = failing_chip { - (count.as_str()) + (count.as_str()) } + -
- if has_waiting { -

(waiting_label)

- - } - (all_label) -
+
(theme_label)
@@ -611,26 +595,37 @@ pub async fn shell( // The profile corner, the signed-in sidebar's account menu. The sidebar and the phone menu // each get their own copy. let hot = !runs.running.is_empty(); - let waiting_rows: Vec = waiting - .iter() - .map(|item| WaitingRow { - href: repo_href( - &item.owner, - &item.repo, - if item.is_pull { "pulls" } else { "issues" }, - &item.number.to_string(), - ), - title: item.title.clone(), - repo: format!("{}/{}#{}", item.owner, item.repo, item.number), - dot_class: if matches!(item.reason, forge_core::notifications::Reason::ReviewRequested) { - "corner-dot review" - } else { - "corner-dot mention" - }, - }) - .collect(); + // Each chip leads to the newest thing it counts; a review or mention past the five newest + // waiting items falls back to the inbox. + let newest_waiting = |review: bool| { + waiting + .iter() + .find(|item| { + matches!(item.reason, forge_core::notifications::Reason::ReviewRequested) == review + }) + .map_or_else( + || "/notifications".to_owned(), + |item| { + let section = if item.is_pull { "pulls" } else { "issues" }; + repo_href(&item.owner, &item.repo, section, &item.number.to_string()) + }, + ) + }; + let review_href = newest_waiting(true); + let mention_href = newest_waiting(false); + let failing_href = runs.newest_failing.as_ref().map_or_else( + || "/notifications".to_owned(), + |(owner, repo, number)| repo_href(owner, repo, "ci", &format!("runs/{number}")), + ); let corner = viewer.map(|(user, session)| ProfileCorner { username: user.username.clone(), + name: user + .display_name + .as_deref() + .map(str::trim) + .filter(|n| !n.is_empty()) + .unwrap_or(&user.username) + .to_owned(), avatar: avatar_url(&user.username, user.avatar_hash.as_deref()), csrf: session.csrf_token.clone(), back: back.clone().unwrap_or_else(|| "/".to_owned()), @@ -640,7 +635,9 @@ pub async fn shell( mentions: inbox.mentions, failing: runs.failing, hot, - waiting: waiting_rows, + review_href, + mention_href, + failing_href, }); let corner_panel = corner.clone(); let corner_aside = corner; @@ -788,26 +785,28 @@ pub async fn shell( } } -
- (child) -
+
+
+ (child) +
+
+ "forge" + if anonymous { + + + + + } +
+
- } @@ -1764,6 +1763,7 @@ mod tests { running: vec![run(RunState::Running, 3)], finished: vec![run(RunState::Failure, 2), run(RunState::Cancelled, 1)], failing: 0, + newest_failing: None, }; let strip = live_strip(Lang::En, &many); assert_eq!(strip.runs.len(), 3); @@ -1773,6 +1773,7 @@ mod tests { running: Vec::new(), finished: vec![run(RunState::Cancelled, 1)], failing: 0, + newest_failing: None, }; let one = live_strip(Lang::En, &alone); assert_eq!(one.runs.len(), 1); diff --git a/style/_shell.scss b/style/_shell.scss index 6117ac0..891e29c 100644 --- a/style/_shell.scss +++ b/style/_shell.scss @@ -657,8 +657,8 @@ white-space: nowrap; } -// The avatar inside a ring: a plain border ring when nothing runs, a full ember ring while a run -// of the viewer's is queued or running (.hot), glowing softly. +// The avatar on its own when nothing runs; while a run of the viewer's is queued or running (.hot) +// an accent ring appears around it, glowing softly. .heat-ring { display: grid; flex: none; @@ -666,7 +666,6 @@ width: 34px; height: 34px; border-radius: 50%; - background: var(--border); &.hot { background: conic-gradient(var(--heat-2), var(--heat-3), var(--heat-4), var(--heat-2)); @@ -675,11 +674,16 @@ .avatar { box-sizing: border-box; - width: 28px; - height: 28px; - border: 2px solid var(--bg); + width: 32px; + height: 32px; border-radius: 50%; } + + &.hot .avatar { + width: 30px; + height: 30px; + border: 2px solid var(--bg); + } } .corner-chips { @@ -712,6 +716,37 @@ } } +// A chip is a link to the newest thing it counts. +a.chip { + text-decoration: none; + + &:hover { + text-decoration: none; + filter: brightness(1.15); + } +} + +// The bell at the corner's right end: the inbox. +.corner-bell { + display: grid; + flex: none; + place-items: center; + width: 28px; + height: 28px; + border-radius: var(--radius-md); + color: var(--muted); + + &:hover { + background: color-mix(in srgb, var(--text) 8%, transparent); + color: var(--text); + } + + .ico { + width: 18px; + height: 18px; + } +} + .chip-review { color: var(--important); background: color-mix(in srgb, var(--important) 12%, var(--surface)); @@ -746,77 +781,6 @@ box-shadow: var(--shadow); } -.corner-cap { - margin: 0; - padding: 6px 10px 2px; - font-size: 11.5px; - font-weight: 600; - color: var(--muted); -} - -.corner-waiting { - display: grid; - gap: 2px; - margin: 0; - padding: 0; - list-style: none; - - a { - display: flex; - align-items: flex-start; - gap: 8px; - padding: 6px 10px; - border-radius: var(--radius-md); - color: var(--text); - text-decoration: none; - - &:hover { - background: var(--surface-2); - text-decoration: none; - } - } -} - -.corner-dot { - flex: none; - width: 7px; - height: 7px; - margin-top: 6px; - border-radius: 50%; - background: var(--muted); - - &.review { - background: var(--important); - } - - &.mention { - background: var(--info); - } -} - -.corner-item { - display: flex; - flex-direction: column; - min-width: 0; - - span { - overflow: hidden; - font-size: 13.5px; - line-height: 1.3; - text-overflow: ellipsis; - white-space: nowrap; - } - - small { - overflow: hidden; - font-family: var(--mono); - font-size: 11.5px; - color: var(--muted); - text-overflow: ellipsis; - white-space: nowrap; - } -} - // `button.corner-link` too (Log out): the extra element in the selector outweighs `button.link-button`. .corner-link, button.corner-link.link-button { @@ -841,13 +805,6 @@ button.corner-link.link-button { } } -.corner-rule { - width: auto; - margin: 4px 6px; - border: 0; - border-top: 1px solid var(--border); -} - .corner-theme { display: flex; align-items: center; @@ -899,15 +856,23 @@ button.corner-link.link-button { } } -// Page column and footer +// Page column and footer. The footer sits under the page in the same column, so a short page and +// its footer fit in the viewport the shell fills (no scroll for a footer's height). + +.shell-body { + display: flex; + flex-direction: column; + min-width: 0; +} -.shell > main { +.shell-body > main { + flex: 1 0 auto; box-sizing: border-box; width: 100%; min-width: 0; max-width: 1280px; margin: 0 auto; - padding: 24px 16px 48px; + padding: 24px 16px 24px; } .site-footer { @@ -970,8 +935,8 @@ button.corner-link.link-button { } @media (min-width: 700px) { - .shell > main { - padding: 28px 28px 48px; + .shell-body > main { + padding: 28px 28px 24px; } .site-footer { diff --git a/style/main.scss b/style/main.scss index 3495823..7dd3c7f 100644 --- a/style/main.scss +++ b/style/main.scss @@ -85,13 +85,14 @@ --note: #2B6CB0; --tip: #1D7A62; --important: #6A4BB0; - // Heat: the live strip and the profile ring (0 is the empty track, 4 the hottest). Chips never use the accent. - --heat-0: #ECE7E1; - --heat-1: #F6C9A8; - --heat-2: #EE9A60; - --heat-3: #D4652A; - --heat-4: #9C3A10; - --heat-glow: rgba(220, 100, 30, .35); + // Heat: the live strip and the profile ring (0 is the empty track, 4 the hottest), shades of the + // accent so they follow the chosen colour. Chips never use the accent. + --heat-0: color-mix(in srgb, var(--accent) 10%, var(--surface)); + --heat-1: color-mix(in srgb, var(--accent) 35%, var(--surface)); + --heat-2: color-mix(in srgb, var(--accent) 65%, var(--surface)); + --heat-3: var(--accent); + --heat-4: color-mix(in srgb, var(--accent) 65%, #000); + --heat-glow: color-mix(in srgb, var(--accent) 35%, transparent); --info: #2B6CB0; --warning: #9A6200; --shadow: 0 10px 28px rgba(30, 36, 32, .10); @@ -131,12 +132,12 @@ --note: #8AB4F0; --tip: #7CCBAE; --important: #C4A7FF; - --heat-0: #24211E; - --heat-1: #5A2614; - --heat-2: #9A3A16; - --heat-3: #D9662A; - --heat-4: #FFB066; - --heat-glow: rgba(255, 150, 70, .55); + --heat-0: color-mix(in srgb, var(--accent) 10%, var(--surface)); + --heat-1: color-mix(in srgb, var(--accent) 30%, var(--surface)); + --heat-2: color-mix(in srgb, var(--accent) 60%, var(--surface)); + --heat-3: var(--accent); + --heat-4: color-mix(in srgb, var(--accent) 65%, #fff); + --heat-glow: color-mix(in srgb, var(--accent) 55%, transparent); --info: #8AB4F0; --warning: #E6B765; --shadow: 0 10px 28px rgba(0, 0, 0, .45); @@ -167,12 +168,12 @@ --note: #8AB4F0; --tip: #7CCBAE; --important: #C4A7FF; - --heat-0: #24211E; - --heat-1: #5A2614; - --heat-2: #9A3A16; - --heat-3: #D9662A; - --heat-4: #FFB066; - --heat-glow: rgba(255, 150, 70, .55); + --heat-0: color-mix(in srgb, var(--accent) 10%, var(--surface)); + --heat-1: color-mix(in srgb, var(--accent) 30%, var(--surface)); + --heat-2: color-mix(in srgb, var(--accent) 60%, var(--surface)); + --heat-3: var(--accent); + --heat-4: color-mix(in srgb, var(--accent) 65%, #fff); + --heat-glow: color-mix(in srgb, var(--accent) 55%, transparent); --info: #8AB4F0; --warning: #E6B765; --shadow: 0 10px 28px rgba(0, 0, 0, .45);