forge
Explore
Log in

Don't you dare go Hollow

The signed-in topbar is a path bar and a live strip: the breadcrumb opens the palette in place, filled with the current path, with the repo's files, Tab completion and "/" to open

Browse files at this commit

324720cbc8fd202ed81775b1b67e159aa066f380Ahmet Kaan GümüşParent: b9f184c
Some checks failed
Show checks
  • feat
    • the signed-in topbar is a path bar and a live strip: the breadcrumb opens the palette in place, filled with the current path, with the repo's files, Tab completion and "/" to open
    • the strip shows the viewer's running and just-finished CI runs as pills
    • the profile corner moves to the foot of the sidebar (and the phone menu): a heat ring fills while a run goes, review, mention and failing-run chips replace the bell, and its menu opens on what waits on you, then theme, profile, settings and log out
    • all of it follows /-/activity/stream live
Show full message
✨ feat: the signed-in topbar is a path bar and a live strip: the breadcrumb opens the palette in place, filled with the current path, with the repo's files, Tab completion and "/" to open; the strip shows the viewer's running and just-finished CI runs as pills; the profile corner moves to the foot of the sidebar (and the phone menu): a heat ring fills while a run goes, review, mention and failing-run chips replace the bell, and its menu opens on what waits on you, then theme, profile, settings and log out; all of it follows /-/activity/stream live

16 changed files +1975 -174

crates/forge-core/src/store/mod.rsmodified+1 -0
@@ -39,6 +39,7 @@ pub mod repo_listing;
39 pub mod review_requests;39 pub mod review_requests;
40 pub mod reviews;40 pub mod reviews;
41 pub mod server_settings;41 pub mod server_settings;
42+pub mod shell_activity;
42 pub mod signatures;43 pub mod signatures;
43 pub mod snapshot;44 pub mod snapshot;
44 pub mod snippets;45 pub mod snippets;
crates/forge-core/src/store/notifications.rsmodified+2 -2
@@ -17,14 +17,14 @@ const MAX_NOTIFICATION_PAGE: u32 = 200;
17 /// The condition under which the inbox owner may still read repo `r`: the read rule, or an17 /// The condition under which the inbox owner may still read repo `r`: the read rule, or an
18 /// instance admin. Takes the user id five times. A repo made private, or one the user was removed18 /// instance admin. Takes the user id five times. A repo made private, or one the user was removed
19 /// from, drops out of the inbox, the dashboard and the unread count at once.19 /// from, drops out of the inbox, the dashboard and the unread count at once.
20-fn readable_repo() -> String {20+pub(super) fn readable_repo() -> String {
21 format!(21 format!(
22 "({READABLE_BY_VIEWER} OR EXISTS (SELECT 1 FROM users ua WHERE ua.id = ? AND ua.is_admin = 1))"22 "({READABLE_BY_VIEWER} OR EXISTS (SELECT 1 FROM users ua WHERE ua.id = ? AND ua.is_admin = 1))"
23 )23 )
24 }24 }
25 25
26 /// The user id, bound once per `?` of `readable_repo`.26 /// The user id, bound once per `?` of `readable_repo`.
27-fn readable_params(user_id: &str) -> impl Iterator<Item = Value> + '_ {27+pub(super) fn readable_params(user_id: &str) -> impl Iterator<Item = Value> + '_ {
28 (0..5).map(move |_| Value::Text(user_id.to_string()))28 (0..5).map(move |_| Value::Text(user_id.to_string()))
29 }29 }
30 30
crates/forge-core/src/store/shell_activity.rsadded+362 -0
@@ -0,0 +1,362 @@
1+//! Read-only queries behind the sidebar "profile corner": the signed-in user's inbox counts, the
2+//! items waiting on them, and the state of their own CI runs. Nothing here writes.
3+
4+use std::time::Duration;
5+
6+use turso::{Row, Value};
7+
8+use super::notifications::{readable_params, readable_repo};
9+use super::{Store, col_int, col_opt_text, col_text, fetch_all};
10+use crate::ci::RunState;
11+use crate::error::{Error, Result};
12+use crate::notifications::Reason;
13+use crate::time::stamp_ago;
14+
15+/// Most runs each of `ActorRuns::running` and `ActorRuns::finished` lists.
16+const MAX_ACTOR_RUNS: i64 = 5;
17+
18+/// How far back a failing run still counts toward `ActorRuns::failing`.
19+const FAILING_WINDOW: Duration = Duration::from_secs(7 * 24 * 60 * 60);
20+
21+/// Unread inbox rows of the two kinds the corner shows.
22+#[derive(Debug, Clone, Copy, Default)]
23+pub struct InboxKinds {
24+ /// Unread review requests.
25+ pub reviews: u64,
26+ /// Unread mentions.
27+ pub mentions: u64,
28+}
29+
30+/// An unread inbox row that is waiting on the user, as the corner lists it.
31+#[derive(Debug, Clone)]
32+pub struct WaitingItem {
33+ /// Owner username of the repo.
34+ pub owner: String,
35+ /// Repo name.
36+ pub repo: String,
37+ /// Issue or pull number.
38+ pub number: i64,
39+ /// True when the number is a pull request.
40+ pub is_pull: bool,
41+ /// Title of the issue or pull.
42+ pub title: String,
43+ /// Why the user was notified (`ReviewRequested` or `Mention`).
44+ pub reason: Reason,
45+ /// When the inbox row last changed.
46+ pub updated_at: String,
47+}
48+
49+/// The user's own CI runs, as the corner shows them.
50+#[derive(Debug, Clone)]
51+pub struct ActorRuns {
52+ /// Queued or running runs, newest first, at most 5.
53+ pub running: Vec<ActorRun>,
54+ /// Runs that finished recently, newest first, at most 5.
55+ pub finished: Vec<ActorRun>,
56+ /// Refs whose newest run by this user failed within the last 7 days.
57+ pub failing: u64,
58+}
59+
60+/// One CI run of the user, with its job progress.
61+#[derive(Debug, Clone)]
62+pub struct ActorRun {
63+ /// Owner username of the repo.
64+ pub owner: String,
65+ /// Repo name.
66+ pub repo: String,
67+ /// Run number within the repo.
68+ pub number: i64,
69+ /// Git ref the run ran on.
70+ pub git_ref: String,
71+ /// Current run state.
72+ pub state: RunState,
73+ /// When the run was created.
74+ pub created_at: String,
75+ /// When the run finished, if it has.
76+ pub finished_at: Option<String>,
77+ /// Jobs the run has.
78+ pub jobs_total: u64,
79+ /// Jobs in a final state (success, failure, cancelled, error or skipped).
80+ pub jobs_done: u64,
81+ /// Name of one job that is running now, if any.
82+ pub current_job: Option<String>,
83+}
84+
85+/// Runs one row per run: owner, repo, number, ref, state, times, job counts and a running job.
86+/// The caller appends the WHERE, ORDER BY and LIMIT.
87+const ACTOR_RUN_SELECT: &str = "SELECT o.username, r.name, ci_runs.number, ci_runs.git_ref, \
88+ ci_runs.state, ci_runs.created_at, ci_runs.finished_at, \
89+ (SELECT COUNT(*) FROM ci_jobs j WHERE j.run_id = ci_runs.id), \
90+ (SELECT COUNT(*) FROM ci_jobs j WHERE j.run_id = ci_runs.id \
91+ AND j.state IN ('success', 'failure', 'cancelled', 'error', 'skipped')), \
92+ (SELECT j.name FROM ci_jobs j WHERE j.run_id = ci_runs.id AND j.state = 'running' \
93+ ORDER BY j.name LIMIT 1) \
94+ FROM ci_runs \
95+ JOIN repos r ON r.id = ci_runs.repo_id \
96+ JOIN users o ON o.id = r.owner_id";
97+
98+/// A count column as `u64`. Counts are never negative, so a negative value is a database error.
99+fn count_from(n: i64) -> Result<u64> {
100+ u64::try_from(n).map_err(|_| Error::Database("negative count".into()))
101+}
102+
103+/// Maps a row of `ACTOR_RUN_SELECT`.
104+fn map_actor_run(row: &Row) -> Result<ActorRun> {
105+ Ok(ActorRun {
106+ owner: col_text(row, 0)?,
107+ repo: col_text(row, 1)?,
108+ number: col_int(row, 2)?,
109+ git_ref: col_text(row, 3)?,
110+ state: col_text(row, 4)?.parse::<RunState>()?,
111+ created_at: col_text(row, 5)?,
112+ finished_at: col_opt_text(row, 6)?,
113+ jobs_total: count_from(col_int(row, 7)?)?,
114+ jobs_done: count_from(col_int(row, 8)?)?,
115+ current_job: col_opt_text(row, 9)?,
116+ })
117+}
118+
119+impl Store {
120+ /// Unread review requests and mentions in the user's inbox, in repos the user can still read.
121+ pub async fn inbox_kind_counts(&self, user_id: &str) -> Result<InboxKinds> {
122+ let readable = readable_repo();
123+ let sql = format!(
124+ "SELECT n.reason, COUNT(*) FROM notifications n JOIN repos r ON r.id = n.repo_id \
125+ WHERE n.user_id = ? AND n.unread = 1 \
126+ AND n.reason IN ('review_requested', 'mention') AND {readable} \
127+ GROUP BY n.reason"
128+ );
129+ let mut params = vec![Value::Text(user_id.to_string())];
130+ params.extend(readable_params(user_id));
131+ let conn = self.read_conn().await;
132+ let rows = fetch_all(&conn, &sql, params, |row| {
133+ Ok((col_text(row, 0)?, col_int(row, 1)?))
134+ })
135+ .await?;
136+ let mut kinds = InboxKinds::default();
137+ for (reason, n) in rows {
138+ match reason.as_str() {
139+ "review_requested" => kinds.reviews = count_from(n)?,
140+ "mention" => kinds.mentions = count_from(n)?,
141+ _ => {}
142+ }
143+ }
144+ Ok(kinds)
145+ }
146+
147+ /// The user's newest unread review requests and mentions, newest first, at most `limit`.
148+ pub async fn waiting_on(&self, user_id: &str, limit: u64) -> Result<Vec<WaitingItem>> {
149+ let readable = readable_repo();
150+ let sql = format!(
151+ "SELECT o.username, r.name, i.number, i.kind, i.title, n.reason, n.updated_at \
152+ FROM notifications n \
153+ JOIN repos r ON r.id = n.repo_id \
154+ JOIN users o ON o.id = r.owner_id \
155+ JOIN issues i ON i.id = n.issue_id \
156+ WHERE n.user_id = ? AND n.unread = 1 \
157+ AND n.reason IN ('review_requested', 'mention') AND {readable} \
158+ ORDER BY n.updated_at DESC, n.id DESC LIMIT ?"
159+ );
160+ let mut params = vec![Value::Text(user_id.to_string())];
161+ params.extend(readable_params(user_id));
162+ params.push(Value::Integer(i64::try_from(limit).unwrap_or(i64::MAX)));
163+ let conn = self.read_conn().await;
164+ fetch_all(&conn, &sql, params, |row| {
165+ let reason_text = col_text(row, 5)?;
166+ let reason = Reason::parse(&reason_text).ok_or_else(|| {
167+ Error::Database(format!("unknown notification reason {reason_text:?}"))
168+ })?;
169+ Ok(WaitingItem {
170+ owner: col_text(row, 0)?,
171+ repo: col_text(row, 1)?,
172+ number: col_int(row, 2)?,
173+ is_pull: col_text(row, 3)? == "pull",
174+ title: col_text(row, 4)?,
175+ reason,
176+ updated_at: col_text(row, 6)?,
177+ })
178+ })
179+ .await
180+ }
181+
182+ /// The user's own CI runs: those still queued or running, those that finished within the last
183+ /// `recent_secs` seconds, and how many refs are failing on their newest run.
184+ pub async fn actor_runs(&self, actor_id: &str, recent_secs: i64) -> Result<ActorRuns> {
185+ // Every query binds the viewer's readable-repo filter, so a run in a repo the actor can no
186+ // longer read is left out. The placeholders are all plain `?`, bound in SQL order.
187+ let readable = readable_repo();
188+ let conn = self.read_conn().await;
189+ let mut params = vec![Value::Text(actor_id.to_string())];
190+ params.extend(readable_params(actor_id));
191+ params.push(Value::Integer(MAX_ACTOR_RUNS));
192+ let running = fetch_all(
193+ &conn,
194+ &format!(
195+ "{ACTOR_RUN_SELECT} WHERE ci_runs.actor_id = ? \
196+ AND ci_runs.state IN ('queued', 'running') AND {readable} \
197+ ORDER BY ci_runs.created_at DESC, ci_runs.id DESC LIMIT ?"
198+ ),
199+ params,
200+ map_actor_run,
201+ )
202+ .await?;
203+
204+ let recent = Duration::from_secs(u64::try_from(recent_secs).unwrap_or(0));
205+ let mut params = vec![
206+ Value::Text(actor_id.to_string()),
207+ Value::Text(stamp_ago(recent)),
208+ ];
209+ params.extend(readable_params(actor_id));
210+ params.push(Value::Integer(MAX_ACTOR_RUNS));
211+ let finished = fetch_all(
212+ &conn,
213+ &format!(
214+ "{ACTOR_RUN_SELECT} WHERE ci_runs.actor_id = ? \
215+ AND ci_runs.finished_at >= ? AND {readable} \
216+ ORDER BY ci_runs.finished_at DESC, ci_runs.id DESC LIMIT ?"
217+ ),
218+ params,
219+ map_actor_run,
220+ )
221+ .await?;
222+
223+ // Newest run per (repo, ref) among this actor's runs, then count the ones that failed.
224+ let mut params = vec![Value::Text(actor_id.to_string())];
225+ params.extend(readable_params(actor_id));
226+ params.push(Value::Text(stamp_ago(FAILING_WINDOW)));
227+ let failing = fetch_all(
228+ &conn,
229+ &format!(
230+ "SELECT COUNT(*) FROM ( \
231+ SELECT ci_runs.state, ci_runs.created_at, ROW_NUMBER() OVER ( \
232+ PARTITION BY ci_runs.repo_id, ci_runs.git_ref ORDER BY ci_runs.number DESC) AS rn \
233+ FROM ci_runs JOIN repos r ON r.id = ci_runs.repo_id \
234+ WHERE ci_runs.actor_id = ? AND {readable} \
235+ ) WHERE rn = 1 AND state IN ('failure', 'error') AND created_at >= ?"
236+ ),
237+ params,
238+ |row| col_int(row, 0),
239+ )
240+ .await?;
241+ let failing = match failing.first() {
242+ Some(n) => count_from(*n)?,
243+ None => 0,
244+ };
245+
246+ Ok(ActorRuns {
247+ running,
248+ finished,
249+ failing,
250+ })
251+ }
252+}
253+
254+#[cfg(test)]
255+mod tests {
256+ use super::*;
257+ use crate::model::Visibility;
258+ use crate::time::now_stamp;
259+
260+ /// Inserts one CI run row directly, with the columns the queries read.
261+ #[allow(clippy::too_many_arguments)]
262+ async fn insert_run(
263+ store: &Store,
264+ id: &str,
265+ repo_id: &str,
266+ number: i64,
267+ git_ref: &str,
268+ actor_id: &str,
269+ state: &str,
270+ created_at: &str,
271+ ) {
272+ store
273+ .inner
274+ .conn
275+ .lock()
276+ .await
277+ .execute(
278+ "INSERT INTO ci_runs (id, repo_id, number, trigger, git_ref, commit_oid, actor_id, \
279+ state, created_at) VALUES (?1, ?2, ?3, 'push', ?4, 'abc123', ?5, ?6, ?7)",
280+ vec![
281+ Value::Text(id.to_string()),
282+ Value::Text(repo_id.to_string()),
283+ Value::Integer(number),
284+ Value::Text(git_ref.to_string()),
285+ Value::Text(actor_id.to_string()),
286+ Value::Text(state.to_string()),
287+ Value::Text(created_at.to_string()),
288+ ],
289+ )
290+ .await
291+ .unwrap();
292+ }
293+
294+ /// Inserts one CI job row of a run.
295+ async fn insert_job(store: &Store, id: &str, run_id: &str, name: &str, state: &str) {
296+ store
297+ .inner
298+ .conn
299+ .lock()
300+ .await
301+ .execute(
302+ "INSERT INTO ci_jobs (id, run_id, name, spec, state) VALUES (?1, ?2, ?3, '{}', ?4)",
303+ vec![
304+ Value::Text(id.to_string()),
305+ Value::Text(run_id.to_string()),
306+ Value::Text(name.to_string()),
307+ Value::Text(state.to_string()),
308+ ],
309+ )
310+ .await
311+ .unwrap();
312+ }
313+
314+ #[tokio::test]
315+ async fn actor_runs_show_running_run_and_failing_ref() {
316+ let dir = tempfile::tempdir().unwrap();
317+ let store = Store::open(&dir.path().join("forge.db")).await.unwrap();
318+ let user = store
319+ .create_user("Tahinli", None, "hash", false)
320+ .await
321+ .unwrap();
322+ let repo = store
323+ .create_repo(&user.id, "proj", "", Visibility::Public, "main")
324+ .await
325+ .unwrap();
326+ let hour_ago = stamp_ago(Duration::from_secs(3600));
327+ // A failed run on dev an hour ago, and a running run on main with one job going.
328+ insert_run(
329+ &store,
330+ "run1",
331+ &repo.id,
332+ 1,
333+ "refs/heads/dev",
334+ &user.id,
335+ "failure",
336+ &hour_ago,
337+ )
338+ .await;
339+ insert_run(
340+ &store,
341+ "run2",
342+ &repo.id,
343+ 2,
344+ "refs/heads/main",
345+ &user.id,
346+ "running",
347+ &now_stamp(),
348+ )
349+ .await;
350+ insert_job(&store, "job1", "run2", "build", "running").await;
351+ insert_job(&store, "job2", "run2", "lint", "success").await;
352+
353+ let runs = store.actor_runs(&user.id, 3600).await.unwrap();
354+ assert_eq!(runs.running.len(), 1);
355+ let running = &runs.running[0];
356+ assert_eq!(running.number, 2);
357+ assert_eq!(running.jobs_total, 2);
358+ assert_eq!(running.jobs_done, 1);
359+ assert_eq!(running.current_job.as_deref(), Some("build"));
360+ assert_eq!(runs.failing, 1);
361+ }
362+}
crates/forge-web/assets/nav.jsmodified+351 -32
@@ -168,7 +168,15 @@
168 syncStyles(doc);168 syncStyles(doc);
169 var kept = keepFields ? captureFields() : null;169 var kept = keepFields ? captureFields() : null;
170 var nodes = Array.prototype.map.call(doc.body.childNodes, function (n) { return document.importNode(n, true); });170 var nodes = Array.prototype.map.call(doc.body.childNodes, function (n) { return document.importNode(n, true); });
171- document.body.replaceChildren.apply(document.body, nodes);171+ // A live change must not shut the palette the reader is typing in. Taking an open modal dialog out
172+ // of the page closes it for good, so everything else is replaced around it.
173+ var palOpen = dd ? document.querySelector('body > dialog.palette[open]') : null;
174+ if (palOpen) {
175+ Array.prototype.slice.call(document.body.childNodes).forEach(function (n) { if (n !== palOpen) { n.remove(); } });
176+ nodes.forEach(function (n) { document.body.insertBefore(n, palOpen); });
177+ } else {
178+ document.body.replaceChildren.apply(document.body, nodes);
179+ }
172 // Re-create scripts so they run (a parsed-in script does not). The guard above keeps this file180 // Re-create scripts so they run (a parsed-in script does not). The guard above keeps this file
173 // from starting twice.181 // from starting twice.
174 document.body.querySelectorAll('script').forEach(function (old) {182 document.body.querySelectorAll('script').forEach(function (old) {
@@ -185,6 +193,7 @@
185 followTail();193 followTail();
186 restoreJobs(jobs);194 restoreJobs(jobs);
187 syncUnread();195 syncUnread();
196+ syncActivity();
188 syncLive();197 syncLive();
189 syncPush();198 syncPush();
190 syncTick();199 syncTick();
@@ -613,13 +622,14 @@
613 }622 }
614 623
615 // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone624 // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone
616- // popover, phone menu). Inline disclosures are not listed: a click outside leaves them open.625+ // popover, phone menu, profile corner). Inline disclosures are not listed: a click outside leaves them open.
617- var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle';626+ var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle, details.corner';
618 627
619- // Closes every open dropdown except `keep` (pass null to close them all).628+ // Closes every open dropdown that does not contain `from` (pass null to close them all). The corner
620- function closeDropdowns(keep) {629+ // sits inside the phone menu, so a click in the corner keeps the phone menu open too.
630+ function closeDropdowns(from) {
621 document.querySelectorAll(DROPDOWN).forEach(function (d) {631 document.querySelectorAll(DROPDOWN).forEach(function (d) {
622- if (d.open && d !== keep) { d.open = false; }632+ if (d.open && !(from && d.contains(from))) { d.open = false; }
623 });633 });
624 }634 }
625 635
@@ -672,8 +682,7 @@
672 // A click outside an open dropdown closes it. A click inside one (a select, a form field) keeps682 // A click outside an open dropdown closes it. A click inside one (a select, a form field) keeps
673 // it open. Opening a dropdown by its summary closes the others: the browser toggles it after this.683 // it open. Opening a dropdown by its summary closes the others: the browser toggles it after this.
674 document.addEventListener('click', function (e) {684 document.addEventListener('click', function (e) {
675- var inside = e.target && e.target.closest ? e.target.closest(DROPDOWN) : null;685+ closeDropdowns(e.target && e.target.nodeType === 1 ? e.target : null);
676- closeDropdowns(inside);
677 }, false);686 }, false);
678 687
679 // Escape closes the open dropdowns and returns focus to the summary of the one that held it.688 // Escape closes the open dropdowns and returns focus to the summary of the one that held it.
@@ -1223,14 +1232,14 @@
1223 1232
1224 // A filtered view asked for in place: the URL is replaced (no history entry per change), fields1233 // A filtered view asked for in place: the URL is replaced (no history entry per change), fields
1225 // and caret come through the swap, and the scroll stays put.1234 // and caret come through the swap, and the scroll stays put.
1226- // Live unread count. The bell is re-rendered by every swap, so it is looked up on each update. One1235+ // Live unread count. The profile corner (data-unread-stream) is re-rendered by every swap, so it is
1227- // EventSource serves the page and stays open across swaps. It is opened only while a bell is shown1236+ // looked up on each update. One EventSource serves the page and stays open across swaps. It is
1228- // (signed-in pages) and closed when the bell is gone. The server pushes each change; nothing polls.1237+ // opened only while a corner is shown (signed-in pages) and closed when it is gone. The server
1229- // The count shows twice: on the bell, and next to Notifications in the sidebar and the phone menu.1238+ // pushes each change; nothing polls. Each `unread` event also tells the activity stream below to
1239+ // refresh. The count shows twice: as a dot on the menu toggle (has-dot), and next to Notifications
1240+ // in the sidebar and the phone menu.
1230 var unreadStream = null;1241 var unreadStream = null;
1231 1242
1232- function bell() { return document.querySelector('a.bell'); }
1233-
1234 // Shows the count in one link the way the server renders it: a span with the number, or no span at zero.1243 // Shows the count in one link the way the server renders it: a span with the number, or no span at zero.
1235 function setCount(el, cls, n) {1244 function setCount(el, cls, n) {
1236 var badge = el.querySelector('.' + cls);1245 var badge = el.querySelector('.' + cls);
@@ -1247,15 +1256,16 @@
1247 }1256 }
1248 1257
1249 function setUnread(n) {1258 function setUnread(n) {
1250- var el = bell();1259+ // The menu toggle carries a dot while anything is unread.
1251- if (el) { setCount(el, 'bell-count', n); }1260+ var toggles = document.querySelectorAll('details.nav-toggle > summary');
1261+ for (var t = 0; t < toggles.length; t++) { toggles[t].classList.toggle('has-dot', n > 0); }
1252 // The sidebar's Notifications link (the sidebar and the phone menu hold one each), `.count` as the server renders it.1262 // The sidebar's Notifications link (the sidebar and the phone menu hold one each), `.count` as the server renders it.
1253 var links = document.querySelectorAll('nav.side-links a[href="/notifications"]');1263 var links = document.querySelectorAll('nav.side-links a[href="/notifications"]');
1254 for (var i = 0; i < links.length; i++) { setCount(links[i], 'count', n); }1264 for (var i = 0; i < links.length; i++) { setCount(links[i], 'count', n); }
1255 }1265 }
1256 1266
1257 function syncUnread() {1267 function syncUnread() {
1258- if (!bell()) {1268+ if (!document.querySelector('[data-unread-stream]')) {
1259 if (unreadStream) { unreadStream.close(); unreadStream = null; }1269 if (unreadStream) { unreadStream.close(); unreadStream = null; }
1260 return;1270 return;
1261 }1271 }
@@ -1263,11 +1273,208 @@
1263 unreadStream = new EventSource('/notifications/stream');1273 unreadStream = new EventSource('/notifications/stream');
1264 unreadStream.addEventListener('unread', function (e) {1274 unreadStream.addEventListener('unread', function (e) {
1265 setUnread(parseInt(e.data, 10) || 0);1275 setUnread(parseInt(e.data, 10) || 0);
1276+ refreshActivity();
1266 });1277 });
1267 }1278 }
1268 1279
1269 syncUnread();1280 syncUnread();
1270 1281
1282+ // The live activity: the profile corner (heat ring, chips, waiting list) and the live strip after
1283+ // the path bar. The server's activity JSON (GET /-/activity) is the source. A `changed` event of
1284+ // its stream, and every `unread` event above, fetches it again and redraws whatever is on the page.
1285+ // Nothing changes before the JSON says so. The stream stays open across swaps while a strip is
1286+ // shown, as the unread one does. A finished run leaves the strip when the server's window ends, so
1287+ // while any is listed the JSON is fetched again every 30 s.
1288+ var activityStream = null;
1289+ var activitySeq = 0; // a fetch's number: only the newest answer is drawn
1290+ var activityTimer = null; // the next refetch while finished runs are listed
1291+ var SVG_NS = 'http://www.w3.org/2000/svg';
1292+ // The icons the server draws in the chips, as [element, attributes] pairs.
1293+ var CHIP_ICONS = {
1294+ review: [['path', { d: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z' }], ['circle', { cx: '12', cy: '12', r: '3' }]],
1295+ mention: [['circle', { cx: '12', cy: '12', r: '4' }], ['path', { d: 'M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94' }]],
1296+ failing: [['path', { d: 'M6 6l12 12M18 6 6 18' }]]
1297+ };
1298+
1299+ // An icon element built from CHIP_ICONS, the same markup the server writes.
1300+ function chipIcon(kind) {
1301+ var svg = document.createElementNS(SVG_NS, 'svg');
1302+ svg.setAttribute('class', 'ico');
1303+ svg.setAttribute('viewBox', '0 0 24 24');
1304+ svg.setAttribute('aria-hidden', 'true');
1305+ CHIP_ICONS[kind].forEach(function (part) {
1306+ var el = document.createElementNS(SVG_NS, part[0]);
1307+ Object.keys(part[1]).forEach(function (k) { el.setAttribute(k, part[1][k]); });
1308+ svg.appendChild(el);
1309+ });
1310+ return svg;
1311+ }
1312+
1313+ // A link target from the server, used only when it is a path on this site.
1314+ function localHref(href) {
1315+ return typeof href === 'string' && href.charAt(0) === '/' && href.charAt(1) !== '/' ? href : '';
1316+ }
1317+
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 = [];
1322+ (json.running || []).forEach(function (run) {
1323+ pills.push({ cls: 'pill hot', run: run, text: run.job ? ' ' + run.job : '' });
1324+ });
1325+ (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 || '') });
1328+ });
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));
1335+ var dot = document.createElement('span');
1336+ 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);
1349+ }
1350+ }
1351+
1352+ // The heat ring: lit while a run is going, filled to the newest run's share of its jobs (at least 8%).
1353+ 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));
1365+ }
1366+
1367+ // The chips: one per non-zero count. The titles come from the chip box's templates, with `{n}`
1368+ // standing for the count; the singular template is used for one.
1369+ function drawChips(box, json) {
1370+ var chips = [
1371+ { kind: 'review', cls: 'chip chip-review', n: json.reviews, tpl: 'data-review' },
1372+ { kind: 'mention', cls: 'chip chip-mention', n: json.mentions, tpl: 'data-mention' },
1373+ { kind: 'failing', cls: 'chip chip-failing', n: json.failing, tpl: 'data-failing' }
1374+ ];
1375+ box.textContent = '';
1376+ chips.forEach(function (c) {
1377+ var n = Number(c.n) || 0;
1378+ if (n <= 0) { return; }
1379+ var tpl = box.getAttribute(c.tpl + (n === 1 ? '-one' : '')) || '';
1380+ var chip = document.createElement('span');
1381+ chip.className = c.cls;
1382+ chip.setAttribute('title', tpl.split('{n}').join(String(n)));
1383+ chip.appendChild(chipIcon(c.kind));
1384+ chip.appendChild(document.createTextNode(String(n)));
1385+ box.appendChild(chip);
1386+ });
1387+ }
1388+
1389+ // The waiting list and its caption: built from the server's items, and removed when there are none.
1390+ // They sit before the menu's first link (All notifications).
1391+ function drawWaiting(menu, waiting) {
1392+ var cap = menu.querySelector('.corner-cap');
1393+ var list = menu.querySelector('.corner-waiting');
1394+ if (!waiting.length) {
1395+ if (cap) { cap.remove(); }
1396+ if (list) { list.remove(); }
1397+ return;
1398+ }
1399+ var anchor = menu.querySelector('.corner-link');
1400+ if (!cap) {
1401+ cap = document.createElement('p');
1402+ cap.className = 'corner-cap';
1403+ cap.textContent = menu.getAttribute('data-cap') || '';
1404+ menu.insertBefore(cap, anchor);
1405+ }
1406+ if (!list) {
1407+ list = document.createElement('ul');
1408+ list.className = 'corner-waiting';
1409+ menu.insertBefore(list, anchor);
1410+ }
1411+ list.textContent = '';
1412+ waiting.forEach(function (item) {
1413+ var li = document.createElement('li');
1414+ var a = document.createElement('a');
1415+ a.setAttribute('href', localHref(item.href));
1416+ var dot = document.createElement('span');
1417+ dot.className = 'corner-dot ' + (item.kind === 'review' ? 'review' : 'mention');
1418+ var text = document.createElement('span');
1419+ text.className = 'corner-item';
1420+ var title = document.createElement('span');
1421+ title.textContent = String(item.title || '');
1422+ var where = document.createElement('small');
1423+ where.textContent = String(item.where || '');
1424+ text.appendChild(title);
1425+ text.appendChild(where);
1426+ a.appendChild(dot);
1427+ a.appendChild(text);
1428+ li.appendChild(a);
1429+ list.appendChild(li);
1430+ });
1431+ }
1432+
1433+ // Redraws every strip, ring, chip box and waiting menu on the page from one activity JSON. The
1434+ // elements are looked up here each time, since a swap may have replaced them.
1435+ function drawActivity(json) {
1436+ var strips = document.querySelectorAll('.live-strip[data-activity]');
1437+ for (var i = 0; i < strips.length; i++) { drawStrip(strips[i], json); }
1438+ var running = json.running || [];
1439+ var rings = document.querySelectorAll('.heat-ring');
1440+ for (var r = 0; r < rings.length; r++) { drawRing(rings[r], running); }
1441+ var boxes = document.querySelectorAll('.corner-chips');
1442+ for (var b = 0; b < boxes.length; b++) { drawChips(boxes[b], json); }
1443+ var menus = document.querySelectorAll('.corner-menu');
1444+ for (var m = 0; m < menus.length; m++) { drawWaiting(menus[m], json.waiting || []); }
1445+ // Finished runs leave the strip when the server's window ends, so the JSON is asked for again.
1446+ clearTimeout(activityTimer);
1447+ activityTimer = null;
1448+ if (json.finished && json.finished.length) { activityTimer = setTimeout(refreshActivity, 30000); }
1449+ }
1450+
1451+ // Fetches the activity JSON and draws it. Only the newest answer is drawn. A failed fetch leaves
1452+ // the page as it is.
1453+ function refreshActivity() {
1454+ if (!document.querySelector('.live-strip[data-activity]')) { return; }
1455+ var seq = ++activitySeq;
1456+ fetch('/-/activity', { headers: { accept: 'application/json' }, credentials: 'same-origin' }).then(function (r) {
1457+ if (!r.ok) { throw new Error('status ' + r.status); }
1458+ return r.json();
1459+ }).then(function (json) {
1460+ if (seq === activitySeq) { drawActivity(json); }
1461+ }).catch(function () { });
1462+ }
1463+
1464+ // One EventSource serves the page's strip and stays open across swaps. It is opened only while a
1465+ // strip is shown and closed when it is gone.
1466+ function syncActivity() {
1467+ if (!document.querySelector('.live-strip[data-activity]')) {
1468+ if (activityStream) { activityStream.close(); activityStream = null; }
1469+ return;
1470+ }
1471+ if (activityStream || !window.EventSource) { return; }
1472+ activityStream = new EventSource('/-/activity/stream');
1473+ activityStream.addEventListener('changed', function () { refreshActivity(); });
1474+ }
1475+
1476+ syncActivity();
1477+
1271 // The CI log (a job page's [data-live-log]). The server sends the raw text; this turns it into1478 // The CI log (a job page's [data-live-log]). The server sends the raw text; this turns it into
1272 // numbered lines (#L12 anchors) with ANSI colours as spans, `::group::name` / `::endgroup::`1479 // numbered lines (#L12 anchors) with ANSI colours as spans, `::group::name` / `::endgroup::`
1273 // sections as <details>, and a search box with highlight and next/previous. Streamed bytes go1480 // sections as <details>, and a search box with highlight and next/previous. Streamed bytes go
@@ -2507,8 +2714,10 @@
2507 var PALETTE_TTL = 60000; // ms a fetched list stays fresh2714 var PALETTE_TTL = 60000; // ms a fetched list stays fresh
2508 var PALETTE_MAX = 50; // options shown at once2715 var PALETTE_MAX = 50; // options shown at once
2509 var PALETTE_WORD = /[\s\/._\-·]/; // a character that starts a word, for the word-start match2716 var PALETTE_WORD = /[\s\/._\-·]/; // a character that starts a word, for the word-start match
2717+ // files: the current repo's file items, once its finder list is loaded (filesSrc names the finder
2718+ // it came from); filesBusy names the source being fetched.
2510 var pal = { dlg: null, input: null, list: null, note: null, hits: [], sel: 0, str: null,2719 var pal = { dlg: null, input: null, list: null, note: null, hits: [], sel: 0, str: null,
2511- data: null, request: null, failed: false };2720+ data: null, request: null, failed: false, files: null, filesSrc: '', filesBusy: null };
2512 2721
2513 // The words the palette shows, read from the topbar button: the server writes them in the viewer's2722 // The words the palette shows, read from the topbar button: the server writes them in the viewer's
2514 // language, so this script carries no text of its own.2723 // language, so this script carries no text of its own.
@@ -2521,7 +2730,8 @@
2521 empty: word('empty'),2730 empty: word('empty'),
2522 loading: word('loading'),2731 loading: word('loading'),
2523 failed: word('failed'),2732 failed: word('failed'),
2524- heads: { repo: word('repos'), org: word('orgs'), page: word('pages') }2733+ search: word('search-label'),
2734+ heads: { repo: word('repos'), org: word('orgs'), page: word('pages'), file: word('files') }
2525 };2735 };
2526 }2736 }
2527 2737
@@ -2564,6 +2774,42 @@
2564 return pal.data ? items.concat(pal.data.items) : items;2774 return pal.data ? items.concat(pal.data.items) : items;
2565 }2775 }
2566 2776
2777+ // The current repo's files, offered once the query starts with its "owner/repo/". The list is the
2778+ // file finder's own (the same fetch and cache), read on first need. Nothing is fetched before then.
2779+ function paletteFiles(q) {
2780+ var dlg = document.querySelector('dialog[data-finder]');
2781+ if (!dlg || !window.__forgeFinder) { return []; }
2782+ var src = dlg.getAttribute('data-src') || '';
2783+ var parts = src.split('/');
2784+ if (parts.length < 3 || !parts[1] || !parts[2]) { return []; }
2785+ var repo = parts[1] + '/' + parts[2];
2786+ if (q.indexOf(repo.toLowerCase() + '/') !== 0) { return []; }
2787+ if (pal.filesSrc !== src) { pal.filesSrc = src; pal.files = null; }
2788+ if (!pal.files && pal.filesBusy !== src) {
2789+ pal.filesBusy = src;
2790+ var sync = true;
2791+ window.__forgeFinder.list(dlg, function (data) {
2792+ if (pal.filesSrc !== src) { return; }
2793+ pal.filesBusy = null;
2794+ if (!data) { return; }
2795+ pal.files = data.paths.map(function (path) {
2796+ return { label: repo + '/' + path, href: window.__forgeFinder.href(dlg, path), kind: 'file' };
2797+ });
2798+ if (!sync && pal.dlg.open) { renderPalette(); }
2799+ });
2800+ sync = false;
2801+ }
2802+ return pal.files || [];
2803+ }
2804+
2805+ // The text a completed item leaves in the input: a tab's label is its repo, and a repo gets a "/".
2806+ function paletteCompletion(item) {
2807+ var label = item.label;
2808+ var at = label.indexOf(' \u00b7 ');
2809+ if (at >= 0) { label = label.slice(0, at); }
2810+ return label + (item.kind === 'repo' ? '/' : '');
2811+ }
2812+
2567 function paletteSelect(index) {2813 function paletteSelect(index) {
2568 var opts = pal.list.querySelectorAll('li[role="option"]');2814 var opts = pal.list.querySelectorAll('li[role="option"]');
2569 if (!opts.length) { pal.input.removeAttribute('aria-activedescendant'); return; }2815 if (!opts.length) { pal.input.removeAttribute('aria-activedescendant'); return; }
@@ -2578,11 +2824,14 @@
2578 // Filters and draws the list. Groups keep the order of their best match, so a page named exactly2824 // Filters and draws the list. Groups keep the order of their best match, so a page named exactly
2579 // like the query leads; with no query, the order is tabs, repos, orgs, then pages.2825 // like the query leads; with no query, the order is tabs, repos, orgs, then pages.
2580 function renderPalette() {2826 function renderPalette() {
2581- var q = pal.input.value.trim().toLowerCase();2827+ var raw = pal.input.value.trim();
2828+ var q = raw.toLowerCase();
2829+ // With a "/" the query is a path: an item matches when its label starts with it.
2830+ var pathMode = q.indexOf('/') >= 0;
2582 var scored = [];2831 var scored = [];
2583- paletteItems().forEach(function (item, idx) {2832+ paletteItems().concat(paletteFiles(q)).forEach(function (item, idx) {
2584 if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; }2833 if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; }
2585- var s = paletteScore(q, item.label);2834+ var s = pathMode ? (item.label.toLowerCase().indexOf(q) === 0 ? 3 : 0) : paletteScore(q, item.label);
2586 if (s > 0) { scored.push({ item: item, score: s, idx: idx }); }2835 if (s > 0) { scored.push({ item: item, score: s, idx: idx }); }
2587 });2836 });
2588 scored.sort(function (a, b) { return b.score - a.score || a.idx - b.idx; });2837 scored.sort(function (a, b) { return b.score - a.score || a.idx - b.idx; });
@@ -2593,14 +2842,21 @@
2593 if (!groups[kind]) { groups[kind] = []; kinds.push(kind); }2842 if (!groups[kind]) { groups[kind] = []; kinds.push(kind); }
2594 groups[kind].push(h.item);2843 groups[kind].push(h.item);
2595 });2844 });
2845+ // A plain query (no "/") ends with a search option, under no heading.
2846+ if (raw && !pathMode) {
2847+ kinds.push('search');
2848+ groups.search = [{ label: pal.str.search + ' \u201c' + raw + '\u201d', href: '/explore?q=' + encodeURIComponent(raw), kind: 'search' }];
2849+ }
2596 pal.list.textContent = '';2850 pal.list.textContent = '';
2597 pal.hits = [];2851 pal.hits = [];
2598 kinds.forEach(function (kind) {2852 kinds.forEach(function (kind) {
2599- var head = document.createElement('li');2853+ if (kind !== 'search') {
2600- head.className = 'palette-head';2854+ var head = document.createElement('li');
2601- head.setAttribute('role', 'presentation');2855+ head.className = 'palette-head';
2602- head.textContent = pal.str.heads[kind];2856+ head.setAttribute('role', 'presentation');
2603- pal.list.appendChild(head);2857+ head.textContent = pal.str.heads[kind];
2858+ pal.list.appendChild(head);
2859+ }
2604 groups[kind].forEach(function (item) {2860 groups[kind].forEach(function (item) {
2605 var n = pal.hits.length;2861 var n = pal.hits.length;
2606 pal.hits.push(item);2862 pal.hits.push(item);
@@ -2672,6 +2928,18 @@
2672 if (e.key === 'ArrowDown') { e.preventDefault(); paletteSelect(pal.sel + 1); }2928 if (e.key === 'ArrowDown') { e.preventDefault(); paletteSelect(pal.sel + 1); }
2673 else if (e.key === 'ArrowUp') { e.preventDefault(); paletteSelect(pal.sel - 1); }2929 else if (e.key === 'ArrowUp') { e.preventDefault(); paletteSelect(pal.sel - 1); }
2674 else if (e.key === 'Enter') { e.preventDefault(); if (pal.hits[pal.sel]) { paletteGo(pal.hits[pal.sel].href); } }2930 else if (e.key === 'Enter') { e.preventDefault(); if (pal.hits[pal.sel]) { paletteGo(pal.hits[pal.sel].href); } }
2931+ // Tab completes the input to the selected item; Ctrl or Alt with Backspace drops the last path segment.
2932+ else if (e.key === 'Tab') {
2933+ e.preventDefault();
2934+ var item = pal.hits[pal.sel];
2935+ if (item && item.kind !== 'search') { pal.input.value = paletteCompletion(item); renderPalette(); }
2936+ }
2937+ else if (e.key === 'Backspace' && (e.ctrlKey || e.altKey)) {
2938+ e.preventDefault();
2939+ // Like a shell: "owner/repo/" goes back to "owner/", and "owner/repo/RE" to "owner/repo/".
2940+ pal.input.value = pal.input.value.replace(/\/+$/, '').replace(/[^\/]*$/, '');
2941+ renderPalette();
2942+ }
2675 });2943 });
2676 // Hover selects; the check keeps a row that is already selected from being touched again.2944 // Hover selects; the check keeps a row that is already selected from being touched again.
2677 pal.list.addEventListener('mousemove', function (e) {2945 pal.list.addEventListener('mousemove', function (e) {
@@ -2698,14 +2966,38 @@
2698 dlg.setAttribute('aria-label', pal.str.label);2966 dlg.setAttribute('aria-label', pal.str.label);
2699 pal.input.placeholder = pal.str.placeholder;2967 pal.input.placeholder = pal.str.placeholder;
2700 pal.input.setAttribute('aria-label', pal.str.placeholder);2968 pal.input.setAttribute('aria-label', pal.str.placeholder);
2969+ // Over the path bar when there is one: the dialog's top and left edges sit at the bar's, and it is
2970+ // at least 360px wide (never wider than the viewport).
2971+ var bar = document.querySelector('.pathbar');
2972+ if (bar) { anchorPalette(dlg, bar.getBoundingClientRect()); } else { unanchorPalette(dlg); }
2701 if (typeof dlg.showModal !== 'function') { return; }2973 if (typeof dlg.showModal !== 'function') { return; }
2702 dlg.showModal();2974 dlg.showModal();
2703- pal.input.value = '';2975+ // The path bar's path comes in as a prefix when it has owner and repo, ready to narrow down.
2976+ var path = (opener.getAttribute('data-path') || '').replace(/\/+$/, '');
2977+ var prefill = path.split('/').filter(Boolean).length >= 2 ? path + '/' : '';
2978+ pal.input.value = prefill;
2704 renderPalette();2979 renderPalette();
2705 pal.input.focus();2980 pal.input.focus();
2981+ pal.input.setSelectionRange(prefill.length, prefill.length);
2706 paletteFetch();2982 paletteFetch();
2707 }2983 }
2708 2984
2985+ function anchorPalette(dlg, rect) {
2986+ var width = Math.min(Math.max(360, rect.width), window.innerWidth - 16);
2987+ var left = Math.max(8, Math.min(rect.left, window.innerWidth - width - 8));
2988+ dlg.classList.add('anchored');
2989+ dlg.style.top = Math.round(rect.bottom + 4) + 'px';
2990+ dlg.style.left = Math.round(left) + 'px';
2991+ dlg.style.width = Math.round(width) + 'px';
2992+ }
2993+
2994+ function unanchorPalette(dlg) {
2995+ dlg.classList.remove('anchored');
2996+ dlg.style.top = '';
2997+ dlg.style.left = '';
2998+ dlg.style.width = '';
2999+ }
3000+
2709 // Ctrl+K and Cmd+K toggle the palette even while a text field has focus, since that is when a3001 // Ctrl+K and Cmd+K toggle the palette even while a text field has focus, since that is when a
2710 // jump is most likely. Other modifiers keep their own meaning.3002 // jump is most likely. Other modifiers keep their own meaning.
2711 document.addEventListener('keydown', function (e) {3003 document.addEventListener('keydown', function (e) {
@@ -2721,6 +3013,17 @@
2721 if (t.closest('[data-palette-open]')) { e.preventDefault(); openPalette(); }3013 if (t.closest('[data-palette-open]')) { e.preventDefault(); openPalette(); }
2722 });3014 });
2723 3015
3016+ // "/" opens the palette when no field has the keyboard and no other dialog is open. Nothing else on
3017+ // the site uses "/" as a key.
3018+ document.addEventListener('keydown', function (e) {
3019+ if (e.key !== '/' || e.ctrlKey || e.metaKey || e.altKey || e.isComposing) { return; }
3020+ var t = e.target;
3021+ if (t && (t.isContentEditable || t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.tagName === 'SELECT')) { return; }
3022+ if (document.querySelector('dialog[open]') || !document.querySelector('[data-palette-open]')) { return; }
3023+ e.preventDefault();
3024+ openPalette();
3025+ });
3026+
2724 // Every relative time shows its exact moment on hover, in the reader's own time zone and language,3027 // Every relative time shows its exact moment on hover, in the reader's own time zone and language,
2725 // so one format holds across the site whatever title the server wrote.3028 // so one format holds across the site whatever title the server wrote.
2726 var relFormat = null, relLang = null;3029 var relFormat = null, relLang = null;
@@ -2957,20 +3260,36 @@
2957 dlg.showModal();3260 dlg.showModal();
2958 els.input.value = '';3261 els.input.value = '';
2959 els.input.focus();3262 els.input.focus();
2960- var src = dlg.getAttribute('data-src');3263+ if (finderLists[dlg.getAttribute('data-src')]) { renderFinder(dlg); return; }
2961- if (finderLists[src]) { renderFinder(dlg); return; }
2962 els.note.textContent = dlg.getAttribute('data-loading');3264 els.note.textContent = dlg.getAttribute('data-loading');
3265+ loadFinderList(dlg, function (data) {
3266+ if (!dlg.isConnected) { return; }
3267+ if (data) { renderFinder(dlg); } else { els.note.textContent = dlg.getAttribute('data-failed'); }
3268+ });
3269+ }
3270+
3271+ // The dialog's file list, fetched once per source URL and kept. `done` gets the list, or null when
3272+ // the fetch fails. A list already held is passed on at once. The command palette reads it here too.
3273+ function loadFinderList(dlg, done) {
3274+ var src = dlg.getAttribute('data-src');
3275+ if (finderLists[src]) { done(finderLists[src]); return; }
2963 fetch(src, { headers: { accept: 'application/json' }, credentials: 'same-origin' }).then(function (r) {3276 fetch(src, { headers: { accept: 'application/json' }, credentials: 'same-origin' }).then(function (r) {
2964 if (!r.ok) { throw new Error('status ' + r.status); }3277 if (!r.ok) { throw new Error('status ' + r.status); }
2965 return r.json();3278 return r.json();
2966 }).then(function (json) {3279 }).then(function (json) {
2967 finderLists[src] = { paths: json.paths || [], truncated: !!json.truncated };3280 finderLists[src] = { paths: json.paths || [], truncated: !!json.truncated };
2968- if (dlg.isConnected) { renderFinder(dlg); }3281+ done(finderLists[src]);
2969 }).catch(function () {3282 }).catch(function () {
2970- if (dlg.isConnected) { els.note.textContent = dlg.getAttribute('data-failed'); }3283+ done(null);
2971 });3284 });
2972 }3285 }
2973 3286
3287+ // For the command palette: the file list of a finder dialog, and the link to one of its files.
3288+ window.__forgeFinder = {
3289+ list: loadFinderList,
3290+ href: function (dlg, path) { return fileHref(dlg, path); }
3291+ };
3292+
2974 document.addEventListener('click', function (e) {3293 document.addEventListener('click', function (e) {
2975 var t = e.target;3294 var t = e.target;
2976 if (!t || !t.closest) { return; }3295 if (!t || !t.closest) { return; }
crates/forge-web/src/ci/live.rsmodified+12 -0
@@ -15,6 +15,10 @@ use tokio::sync::watch;
15 /// The one key of the runners signal: the admin pages follow all runners together.15 /// The one key of the runners signal: the admin pages follow all runners together.
16 const RUNNERS_KEY: &str = "runners";16 const RUNNERS_KEY: &str = "runners";
17 17
18+/// The one key of the any-run signal: a page that lists runs of many repos follows them together.
19+/// It lives in the runs map, next to the per-run keys, which are run ids and never equal this.
20+const RUNS_ANY_KEY: &str = "*runs";
21+
18 /// The change counters of CI jobs and runs, each keyed by its id.22 /// The change counters of CI jobs and runs, each keyed by its id.
19 #[derive(Default)]23 #[derive(Default)]
20 pub struct CiLive {24 pub struct CiLive {
@@ -82,6 +86,12 @@ impl CiLive {
82 self.runs.subscribe(run_id)86 self.runs.subscribe(run_id)
83 }87 }
84 88
89+ /// Subscribes to changes of any run of any repo: a run was created or changed state, or one of
90+ /// its jobs did. Same rules as [`CiLive::subscribe_job`].
91+ pub fn subscribe_any_run(&self) -> watch::Receiver<u64> {
92+ self.runs.subscribe(RUNS_ANY_KEY)
93+ }
94+
85 /// Subscribes to changes of repo `repo_id`: a run of the repo was created or changed state.95 /// Subscribes to changes of repo `repo_id`: a run of the repo was created or changed state.
86 /// Same rules as [`CiLive::subscribe_job`].96 /// Same rules as [`CiLive::subscribe_job`].
87 pub fn subscribe_repo(&self, repo_id: &str) -> watch::Receiver<u64> {97 pub fn subscribe_repo(&self, repo_id: &str) -> watch::Receiver<u64> {
@@ -108,12 +118,14 @@ impl CiLive {
108 /// Wakes the subscribers of run `run_id`: one of its jobs or its own status changed.118 /// Wakes the subscribers of run `run_id`: one of its jobs or its own status changed.
109 pub fn bump_run(&self, run_id: &str) {119 pub fn bump_run(&self, run_id: &str) {
110 self.runs.bump(run_id);120 self.runs.bump(run_id);
121+ self.runs.bump(RUNS_ANY_KEY);
111 }122 }
112 123
113 /// Wakes the subscribers of repo `repo_id`: a run of the repo was created or changed state.124 /// Wakes the subscribers of repo `repo_id`: a run of the repo was created or changed state.
114 /// Callers bump it next to the run bump, since the run signal does not know its repo.125 /// Callers bump it next to the run bump, since the run signal does not know its repo.
115 pub fn bump_repo(&self, repo_id: &str) {126 pub fn bump_repo(&self, repo_id: &str) {
116 self.repos.bump(repo_id);127 self.repos.bump(repo_id);
128+ self.runs.bump(RUNS_ANY_KEY);
117 }129 }
118 130
119 /// Wakes the subscribers of job `job_id` once more and drops its signal. Call it when the job131 /// Wakes the subscribers of job `job_id` once more and drops its signal. Call it when the job
crates/forge-web/src/i18n/browse.rsmodified+1 -0
@@ -60,6 +60,7 @@ strings! {
60 PaletteNoMatches => "No matches", "Eşleşme yok";60 PaletteNoMatches => "No matches", "Eşleşme yok";
61 PaletteLoading => "Loading…", "Yükleniyor…";61 PaletteLoading => "Loading…", "Yükleniyor…";
62 PaletteFailed => "The list could not be loaded.", "Liste yüklenemedi.";62 PaletteFailed => "The list could not be loaded.", "Liste yüklenemedi.";
63+ PaletteFiles => "Files", "Dosyalar";
63 64
64 BranchAuthorHeader => "Author", "Yazar";65 BranchAuthorHeader => "Author", "Yazar";
65 BranchAheadBehindHeader => "Ahead / behind", "Önde / geride";66 BranchAheadBehindHeader => "Ahead / behind", "Önde / geride";
crates/forge-web/src/i18n/misc.rsmodified+45 -0
@@ -171,6 +171,12 @@ pub enum K {
171 // Top-bar user menu: the viewer's public profile and the settings editor.171 // Top-bar user menu: the viewer's public profile and the settings editor.
172 YourProfile,172 YourProfile,
173 EditProfile,173 EditProfile,
174+ // Profile corner, live strip and path bar search.
175+ WaitingOnYou,
176+ AllNotifications,
177+ Passed,
178+ Failed,
179+ SearchPublicReposFor,
174 }180 }
175 181
176 /// Every variant, for the coverage test below.182 /// Every variant, for the coverage test below.
@@ -320,6 +326,11 @@ const ALL: &[K] = &[
320 K::RefLabel,326 K::RefLabel,
321 K::YourProfile,327 K::YourProfile,
322 K::EditProfile,328 K::EditProfile,
329+ K::WaitingOnYou,
330+ K::AllNotifications,
331+ K::Passed,
332+ K::Failed,
333+ K::SearchPublicReposFor,
323 ];334 ];
324 335
325 pub fn t(lang: Lang, key: K) -> &'static str {336 pub fn t(lang: Lang, key: K) -> &'static str {
@@ -640,6 +651,16 @@ pub fn t(lang: Lang, key: K) -> &'static str {
640 (YourProfile, Tr) => "Profilin",651 (YourProfile, Tr) => "Profilin",
641 (EditProfile, En) => "Edit profile",652 (EditProfile, En) => "Edit profile",
642 (EditProfile, Tr) => "Profili düzenle",653 (EditProfile, Tr) => "Profili düzenle",
654+ (WaitingOnYou, En) => "Waiting on you",
655+ (WaitingOnYou, Tr) => "Seni bekleyenler",
656+ (AllNotifications, En) => "All notifications",
657+ (AllNotifications, Tr) => "Tüm bildirimler",
658+ (Passed, En) => "passed",
659+ (Passed, Tr) => "geçti",
660+ (Failed, En) => "failed",
661+ (Failed, Tr) => "başarısız",
662+ (SearchPublicReposFor, En) => "Search public repositories for",
663+ (SearchPublicReposFor, Tr) => "Herkese açık depolarda ara:",
643 }664 }
644 }665 }
645 666
@@ -668,6 +689,30 @@ pub fn streak_days(lang: Lang, n: u64) -> String {
668 }689 }
669 }690 }
670 691
692+/// `2 review requests` / `1 review request`, and `2 inceleme isteği` in Turkish.
693+pub fn review_requests_count(lang: Lang, n: u64) -> String {
694+ match lang {
695+ Lang::En => format!("{n} review request{}", if n == 1 { "" } else { "s" }),
696+ Lang::Tr => format!("{n} inceleme isteği"),
697+ }
698+}
699+
700+/// `2 mentions` / `1 mention`, and `2 anılma` in Turkish.
701+pub fn mentions_count(lang: Lang, n: u64) -> String {
702+ match lang {
703+ Lang::En => format!("{n} mention{}", if n == 1 { "" } else { "s" }),
704+ Lang::Tr => format!("{n} anılma"),
705+ }
706+}
707+
708+/// `2 failing runs` / `1 failing run`, and `2 başarısız çalıştırma` in Turkish.
709+pub fn failing_runs_count(lang: Lang, n: u64) -> String {
710+ match lang {
711+ Lang::En => format!("{n} failing run{}", if n == 1 { "" } else { "s" }),
712+ Lang::Tr => format!("{n} başarısız çalıştırma"),
713+ }
714+}
715+
671 /// `1 contribution` / `3 contributions`, and `3 katkı` in Turkish.716 /// `1 contribution` / `3 contributions`, and `3 katkı` in Turkish.
672 pub fn contributions_count(lang: Lang, n: u64) -> String {717 pub fn contributions_count(lang: Lang, n: u64) -> String {
673 match lang {718 match lang {
crates/forge-web/src/pages/activity.rsadded+182 -0
@@ -0,0 +1,182 @@
1+//! The profile corner's live data: `GET /-/activity` returns the signed-in viewer's inbox counts, the
2+//! reviews and mentions waiting on them, and the state of their own CI runs. `GET /-/activity/stream`
3+//! sends a `changed` event with that JSON whenever a CI run changes and the JSON differs from the
4+//! last one sent. Anonymous requests get a bare 401.
5+
6+use forge_core::ci::RunState;
7+use forge_core::store::shell_activity::ActorRun;
8+use forge_core::{Reason, User};
9+use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS};
10+use serde_json::{Value, json};
11+use topcoat::Result;
12+use topcoat::context::{Cx, app_context};
13+use topcoat::router::response::Response;
14+use topcoat::router::{Body, HeaderValue, StatusCode, route};
15+
16+use crate::auth::current_user;
17+use crate::pages::ci_runs::{changed_stream, events_response, run_href};
18+use crate::state::AppState;
19+use crate::views::repo_href;
20+
21+/// How far back a finished run still counts as recent in the activity JSON, in seconds.
22+const RECENT_SECS: i64 = 120;
23+
24+/// How many waiting items the activity JSON lists.
25+const WAITING_LIMIT: u64 = 5;
26+
27+/// One CI run as the activity JSON lists it: label, link, running job, job counts and start time.
28+fn run_json(run: &ActorRun) -> Value {
29+ let title = format!("{}/{}", run.owner, run.repo);
30+ json!({
31+ "label": format!("{title} #{}", run.number),
32+ "href": run_href(&title, run.number),
33+ "job": run.current_job,
34+ "done": run.jobs_done,
35+ "total": run.jobs_total,
36+ "started": run.created_at,
37+ })
38+}
39+
40+/// The viewer's activity as JSON. `reviews` and `mentions` count unread inbox rows, `failing` counts
41+/// refs whose newest run failed, `running` and `finished` list the viewer's CI runs and `waiting`
42+/// lists the newest review requests and mentions. Reads only; the caller decides how to send it.
43+pub(crate) async fn activity_json(state: &AppState, user: &User) -> Result<Value> {
44+ let kinds = state.store.inbox_kind_counts(&user.id).await?;
45+ let runs = state.store.actor_runs(&user.id, RECENT_SECS).await?;
46+ let waiting = state.store.waiting_on(&user.id, WAITING_LIMIT).await?;
47+
48+ let running: Vec<Value> = runs.running.iter().map(run_json).collect();
49+ let finished: Vec<Value> = runs
50+ .finished
51+ .iter()
52+ .map(|run| {
53+ let mut item = run_json(run);
54+ item["ok"] = json!(matches!(run.state, RunState::Success));
55+ item
56+ })
57+ .collect();
58+ let waiting: Vec<Value> = waiting
59+ .iter()
60+ .map(|item| {
61+ let kind = if matches!(item.reason, Reason::ReviewRequested) {
62+ "review"
63+ } else {
64+ "mention"
65+ };
66+ let section = if item.is_pull { "pulls" } else { "issues" };
67+ json!({
68+ "kind": kind,
69+ "title": item.title,
70+ "where": format!("{}/{}#{}", item.owner, item.repo, item.number),
71+ "href": repo_href(&item.owner, &item.repo, section, &item.number.to_string()),
72+ })
73+ })
74+ .collect();
75+
76+ Ok(json!({
77+ "reviews": kinds.reviews,
78+ "mentions": kinds.mentions,
79+ "failing": runs.failing,
80+ "running": running,
81+ "finished": finished,
82+ "waiting": waiting,
83+ }))
84+}
85+
86+/// `GET /-/activity`: the viewer's activity as JSON. Anonymous visitors get 401.
87+#[route(GET "/-/activity")]
88+async fn activity(cx: &Cx) -> Result<Response> {
89+ let Some((user, _)) = current_user(cx).await? else {
90+ let mut res = Response::new(Body::empty());
91+ *res.status_mut() = StatusCode::UNAUTHORIZED;
92+ return Ok(res);
93+ };
94+ let state = app_context::<AppState>(cx);
95+ let body = activity_json(state, &user).await?;
96+ let mut response = Response::new(Body::from(body.to_string().into_bytes()));
97+ let headers = response.headers_mut();
98+ headers.insert(
99+ CONTENT_TYPE,
100+ HeaderValue::from_static("application/json; charset=utf-8"),
101+ );
102+ headers.insert(CACHE_CONTROL, HeaderValue::from_static("private, no-cache"));
103+ headers.insert(X_CONTENT_TYPE_OPTIONS, HeaderValue::from_static("nosniff"));
104+ Ok(response)
105+}
106+
107+/// `GET /-/activity/stream`: a `changed` event with the viewer's activity JSON now, then one after
108+/// each CI run change that alters it. The viewer comes from the session only. Anonymous visitors
109+/// get a bare 401, as the notifications stream does.
110+#[route(GET "/-/activity/stream")]
111+async fn activity_stream(cx: &Cx) -> Result<Response> {
112+ let Some((user, _)) = current_user(cx).await? else {
113+ let mut res = Response::new(Body::empty());
114+ *res.status_mut() = StatusCode::UNAUTHORIZED;
115+ return Ok(res);
116+ };
117+ let state = app_context::<AppState>(cx).clone();
118+ // Subscribed before the first read, so a run change in between is sent.
119+ let wake = state.ci_live.subscribe_any_run();
120+ let events = changed_stream(wake, true, move || {
121+ let state = state.clone();
122+ let user = user.clone();
123+ async move {
124+ // The JSON is the fingerprint: an event is sent only when the viewer's state changed.
125+ let body = activity_json(&state, &user).await?.to_string();
126+ Ok(Some((body, false)))
127+ }
128+ });
129+ events_response(cx, events)
130+}
131+
132+#[cfg(test)]
133+mod tests {
134+ use topcoat::router::request::Request;
135+ use topcoat::router::{Body, to_bytes};
136+
137+ use crate::auth::SESSION_COOKIE;
138+
139+ #[tokio::test]
140+ async fn activity_gives_the_viewers_json_and_401_to_anonymous() {
141+ let dir = tempfile::tempdir().expect("tempdir");
142+ let state = crate::test_support::test_state(dir.path()).await;
143+ let store = state.store.clone();
144+ let router = crate::test_support::app_router(state);
145+ let user = store
146+ .create_user("tahinli", None, "x", false)
147+ .await
148+ .expect("user");
149+
150+ let anon = router
151+ .handle(
152+ Request::builder()
153+ .method("GET")
154+ .uri("/-/activity")
155+ .body(Body::empty())
156+ .expect("request"),
157+ )
158+ .await;
159+ assert_eq!(anon.status().as_u16(), 401);
160+
161+ crate::test_support::create_session(&store, &user.id, "tok", "csrf").await;
162+ let res = router
163+ .handle(
164+ Request::builder()
165+ .method("GET")
166+ .uri("/-/activity")
167+ .header("cookie", format!("__Host-{SESSION_COOKIE}=tok"))
168+ .body(Body::empty())
169+ .expect("request"),
170+ )
171+ .await;
172+ assert_eq!(res.status().as_u16(), 200);
173+ let bytes = to_bytes(res.into_body(), usize::MAX).await.expect("body");
174+ let json: serde_json::Value = serde_json::from_slice(&bytes).expect("json");
175+ for key in [
176+ "reviews", "mentions", "failing", "running", "finished", "waiting",
177+ ] {
178+ assert!(json.get(key).is_some(), "missing {key}");
179+ }
180+ assert_eq!(json["running"], serde_json::json!([]));
181+ }
182+}
crates/forge-web/src/pages/ci_tests.rsmodified+8 -9
@@ -300,7 +300,9 @@ async fn run_list_pages_and_its_live_marker() {
300 }300 }
301 let first = get(&fx.app, RUN_BASE, Some(&cookie_for("tahinli-token"))).await;301 let first = get(&fx.app, RUN_BASE, Some(&cookie_for("tahinli-token"))).await;
302 let text = first.text();302 let text = first.text();
303- assert_eq!(text.matches("href=\"/tahinli/proj/ci/runs/").count(), 25);303+ // The topbar's live strip links the viewer's own running runs too; only the list counts.
304+ let list = text.split_once("</header>").map_or(text.as_str(), |(_, rest)| rest);
305+ assert_eq!(list.matches("href=\"/tahinli/proj/ci/runs/").count(), 25);
304 assert!(text.contains("?page=2"), "older link");306 assert!(text.contains("?page=2"), "older link");
305 assert!(!text.contains(">Newer<"));307 assert!(!text.contains(">Newer<"));
306 let second = get(308 let second = get(
@@ -310,7 +312,8 @@ async fn run_list_pages_and_its_live_marker() {
310 )312 )
311 .await;313 .await;
312 let text = second.text();314 let text = second.text();
313- assert_eq!(text.matches("href=\"/tahinli/proj/ci/runs/").count(), 5);315+ let list = text.split_once("</header>").map_or(text.as_str(), |(_, rest)| rest);
316+ assert_eq!(list.matches("href=\"/tahinli/proj/ci/runs/").count(), 5);
314 assert!(text.contains(">Newer<"), "newer link");317 assert!(text.contains(">Newer<"), "newer link");
315 assert!(!text.contains("?page=3"), "no older link on the last page");318 assert!(!text.contains("?page=3"), "no older link on the last page");
316 let bogus = get(319 let bogus = get(
@@ -320,13 +323,9 @@ async fn run_list_pages_and_its_live_marker() {
320 )323 )
321 .await;324 .await;
322 assert_eq!(bogus.status, 200);325 assert_eq!(bogus.status, 200);
323- assert_eq!(326+ let text = bogus.text();
324- bogus327+ let list = text.split_once("</header>").map_or(text.as_str(), |(_, rest)| rest);
325- .text()328+ assert_eq!(list.matches("href=\"/tahinli/proj/ci/runs/").count(), 25);
326- .matches("href=\"/tahinli/proj/ci/runs/")
327- .count(),
328- 25
329- );
330 }329 }
331 330
332 {331 {
crates/forge-web/src/pages/mod.rsmodified+1 -0
@@ -2,6 +2,7 @@
2 2
3 #[cfg(test)]3 #[cfg(test)]
4 mod account_tools_tests;4 mod account_tools_tests;
5+pub mod activity;
5 pub mod admin_backups;6 pub mod admin_backups;
6 pub mod admin_health;7 pub mod admin_health;
7 #[cfg(test)]8 #[cfg(test)]
crates/forge-web/src/pages/notifications.rsmodified+3 -3
@@ -1406,18 +1406,18 @@ mod tests {
1406 }1406 }
1407 1407
1408 #[tokio::test]1408 #[tokio::test]
1409- async fn header_bell_shows_the_unread_count() {1409+ async fn sidebar_shows_the_unread_count() {
1410 let site = site().await;1410 let site = site().await;
1411 let w = world(&site, Visibility::Public).await;1411 let w = world(&site, Visibility::Public).await;
1412 let cookie = sign_in(&site.store, &w.bob.id, "bob-token").await;1412 let cookie = sign_in(&site.store, &w.bob.id, "bob-token").await;
1413 1413
1414 let none = get(&site, "/", Some(&cookie)).await;1414 let none = get(&site, "/", Some(&cookie)).await;
1415 assert!(none.body.contains("href=\"/notifications\""));1415 assert!(none.body.contains("href=\"/notifications\""));
1416- assert!(!none.body.contains("bell-count"));1416+ assert!(!none.body.contains("<span class=\"count\">"));
1417 1417
1418 notify(&site, &w, Reason::Mention).await;1418 notify(&site, &w, Reason::Mention).await;
1419 let one = get(&site, "/", Some(&cookie)).await;1419 let one = get(&site, "/", Some(&cookie)).await;
1420- assert!(one.body.contains("<span class=\"bell-count\">1</span>"));1420+ assert!(one.body.contains("<span class=\"count\">1</span>"));
1421 }1421 }
1422 1422
1423 #[tokio::test]1423 #[tokio::test]
crates/forge-web/src/pages/settings_profile.rsmodified+1 -1
@@ -676,7 +676,7 @@ pub(crate) mod tests {
676 let (status, _, body) = send(&fx.router, "GET", "/", true, None).await;676 let (status, _, body) = send(&fx.router, "GET", "/", true, None).await;
677 assert_eq!(status, 200, "capitalization: nav");677 assert_eq!(status, 200, "capitalization: nav");
678 assert!(678 assert!(
679- body.contains("<summary aria-label=\"Tahinli\">"),679+ body.contains("<summary class=\"corner-btn\" aria-label=\"Tahinli\">"),
680 "capitalization: nav {body}"680 "capitalization: nav {body}"
681 );681 );
682 let (status, _, body) =682 let (status, _, body) =
crates/forge-web/src/views/mod.rsmodified+424 -80
@@ -9,8 +9,10 @@ pub mod review_thread;
9 9
10 use std::sync::OnceLock;10 use std::sync::OnceLock;
11 11
12+use forge_core::ci::RunState;
12 use forge_core::store::RepoSort;13 use forge_core::store::RepoSort;
13 use forge_core::store::repo_listing::RepoScope;14 use forge_core::store::repo_listing::RepoScope;
15+use forge_core::store::shell_activity::{ActorRuns, InboxKinds};
14 use forge_core::{Error as CoreError, Session, User};16 use forge_core::{Error as CoreError, Session, User};
15 use hex::encode;17 use hex::encode;
16 use http::header::{18 use http::header::{
@@ -23,7 +25,7 @@ use topcoat::context::{Cx, try_app_context};
23 use topcoat::router::request::uri;25 use topcoat::router::request::uri;
24 use topcoat::router::response::{Response, response_headers};26 use topcoat::router::response::{Response, response_headers};
25 use topcoat::router::{Body, Next, layer};27 use topcoat::router::{Body, Next, layer};
26-use topcoat::view::{Child, Unescaped, View, component, view};28+use topcoat::view::{Child, Unescaped, View, ViewExt, component, view};
27 29
28 use crate::i18n::admin::{self as ad, K as AK};30 use crate::i18n::admin::{self as ad, K as AK};
29 use crate::i18n::browse as br;31 use crate::i18n::browse as br;
@@ -122,10 +124,277 @@ fn side_class(on: bool) -> &'static str {
122 if on { "side-link on" } else { "side-link" }124 if on { "side-link on" } else { "side-link" }
123 }125 }
124 126
125-/// Page shell: sticky top bar (logo, page title, search, theme, bell and user menu), the signed-in127+/// First path segments that are pages of their own, not owners. A `-` prefix is the same.
126-/// sidebar and `child` as the page content. `viewer` drives the chrome: the sidebar, bell and user128+const TOP_LEVEL_PAGES: &[&str] = &[
127-/// menu when signed in, Explore and Log in otherwise. `extra_stylesheet` adds one more stylesheet129+ "explore",
128-/// link to the head (such as a repo's generated label colors).130+ "notifications",
131+ "settings",
132+ "admin",
133+ "new",
134+ "snippets",
135+ "login",
136+ "logout",
137+ "register",
138+ "forgot",
139+ "import",
140+ "review-requests",
141+ "setup",
142+ "org",
143+];
144+
145+/// Decodes `%XX` escapes. A malformed escape is kept as written.
146+fn percent_decode(s: &str) -> String {
147+ let bytes = s.as_bytes();
148+ let mut out = Vec::with_capacity(bytes.len());
149+ let mut i = 0;
150+ while i < bytes.len() {
151+ if bytes[i] == b'%'
152+ && let Some(hex) = s.get(i + 1..i + 3)
153+ && let Ok(byte) = u8::from_str_radix(hex, 16)
154+ {
155+ out.push(byte);
156+ i += 3;
157+ } else {
158+ out.push(bytes[i]);
159+ i += 1;
160+ }
161+ }
162+ String::from_utf8_lossy(&out).into_owned()
163+}
164+
165+/// The path bar for a request path, as `(label, href)` pairs. The root and the global pages show
166+/// one segment: the page `title`. A repo path shows the owner, the repo and, for a `tree` or
167+/// `blob` path, one segment per path part. The last segment never links. Labels are decoded.
168+fn path_segments(path: &str, title: &str) -> Vec<(String, Option<String>)> {
169+ let parts: Vec<String> = path
170+ .trim_matches('/')
171+ .split('/')
172+ .filter(|part| !part.is_empty())
173+ .map(percent_decode)
174+ .collect();
175+ let Some(owner) = parts.first() else {
176+ return vec![(title.to_owned(), None)];
177+ };
178+ if owner.starts_with('-') || TOP_LEVEL_PAGES.contains(&owner.as_str()) {
179+ return vec![(title.to_owned(), None)];
180+ }
181+ let mut segments = vec![(owner.clone(), Some(user_href(owner)))];
182+ if let Some(repo) = parts.get(1) {
183+ segments.push((repo.clone(), Some(repo_href(owner, repo, "", ""))));
184+ match &parts[2..] {
185+ [kind, git_ref, prefix @ ..] if matches!(kind.as_str(), "tree" | "blob") && !prefix.is_empty() => {
186+ let mut at = git_ref.clone();
187+ for part in prefix {
188+ at.push('/');
189+ at.push_str(part);
190+ segments.push((part.clone(), Some(repo_href(owner, repo, "tree", &at))));
191+ }
192+ }
193+ // The repo's home: the repo name is the last segment already.
194+ [] => {}
195+ _ => segments.push((title.to_owned(), None)),
196+ }
197+ }
198+ if let Some(last) = segments.last_mut() {
199+ last.1 = None;
200+ }
201+ segments
202+}
203+
204+/// One segment of the path bar.
205+struct PathCrumb {
206+ label: String,
207+ href: Option<String>,
208+ class: &'static str,
209+}
210+
211+/// One pill of the live strip: a CI run of the viewer.
212+struct LivePill {
213+ class: &'static str,
214+ label: String,
215+ /// The current job's name (with a leading space) or the outcome word; empty when there is none.
216+ text: String,
217+ href: String,
218+}
219+
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();
224+ for run in &runs.running {
225+ 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+ });
232+ }
233+ 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)),
237+ _ => continue,
238+ };
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+ });
245+ }
246+ let more = pills.len().saturating_sub(2);
247+ pills.truncate(2);
248+ (pills, more)
249+}
250+
251+/// A count's phrase with its number replaced by `{n}`, for nav.js to fill in again.
252+fn count_template(phrase: &str, n: u64) -> String {
253+ phrase.replacen(&n.to_string(), "{n}", 1)
254+}
255+
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+
261+/// The viewer's runs when there is no viewer or no app context: none.
262+fn no_runs() -> ActorRuns {
263+ ActorRuns {
264+ running: Vec::new(),
265+ finished: Vec::new(),
266+ failing: 0,
267+ }
268+}
269+
270+/// One item of the profile corner's waiting list.
271+#[derive(Clone)]
272+struct WaitingRow {
273+ href: String,
274+ title: String,
275+ /// `owner/repo#number`.
276+ repo: String,
277+ /// `corner-dot review` or `corner-dot mention`.
278+ dot_class: &'static str,
279+}
280+
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.
283+#[derive(Clone)]
284+struct ProfileCorner {
285+ username: String,
286+ avatar: String,
287+ csrf: String,
288+ back: String,
289+ is_admin: bool,
290+ theme: String,
291+ reviews: u64,
292+ mentions: u64,
293+ failing: u64,
294+ heat: Option<u64>,
295+ waiting: Vec<WaitingRow>,
296+}
297+
298+/// The account corner at the foot of the signed-in sidebar and in the phone menu. It opens upward:
299+/// the heat ring, the chips, what waits on the viewer, the notifications link, the theme choice,
300+/// and the profile, settings, admin and log out links.
301+#[component]
302+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;
306+ let review_chip = (corner.reviews > 0).then(|| {
307+ (corner.reviews.to_string(), mi::review_requests_count(lang, corner.reviews))
308+ });
309+ let mention_chip = (corner.mentions > 0)
310+ .then(|| (corner.mentions.to_string(), mi::mentions_count(lang, corner.mentions)));
311+ let failing_chip = (corner.failing > 0)
312+ .then(|| (corner.failing.to_string(), mi::failing_runs_count(lang, corner.failing)));
313+ let waiting_label = mi::t(lang, MK::WaitingOnYou);
314+ let all_label = mi::t(lang, MK::AllNotifications);
315+ let theme_label = mi::t(lang, MK::ThemeLabel);
316+ let match_label = mi::t(lang, MK::MatchSystem);
317+ let light_label = mi::t(lang, MK::Light);
318+ let dark_label = mi::t(lang, MK::Dark);
319+ let auto_pressed = if corner.theme == "auto" { "true" } else { "false" };
320+ let light_pressed = if corner.theme == "light" { "true" } else { "false" };
321+ let dark_pressed = if corner.theme == "dark" { "true" } else { "false" };
322+ let has_waiting = !corner.waiting.is_empty();
323+ // The chips' titles as nav.js rebuilds them: the server's phrase with `{n}` for the count. The
324+ // singular and plural forms are separate, as English puts "request" and "requests" apart.
325+ let review_template = count_template(&mi::review_requests_count(lang, 2), 2);
326+ let review_one = count_template(&mi::review_requests_count(lang, 1), 1);
327+ let mention_template = count_template(&mi::mentions_count(lang, 2), 2);
328+ let mention_one = count_template(&mi::mentions_count(lang, 1), 1);
329+ let failing_template = count_template(&mi::failing_runs_count(lang, 2), 2);
330+ let failing_one = count_template(&mi::failing_runs_count(lang, 1), 1);
331+ let profile_href = user_href(&corner.username);
332+ let profile_label = mi::t(lang, MK::YourProfile);
333+ let settings_label = o::t(lang, OK::Settings);
334+ let admin_label = ad::t(lang, AK::AdminArea);
335+ let logout_label = t(lang, Key::LogOut);
336+ Ok(view! {
337+ <details class="corner" data-unread-stream="">
338+ <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>
340+ <span class="corner-name">(corner.username.as_str())</span>
341+ <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())>
342+ if let Some((count, title)) = review_chip {
343+ <span class="chip chip-review" title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></svg>(count.as_str())</span>
344+ }
345+ if let Some((count, title)) = mention_chip {
346+ <span class="chip chip-mention" title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-3.92 7.94"/></svg>(count.as_str())</span>
347+ }
348+ if let Some((count, title)) = failing_chip {
349+ <span class="chip chip-failing" title=(title.as_str())><svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>(count.as_str())</span>
350+ }
351+ </span>
352+ </summary>
353+ <div class="corner-menu" data-cap=(waiting_label)>
354+ if has_waiting {
355+ <p class="corner-cap">(waiting_label)</p>
356+ <ul class="corner-waiting">
357+ for item in corner.waiting.iter() {
358+ <li><a href=(item.href.as_str())><span class=(item.dot_class)></span><span class="corner-item"><span>(item.title.as_str())</span><small>(item.repo.as_str())</small></span></a></li>
359+ }
360+ </ul>
361+ }
362+ <a class="corner-link" href="/notifications">(all_label)</a>
363+ <hr class="corner-rule">
364+ <div class="corner-theme"><span>(theme_label)</span>
365+ <form method="post" action="/-/theme" class="corner-theme-set">
366+ <input type="hidden" name="csrf" value=(corner.csrf.as_str())>
367+ <input type="hidden" name="back" value=(corner.back.as_str())>
368+ <button type="submit" name="theme" value="auto" aria-pressed=(auto_pressed) title=(match_label) aria-label=(match_label)>
369+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg>
370+ </button>
371+ <button type="submit" name="theme" value="light" aria-pressed=(light_pressed) title=(light_label) aria-label=(light_label)>
372+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
373+ </button>
374+ <button type="submit" name="theme" value="dark" aria-pressed=(dark_pressed) title=(dark_label) aria-label=(dark_label)>
375+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z"/></svg>
376+ </button>
377+ </form>
378+ </div>
379+ <a class="corner-link" href=(profile_href.as_str())>(profile_label)</a>
380+ <a class="corner-link" href="/settings/profile">(settings_label)</a>
381+ if corner.is_admin {
382+ <a class="corner-link" href="/admin/users">(admin_label)</a>
383+ }
384+ <form data-hard="true" method="post" action="/logout">
385+ <input type="hidden" name="csrf" value=(corner.csrf.as_str())>
386+ <button type="submit" class="corner-link link-button">(logout_label)</button>
387+ </form>
388+ </div>
389+ </details>
390+ })
391+}
392+
393+/// Page shell: sticky top bar (logo, path bar and, signed in, the live strip), the signed-in
394+/// sidebar with its profile corner, and `child` as the page content. `viewer` drives the chrome:
395+/// the sidebar, the live strip and the profile corner when signed in; search, theme, Explore and
396+/// Log in otherwise. `extra_stylesheet` adds one more stylesheet link to the head (such as a
397+/// repo's generated label colors).
129 #[component]398 #[component]
130 pub async fn shell(399 pub async fn shell(
131 title: &str,400 title: &str,
@@ -134,9 +403,9 @@ pub async fn shell(
134 #[default] child: Child<'_>,403 #[default] child: Child<'_>,
135 ) -> Result<impl View> {404 ) -> Result<impl View> {
136 let full_title = format!("{title} \u{b7} forge");405 let full_title = format!("{title} \u{b7} forge");
137- // The bell count and the viewer's freshest repos for the sidebar, with the total: two queries,406+ // The unread count, the viewer's freshest repos for the sidebar (with the total), the profile
138- // signed-in only.407+ // corner's inbox counts, their CI runs and the items waiting on them. Signed-in only.
139- let (unread, (listed, _)) = match viewer {408+ let (unread, (listed, _), inbox, runs, waiting) = match viewer {
140 Some((user, _)) => match try_app_context::<AppState>(__cx) {409 Some((user, _)) => match try_app_context::<AppState>(__cx) {
141 Some(state) => (410 Some(state) => (
142 state.store.unread_count(&user.id).await?,411 state.store.unread_count(&user.id).await?,
@@ -151,10 +420,13 @@ pub async fn shell(
151 SIDE_REPOS,420 SIDE_REPOS,
152 )421 )
153 .await?,422 .await?,
423+ state.store.inbox_kind_counts(&user.id).await?,
424+ state.store.actor_runs(&user.id, 120).await?,
425+ state.store.waiting_on(&user.id, 5).await?,
154 ),426 ),
155- None => (0, (Vec::new(), 0)),427+ None => (0, (Vec::new(), 0), InboxKinds::default(), no_runs(), Vec::new()),
156 },428 },
157- None => (0, (Vec::new(), 0)),429+ None => (0, (Vec::new(), 0), InboxKinds::default(), no_runs(), Vec::new()),
158 };430 };
159 let unread_badge = (unread > 0).then(|| unread.to_string());431 let unread_badge = (unread > 0).then(|| unread.to_string());
160 let side_repos: Vec<SideRepo> = listed432 let side_repos: Vec<SideRepo> = listed
@@ -180,14 +452,6 @@ pub async fn shell(
180 .map(|(user, _)| format!("/{}?tab=repositories", enc(&user.username)))452 .map(|(user, _)| format!("/{}?tab=repositories", enc(&user.username)))
181 .unwrap_or_default();453 .unwrap_or_default();
182 let signed_in = viewer.is_some();454 let signed_in = viewer.is_some();
183- let nav = viewer.map(|(user, session)| {
184- (
185- user.username.clone(),
186- session.csrf_token.clone(),
187- avatar_url(&user.username, user.avatar_hash.as_deref()),
188- user.is_admin,
189- )
190- });
191 // Both kinds of visitor post to `/-/theme`. Signed-in users send their CSRF token and get the455 // Both kinds of visitor post to `/-/theme`. Signed-in users send their CSRF token and get the
192 // stored preference saved. Anonymous visitors get the cookie. Either way the browser comes456 // stored preference saved. Anonymous visitors get the cookie. Either way the browser comes
193 // back to the page it was on.457 // back to the page it was on.
@@ -284,11 +548,66 @@ pub async fn shell(
284 let anonymous = viewer.is_none();548 let anonymous = viewer.is_none();
285 let search_label = o::t(lang, OK::SearchPublicRepos);549 let search_label = o::t(lang, OK::SearchPublicRepos);
286 let palette_label = br::t(lang, br::K::PaletteOpen).to_owned();550 let palette_label = br::t(lang, br::K::PaletteOpen).to_owned();
287- let notif_label = t(lang, Key::Notifications);
288 let menu_label = t(lang, Key::SiteMenu);551 let menu_label = t(lang, Key::SiteMenu);
552+ let toggle_class = if unread > 0 { "icon-btn has-dot" } else { "icon-btn" };
289 let side_repos_menu = side_repos.clone();553 let side_repos_menu = side_repos.clone();
290 let unread_menu = unread_badge.clone();554 let unread_menu = unread_badge.clone();
291 let unread_aside = unread_badge.clone();555 let unread_aside = unread_badge.clone();
556+ // The path bar: one segment per part of the request path, the last one unlinked.
557+ let segments = path_segments(uri(__cx).path(), title);
558+ let path_attr = segments
559+ .iter()
560+ .map(|(label, _)| label.as_str())
561+ .collect::<Vec<_>>()
562+ .join("/");
563+ let crumbs: Vec<PathCrumb> = segments
564+ .into_iter()
565+ .enumerate()
566+ .map(|(i, (label, href))| PathCrumb {
567+ class: if i == 0 && href.is_some() { "pathbar-seg owner" } else { "pathbar-seg" },
568+ label,
569+ href,
570+ })
571+ .collect();
572+ let (pills, more) = live_pills(lang, &runs);
573+ let more_label = format!("+{more}");
574+ let search_for_label = mi::t(lang, MK::SearchPublicReposFor);
575+ // The profile corner, the signed-in sidebar's account menu. The sidebar and the phone menu
576+ // each get their own copy.
577+ let heat = runs.running.first().map(|run| heat_percent(run.jobs_done, run.jobs_total));
578+ let waiting_rows: Vec<WaitingRow> = waiting
579+ .iter()
580+ .map(|item| WaitingRow {
581+ href: repo_href(
582+ &item.owner,
583+ &item.repo,
584+ if item.is_pull { "pulls" } else { "issues" },
585+ &item.number.to_string(),
586+ ),
587+ title: item.title.clone(),
588+ repo: format!("{}/{}#{}", item.owner, item.repo, item.number),
589+ dot_class: if matches!(item.reason, forge_core::notifications::Reason::ReviewRequested) {
590+ "corner-dot review"
591+ } else {
592+ "corner-dot mention"
593+ },
594+ })
595+ .collect();
596+ let corner = viewer.map(|(user, session)| ProfileCorner {
597+ username: user.username.clone(),
598+ avatar: avatar_url(&user.username, user.avatar_hash.as_deref()),
599+ csrf: session.csrf_token.clone(),
600+ back: back.clone().unwrap_or_else(|| "/".to_owned()),
601+ is_admin: user.is_admin,
602+ theme: theme_pref.to_owned(),
603+ reviews: inbox.reviews,
604+ mentions: inbox.mentions,
605+ failing: runs.failing,
606+ heat,
607+ waiting: waiting_rows,
608+ });
609+ let corner_panel = corner.clone();
610+ let corner_aside = corner;
292 Ok(view! {611 Ok(view! {
293 <!DOCTYPE html>612 <!DOCTYPE html>
294 <html lang=(lang.code()) data-theme=(theme_attr) data-accent-light=(accent_light_id) data-accent-dark=(accent_dark_id) data-base-light=(base_light_id) data-base-dark=(base_dark_id) data-sidebar=(sidebar_side) data-rel-words=(rel_words_attr.as_str()) data-rel-now=(rel_now_attr.as_str())>613 <html lang=(lang.code()) data-theme=(theme_attr) data-accent-light=(accent_light_id) data-accent-dark=(accent_dark_id) data-base-light=(base_light_id) data-base-dark=(base_dark_id) data-sidebar=(sidebar_side) data-rel-words=(rel_words_attr.as_str()) data-rel-now=(rel_now_attr.as_str())>
@@ -316,7 +635,7 @@ pub async fn shell(
316 <header class="topbar">635 <header class="topbar">
317 if signed_in {636 if signed_in {
318 <details class="nav-toggle">637 <details class="nav-toggle">
319- <summary class="icon-btn" aria-label=(menu_label) title=(menu_label)>638+ <summary class=(toggle_class) aria-label=(menu_label) title=(menu_label)>
320 <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg>639 <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16"/></svg>
321 </summary>640 </summary>
322 <div class="nav-panel">641 <div class="nav-panel">
@@ -325,6 +644,9 @@ pub async fn shell(
325 } else {644 } else {
326 side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_menu, repos: side_repos_menu)645 side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_menu, repos: side_repos_menu)
327 }646 }
647+ if let Some(corner) = corner_panel {
648+ profile_corner(lang: lang, corner: corner)
649+ }
328 </div>650 </div>
329 </details>651 </details>
330 }652 }
@@ -332,71 +654,64 @@ pub async fn shell(
332 <svg class="ico wordmark-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 19c0-7 5-12 14-13-1 9-6 14-13 14"/><path d="M5 19l6-6"/></svg>654 <svg class="ico wordmark-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 19c0-7 5-12 14-13-1 9-6 14-13 14"/><path d="M5 19l6-6"/></svg>
333 "forge"655 "forge"
334 </a>656 </a>
335- <nav class="crumbs" aria-label=(mi::t(lang, MK::BreadcrumbNav))>657+ <nav class="pathbar" aria-label=(mi::t(lang, MK::BreadcrumbNav))>
336- <ol>658+ <ol class="pathbar-segs">
337- <li><span aria-current="page">(title)</span></li>659+ for crumb in crumbs.iter() {
660+ if let Some(href) = &crumb.href {
661+ <li><a class=(crumb.class) href=(href.as_str())>(crumb.label.as_str())</a></li>
662+ } else {
663+ <li><span class="pathbar-seg last" aria-current="page">(crumb.label.as_str())</span></li>
664+ }
665+ }
338 </ol>666 </ol>
339- </nav>667+ if signed_in {
340- <form class="top-search" role="search" method="get" action="/explore">668+ // The palette's strings ride on its button, so nav.js builds the dialog in the viewer's language.
341- <svg class="ico top-search-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>669+ <button type="button" class="pathbar-edit" data-palette-open="" data-path=(path_attr.as_str()) aria-label=(palette_label.as_str()) title=(palette_label.as_str())
342- <input type="search" name="q" placeholder=(search_label) aria-label=(search_label)>670+ data-placeholder=(br::t(lang, br::K::PalettePlaceholder)) data-repos=(br::t(lang, br::K::PaletteRepos))
343- </form>671+ data-orgs=(o::t(lang, OK::Organizations)) data-pages=(br::t(lang, br::K::PalettePages))
344- <a class="icon-btn top-search-link" href="/explore" aria-label=(search_label) title=(search_label)>672+ data-empty=(br::t(lang, br::K::PaletteNoMatches)) data-loading=(br::t(lang, br::K::PaletteLoading))
345- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>673+ data-failed=(br::t(lang, br::K::PaletteFailed)) data-hint=(br::t(lang, br::K::FinderHint))
346- </a>674+ data-search-label=(search_for_label) data-files=(br::t(lang, br::K::PaletteFiles))>
347- <form class="theme-form" method="post" action="/-/theme">675+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
348- if let Some(csrf) = theme_csrf {676+ <kbd>"Ctrl K"</kbd>
349- <input type="hidden" name="csrf" value=(csrf.as_str())>677+ </button>
350- }
351- if let Some(back) = back {
352- <input type="hidden" name="back" value=(back.as_str())>
353 }678 }
354- <input type="hidden" name="theme" value=(next_theme)>679+ </nav>
355- <button type="submit" class="icon-btn" aria-label=(switch_label.as_str()) title=(switch_label.as_str())>680+ if signed_in {
356- if theme_pref == "light" {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">
357- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>682+ for pill in pills.iter() {
358- } else if theme_pref == "dark" {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>
359- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z"/></svg>
360- } else {
361- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg>
362 }684 }
363- </button>685+ if more > 0 {
364- </form>686+ <span class="pill more">(more_label.as_str())</span>
365- if let Some((username, csrf, avatar_src, is_admin)) = nav {
366- // The palette's strings ride on its button, so nav.js builds the dialog in the viewer's language.
367- <button type="button" class="palette-open" data-palette-open="" aria-label=(palette_label.as_str()) title=(palette_label.as_str())
368- data-placeholder=(br::t(lang, br::K::PalettePlaceholder)) data-repos=(br::t(lang, br::K::PaletteRepos))
369- data-orgs=(o::t(lang, OK::Organizations)) data-pages=(br::t(lang, br::K::PalettePages))
370- data-empty=(br::t(lang, br::K::PaletteNoMatches)) data-loading=(br::t(lang, br::K::PaletteLoading))
371- data-failed=(br::t(lang, br::K::PaletteFailed)) data-hint=(br::t(lang, br::K::FinderHint))>
372- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
373- <kbd>"Ctrl K"</kbd>
374- </button>
375- <a class="icon-btn bell" href="/notifications" aria-label=(notif_label) title=(notif_label)>
376- <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 7 3 9H3c0-2 3-2 3-9"/><path d="M10.3 21a1.9 1.9 0 0 0 3.4 0"/></svg>
377- if let Some(badge) = unread_badge {
378- <span class="bell-count">(badge.as_str())</span>
379 }687 }
688+ </div>
689+ } else {
690+ <form class="top-search" role="search" method="get" action="/explore">
691+ <svg class="ico top-search-icon" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
692+ <input type="search" name="q" placeholder=(search_label) aria-label=(search_label)>
693+ </form>
694+ <a class="icon-btn top-search-link" href="/explore" aria-label=(search_label) title=(search_label)>
695+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
380 </a>696 </a>
381- <details class="menu">697+ <form class="theme-form" method="post" action="/-/theme">
382- <summary aria-label=(username.as_str())>698+ if let Some(csrf) = theme_csrf {
383- <img class="avatar avatar-sm" src=(avatar_src) alt="" width="28" height="28">699+ <input type="hidden" name="csrf" value=(csrf.as_str())>
384- </summary>700+ }
385- <ul class="menu-list">701+ if let Some(back) = back {
386- <li><a href=(user_href(username.as_str()))>(mi::t(lang, MK::YourProfile))</a></li>702+ <input type="hidden" name="back" value=(back.as_str())>
387- <li><a href="/settings/profile">(o::t(lang, OK::Settings))</a></li>703+ }
388- if is_admin {704+ <input type="hidden" name="theme" value=(next_theme)>
389- <li><a href="/admin/users">(ad::t(lang, AK::AdminArea))</a></li>705+ <button type="submit" class="icon-btn" aria-label=(switch_label.as_str()) title=(switch_label.as_str())>
706+ if theme_pref == "light" {
707+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
708+ } else if theme_pref == "dark" {
709+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z"/></svg>
710+ } else {
711+ <svg class="ico" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="12" rx="2"/><path d="M8 20h8M12 16v4"/></svg>
390 }712 }
391- <li>713+ </button>
392- <form data-hard="true" method="post" action="/logout">714+ </form>
393- <input type="hidden" name="csrf" value=(csrf)>
394- <button type="submit" class="link-button">(t(lang, Key::LogOut))</button>
395- </form>
396- </li>
397- </ul>
398- </details>
399- } else {
400 <a class="topbar-link" href="/explore">(t(lang, Key::Explore))</a>715 <a class="topbar-link" href="/explore">(t(lang, Key::Explore))</a>
401 <a class="button primary" href="/login">(t(lang, Key::LogIn))</a>716 <a class="button primary" href="/login">(t(lang, Key::LogIn))</a>
402 }717 }
@@ -421,6 +736,9 @@ pub async fn shell(
421 } else {736 } else {
422 side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_aside, repos: side_repos)737 side_nav(lang: lang, current: current, profile_repos_href: profile_repos_href.as_str(), unread: unread_aside, repos: side_repos)
423 }738 }
739+ if let Some(corner) = corner_aside {
740+ profile_corner(lang: lang, corner: corner)
741+ }
424 </aside>742 </aside>
425 }743 }
426 <main tabindex="-1">744 <main tabindex="-1">
@@ -445,7 +763,9 @@ pub async fn shell(
445 </footer>763 </footer>
446 </body>764 </body>
447 </html>765 </html>
448- })766+ }
767+ // Boxed: the shell's view is part of every page's view, and inline it overflows the stack of a deep page.
768+ .boxed())
449 }769 }
450 770
451 /// The signed-in global links and the viewer's repos. The sidebar shows it, and so does the phone771 /// The signed-in global links and the viewer's repos. The sidebar shows it, and so does the phone
@@ -1392,6 +1712,30 @@ mod tests {
1392 );1712 );
1393 }1713 }
1394 1714
1715+ #[test]
1716+ fn path_segments_follow_the_request_path() {
1717+ assert_eq!(
1718+ path_segments("/tahinli/forge/blob/main/src/main.rs", "main.rs"),
1719+ vec![
1720+ ("tahinli".to_owned(), Some("/tahinli".to_owned())),
1721+ ("forge".to_owned(), Some("/tahinli/forge".to_owned())),
1722+ ("src".to_owned(), Some("/tahinli/forge/tree/main/src".to_owned())),
1723+ ("main.rs".to_owned(), None),
1724+ ]
1725+ );
1726+ assert_eq!(
1727+ path_segments("/tahinli/forge", "tahinli/forge"),
1728+ vec![
1729+ ("tahinli".to_owned(), Some("/tahinli".to_owned())),
1730+ ("forge".to_owned(), None),
1731+ ]
1732+ );
1733+ assert_eq!(
1734+ path_segments("/explore", "Explore"),
1735+ vec![("Explore".to_owned(), None)]
1736+ );
1737+ }
1738+
1395 #[test]1739 #[test]
1396 fn csp_allows_the_raw_origin_for_images_and_falls_back_otherwise() {1740 fn csp_allows_the_raw_origin_for_images_and_falls_back_otherwise() {
1397 let origin = origin_of("https://raw.forge.test:8443/some/path/");1741 let origin = origin_of("https://raw.forge.test:8443/some/path/");
style/_palette.scssmodified+10 -38
@@ -1,44 +1,8 @@
1 // Command palette (Ctrl+K): a dialog over the page with a search row, one scrolling list grouped by1 // Command palette (Ctrl+K): a dialog over the page with a search row, one scrolling list grouped by
2 // kind, and a footer note. It follows the branch switcher's command palette look.2 // kind, and a footer note. It follows the branch switcher's command palette look.
3 3
4-// The topbar button that opens it: a search icon and the shortcut, sized like the other top bar links.4+// The path bar's edit button (_shell.scss .pathbar-edit) opens it. The dialog is in the top layer,
5-.palette-open {5+// so it sits over the page and the path bar without any positioning of its own.
6- display: inline-flex;
7- align-items: center;
8- flex: none;
9- align-self: center; // buttons default to flex-start, which lifts it off the top bar's centre line
10- gap: 6px;
11- height: 36px;
12- padding: 0 8px;
13- color: var(--muted);
14- background: var(--surface);
15- border: 1px solid var(--border);
16- border-radius: var(--radius-md);
17- cursor: pointer;
18-
19- &:hover {
20- color: var(--text);
21- border-color: var(--border-strong);
22- }
23-
24- kbd {
25- padding: 0 5px;
26- font-family: var(--mono);
27- font-size: 0.6875rem;
28- line-height: 18px;
29- color: var(--text-2);
30- background: var(--surface-2);
31- border: 1px solid var(--border-strong);
32- border-radius: var(--radius-sm);
33- }
34-}
35-
36-// Phones have no keyboard, so the shortcut hint goes and the button is only the icon.
37-@media (max-width: 600px) {
38- .palette-open kbd {
39- display: none;
40- }
41-}
42 6
43 dialog.palette {7 dialog.palette {
44 width: min(560px, calc(100vw - 32px));8 width: min(560px, calc(100vw - 32px));
@@ -68,6 +32,14 @@ dialog.palette {
68 flex: 1 1 auto;32 flex: 1 1 auto;
69 }33 }
70 34
35+// Opened from the path bar, the dialog sits under it: fixed, with its top and left set inline by
36+// nav.js. The auto margins of a modal and its bottom inset are cleared so only those two apply.
37+.palette.anchored {
38+ margin: 0;
39+ position: fixed;
40+ inset: auto;
41+}
42+
71 // The search row is part of the palette, not a field inside it: no box, only the divider below.43 // The search row is part of the palette, not a field inside it: no box, only the divider below.
72 .palette-search {44 .palette-search {
73 flex: none;45 flex: none;
style/_shell.scssmodified+550 -9
@@ -150,19 +150,216 @@
150 margin: 0;150 margin: 0;
151 }151 }
152 152
153-.topbar .bell {153+// Path bar: the breadcrumb of the page, and the click target that opens the Ctrl K palette.
154+// The bar fills the top bar's free space; its edit button covers the rest of it.
155+
156+.pathbar {
157+ display: flex;
158+ align-items: center;
159+ flex: 1 1 auto;
160+ min-width: 0;
161+ max-width: 640px;
162+ height: 32px;
163+ box-sizing: border-box;
164+ padding: 0 0 0 4px;
165+ overflow: hidden;
166+ border: 1px solid transparent;
167+ border-radius: var(--radius-sm);
168+ font-family: var(--mono);
169+ font-size: 12.5px;
170+ color: var(--muted);
171+
172+ &:hover {
173+ border-color: var(--border);
174+ }
175+}
176+
177+.pathbar-segs {
178+ display: flex;
179+ align-items: center;
180+ flex: 0 1 auto;
181+ min-width: 0;
182+ margin: 0;
183+ padding: 0;
184+ overflow: hidden;
185+ list-style: none;
186+ white-space: nowrap;
187+
188+ li {
189+ display: flex;
190+ align-items: center;
191+ min-width: 0;
192+
193+ & + li::before {
194+ content: "/";
195+ flex: none;
196+ padding: 0 6px;
197+ color: var(--border-strong);
198+ }
199+ }
200+}
201+
202+.pathbar-seg {
203+ min-width: 0;
204+ overflow: hidden;
205+ padding: 2px 4px;
206+ border-radius: var(--radius-sm);
207+ color: var(--muted);
208+ text-overflow: ellipsis;
209+ text-decoration: none;
210+ white-space: nowrap;
211+
212+ &:hover {
213+ color: var(--text);
214+ background: var(--surface-2);
215+ text-decoration: none;
216+ }
217+
218+ &.owner {
219+ color: var(--accent-ink);
220+ }
221+
222+ &.last {
223+ color: var(--text);
224+ font-weight: 600;
225+
226+ &:hover {
227+ background: none;
228+ }
229+ }
230+}
231+
232+.pathbar-edit {
233+ display: flex;
234+ align-items: center;
235+ justify-content: flex-end;
236+ flex: 1 1 0;
237+ height: 100%;
238+ min-width: 0;
239+ margin: 0;
240+ padding: 0 6px;
241+ border: 0;
242+ background: transparent;
243+ color: var(--muted);
244+ font: inherit;
245+ cursor: text;
246+
247+ kbd {
248+ flex: none;
249+ padding: 0 5px;
250+ font-family: var(--mono);
251+ font-size: 11px;
252+ line-height: 18px;
253+ color: var(--text-2);
254+ background: var(--surface-2);
255+ border: 1px solid var(--border-strong);
256+ border-radius: var(--radius-sm);
257+ opacity: 0;
258+ }
259+
260+ &:hover kbd,
261+ &:focus-visible kbd {
262+ opacity: 1;
263+ }
264+}
265+
266+// Live strip: what is running or just finished, at the end of the top bar.
267+
268+.live-strip {
269+ display: flex;
270+ align-items: center;
271+ gap: 6px;
272+ flex: none;
273+ min-width: 0;
274+ margin-left: auto;
275+}
276+
277+.pill {
278+ display: inline-flex;
279+ align-items: center;
280+ gap: 6px;
281+ flex: 0 1 auto;
282+ min-width: 0;
283+ height: 26px;
284+ box-sizing: border-box;
285+ padding: 0 10px;
286+ overflow: hidden;
287+ border: 1px solid var(--border);
288+ border-radius: var(--radius-full);
289+ background: var(--surface);
154 color: var(--text-2);290 color: var(--text-2);
291+ font-size: 12.5px;
292+ white-space: nowrap;
293+ text-decoration: none;
294+
295+ b {
296+ font-weight: 600;
297+ color: var(--text);
298+ }
299+
300+ &:hover {
301+ background: var(--surface-2);
302+ text-decoration: none;
303+ }
304+}
305+
306+.pill-dot {
307+ flex: none;
308+ width: 7px;
309+ height: 7px;
310+ border-radius: 50%;
311+ background: var(--muted);
155 }312 }
156 313
157-.topbar .bell-count {314+.pill.ok .pill-dot {
315+ background: var(--ok);
316+}
317+
318+.pill.bad .pill-dot {
319+ background: var(--danger);
320+}
321+
322+.pill.hot {
323+ border-color: color-mix(in srgb, var(--heat-3) 45%, var(--border));
324+ background: linear-gradient(
325+ 90deg,
326+ color-mix(in srgb, var(--heat-3) 18%, var(--surface)),
327+ color-mix(in srgb, var(--heat-3) 6%, var(--surface))
328+ );
329+
330+ .pill-dot {
331+ background: var(--heat-4);
332+ animation: pill-pulse 1.6s ease-out infinite;
333+ }
334+}
335+
336+.pill.more {
337+ color: var(--muted);
338+ border-style: dashed;
339+}
340+
341+@keyframes pill-pulse {
342+ 0% {
343+ box-shadow: 0 0 0 0 var(--heat-glow);
344+ }
345+
346+ 70%,
347+ 100% {
348+ box-shadow: 0 0 0 6px transparent;
349+ }
350+}
351+
352+// A dot on the menu button when there are unread notifications (the bell's count moved here).
353+.nav-toggle summary.has-dot::after {
354+ content: "";
158 position: absolute;355 position: absolute;
159- top: -6px;356+ top: 5px;
160- right: -6px;357+ right: 5px;
161- min-width: 1.2rem;358+ width: 8px;
162- padding: 0 0.3rem;359+ height: 8px;
360+ border-radius: 50%;
361+ background: var(--heat-3);
163 box-shadow: 0 0 0 2px var(--bg);362 box-shadow: 0 0 0 2px var(--bg);
164- font-size: 0.6875rem;
165- line-height: 1.2rem;
166 }363 }
167 364
168 // The shared button keeps its natural width in columns; in the top bar it sits on the centre line.365 // The shared button keeps its natural width in columns; in the top bar it sits on the centre line.
@@ -338,6 +535,305 @@
338 }535 }
339 }536 }
340 537
538+// Profile corner: the signed-in user at the bottom of the sidebar. Its menu opens upward.
539+
540+.corner {
541+ position: relative;
542+ margin-top: auto;
543+ padding-top: 8px;
544+ border-top: 1px solid var(--border);
545+}
546+
547+.nav-panel .corner {
548+ margin-top: 12px;
549+}
550+
551+// The phone panel scrolls, so a menu opening upward would be cut at its top: it opens in place.
552+.nav-panel .corner-menu {
553+ position: static;
554+ margin-top: 6px;
555+ box-shadow: none;
556+}
557+
558+.corner-btn {
559+ display: flex;
560+ align-items: center;
561+ gap: 8px;
562+ padding: 8px;
563+ border-radius: var(--radius-md);
564+ color: var(--text);
565+ cursor: pointer;
566+ list-style: none;
567+
568+ &:hover {
569+ background: var(--surface-2);
570+ }
571+
572+ &::-webkit-details-marker {
573+ display: none;
574+ }
575+}
576+
577+.corner-name {
578+ min-width: 0;
579+ overflow: hidden;
580+ font-size: 14px;
581+ font-weight: 600;
582+ text-overflow: ellipsis;
583+ white-space: nowrap;
584+}
585+
586+// The avatar inside a ring: the ring fills with the running run's progress (--p), and glows while hot.
587+.heat-ring {
588+ display: grid;
589+ flex: none;
590+ place-items: center;
591+ width: 34px;
592+ height: 34px;
593+ 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+ }
604+
605+ &.hot {
606+ filter: drop-shadow(0 0 5px var(--heat-glow));
607+ }
608+
609+ .avatar {
610+ box-sizing: border-box;
611+ width: 28px;
612+ height: 28px;
613+ border: 2px solid var(--bg);
614+ border-radius: 50%;
615+ }
616+}
617+
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+
625+.corner-chips {
626+ display: flex;
627+ align-items: center;
628+ gap: 4px;
629+ margin-left: auto;
630+}
631+
632+// Chips count what waits on the user. They never take the accent.
633+.chip {
634+ display: inline-flex;
635+ align-items: center;
636+ gap: 3px;
637+ flex: none;
638+ height: 20px;
639+ box-sizing: border-box;
640+ padding: 0 6px;
641+ border: 1px solid var(--border);
642+ border-radius: var(--radius-full);
643+ background: var(--surface-2);
644+ color: var(--text-2);
645+ font-size: 11px;
646+ font-weight: 700;
647+ font-variant-numeric: tabular-nums;
648+
649+ .ico {
650+ width: 12px;
651+ height: 12px;
652+ }
653+}
654+
655+.chip-review {
656+ color: var(--important);
657+ background: color-mix(in srgb, var(--important) 12%, var(--surface));
658+ border-color: color-mix(in srgb, var(--important) 35%, transparent);
659+}
660+
661+.chip-mention {
662+ color: var(--info);
663+ background: color-mix(in srgb, var(--info) 12%, var(--surface));
664+ border-color: color-mix(in srgb, var(--info) 35%, transparent);
665+}
666+
667+.chip-failing {
668+ color: var(--danger);
669+ background: var(--danger-bg);
670+ border-color: color-mix(in srgb, var(--danger) 35%, transparent);
671+}
672+
673+.corner-menu {
674+ position: absolute;
675+ left: 8px;
676+ right: 8px;
677+ bottom: calc(100% + 6px);
678+ z-index: 40;
679+ display: grid;
680+ gap: 2px;
681+ box-sizing: border-box;
682+ padding: 6px;
683+ background: var(--surface);
684+ border: 1px solid var(--border);
685+ border-radius: var(--radius-md);
686+ box-shadow: var(--shadow);
687+}
688+
689+.corner-cap {
690+ margin: 0;
691+ padding: 6px 10px 2px;
692+ font-size: 11.5px;
693+ font-weight: 600;
694+ color: var(--muted);
695+}
696+
697+.corner-waiting {
698+ display: grid;
699+ gap: 2px;
700+ margin: 0;
701+ padding: 0;
702+ list-style: none;
703+
704+ a {
705+ display: flex;
706+ align-items: flex-start;
707+ gap: 8px;
708+ padding: 6px 10px;
709+ border-radius: var(--radius-md);
710+ color: var(--text);
711+ text-decoration: none;
712+
713+ &:hover {
714+ background: var(--surface-2);
715+ text-decoration: none;
716+ }
717+ }
718+}
719+
720+.corner-dot {
721+ flex: none;
722+ width: 7px;
723+ height: 7px;
724+ margin-top: 6px;
725+ border-radius: 50%;
726+ background: var(--muted);
727+
728+ &.review {
729+ background: var(--important);
730+ }
731+
732+ &.mention {
733+ background: var(--info);
734+ }
735+}
736+
737+.corner-item {
738+ display: flex;
739+ flex-direction: column;
740+ min-width: 0;
741+
742+ span {
743+ overflow: hidden;
744+ font-size: 13.5px;
745+ line-height: 1.3;
746+ text-overflow: ellipsis;
747+ white-space: nowrap;
748+ }
749+
750+ small {
751+ overflow: hidden;
752+ font-family: var(--mono);
753+ font-size: 11.5px;
754+ color: var(--muted);
755+ text-overflow: ellipsis;
756+ white-space: nowrap;
757+ }
758+}
759+
760+// `button.corner-link` too (Log out): the extra element in the selector outweighs `button.link-button`.
761+.corner-link,
762+button.corner-link.link-button {
763+ display: block;
764+ width: 100%;
765+ box-sizing: border-box;
766+ margin: 0;
767+ padding: 8px 10px;
768+ border: 0;
769+ border-radius: var(--radius-md);
770+ background: none;
771+ color: var(--text);
772+ font: inherit;
773+ font-size: 14px;
774+ text-align: left;
775+ text-decoration: none;
776+ cursor: pointer;
777+
778+ &:hover {
779+ background: var(--surface-2);
780+ text-decoration: none;
781+ }
782+}
783+
784+.corner-rule {
785+ width: auto;
786+ margin: 4px 6px;
787+ border: 0;
788+ border-top: 1px solid var(--border);
789+}
790+
791+.corner-theme {
792+ display: flex;
793+ align-items: center;
794+ justify-content: space-between;
795+ padding: 4px 6px 4px 10px;
796+ font-size: 14px;
797+ color: var(--muted);
798+
799+ span {
800+ color: var(--text-2);
801+ }
802+}
803+
804+.corner-theme-set {
805+ display: flex;
806+ gap: 2px;
807+ margin: 0;
808+
809+ button {
810+ display: grid;
811+ place-items: center;
812+ width: 28px;
813+ height: 26px;
814+ padding: 0;
815+ border: 0;
816+ border-radius: var(--radius-sm);
817+ background: none;
818+ color: var(--muted);
819+ cursor: pointer;
820+
821+ &:hover {
822+ color: var(--text);
823+ }
824+
825+ &[aria-pressed="true"] {
826+ background: var(--surface-2);
827+ color: var(--text);
828+ }
829+ }
830+
831+ .ico {
832+ width: 16px;
833+ height: 16px;
834+ }
835+}
836+
341 // Page column and footer837 // Page column and footer
342 838
343 .shell > main {839 .shell > main {
@@ -371,6 +867,24 @@
371 .top-search {867 .top-search {
372 flex: 1 1 0;868 flex: 1 1 0;
373 }869 }
870+
871+ // Phones: the path bar shows only the last segment, and the live strip goes (its counts are in the menu).
872+ .pathbar-segs li:not(:last-child) {
873+ display: none;
874+ }
875+
876+ .pathbar-segs li + li::before {
877+ display: none;
878+ }
879+
880+ // Phones have no keyboard, so the shortcut hint goes.
881+ .pathbar-edit kbd {
882+ display: none;
883+ }
884+
885+ .live-strip {
886+ display: none;
887+ }
374 }888 }
375 889
376 // Narrow phones: the search field no longer fits beside the other top bar items, so it becomes an890 // Narrow phones: the search field no longer fits beside the other top bar items, so it becomes an
@@ -413,7 +927,9 @@
413 position: sticky;927 position: sticky;
414 top: var(--topbar-h);928 top: var(--topbar-h);
415 align-self: start;929 align-self: start;
416- display: block;930+ // A column, so the profile corner sits at its bottom (margin-top: auto).
931+ display: flex;
932+ flex-direction: column;
417 box-sizing: border-box;933 box-sizing: border-box;
418 // Ends at the viewport's bottom while the site banner still shows above it (--shell-top, nav.js).934 // Ends at the viewport's bottom while the site banner still shows above it (--shell-top, nav.js).
419 height: calc(100vh - max(var(--topbar-h), var(--shell-top, 0px)));935 height: calc(100vh - max(var(--topbar-h), var(--shell-top, 0px)));
@@ -424,6 +940,27 @@
424 border-right: 1px solid var(--border);940 border-right: 1px solid var(--border);
425 }941 }
426 942
943+ // The profile corner stays above a repo page's fixed tabs, which end where it starts: 50px of
944+ // corner, its rule and the sidebar's 24px bottom padding.
945+ .shell-sidebar .corner {
946+ position: relative;
947+ z-index: 6;
948+ }
949+
950+ .shell:has(> .shell-sidebar .corner) .repo-tabs {
951+ bottom: 76px;
952+ }
953+
954+ // The sticky sidebar is its own stacking layer, under the fixed tabs, so the open menu would sit
955+ // behind them: while it is open the sidebar rises above the tabs, see-through so they still show.
956+ .shell-sidebar:has(.corner[open]) {
957+ z-index: 6;
958+ }
959+
960+ .shell:has(.repo-tabs) .shell-sidebar:has(.corner[open]) {
961+ background: transparent;
962+ }
963+
427 // A repo page: its tabs become the sidebar, fixed under the top bar, and the global links go.964 // A repo page: its tabs become the sidebar, fixed under the top bar, and the global links go.
428 .shell:has(.repo-tabs) .shell-sidebar .side-links,965 .shell:has(.repo-tabs) .shell-sidebar .side-links,
429 .shell:has(.repo-tabs) .shell-sidebar .side-group {966 .shell:has(.repo-tabs) .shell-sidebar .side-group {
@@ -536,4 +1073,8 @@ html[aria-busy="true"] body::before {
536 transform: scaleX(1);1073 transform: scaleX(1);
537 opacity: 0.45;1074 opacity: 0.45;
538 }1075 }
1076+
1077+ .pill.hot .pill-dot {
1078+ animation: none;
1079+ }
539 }1080 }
style/main.scssmodified+22 -0
@@ -85,6 +85,14 @@
85 --note: #2B6CB0;85 --note: #2B6CB0;
86 --tip: #1D7A62;86 --tip: #1D7A62;
87 --important: #6A4BB0;87 --important: #6A4BB0;
88+ // Heat: the live strip and the profile ring (0 is the empty track, 4 the hottest). Chips never use the accent.
89+ --heat-0: #ECE7E1;
90+ --heat-1: #F6C9A8;
91+ --heat-2: #EE9A60;
92+ --heat-3: #D4652A;
93+ --heat-4: #9C3A10;
94+ --heat-glow: rgba(220, 100, 30, .35);
95+ --info: #2B6CB0;
88 --warning: #9A6200;96 --warning: #9A6200;
89 --shadow: 0 10px 28px rgba(30, 36, 32, .10);97 --shadow: 0 10px 28px rgba(30, 36, 32, .10);
90 // Radius scale: sm chips/badges, md every control (buttons, inputs, selects, textareas),98 // Radius scale: sm chips/badges, md every control (buttons, inputs, selects, textareas),
@@ -123,6 +131,13 @@
123 --note: #8AB4F0;131 --note: #8AB4F0;
124 --tip: #7CCBAE;132 --tip: #7CCBAE;
125 --important: #C4A7FF;133 --important: #C4A7FF;
134+ --heat-0: #24211E;
135+ --heat-1: #5A2614;
136+ --heat-2: #9A3A16;
137+ --heat-3: #D9662A;
138+ --heat-4: #FFB066;
139+ --heat-glow: rgba(255, 150, 70, .55);
140+ --info: #8AB4F0;
126 --warning: #E6B765;141 --warning: #E6B765;
127 --shadow: 0 10px 28px rgba(0, 0, 0, .45);142 --shadow: 0 10px 28px rgba(0, 0, 0, .45);
128 color-scheme: dark;143 color-scheme: dark;
@@ -152,6 +167,13 @@
152 --note: #8AB4F0;167 --note: #8AB4F0;
153 --tip: #7CCBAE;168 --tip: #7CCBAE;
154 --important: #C4A7FF;169 --important: #C4A7FF;
170+ --heat-0: #24211E;
171+ --heat-1: #5A2614;
172+ --heat-2: #9A3A16;
173+ --heat-3: #D9662A;
174+ --heat-4: #FFB066;
175+ --heat-glow: rgba(255, 150, 70, .55);
176+ --info: #8AB4F0;
155 --warning: #E6B765;177 --warning: #E6B765;
156 --shadow: 0 10px 28px rgba(0, 0, 0, .45);178 --shadow: 0 10px 28px rgba(0, 0, 0, .45);
157 color-scheme: dark;179 color-scheme: dark;