forge
Explore
Log in

Don't you dare go Hollow

A repo made private or a lost membership stops showing everywhere

Browse files at this commit

50d52fa870add94321724c43c100038535621c1dAhmet Kaan GümüşParent: 374e721
All checks have passed
Show checks
  • fix
    • a repo made private or a lost membership stops showing everywhere
  • feat
    • command palette, hover prefetch, saved ticks, comment drafts, list memory, empty states, relative times with the exact time on hover, motion on the reader's own actions, and confirm popups in place of "I understand" ticks
Show full message
🔒 fix: a repo made private or a lost membership stops showing everywhere; ✨ feat: command palette, hover prefetch, saved ticks, comment drafts, list memory, empty states, relative times with the exact time on hover, motion on the reader's own actions, and confirm popups in place of "I understand" ticks

- Contribution calendar counts public repos only; the inbox, dashboard attention rows and unread count drop repos the user can no longer read.
- Packages linked to a repo follow its read access; CI log and run streams end when access is lost; raw files, media and attachments revalidate on every use.
- Import history no longer names a repo its creator can no longer read.
- Repo settings: visibility and archive become action rows with confirm popups; release, webhook and mirror deletes confirm the same way.
- The site banner no longer slides under the repo sidebar; live re-renders keep every disclosure open or closed; calendar day links keep the scroll position.

82 changed files +2188 -556

crates/forge-core/src/store/contributions.rsmodified+54 -6
@@ -73,7 +73,8 @@ impl Store {
7373 /// Events are grouped by minute and each minute is placed on its local day, so zones with
7474 /// half-hour or quarter-hour offsets and DST changes land on the right day.
7575 /// A contribution is a push (ref deletions are left out), an issue or pull request opened
76- /// (pull requests are `issues` rows with `kind = 'pull'`), or a comment.
76+ /// (pull requests are `issues` rows with `kind = 'pull'`), or a comment. Only public repos count:
77+ /// a repo made private takes its contributions off the calendar.
7778 pub async fn contribution_counts(
7879 &self,
7980 user_id: &str,
@@ -84,15 +85,17 @@ impl Store {
8485 let sql = "SELECT minute, COUNT(*) FROM ( \
8586 SELECT substr(created_at, 1, 16) AS minute FROM push_events \
8687 WHERE actor_id = ?1 AND created_at >= ?2 AND new_oid NOT IN (?3, ?4) \
88+ AND repo_id IN (SELECT id FROM repos WHERE visibility = 'public') \
8789 UNION ALL \
8890 SELECT substr(created_at, 1, 16) FROM issues \
8991 WHERE author_id = ?1 AND created_at >= ?2 AND kind IN ('issue', 'pull') \
92+ AND repo_id IN (SELECT id FROM repos WHERE visibility = 'public') \
9093 UNION ALL \
91- SELECT substr(created_at, 1, 16) FROM comments \
92- WHERE author_id = ?1 AND created_at >= ?2 \
94+ SELECT substr(c.created_at, 1, 16) FROM comments c JOIN issues i ON i.id = c.issue_id \
95+ WHERE c.author_id = ?1 AND c.created_at >= ?2 AND i.repo_id IN (SELECT id FROM repos WHERE visibility = 'public') \
9396 UNION ALL \
9497 SELECT substr(created_at, 1, 16) FROM coauthored_commits \
95- WHERE user_id = ?1 AND created_at >= ?2 \
98+ WHERE user_id = ?1 AND created_at >= ?2 AND repo_id IN (SELECT id FROM repos WHERE visibility = 'public') \
9699 ) GROUP BY minute";
97100 let params = vec![
98101 Value::Text(user_id.to_string()),
@@ -133,22 +136,24 @@ impl Store {
133136 0, '', '' FROM push_events p \
134137 JOIN repos r ON r.id = p.repo_id JOIN users o ON o.id = r.owner_id \
135138 WHERE p.actor_id = ?1 AND p.created_at >= ?2 AND p.created_at < ?3 \
136- AND p.new_oid NOT IN (?4, ?5) \
139+ AND p.new_oid NOT IN (?4, ?5) AND r.visibility = 'public' \
137140 UNION ALL \
138141 SELECT i.kind, o.username, r.name, i.created_at, '', i.number, i.title, '' FROM issues i \
139142 JOIN repos r ON r.id = i.repo_id JOIN users o ON o.id = r.owner_id \
140143 WHERE i.author_id = ?1 AND i.created_at >= ?2 AND i.created_at < ?3 \
141- AND i.kind IN ('issue', 'pull') \
144+ AND i.kind IN ('issue', 'pull') AND r.visibility = 'public' \
142145 UNION ALL \
143146 SELECT 'comment', o.username, r.name, c.created_at, '', i.number, i.title, '' \
144147 FROM comments c JOIN issues i ON i.id = c.issue_id \
145148 JOIN repos r ON r.id = i.repo_id JOIN users o ON o.id = r.owner_id \
146149 WHERE c.author_id = ?1 AND c.created_at >= ?2 AND c.created_at < ?3 \
150+ AND r.visibility = 'public' \
147151 UNION ALL \
148152 SELECT 'coauthored', o.username, r.name, k.created_at, '', 0, k.summary, k.commit_oid \
149153 FROM coauthored_commits k \
150154 JOIN repos r ON r.id = k.repo_id JOIN users o ON o.id = r.owner_id \
151155 WHERE k.user_id = ?1 AND k.created_at >= ?2 AND k.created_at < ?3 \
156+ AND r.visibility = 'public' \
152157 ORDER BY created_at DESC LIMIT ?6";
153158 let params = vec![
154159 Value::Text(user_id.to_string()),
@@ -405,4 +410,47 @@ mod tests {
405410 .is_empty()
406411 );
407412 }
413+ #[tokio::test]
414+ async fn private_repos_are_left_out() {
415+ let dir = tempfile::tempdir().unwrap();
416+ let store = Store::open(&dir.path().join("forge.db")).await.unwrap();
417+ let tahinli = store
418+ .create_user("tahinli", None, "x", false)
419+ .await
420+ .unwrap();
421+ let demo = store
422+ .create_repo(&tahinli.id, "demo", "", Visibility::Public, "main")
423+ .await
424+ .unwrap();
425+ let at = "2026-03-01T10:00:00.000000000Z";
426+ store
427+ .record_push_event_at(&demo.id, &tahinli.id, "refs/heads/main", ZERO, OID, at)
428+ .await
429+ .unwrap();
430+ let since = "2026-03-01T00:00:00.000000000Z";
431+ let until = "2026-03-02T00:00:00.000000000Z";
432+ assert_eq!(
433+ store.contribution_counts(&tahinli.id, since, "UTC").await.unwrap().len(),
434+ 1
435+ );
436+
437+ store
438+ .set_repo_visibility(&demo.id, Visibility::Private)
439+ .await
440+ .unwrap();
441+ assert!(
442+ store
443+ .contribution_counts(&tahinli.id, since, "UTC")
444+ .await
445+ .unwrap()
446+ .is_empty()
447+ );
448+ assert!(
449+ store
450+ .contributions_between(&tahinli.id, since, until)
451+ .await
452+ .unwrap()
453+ .is_empty()
454+ );
455+ }
408456 }
crates/forge-core/src/store/notifications.rsmodified+41 -13
@@ -4,6 +4,7 @@ use turso::transaction::Transaction;
44 use turso::{Row, Value};
55
66 use super::issues::finish;
7+use super::repo_listing::READABLE_BY_VIEWER;
78 use super::{Store, col_int, col_text, db_err, fetch_all, fetch_opt, new_id};
89 use crate::error::{Error, Result};
910 use crate::model::Id;
@@ -13,6 +14,20 @@ use crate::time::now_stamp;
1314 /// Largest page `list_notifications` returns, whatever the caller asks for.
1415 const MAX_NOTIFICATION_PAGE: u32 = 200;
1516
17+/// 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 removed
19+/// from, drops out of the inbox, the dashboard and the unread count at once.
20+fn readable_repo() -> String {
21+ format!(
22+ "({READABLE_BY_VIEWER} OR EXISTS (SELECT 1 FROM users ua WHERE ua.id = ? AND ua.is_admin = 1))"
23+ )
24+}
25+
26+/// The user id, bound once per `?` of `readable_repo`.
27+fn readable_params(user_id: &str) -> impl Iterator<Item = Value> + '_ {
28+ (0..5).map(move |_| Value::Text(user_id.to_string()))
29+}
30+
1631 /// Inbox rows joined with their repo, owner, issue or pull, and last actor. `?` placeholders
1732 /// are appended to by `list_notifications`.
1833 const NOTIFICATION_SELECT: &str = "SELECT n.id, n.repo_id, o.username, r.name, n.issue_id, \
@@ -301,8 +316,12 @@ impl Store {
301316 before: Option<&str>,
302317 limit: u32,
303318 ) -> Result<Vec<Notification>> {
304- let mut sql = format!("{NOTIFICATION_SELECT} WHERE n.user_id = ?");
319+ let mut sql = format!(
320+ "{NOTIFICATION_SELECT} WHERE n.user_id = ? AND {}",
321+ readable_repo()
322+ );
305323 let mut params = vec![Value::Text(user_id.to_string())];
324+ params.extend(readable_params(user_id));
306325 if unread_only {
307326 sql.push_str(" AND n.unread = 1");
308327 }
@@ -318,20 +337,29 @@ impl Store {
318337 fetch_all(&conn, &sql, params, map_notification).await
319338 }
320339
321- /// Number of unread inbox rows of the user, issues and discussions together.
340+ /// Number of unread inbox rows of the user, issues and discussions together. Rows of repos the
341+ /// user can no longer read are left out.
322342 pub async fn unread_count(&self, user_id: &str) -> Result<u64> {
343+ let readable = readable_repo();
344+ let sql = format!(
345+ "SELECT (SELECT COUNT(*) FROM notifications n JOIN repos r ON r.id = n.repo_id \
346+ WHERE n.user_id = ? AND n.unread = 1 AND {readable}) + \
347+ (SELECT COUNT(*) FROM discussion_notifications n JOIN repos r ON r.id = n.repo_id \
348+ WHERE n.user_id = ? AND n.unread = 1 AND {readable}) + \
349+ (SELECT COUNT(*) FROM advisory_notifications n JOIN repos r ON r.id = n.repo_id \
350+ WHERE n.user_id = ? AND n.unread = 1 AND {readable}) + \
351+ (SELECT COUNT(*) FROM admin_notifications WHERE user_id = ? AND unread = 1)"
352+ );
353+ let mut params = Vec::new();
354+ for _ in 0..3 {
355+ params.push(Value::Text(user_id.to_string()));
356+ params.extend(readable_params(user_id));
357+ }
358+ params.push(Value::Text(user_id.to_string()));
323359 let conn = self.read_conn().await;
324- let n = fetch_opt(
325- &conn,
326- "SELECT (SELECT COUNT(*) FROM notifications WHERE user_id = ?1 AND unread = 1) + \
327- (SELECT COUNT(*) FROM discussion_notifications WHERE user_id = ?1 AND unread = 1) + \
328- (SELECT COUNT(*) FROM advisory_notifications WHERE user_id = ?1 AND unread = 1) + \
329- (SELECT COUNT(*) FROM admin_notifications WHERE user_id = ?1 AND unread = 1)",
330- (user_id.to_string(),),
331- |row| col_int(row, 0),
332- )
333- .await?
334- .unwrap_or(0);
360+ let n = fetch_opt(&conn, &sql, params, |row| col_int(row, 0))
361+ .await?
362+ .unwrap_or(0);
335363 u64::try_from(n).map_err(|_| Error::Database("negative count".into()))
336364 }
337365
crates/forge-core/src/store/repo_listing.rsmodified+26 -2
@@ -9,7 +9,7 @@ use super::{
99 map_repo,
1010 };
1111 use crate::error::Result;
12-use crate::model::User;
12+use crate::model::{Repo, User};
1313
1414 /// Whose repos a profile tab lists.
1515 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -31,7 +31,7 @@ const STARS: &str = "(SELECT COUNT(*) FROM stars s WHERE s.repo_id = r.id)";
3131 /// public repos, the viewer's own repos, repos where the viewer is a collaborator, and repos of an
3232 /// org where the viewer's org role (`Store::org_repo_role`) is some role: an org owner, a member
3333 /// when the default repo role is not `none`, or a member of a team covering the repo.
34-const READABLE_BY_VIEWER: &str = "(r.visibility = 'public' OR r.owner_id = ? \
34+pub(crate) const READABLE_BY_VIEWER: &str = "(r.visibility = 'public' OR r.owner_id = ? \
3535 OR EXISTS (SELECT 1 FROM collaborators c WHERE c.repo_id = r.id AND c.user_id = ?) \
3636 OR EXISTS (SELECT 1 FROM org_members m WHERE m.org_id = r.owner_id AND m.user_id = ? AND ( \
3737 m.role = 'owner' \
@@ -94,6 +94,30 @@ impl Store {
9494 Ok(u64::try_from(n).unwrap_or(0))
9595 }
9696
97+ /// Up to `limit` repos the signed-in `viewer` is part of: their own, ones they collaborate on, and
98+ /// org repos they reach. Sorted by owner and name, for the command palette. Other public repos are
99+ /// left out (Explore lists them), and so are an admin's: on a big instance they would push the
100+ /// viewer's own repos past the limit. The rule is `READABLE_BY_VIEWER` without its public clause.
101+ pub async fn list_viewer_repos(&self, viewer: &User, limit: u64) -> Result<Vec<Repo>> {
102+ let where_sql = READABLE_BY_VIEWER.replacen("r.visibility = 'public' OR ", "", 1);
103+ debug_assert_ne!(where_sql, READABLE_BY_VIEWER, "the public clause moved");
104+ let params: Vec<Value> = (0..4).map(|_| Value::Text(viewer.id.clone())).collect();
105+ let limit = i64::try_from(limit).unwrap_or(i64::MAX);
106+ let mut params = params;
107+ params.push(Value::Integer(limit));
108+ let conn = self.read_conn().await;
109+ fetch_all(
110+ &conn,
111+ &format!(
112+ "SELECT {REPO_COLS} FROM repos r JOIN users u ON u.id = r.owner_id \
113+ WHERE {where_sql} ORDER BY u.username_folded ASC, r.name_folded ASC LIMIT ?"
114+ ),
115+ params,
116+ map_repo,
117+ )
118+ .await
119+ }
120+
97121 /// One page of the repos `from_sql` (which joins `repos r` and its owner `users u`) yields
98122 /// under `where_sql`, in `sort` order, with the total match count. `page` is 1-based and is
99123 /// clamped to the last page; `per_page` to 1..=100.
crates/forge-web/assets/nav.jsmodified+799 -18
@@ -175,6 +175,8 @@
175175 syncTick();
176176 syncRel();
177177 syncBannerExpiry();
178+ syncShellTop();
179+ syncDrafts();
178180 }
179181
180182 // The log tail is a terminal: it opens at its end. A reader who scrolls up keeps their place.
@@ -363,18 +365,20 @@
363365 var user = o.how !== 'live';
364366 if (user) { userBusy += 1; clearNote(); }
365367 busyStart();
366- fetch(o.target.href, o.init).then(function (r) {
368+ // A link the reader hovered may already be on its way (takePrefetch); a POST never is.
369+ (o.how === 'nav' && !o.form && takePrefetch(o.target.href) || fetch(o.target.href, o.init)).then(function (r) {
367370 if (RESTART.indexOf(r.status) >= 0) { return { down: true }; }
368371 var final = new URL(r.url || o.target.href);
369372 var html = /^\s*text\/html/i.test(r.headers.get('content-type') || '');
370373 if (final.origin !== location.origin || !html) {
371374 return { leave: true, url: final, redirected: r.redirected };
372375 }
373- return r.text().then(function (text) { return { html: text, url: final, status: r.status }; });
376+ return r.text().then(function (text) { return { html: text, url: final, status: r.status, redirected: r.redirected }; });
374377 }, function () {
375378 // No answer at all: the server is down.
376379 return { down: true };
377380 }).then(function (res) {
381+ o.result = res;
378382 if (mark !== latest) { return; }
379383 if (res.down) { if (o.how !== 'live') { outage(o); } return; }
380384 if (res.leave) { leave(res, o); return; }
@@ -389,11 +393,21 @@
389393 // navigation: it gets a history entry, so the address bar shows where the page now is.
390394 var how = o.how === 'live' && res.url.pathname !== o.target.pathname ? 'nav' : o.how;
391395 swap(res.html, dest, how, !!o.keep && res.url.pathname === o.target.pathname);
396+ // Other parts of this file follow page changes through this event (list memory, say).
397+ document.dispatchEvent(new CustomEvent('forge:swapped', { detail: { how: how, url: dest } }));
392398 }).catch(function () {
393399 if (mark !== latest || o.how === 'live') { return; }
394400 if (o.post) { o.form.submit(); } else { location.assign(o.dest.href); }
395401 }).then(function () {
396402 busyEnd();
403+ if (o.post) {
404+ submitDone(o, mark === latest);
405+ // A POST counts as done only when the server answered with a redirect to a page: the
406+ // post-redirect-get every successful form here ends in. Drafts listen for it.
407+ var r = o.result;
408+ var ok = mark === latest && !!(r && r.html && r.redirected && r.status < 400);
409+ document.dispatchEvent(new CustomEvent('forge:submitted', { detail: { form: o.form, ok: ok } }));
410+ }
397411 if (o.form) { pending.delete(o.form); }
398412 if (o.how === 'live') { liveBusy = false; }
399413 if (user) { userBusy -= 1; }
@@ -583,7 +597,7 @@
583597 }
584598
585599 // Dropdown menus: the <details> that float over the page (avatar menu, branch selector, clone
586- // popover, phone menu). Inline disclosures are not listed here and keep their state.
600+ // popover, phone menu). Inline disclosures are not listed: a click outside leaves them open.
587601 var DROPDOWN = 'details.menu, details.ref-select, details.clone, details.nav-toggle';
588602
589603 // Closes every open dropdown except `keep` (pass null to close them all).
@@ -593,11 +607,13 @@
593607 });
594608 }
595609
596- // Each dropdown gets a key that survives a re-render: its id when it has one, else its summary
597- // text plus a count for repeats (two menus with the same text stay apart, in document order).
610+ // Each <details> gets a key that survives a re-render: its id when it has one, else its summary
611+ // text plus a count for repeats (two with the same text stay apart, in document order). A live swap
612+ // keeps every one as the reader left it: a menu stays open, and so does an inline editor (a branch
613+ // rule) the server renders closed, or a form it renders open that the reader closed.
598614 function dropdownKeys() {
599615 var seen = Object.create(null);
600- return Array.prototype.map.call(document.querySelectorAll(DROPDOWN), function (d) {
616+ return Array.prototype.map.call(document.querySelectorAll('details'), function (d) {
601617 if (d.id) { return { key: 'id:' + d.id, el: d }; }
602618 var s = d.querySelector('summary');
603619 var text = s ? s.textContent.replace(/\s+/g, ' ').trim() : '';
@@ -606,21 +622,22 @@
606622 });
607623 }
608624
609- // Before a live swap: the keys of the open dropdowns, and the key of the one holding focus.
625+ // Before a live swap: whether each <details> is open, and the key of the open one holding focus
626+ // (the innermost, as nested ones come later in document order).
610627 function captureDropdowns() {
611628 var active = document.activeElement;
612- var out = { open: [], focus: null };
629+ var out = { open: Object.create(null), focus: null };
613630 dropdownKeys().forEach(function (item) {
614- if (!item.el.open) { return; }
615- out.open.push(item.key);
616- if (active && item.el.contains(active)) { out.focus = item.key; }
631+ out.open[item.key] = item.el.open;
632+ if (item.el.open && active && item.el.contains(active)) { out.focus = item.key; }
617633 });
618634 return out;
619635 }
620636
621637 function openDropdowns(kept) {
622638 dropdownKeys().forEach(function (item) {
623- if (kept.open.indexOf(item.key) >= 0) { item.el.open = true; }
639+ var was = kept.open[item.key];
640+ if (was !== undefined && item.el.open !== was) { item.el.open = was; }
624641 });
625642 }
626643
@@ -658,6 +675,83 @@
658675 }
659676 }, false);
660677
678+ // Inline disclosures (a branch rule, a review thread, a delivery, a <details> in markdown) slide
679+ // open and shut instead of jumping. The details' height is animated from where it is to where it
680+ // goes, clipped only while it moves, so an open one never clips what it holds. Closing keeps it open
681+ // until the slide ends. A click during a slide turns it around. Floating panels (menus, popovers,
682+ // inline confirms) are left to the browser, as is a reader who asks for reduced motion.
683+ var FLOATING = DROPDOWN + ', details.row-menu, details.confirm-inline, details.commit-status, details.reaction-picker';
684+ var reducedMotion = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : null;
685+
686+ function slideDetails(d) {
687+ var opening = d.__closing || !d.open;
688+ var from = d.getBoundingClientRect().height;
689+ if (d.__slide) { d.__slide.cancel(); }
690+ d.open = false;
691+ var shut = d.getBoundingClientRect().height;
692+ d.open = true;
693+ var to = opening ? d.getBoundingClientRect().height : shut;
694+ d.__closing = !opening;
695+ d.style.overflow = 'hidden';
696+ var slide = d.animate({ height: [from + 'px', to + 'px'] }, { duration: 200, easing: 'cubic-bezier(0.2, 0, 0, 1)' });
697+ d.__slide = slide;
698+ slide.onfinish = function () {
699+ d.__slide = null;
700+ d.style.overflow = '';
701+ if (d.__closing) { d.__closing = false; d.open = false; }
702+ };
703+ }
704+
705+ document.addEventListener('click', function (e) {
706+ if (e.defaultPrevented || !e.target || !e.target.closest) { return; }
707+ var summary = e.target.closest('summary');
708+ var d = summary && summary.parentElement;
709+ if (!d || d.tagName !== 'DETAILS' || d.querySelector('summary') !== summary) { return; }
710+ if (d.matches(FLOATING) || (reducedMotion && reducedMotion.matches)) { return; }
711+ // A link or control inside the summary does its own thing.
712+ var control = e.target.closest('a, button, input, select, textarea');
713+ if (control && summary.contains(control)) { return; }
714+ e.preventDefault();
715+ slideDetails(d);
716+ }, false);
717+
718+ // Plays a one-shot motion class (see _motion.scss) on the reader's own action.
719+ function play(el, cls) {
720+ el.classList.remove(cls);
721+ void el.offsetWidth;
722+ el.classList.add(cls);
723+ setTimeout(function () { el.classList.remove(cls); }, 400);
724+ }
725+
726+ // A menu or popover the reader opens drops in. Only a click opens it this way: a live swap that
727+ // keeps one open sets `open` directly and plays nothing.
728+ document.addEventListener('click', function (e) {
729+ var summary = e.target && e.target.closest ? e.target.closest('summary') : null;
730+ var d = summary && summary.parentElement;
731+ if (d && d.tagName === 'DETAILS' && !d.open && d.matches(FLOATING)) { play(d, 'pop'); }
732+ }, false);
733+
734+ // Dismissing the site banner folds it away, then the dismissal is sent. This runs before the
735+ // soft submit below, which then sends it.
736+ document.addEventListener('submit', function (e) {
737+ var form = e.target;
738+ var banner = form && form.closest ? form.closest('.site-banner') : null;
739+ if (!banner || form.__folded || (reducedMotion && reducedMotion.matches)) { return; }
740+ e.preventDefault();
741+ e.stopPropagation();
742+ banner.style.overflow = 'hidden';
743+ banner.animate({
744+ height: [banner.offsetHeight + 'px', '0px'],
745+ paddingTop: [getComputedStyle(banner).paddingTop, '0px'],
746+ paddingBottom: [getComputedStyle(banner).paddingBottom, '0px'],
747+ opacity: [1, 0]
748+ }, { duration: 180, easing: 'cubic-bezier(0.2, 0, 0, 1)', fill: 'forwards' }).onfinish = function () {
749+ form.__folded = true;
750+ form.requestSubmit();
751+ syncShellTop();
752+ };
753+ }, true);
754+
661755 // Branch rule form: a suggested check context is added to the required checks field.
662756 document.addEventListener('click', function (e) {
663757 var chip = e.target && e.target.closest ? e.target.closest('[data-check-add]') : null;
@@ -684,6 +778,13 @@
684778 // A fragment on the page already shown: the browser scrolls by itself.
685779 if (url.pathname + url.search === shown && url.hash) { return; }
686780 e.preventDefault();
781+ // A link that only changes what part of this page shows (a calendar day) swaps in place: the
782+ // reader's scroll stays, and its anchor, meant for a full page load, is not followed.
783+ if (a.hasAttribute('data-keep-scroll') && url.pathname === location.pathname) {
784+ var here = withoutHash(url);
785+ load({ target: here, dest: here, init: GET_INIT, how: 'query', keep: true, post: false, form: null });
786+ return;
787+ }
687788 saveScroll();
688789 load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'nav', keep: false, post: false, form: null });
689790 }, true);
@@ -716,6 +817,7 @@
716817 }
717818
718819 var multipart = (form.enctype || '').toLowerCase().indexOf('multipart') === 0;
820+ submitStart(form, submitter);
719821 load({
720822 target: withoutHash(url),
721823 dest: url,
@@ -727,7 +829,8 @@
727829 how: 'post',
728830 keep: true,
729831 post: true,
730- form: form
832+ form: form,
833+ submitter: submitter
731834 });
732835 }, false);
733836
@@ -782,6 +885,7 @@
782885 var max = parseFloat(field.max);
783886 if (!isNaN(min)) { next = Math.max(min, next); }
784887 if (!isNaN(max)) { next = Math.min(max, next); }
888+ if (String(next) !== field.value) { play(field, 'tick'); }
785889 field.value = String(next);
786890 field.dispatchEvent(new Event('input', { bubbles: true }));
787891 });
@@ -1833,23 +1937,42 @@
18331937 // is removed here, so an open page does not keep one that is gone. One timer is armed for the
18341938 // banner on the page; a swap re-arms it. setTimeout takes a 32-bit delay, so a longer wait is armed
18351939 // again when this one fires.
1836- var bannerTimer = null;
1940+ var expiryTimer = null;
18371941
18381942 function syncBannerExpiry() {
1839- if (bannerTimer) { clearTimeout(bannerTimer); }
1840- bannerTimer = null;
1943+ if (expiryTimer) { clearTimeout(expiryTimer); }
1944+ expiryTimer = null;
18411945 var banner = document.querySelector('.site-banner[data-expires]');
18421946 if (!banner) { return; }
18431947 var wait = (parseInt(banner.getAttribute('data-expires'), 10) || 0) * 1000 - Date.now();
1844- if (wait <= 0) { banner.remove(); return; }
1845- bannerTimer = setTimeout(syncBannerExpiry, Math.min(wait, 2147483647));
1948+ if (wait <= 0) { banner.remove(); syncShellTop(); return; }
1949+ expiryTimer = setTimeout(syncBannerExpiry, Math.min(wait, 2147483647));
1950+ }
1951+
1952+ // A repo's tabs are a fixed column (see _shell.scss). They start where the page body starts, so
1953+ // whatever sits above it (the site banner) shows, and they rise with it to the top bar on scroll.
1954+ var shellFrame = 0;
1955+
1956+ function syncShellTop() {
1957+ shellFrame = 0;
1958+ var shell = document.querySelector('.shell');
1959+ if (!shell) { return; }
1960+ document.documentElement.style.setProperty('--shell-top', Math.round(shell.getBoundingClientRect().top) + 'px');
18461961 }
18471962
1963+ function queueShellTop() {
1964+ if (!shellFrame) { shellFrame = requestAnimationFrame(syncShellTop); }
1965+ }
1966+
1967+ window.addEventListener('scroll', queueShellTop, { passive: true });
1968+ window.addEventListener('resize', queueShellTop);
1969+
18481970 function syncRel() {
18491971 var now = document.documentElement.getAttribute('data-rel-now');
18501972 relSkew = now === null ? 0 : (parseInt(now, 10) || 0) * 1000 - Date.now();
18511973 if (relTimer) { clearTimeout(relTimer); relTimer = null; }
18521974 relUpdate();
1975+ relTitles();
18531976 }
18541977
18551978 function fmtDuration(secs, root) {
@@ -1921,6 +2044,8 @@
19212044 syncTick();
19222045 syncRel();
19232046 syncBannerExpiry();
2047+ syncShellTop();
2048+ syncDrafts();
19242049
19252050 window.__forgeQuery = function (href) {
19262051 var url = pageUrl(href);
@@ -1928,6 +2053,662 @@
19282053 load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'query', keep: true, post: false, form: null });
19292054 };
19302055 placeRun();
2056+
2057+ // Hover prefetch: a link the pointer rests on for a moment starts its page request early, so the
2058+ // click that often follows finds the answer already on its way. Only what the click handler would
2059+ // soft-navigate is fetched, and never a path that writes when viewed or serves a file.
2060+ var PREFETCH_DELAY = 80; // ms the pointer must rest on a link before its request starts
2061+ var PREFETCH_TTL = 10000; // ms a finished or running prefetch is still used by a click
2062+ var PREFETCH_MAX = 4; // stored prefetches; the oldest is dropped first
2063+ var NO_PREFETCH = /\/-\/|\/(live|events|stream|open|download)$|\/(archive|raw|actions|attachments|artifacts)\/|\.zip$|\.tar\.gz$|\/releases\/download\/|^\/(logout|notifications)(\/|$)/;
2064+ var prefetches = []; // { key, promise, at }: the request for a URL without its hash
2065+ var prefetchTimer = null;
2066+ var prefetchLink = null;
2067+
2068+ // Touch screens have no hover, and a saver asks for less data: neither gets prefetches.
2069+ function prefetchAllowed() {
2070+ var conn = navigator.connection;
2071+ if (conn && conn.saveData) { return false; }
2072+ return !(window.matchMedia && window.matchMedia('(hover: none)').matches);
2073+ }
2074+
2075+ // The URL to prefetch for link `a`, or null. The same rules as the click handler apply, so a
2076+ // prefetch never fetches a page a click would not show.
2077+ function prefetchUrl(a) {
2078+ if (a.target || a.hasAttribute('download') || a.hasAttribute('data-hard') || a.hasAttribute('data-no-prefetch')) { return null; }
2079+ var href = a.getAttribute('href') || '';
2080+ if (href.charAt(0) !== '/' || href.charAt(1) === '/') { return null; }
2081+ var url = pageUrl(href);
2082+ if (!url || NO_PREFETCH.test(url.pathname)) { return null; }
2083+ if (url.pathname + url.search === shown) { return null; }
2084+ return withoutHash(url);
2085+ }
2086+
2087+ function startPrefetch(url) {
2088+ var key = url.href;
2089+ // A page fetched while a form is on its way may show the state before the write.
2090+ if (userBusy > 0) { return; }
2091+ for (var i = prefetches.length - 1; i >= 0; i--) {
2092+ if (prefetches[i].key === key) { prefetches.splice(i, 1); }
2093+ }
2094+ // A prefetch that fails is asked again when the click takes it, so a blip while hovering never
2095+ // reads as an outage. Nothing surfaces from one nobody clicks.
2096+ var promise = fetch(key, GET_INIT).catch(function () { return fetch(key, GET_INIT); });
2097+ promise.catch(function () {});
2098+ prefetches.push({ key: key, promise: promise, at: Date.now() });
2099+ while (prefetches.length > PREFETCH_MAX) { prefetches.shift(); }
2100+ }
2101+
2102+ // Returns a pending fetch Promise<Response> for `href` started on hover, or null. Taken once: a
2103+ // Response body can be read only once, so the entry goes whether or not it is still fresh.
2104+ function takePrefetch(href) {
2105+ for (var i = 0; i < prefetches.length; i++) {
2106+ if (prefetches[i].key !== href) { continue; }
2107+ var hit = prefetches.splice(i, 1)[0];
2108+ return Date.now() - hit.at < PREFETCH_TTL ? hit.promise : null;
2109+ }
2110+ return null;
2111+ }
2112+
2113+ document.addEventListener('mouseover', function (e) {
2114+ var a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
2115+ if (!a || a === prefetchLink) { return; }
2116+ clearTimeout(prefetchTimer);
2117+ prefetchTimer = null;
2118+ prefetchLink = a;
2119+ var url = prefetchUrl(a);
2120+ if (!url || !prefetchAllowed()) { return; }
2121+ prefetchTimer = setTimeout(function () {
2122+ prefetchTimer = null;
2123+ startPrefetch(url);
2124+ }, PREFETCH_DELAY);
2125+ }, true);
2126+
2127+ // Leaving the link (not moving between its children) cancels a prefetch that has not started yet.
2128+ document.addEventListener('mouseout', function (e) {
2129+ var a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
2130+ if (!a || a !== prefetchLink || (e.relatedTarget && a.contains(e.relatedTarget))) { return; }
2131+ clearTimeout(prefetchTimer);
2132+ prefetchTimer = null;
2133+ prefetchLink = null;
2134+ }, true);
2135+
2136+ // A write can change every page, so no prefetch made before a form goes out is kept.
2137+ document.addEventListener('submit', function () {
2138+ prefetches.length = 0;
2139+ clearTimeout(prefetchTimer);
2140+ prefetchTimer = null;
2141+ prefetchLink = null;
2142+ }, true);
2143+
2144+ // Submit feedback
2145+ // The button shows busy only when the answer is slow (after BUSY_MS), so a quick reply never flickers.
2146+ // The tick comes only once the server redirected to a page without an error: nothing looks saved first.
2147+ var BUSY_MS = 150;
2148+ var TICK_MS = 2200;
2149+ var SUBMIT_SEL = 'button[type=submit], button:not([type]), input[type=submit]';
2150+
2151+ function buttonLabel(b) {
2152+ return ((b.tagName === 'INPUT' ? b.value : b.textContent) || '').replace(/\s+/g, ' ').trim();
2153+ }
2154+
2155+ // The page's forms with this action and method, in document order.
2156+ function sameForms(action, method) {
2157+ return Array.prototype.filter.call(document.querySelectorAll('form'), function (f) {
2158+ return f.getAttribute('action') === action && (f.getAttribute('method') || 'get').toLowerCase() === method;
2159+ });
2160+ }
2161+
2162+ // Which form and button a POST came from. Taken before the swap: the old form is gone by the answer.
2163+ function submitKey(form, btn) {
2164+ var action = form.getAttribute('action');
2165+ var method = (form.getAttribute('method') || 'get').toLowerCase();
2166+ return {
2167+ action: action,
2168+ method: method,
2169+ index: sameForms(action, method).indexOf(form),
2170+ name: btn ? btn.name : '',
2171+ value: btn ? btn.value : '',
2172+ text: btn ? buttonLabel(btn) : '',
2173+ dirty: form.hasAttribute('data-dirty-form'),
2174+ banner: !!(form.closest && form.closest('.site-banner'))
2175+ };
2176+ }
2177+
2178+ function submitStart(form, submitter) {
2179+ var btn = submitter || form.querySelector(SUBMIT_SEL);
2180+ var busy = { timer: null, btn: btn, key: submitKey(form, btn) };
2181+ busy.timer = setTimeout(function () {
2182+ if (!btn) { return; }
2183+ btn.classList.add('is-busy');
2184+ btn.setAttribute('aria-busy', 'true');
2185+ }, BUSY_MS);
2186+ form.__busy = busy;
2187+ }
2188+
2189+ // The button a finished POST came from, in the page now shown: the same-index form with the same
2190+ // action and method, then its button by name and value, then by text, then its first submit button.
2191+ function doneButton(key) {
2192+ var form = sameForms(key.action, key.method)[key.index];
2193+ if (!form) { return null; }
2194+ var buttons = form.querySelectorAll('button, input[type=submit]');
2195+ var i;
2196+ if (key.name) {
2197+ for (i = 0; i < buttons.length; i++) {
2198+ if (buttons[i].name === key.name && buttons[i].value === key.value) { return buttons[i]; }
2199+ }
2200+ }
2201+ if (key.text) {
2202+ for (i = 0; i < buttons.length; i++) {
2203+ if (buttonLabel(buttons[i]) === key.text) { return buttons[i]; }
2204+ }
2205+ }
2206+ return form.querySelector(SUBMIT_SEL);
2207+ }
2208+
2209+ function showTick(btn, word) {
2210+ var svgNs = 'http://www.w3.org/2000/svg';
2211+ var tick = document.createElement('span');
2212+ tick.className = 'done-tick';
2213+ tick.setAttribute('role', 'status');
2214+ var svg = document.createElementNS(svgNs, 'svg');
2215+ svg.setAttribute('class', 'ico');
2216+ svg.setAttribute('viewBox', '0 0 24 24');
2217+ svg.setAttribute('aria-hidden', 'true');
2218+ var path = document.createElementNS(svgNs, 'path');
2219+ path.setAttribute('d', 'M5 12.5l4.5 4.5L19 7.5');
2220+ svg.appendChild(path);
2221+ tick.appendChild(svg);
2222+ tick.appendChild(document.createTextNode(word));
2223+ btn.insertAdjacentElement('afterend', tick);
2224+ setTimeout(function () { tick.remove(); }, TICK_MS);
2225+ }
2226+
2227+ function submitDone(o, current) {
2228+ var form = o.form;
2229+ var busy = form && form.__busy;
2230+ if (!busy) { return; }
2231+ form.__busy = null;
2232+ clearTimeout(busy.timer);
2233+ if (busy.btn && document.documentElement.contains(busy.btn)) {
2234+ busy.btn.classList.remove('is-busy');
2235+ busy.btn.removeAttribute('aria-busy');
2236+ }
2237+ var r = o.result;
2238+ if (!current || !r || !r.html || !r.redirected || !(r.status < 400)) { return; }
2239+ // A refusal sent back on the query (merge_error, branch_error, error...) is not a success.
2240+ if (/[?&]\w*error=/.test(r.url.search)) { return; }
2241+ var key = busy.key;
2242+ if (key.banner || document.querySelector('main .alert, main [role="alert"]')) { return; }
2243+ var word = document.body.getAttribute(key.dirty ? 'data-done-saved' : 'data-done-ok');
2244+ var target = doneButton(key);
2245+ if (target && word) { showTick(target, word); }
2246+ }
2247+
2248+ // Comment drafts. Free text in a POST form (comments, bodies, wiki pages, the profile about) is kept
2249+ // in localStorage as the reader types, so a closed tab, a crash or a navigation keeps it. An empty
2250+ // field with a draft gets the text back, with a note to discard it. A successful post clears them.
2251+ function draftConfig() {
2252+ // A function, not a var: syncDrafts runs at startup, above this block, and needs these values.
2253+ return {
2254+ prefix: 'forge-draft:',
2255+ maxAge: 7 * 24 * 60 * 60 * 1000,
2256+ max: 50,
2257+ fields: 'form[method="post"] textarea[name="body"], form[method="post"] textarea[name="content"], form[method="post"] textarea[name="about"]'
2258+ };
2259+ }
2260+ var draftTimers = new WeakMap(); // a field's pending save: typing again restarts its 400 ms wait
2261+ var draftsOnSubmit = new WeakMap(); // a form being posted: the draft keys it held when it was sent
2262+
2263+ function draftText(name) {
2264+ return (document.body && document.body.getAttribute('data-draft-' + name)) || '';
2265+ }
2266+
2267+ // Each field's key: its page, the action it posts to, its name, and its occurrence among the same.
2268+ function draftFields() {
2269+ var cfg = draftConfig();
2270+ var seen = Object.create(null);
2271+ return Array.prototype.map.call(document.querySelectorAll(cfg.fields), function (el) {
2272+ var base = cfg.prefix + location.pathname + '|' + ((el.form && el.form.getAttribute('action')) || '') + '|' + el.name;
2273+ var n = seen[base] || 0;
2274+ seen[base] = n + 1;
2275+ return { el: el, k: base + '#' + n };
2276+ });
2277+ }
2278+
2279+ function draftKey(el) {
2280+ var items = draftFields();
2281+ for (var i = 0; i < items.length; i++) {
2282+ if (items[i].el === el) { return items[i].k; }
2283+ }
2284+ return null;
2285+ }
2286+
2287+ function readDraft(key) {
2288+ try {
2289+ var rec = JSON.parse(localStorage.getItem(key));
2290+ return rec && typeof rec.v === 'string' && typeof rec.at === 'number' ? rec : null;
2291+ } catch (err) { return null; }
2292+ }
2293+
2294+ // An empty text removes the draft. Storage can refuse (private mode, a full quota): the draft is then
2295+ // not kept, and the page works as before.
2296+ function setDraft(key, text) {
2297+ try {
2298+ if (text === '') { localStorage.removeItem(key); }
2299+ else { localStorage.setItem(key, JSON.stringify({ v: text, at: Date.now() })); }
2300+ } catch (err) { }
2301+ }
2302+
2303+ // A draft older than the limit is no draft: it is removed as it is found.
2304+ function freshDraft(key) {
2305+ var rec = readDraft(key);
2306+ if (!rec) { return null; }
2307+ if (Date.now() - rec.at > draftConfig().maxAge) { setDraft(key, ''); return null; }
2308+ return rec;
2309+ }
2310+
2311+ // At startup: drop drafts older than the limit and, past the cap, the oldest ones.
2312+ function pruneDrafts() {
2313+ var cfg = draftConfig();
2314+ try {
2315+ var live = [];
2316+ for (var i = localStorage.length - 1; i >= 0; i--) {
2317+ var key = localStorage.key(i);
2318+ if (!key || key.indexOf(cfg.prefix) !== 0) { continue; }
2319+ var rec = freshDraft(key);
2320+ if (rec) { live.push({ k: key, at: rec.at }); }
2321+ }
2322+ live.sort(function (a, b) { return b.at - a.at; });
2323+ live.slice(cfg.max).forEach(function (d) { setDraft(d.k, ''); });
2324+ } catch (err) { }
2325+ }
2326+
2327+ // Puts each stored draft into the empty field it belongs to, once per field, with a note under it.
2328+ function restoreDrafts() {
2329+ draftFields().forEach(function (item) {
2330+ var el = item.el;
2331+ if (el.hasAttribute('data-draft-done') || el.value !== '') { return; }
2332+ var rec = freshDraft(item.k);
2333+ if (!rec) { return; }
2334+ el.setAttribute('data-draft-done', '');
2335+ el.value = rec.v;
2336+ // The input event lets the dirty-form logic see the field as changed.
2337+ el.dispatchEvent(new Event('input', { bubbles: true }));
2338+ var note = document.createElement('p');
2339+ note.className = 'draft-note';
2340+ note.appendChild(document.createTextNode(draftText('restored') + ' · '));
2341+ var discard = document.createElement('button');
2342+ discard.type = 'button';
2343+ discard.className = 'link-button';
2344+ discard.setAttribute('data-draft-discard', '');
2345+ discard.textContent = draftText('discard');
2346+ note.appendChild(discard);
2347+ el.insertAdjacentElement('afterend', note);
2348+ });
2349+ }
2350+
2351+ // A swap adopts the new body before its history entry is pushed, so the restore waits a tick and
2352+ // the keys then carry the page's own path.
2353+ function syncDrafts() { setTimeout(restoreDrafts, 0); }
2354+
2355+ pruneDrafts();
2356+
2357+ // A save waits 400 ms after the last keystroke. The key is taken at the keystroke, so a save still
2358+ // lands under the page it was typed on when the reader leaves within that wait.
2359+ document.addEventListener('input', function (e) {
2360+ var el = e.target;
2361+ if (!el || !el.matches || !el.matches(draftConfig().fields)) { return; }
2362+ var key = draftKey(el);
2363+ if (!key) { return; }
2364+ clearTimeout(draftTimers.get(el));
2365+ draftTimers.set(el, setTimeout(function () { setDraft(key, el.value); }, 400));
2366+ });
2367+
2368+ // The keys a form holds are taken as it is sent: after a swap the old form is detached.
2369+ document.addEventListener('submit', function (e) {
2370+ var form = e.target;
2371+ if (!form || !form.matches || !form.matches('form[method="post"]')) { return; }
2372+ var items = draftFields().filter(function (item) { return form.contains(item.el); });
2373+ // A save still waiting would land after a confirmed post cleared the draft: it is made now.
2374+ items.forEach(function (item) {
2375+ clearTimeout(draftTimers.get(item.el));
2376+ setDraft(item.k, item.el.value);
2377+ });
2378+ draftsOnSubmit.set(form, items.map(function (item) { return item.k; }));
2379+ }, true);
2380+
2381+ // A post the server confirmed clears the drafts it held. A failed one keeps them.
2382+ document.addEventListener('forge:submitted', function (e) {
2383+ var form = e.detail ? e.detail.form : null;
2384+ var keys = form ? draftsOnSubmit.get(form) : null;
2385+ if (!keys) { return; }
2386+ draftsOnSubmit.delete(form);
2387+ if (e.detail.ok) { keys.forEach(function (k) { setDraft(k, ''); }); }
2388+ });
2389+
2390+ // Discard: the field is emptied, its draft removed, and the note goes.
2391+ document.addEventListener('click', function (e) {
2392+ var btn = e.target && e.target.closest ? e.target.closest('button[data-draft-discard]') : null;
2393+ if (!btn) { return; }
2394+ var note = btn.parentNode;
2395+ var field = note.previousElementSibling;
2396+ if (field && field.matches(draftConfig().fields)) {
2397+ clearTimeout(draftTimers.get(field));
2398+ var key = draftKey(field);
2399+ if (key) { setDraft(key, ''); }
2400+ field.value = '';
2401+ field.dispatchEvent(new Event('input', { bubbles: true }));
2402+ }
2403+ note.remove();
2404+ });
2405+
2406+ // List memory: a list page keeps its filters (per path, in sessionStorage) and its scroll position
2407+ // when the reader leaves and comes back. Paging parameters are not filters.
2408+ var LIST_PAGE = /^\/[^\/]+\/[^\/]+\/(issues|pulls|ci|commits\/.*|releases|tags|branches|discussions|labels|milestones|merge-queue|search)$|^\/(explore|notifications|review-requests|admin\/users|admin\/runners|admin\/audit|settings\/security\/log|org\/[^\/]+\/members)$/;
2409+ var LIST_PAGING = ['page', 'before', 'after', 'cursor'];
2410+ var LIST_Y_TTL = 30 * 60 * 1000; // ms a remembered scroll position is still used
2411+
2412+ function listStore(key, value) {
2413+ try {
2414+ if (value === null) { sessionStorage.removeItem(key); } else { sessionStorage.setItem(key, value); }
2415+ } catch (err) { }
2416+ }
2417+
2418+ function listLoad(key) {
2419+ try { return sessionStorage.getItem(key); } catch (err) { return null; }
2420+ }
2421+
2422+ // The filters of a list page's search, with a leading `?`, or '' when there are none.
2423+ function listFilters(search) {
2424+ var params = new URLSearchParams(search);
2425+ LIST_PAGING.forEach(function (key) { params.delete(key); });
2426+ var text = params.toString();
2427+ return text ? '?' + text : '';
2428+ }
2429+
2430+ // An empty filter set forgets the page: a cleared list comes back clear.
2431+ function rememberList(path, search) {
2432+ if (!LIST_PAGE.test(path)) { return; }
2433+ var filters = listFilters(search);
2434+ listStore('forge-list:' + path, filters || null);
2435+ }
2436+
2437+ rememberList(location.pathname, location.search);
2438+
2439+ document.addEventListener('forge:swapped', function (e) {
2440+ var url = e.detail.url;
2441+ rememberList(url.pathname, url.search);
2442+ // Only a navigation lands at the top of a list the reader had scrolled; back and forward have their own place.
2443+ if (e.detail.how !== 'nav' || !LIST_PAGE.test(url.pathname) || url.hash) { return; }
2444+ var saved = null;
2445+ try { saved = JSON.parse(listLoad('forge-list-y:' + url.pathname + url.search) || 'null'); } catch (err) { saved = null; }
2446+ if (!saved || typeof saved.y !== 'number' || Date.now() - saved.t > LIST_Y_TTL) { return; }
2447+ // Only when the page is tall enough to reach the place; a shorter page would scroll to its end.
2448+ if (document.documentElement.scrollHeight - window.innerHeight < saved.y) { return; }
2449+ window.scrollTo(0, saved.y);
2450+ });
2451+
2452+ // Runs before the navigation handler below: a link to a list's bare path goes to its remembered
2453+ // filters, unless the reader is on that list already (then the bare link clears them).
2454+ window.addEventListener('click', function (e) {
2455+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) { return; }
2456+ var a = e.target && e.target.closest ? e.target.closest('a[href]') : null;
2457+ if (!a || a.target || a.hasAttribute('download') || a.hasAttribute('data-hard')) { return; }
2458+ var href = a.getAttribute('href') || '';
2459+ if (href.charAt(0) !== '/' || href.charAt(1) === '/') { return; }
2460+ var url = pageUrl(href);
2461+ if (!url) { return; }
2462+ // Leaving a list by a link: its scroll position is kept for when the reader comes back.
2463+ if (LIST_PAGE.test(location.pathname) && !(url.pathname + url.search === shown && url.hash)) {
2464+ listStore('forge-list-y:' + shown, JSON.stringify({ y: window.scrollY, t: Date.now() }));
2465+ }
2466+ if (href === url.pathname && url.pathname !== location.pathname && LIST_PAGE.test(href)) {
2467+ var kept = listLoad('forge-list:' + href);
2468+ if (kept) { a.setAttribute('href', href + kept); }
2469+ }
2470+ }, true);
2471+
2472+ // Command palette
2473+ // Ctrl+K (Cmd+K on a Mac, or the topbar button) opens a dialog that jumps to the viewer's repos,
2474+ // orgs and pages. The server list is fetched on the first open and kept for a minute; on a repo
2475+ // page that repo's tabs are read from the page instead, so they never wait for the server.
2476+ var PALETTE_TTL = 60000; // ms a fetched list stays fresh
2477+ var PALETTE_MAX = 50; // options shown at once
2478+ var PALETTE_WORD = /[\s\/._\-·]/; // a character that starts a word, for the word-start match
2479+ var pal = { dlg: null, input: null, list: null, note: null, hits: [], sel: 0, str: null,
2480+ data: null, request: null, failed: false };
2481+
2482+ // The words the palette shows, read from the topbar button: the server writes them in the viewer's
2483+ // language, so this script carries no text of its own.
2484+ function paletteStrings(opener) {
2485+ function word(name) { return opener.getAttribute('data-' + name) || ''; }
2486+ return {
2487+ label: opener.getAttribute('aria-label') || '',
2488+ placeholder: word('placeholder'),
2489+ hint: word('hint'),
2490+ empty: word('empty'),
2491+ loading: word('loading'),
2492+ failed: word('failed'),
2493+ heads: { repo: word('repos'), org: word('orgs'), page: word('pages') }
2494+ };
2495+ }
2496+
2497+ // How well the lowercased query matches a label: 3 for a prefix, 2 for a match at a word start,
2498+ // 1 for the letters in order anywhere, 0 for no match. A shorter label wins within a tier, and the
2499+ // bonus stays under 0.5 so it never lifts a label into the tier above. An empty query matches all.
2500+ function paletteScore(q, label) {
2501+ if (!q) { return 1; }
2502+ var s = label.toLowerCase();
2503+ var bonus = 1 / (s.length + 2);
2504+ var at = s.indexOf(q);
2505+ while (at >= 0) {
2506+ if (at === 0) { return 3 + bonus; }
2507+ if (PALETTE_WORD.test(s.charAt(at - 1))) { return 2 + bonus; }
2508+ at = s.indexOf(q, at + 1);
2509+ }
2510+ var qi = 0;
2511+ for (var i = 0; i < s.length && qi < q.length; i++) {
2512+ if (s.charAt(i) === q.charAt(qi)) { qi++; }
2513+ }
2514+ return qi === q.length ? 1 + bonus : 0;
2515+ }
2516+
2517+ // The destinations to filter: the current repo's tabs first, then the fetched list.
2518+ function paletteItems() {
2519+ var items = [];
2520+ var tabs = document.querySelectorAll('.repo-tabs a');
2521+ if (tabs.length) {
2522+ // The first tab is the repo's Code link, so its path starts with owner/name.
2523+ var parts = tabs[0].pathname.split('/');
2524+ var repo = parts.length >= 3 ? parts[1] + '/' + parts[2] : '';
2525+ if (repo) {
2526+ Array.prototype.forEach.call(tabs, function (a) {
2527+ // Counts sit in a span at the end of the tab ("Issues 3"); the name is the rest.
2528+ var name = a.textContent.replace(/\s+/g, ' ').trim().replace(/ \d+$/, '');
2529+ items.push({ label: repo + ' · ' + name, href: a.getAttribute('href') || '', kind: 'repo' });
2530+ });
2531+ }
2532+ }
2533+ return pal.data ? items.concat(pal.data.items) : items;
2534+ }
2535+
2536+ function paletteSelect(index) {
2537+ var opts = pal.list.querySelectorAll('li[role="option"]');
2538+ if (!opts.length) { pal.input.removeAttribute('aria-activedescendant'); return; }
2539+ pal.sel = Math.max(0, Math.min(opts.length - 1, index));
2540+ for (var i = 0; i < opts.length; i++) {
2541+ opts[i].setAttribute('aria-selected', i === pal.sel ? 'true' : 'false');
2542+ }
2543+ pal.input.setAttribute('aria-activedescendant', opts[pal.sel].id);
2544+ opts[pal.sel].scrollIntoView({ block: 'nearest' });
2545+ }
2546+
2547+ // Filters and draws the list. Groups keep the order of their best match, so a page named exactly
2548+ // like the query leads; with no query, the order is tabs, repos, orgs, then pages.
2549+ function renderPalette() {
2550+ var q = pal.input.value.trim().toLowerCase();
2551+ var scored = [];
2552+ paletteItems().forEach(function (item, idx) {
2553+ if (!Object.prototype.hasOwnProperty.call(pal.str.heads, item.kind)) { return; }
2554+ var s = paletteScore(q, item.label);
2555+ if (s > 0) { scored.push({ item: item, score: s, idx: idx }); }
2556+ });
2557+ scored.sort(function (a, b) { return b.score - a.score || a.idx - b.idx; });
2558+ scored = scored.slice(0, PALETTE_MAX);
2559+ var kinds = [], groups = {};
2560+ scored.forEach(function (h) {
2561+ var kind = h.item.kind;
2562+ if (!groups[kind]) { groups[kind] = []; kinds.push(kind); }
2563+ groups[kind].push(h.item);
2564+ });
2565+ pal.list.textContent = '';
2566+ pal.hits = [];
2567+ kinds.forEach(function (kind) {
2568+ var head = document.createElement('li');
2569+ head.className = 'palette-head';
2570+ head.setAttribute('role', 'presentation');
2571+ head.textContent = pal.str.heads[kind];
2572+ pal.list.appendChild(head);
2573+ groups[kind].forEach(function (item) {
2574+ var n = pal.hits.length;
2575+ pal.hits.push(item);
2576+ var li = document.createElement('li');
2577+ li.id = 'palette-opt-' + n;
2578+ li.setAttribute('role', 'option');
2579+ li.setAttribute('aria-selected', 'false');
2580+ li.setAttribute('data-n', String(n));
2581+ li.textContent = item.label;
2582+ pal.list.appendChild(li);
2583+ });
2584+ });
2585+ if (pal.hits.length) {
2586+ pal.note.textContent = pal.str.hint;
2587+ paletteSelect(0);
2588+ } else {
2589+ pal.note.textContent = pal.failed ? pal.str.failed : (pal.data ? pal.str.empty : pal.str.loading);
2590+ pal.input.removeAttribute('aria-activedescendant');
2591+ }
2592+ }
2593+
2594+ // Fetches the server list unless a fresh one is held or a request is already on the wire.
2595+ function paletteFetch() {
2596+ if (pal.request || (pal.data && Date.now() - pal.data.at < PALETTE_TTL)) { return; }
2597+ pal.failed = false;
2598+ pal.request = fetch('/-/palette', { headers: { accept: 'application/json' }, credentials: 'same-origin' }).then(function (r) {
2599+ if (!r.ok) { throw new Error('status ' + r.status); }
2600+ return r.json();
2601+ }).then(function (json) {
2602+ pal.data = { at: Date.now(), items: Array.isArray(json.items) ? json.items : [] };
2603+ pal.request = null;
2604+ if (pal.dlg.open) { renderPalette(); }
2605+ }).catch(function () {
2606+ pal.request = null;
2607+ pal.failed = true;
2608+ if (pal.dlg.open) { renderPalette(); }
2609+ });
2610+ }
2611+
2612+ // Leaves the palette for a destination. The dialog closes first, then the page loads the same way
2613+ // a sidebar link does; a link the browser must handle itself goes through location.
2614+ function paletteGo(href) {
2615+ if (!href) { return; }
2616+ pal.dlg.close();
2617+ var url = pageUrl(href);
2618+ if (!url) { location.assign(href); return; }
2619+ saveScroll();
2620+ load({ target: withoutHash(url), dest: url, init: GET_INIT, how: 'nav', keep: false, post: false, form: null });
2621+ }
2622+
2623+ // Built once. Its markup is static; every word in it arrives through the button's data attributes.
2624+ function buildPalette() {
2625+ var dlg = document.createElement('dialog');
2626+ dlg.className = 'palette';
2627+ dlg.innerHTML = '<div class="palette-box">' +
2628+ '<div class="palette-search"><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>' +
2629+ '<input type="text" class="palette-input" autocomplete="off" spellcheck="false" role="combobox" ' +
2630+ 'aria-expanded="true" aria-controls="palette-list" aria-autocomplete="list"></div>' +
2631+ '<ul id="palette-list" class="palette-list" role="listbox"></ul>' +
2632+ '<p class="palette-note muted small"></p></div>';
2633+ pal.dlg = dlg;
2634+ pal.input = dlg.querySelector('.palette-input');
2635+ pal.list = dlg.querySelector('.palette-list');
2636+ pal.note = dlg.querySelector('.palette-note');
2637+
2638+ pal.input.addEventListener('input', renderPalette);
2639+ pal.input.addEventListener('keydown', function (e) {
2640+ if (e.isComposing) { return; }
2641+ if (e.key === 'ArrowDown') { e.preventDefault(); paletteSelect(pal.sel + 1); }
2642+ else if (e.key === 'ArrowUp') { e.preventDefault(); paletteSelect(pal.sel - 1); }
2643+ else if (e.key === 'Enter') { e.preventDefault(); if (pal.hits[pal.sel]) { paletteGo(pal.hits[pal.sel].href); } }
2644+ });
2645+ // Hover selects; the check keeps a row that is already selected from being touched again.
2646+ pal.list.addEventListener('mousemove', function (e) {
2647+ var li = e.target && e.target.closest ? e.target.closest('li[role="option"]') : null;
2648+ if (li && Number(li.getAttribute('data-n')) !== pal.sel) { paletteSelect(Number(li.getAttribute('data-n'))); }
2649+ });
2650+ pal.list.addEventListener('click', function (e) {
2651+ var li = e.target && e.target.closest ? e.target.closest('li[role="option"]') : null;
2652+ if (li) { paletteGo(pal.hits[Number(li.getAttribute('data-n'))].href); }
2653+ });
2654+ // The backdrop is the dialog element itself; the box fills the rest.
2655+ dlg.addEventListener('click', function (e) { if (e.target === dlg) { dlg.close(); } });
2656+ }
2657+
2658+ function openPalette() {
2659+ var opener = document.querySelector('[data-palette-open]');
2660+ if (!opener) { return; }
2661+ if (!pal.dlg) { buildPalette(); }
2662+ var dlg = pal.dlg;
2663+ if (dlg.open) { return; }
2664+ // A page swap removes body children, the dialog among them, so it is put back on each open.
2665+ if (dlg.parentNode !== document.body) { document.body.appendChild(dlg); }
2666+ pal.str = paletteStrings(opener);
2667+ dlg.setAttribute('aria-label', pal.str.label);
2668+ pal.input.placeholder = pal.str.placeholder;
2669+ pal.input.setAttribute('aria-label', pal.str.placeholder);
2670+ if (typeof dlg.showModal !== 'function') { return; }
2671+ dlg.showModal();
2672+ pal.input.value = '';
2673+ renderPalette();
2674+ pal.input.focus();
2675+ paletteFetch();
2676+ }
2677+
2678+ // Ctrl+K and Cmd+K toggle the palette even while a text field has focus, since that is when a
2679+ // jump is most likely. Other modifiers keep their own meaning.
2680+ document.addEventListener('keydown', function (e) {
2681+ if (!(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey || (e.key !== 'k' && e.key !== 'K')) { return; }
2682+ if (!document.querySelector('[data-palette-open]')) { return; }
2683+ e.preventDefault();
2684+ if (pal.dlg && pal.dlg.open) { pal.dlg.close(); } else { openPalette(); }
2685+ });
2686+
2687+ document.addEventListener('click', function (e) {
2688+ var t = e.target;
2689+ if (!t || !t.closest) { return; }
2690+ if (t.closest('[data-palette-open]')) { e.preventDefault(); openPalette(); }
2691+ });
2692+
2693+ // Every relative time shows its exact moment on hover, in the reader's own time zone and language,
2694+ // so one format holds across the site whatever title the server wrote.
2695+ var relFormat = null, relLang = null;
2696+
2697+ function relTitles() {
2698+ var lang = root.getAttribute('lang') || '';
2699+ if (!relFormat || relLang !== lang) {
2700+ try {
2701+ relFormat = new Intl.DateTimeFormat(lang || undefined, { dateStyle: 'medium', timeStyle: 'short' });
2702+ relLang = lang;
2703+ } catch (err) { return; }
2704+ }
2705+ Array.prototype.forEach.call(document.querySelectorAll('time[data-rel][datetime]'), function (el) {
2706+ var at = Date.parse(el.getAttribute('datetime') || '');
2707+ if (isNaN(at)) { return; }
2708+ var exact = relFormat.format(at);
2709+ if (el.getAttribute('title') !== exact) { el.setAttribute('title', exact); }
2710+ });
2711+ }
19312712 })();
19322713
19332714 // Code browsing: line selection on blobs and blame, the permalink copy and `y` shortcut, the file
crates/forge-web/src/i18n/admin.rsmodified+28 -0
@@ -107,6 +107,7 @@ pub enum K {
107107 MailTransportInUse,
108108 MailQueueIntro,
109109 MailNothingMatches,
110+ MailQueueEmpty,
110111 MailPort,
111112 MailSettingsSaved,
112113 MovedToGhost,
@@ -116,6 +117,10 @@ pub enum K {
116117 NoRunnersYet,
117118 NoRunnerWithId,
118119 NoRunsYet,
120+ BackupsEmptyHint,
121+ ReplicationConfigHint,
122+ ReposEmptyHint,
123+ RunnersEmptyHint,
119124 Older,
120125 OwnLogIntro,
121126 PasswordStoredHint,
@@ -419,6 +424,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
419424 }
420425 (MailNothingMatches, En) => "No message is in this state.",
421426 (MailNothingMatches, Tr) => "Bu durumda ileti yok.",
427+ (MailQueueEmpty, En) => "Nothing waiting to be sent.",
428+ (MailQueueEmpty, Tr) => "Gönderilmeyi bekleyen ileti yok.",
422429 (MailHost, En) => "Host",
423430 (MailHost, Tr) => "Sunucu",
424431 (MailIntro, En) => {
@@ -445,6 +452,22 @@ pub fn t(lang: Lang, key: K) -> &'static str {
445452 (NoRunnerWithId, Tr) => "Bu kimlikte bir çalıştırıcı yok. Hiçbir şey değiştirilmedi.",
446453 (NoRunsYet, En) => "No runs yet.",
447454 (NoRunsYet, Tr) => "Henüz çalıştırma yok.",
455+ (BackupsEmptyHint, En) => "Scheduled and manual runs are listed here.",
456+ (BackupsEmptyHint, Tr) => "Zamanlanmış ve elle başlatılan çalıştırmalar burada listelenir.",
457+ (ReplicationConfigHint, En) => {
458+ "Replication is set under [replication] in the config file. See docs/backup.md."
459+ }
460+ (ReplicationConfigHint, Tr) => {
461+ "Replikasyon, yapılandırma dosyasındaki [replication] bölümünde ayarlanır. Bkz. docs/backup.md."
462+ }
463+ (ReposEmptyHint, En) => "Each repo is copied to the standby and listed here.",
464+ (ReposEmptyHint, Tr) => "Her depo yedek sunucuya kopyalanır ve burada listelenir.",
465+ (RunnersEmptyHint, En) => {
466+ "Create a registration token below, then run this command on the runner machine."
467+ }
468+ (RunnersEmptyHint, Tr) => {
469+ "Aşağıdan bir kayıt belirteci oluşturun, ardından bu komutu çalıştırıcı makinesinde çalıştırın."
470+ }
448471 (Older, En) => "Older",
449472 (Older, Tr) => "Daha eski",
450473 (OwnLogIntro, En) => {
@@ -896,6 +919,11 @@ mod tests {
896919 K::NoRunnersYet,
897920 K::NoRunnerWithId,
898921 K::NoRunsYet,
922+ K::BackupsEmptyHint,
923+ K::ReplicationConfigHint,
924+ K::ReposEmptyHint,
925+ K::RunnersEmptyHint,
926+ K::MailQueueEmpty,
899927 K::Older,
900928 K::OwnLogIntro,
901929 K::PasswordStoredHint,
crates/forge-web/src/i18n/browse.rsmodified+8 -0
@@ -53,6 +53,14 @@ strings! {
5353 FinderFailed => "The file list could not be loaded.", "Dosya listesi yüklenemedi.";
5454 FinderTruncated => "Very large tree: only the first files are searchable.", "Çok büyük ağaç: yalnızca ilk dosyalar aranabilir.";
5555
56+ PaletteOpen => "Open command palette", "Komut paletini aç";
57+ PalettePlaceholder => "Jump to…", "Şuraya git…";
58+ PaletteRepos => "Repositories", "Depolar";
59+ PalettePages => "Pages", "Sayfalar";
60+ PaletteNoMatches => "No matches", "Eşleşme yok";
61+ PaletteLoading => "Loading…", "Yükleniyor…";
62+ PaletteFailed => "The list could not be loaded.", "Liste yüklenemedi.";
63+
5664 BranchAuthorHeader => "Author", "Yazar";
5765 BranchAheadBehindHeader => "Ahead / behind", "Önde / geride";
5866 BranchActionsHeader => "Actions", "İşlemler";
crates/forge-web/src/i18n/code.rsmodified+6 -6
@@ -521,18 +521,18 @@ pub fn forks_count(lang: Lang, forks: u64) -> String {
521521 }
522522
523523 /// The mirror status after a successful sync.
524-pub fn mirror_synced(lang: Lang, at: &str) -> String {
524+pub fn mirror_synced(lang: Lang) -> (&'static str, &'static str) {
525525 match lang {
526- Lang::En => format!("last synced {at}"),
527- Lang::Tr => format!("son eşitleme: {at}"),
526+ Lang::En => ("last synced ", ""),
527+ Lang::Tr => ("son eşitleme: ", ""),
528528 }
529529 }
530530
531531 /// The mirror status after a failed sync.
532-pub fn mirror_sync_failed(lang: Lang, at: &str) -> String {
532+pub fn mirror_sync_failed(lang: Lang) -> (&'static str, &'static str) {
533533 match lang {
534- Lang::En => format!("last sync {at} failed"),
535- Lang::Tr => format!("son eşitleme {at} başarısız oldu"),
534+ Lang::En => ("last sync ", " failed"),
535+ Lang::Tr => ("son eşitleme ", " başarısız oldu"),
536536 }
537537 }
538538
crates/forge-web/src/i18n/community.rsmodified+18 -13
@@ -406,22 +406,27 @@ pub fn page_too_large(lang: Lang, max: usize) -> String {
406406 }
407407 }
408408
409-/// `2 files · updated 3 days ago` / `2 dosya · 3 gün önce güncellendi`.
410-/// `updated 3 days ago` / `3 gün önce güncellendi`.
411-pub fn updated_on(lang: Lang, updated: &str) -> String {
409+/// Words before a relative update time: `updated ` in English. Turkish puts the time first.
410+pub fn updated_before(lang: Lang) -> &'static str {
412411 match lang {
413- Lang::En => format!("updated {updated}"),
414- Lang::Tr => format!("{updated} güncellendi"),
412+ Lang::En => "updated ",
413+ Lang::Tr => "",
415414 }
416415 }
417416
418-pub fn files_updated(lang: Lang, count: u64, updated: &str) -> String {
417+/// Words after a relative update time: ` güncellendi` in Turkish. English puts the time last.
418+pub fn updated_after(lang: Lang) -> &'static str {
419419 match lang {
420- Lang::En => format!(
421- "{count} {} · updated {updated}",
422- if count == 1 { "file" } else { "files" }
423- ),
424- Lang::Tr => format!("{count} dosya · {updated} güncellendi"),
420+ Lang::En => "",
421+ Lang::Tr => " güncellendi",
422+ }
423+}
424+
425+/// `2 files` / `1 file` / `2 dosya`.
426+pub fn files_count(lang: Lang, count: u64) -> String {
427+ match lang {
428+ Lang::En => format!("{count} {}", if count == 1 { "file" } else { "files" }),
429+ Lang::Tr => format!("{count} dosya"),
425430 }
426431 }
427432
@@ -573,7 +578,7 @@ mod tests {
573578 assert_eq!(comments_count(Lang::En, 3), "3 comments");
574579 assert_eq!(comments_count(Lang::Tr, 3), "3 yorum");
575580 assert_eq!(page_number(Lang::Tr, 2), "Sayfa 2");
576- assert_eq!(files_updated(Lang::En, 2, "now"), "2 files · updated now");
577- assert_eq!(files_updated(Lang::En, 1, "now"), "1 file · updated now");
581+ assert_eq!(files_count(Lang::En, 2), "2 files");
582+ assert_eq!(files_count(Lang::En, 1), "1 file");
578583 }
579584 }
crates/forge-web/src/i18n/integrations.rsmodified+9 -10
@@ -17,6 +17,7 @@ pub enum K {
1717 ClearSecret,
1818 CreateWebhook,
1919 CurrentUrl,
20+ Cancel,
2021 DeleteConfirm,
2122 DeleteIntro,
2223 DeleteMirror,
@@ -54,7 +55,6 @@ pub enum K {
5455 ManualOnly,
5556 Mirrors,
5657 MirrorsIntro,
57- Never,
5858 NoDeliveries,
5959 NoMirrors,
6060 NoWebhooks,
@@ -164,7 +164,6 @@ pub const ALL: &[K] = &[
164164 K::ManualOnly,
165165 K::Mirrors,
166166 K::MirrorsIntro,
167- K::Never,
168167 K::NoDeliveries,
169168 K::NoMirrors,
170169 K::NoWebhooks,
@@ -268,8 +267,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
268267 (CreateWebhook, Tr) => "Web kancası oluştur",
269268 (CurrentUrl, En) => "Current URL:",
270269 (CurrentUrl, Tr) => "Mevcut URL:",
271- (DeleteConfirm, En) => "I understand this cannot be undone",
272- (DeleteConfirm, Tr) => "Bunun geri alınamayacağını anlıyorum",
270+ (Cancel, En) => "Cancel",
271+ (Cancel, Tr) => "Vazgeç",
272+ (DeleteConfirm, En) => "Delete it? This cannot be undone.",
273+ (DeleteConfirm, Tr) => "Silinsin mi? Bu işlem geri alınamaz.",
273274 (DeleteIntro, En) => {
274275 "Deleting removes the webhook and its delivery history. Events stop being sent to its URL at once."
275276 }
@@ -339,10 +340,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
339340 "Bu depo arşivlenmiş. Web kancaları salt okunurdur: değiştirilemez, test edilemez ya da yeniden teslim edilemez."
340341 }
341342 (HookNoticeConfirm, En) => {
342- "Tick the confirmation box to delete the webhook. Nothing was deleted."
343+ "The delete was not confirmed. Nothing was deleted."
343344 }
344345 (HookNoticeConfirm, Tr) => {
345- "Web kancasını silmek için onay kutusunu işaretleyin. Hiçbir şey silinmedi."
346+ "Silme onaylanmadı. Hiçbir şey silinmedi."
346347 }
347348 (HookNoticeCreated, En) => "Webhook created. A ping was queued.",
348349 (HookNoticeCreated, Tr) => "Web kancası oluşturuldu. Bir ping sıraya alındı.",
@@ -368,8 +369,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
368369 (MirrorsIntro, Tr) => {
369370 "Çekme yansısı bu depoyu uzak bir depoyla eşit tutar: dallar ve etiketler aralıkla ya da istendiğinde çekilir, göndermeler reddedilir. Gönderme yansısı her göndermeden sonra dalları ve etiketleri uzak depoya gönderir. Çekme istekleri ve sorunlar yerel kalır."
370371 }
371- (Never, En) => "never",
372- (Never, Tr) => "hiç",
373372 (NoDeliveries, En) => "No deliveries yet.",
374373 (NoDeliveries, Tr) => "Henüz teslimat yok.",
375374 (NoMirrors, En) => "No mirrors yet.",
@@ -381,10 +380,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
381380 (NoResponse, En) => "no response",
382381 (NoResponse, Tr) => "yanıt yok",
383382 (NoticeConfirm, En) => {
384- "Tick the confirmation box to delete the mirror. Nothing was deleted."
383+ "The delete was not confirmed. Nothing was deleted."
385384 }
386385 (NoticeConfirm, Tr) => {
387- "Yansıyı silmek için onay kutusunu işaretleyin. Hiçbir şey silinmedi."
386+ "Silme onaylanmadı. Hiçbir şey silinmedi."
388387 }
389388 (NoticeCreated, En) => {
390389 "Push mirror created. It will be pushed after the next push or on its interval."
crates/forge-web/src/i18n/issues.rsmodified+4 -0
@@ -151,6 +151,7 @@ pub enum K {
151151 SortUpdated,
152152 NewIssue,
153153 NoIssuesMatch,
154+ NoIssuesYet,
154155 SearchTitles,
155156 IssuesByState,
156157 LabelsAndMilestones,
@@ -460,6 +461,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
460461 (K::NewIssue, Lang::Tr) => "Yeni sorun",
461462 (K::NoIssuesMatch, Lang::En) => "No issues match these filters.",
462463 (K::NoIssuesMatch, Lang::Tr) => "Bu filtrelerle eşleşen sorun yok.",
464+ (K::NoIssuesYet, Lang::En) => "No issues yet.",
465+ (K::NoIssuesYet, Lang::Tr) => "Henüz sorun yok.",
463466 (K::SearchTitles, Lang::En) => "Search titles",
464467 (K::SearchTitles, Lang::Tr) => "Başlıklarda ara",
465468 (K::IssuesByState, Lang::En) => "Issues by state",
@@ -1032,6 +1035,7 @@ mod tests {
10321035 K::SortUpdated,
10331036 K::NewIssue,
10341037 K::NoIssuesMatch,
1038+ K::NoIssuesYet,
10351039 K::SearchTitles,
10361040 K::IssuesByState,
10371041 K::LabelsAndMilestones,
crates/forge-web/src/i18n/link.rsmodified+17 -1
@@ -7,6 +7,14 @@ use super::Lang;
77 pub enum K {
88 Restarting,
99 BackSubmit,
10+ /// The tick after a settings form saved.
11+ Saved,
12+ /// The tick after another form succeeded.
13+ Done,
14+ /// The note under a comment draft put back into its field.
15+ DraftRestored,
16+ /// The button that drops a restored draft.
17+ DraftDiscard,
1018 }
1119
1220 /// The phrase for `key`.
@@ -17,6 +25,14 @@ pub fn t(lang: Lang, key: K) -> &'static str {
1725 (Restarting, Lang::Tr) => "Sunucu yeniden başlıyor\u{2026} sayfanız korunuyor",
1826 (BackSubmit, Lang::En) => "Server is back, submit again",
1927 (BackSubmit, Lang::Tr) => "Sunucu geri geldi, tekrar gönderin",
28+ (Saved, Lang::En) => "Saved",
29+ (Saved, Lang::Tr) => "Kaydedildi",
30+ (Done, Lang::En) => "Done",
31+ (Done, Lang::Tr) => "Tamam",
32+ (DraftRestored, Lang::En) => "Draft restored",
33+ (DraftRestored, Lang::Tr) => "Taslak geri yüklendi",
34+ (DraftDiscard, Lang::En) => "Discard",
35+ (DraftDiscard, Lang::Tr) => "Vazgeç",
2036 }
2137 }
2238
@@ -27,7 +43,7 @@ mod tests {
2743 #[test]
2844 fn every_string_has_no_em_dash() {
2945 for lang in [Lang::En, Lang::Tr] {
30- for key in [K::Restarting, K::BackSubmit] {
46+ for key in [K::Restarting, K::BackSubmit, K::Saved, K::Done, K::DraftRestored, K::DraftDiscard] {
3147 assert!(!t(lang, key).contains('\u{2014}'));
3248 }
3349 }
crates/forge-web/src/i18n/migrate.rsmodified+4 -4
@@ -325,11 +325,11 @@ pub fn t(lang: Lang, key: K) -> &'static str {
325325 }
326326 }
327327
328-/// "Expires in N days" style line for the export list.
329-pub fn expires_on(lang: Lang, date: &str) -> String {
328+/// The label before an export's expiry time, which follows as a relative time.
329+pub fn expires_label(lang: Lang) -> &'static str {
330330 match lang {
331- Lang::En => format!("Expires {date}"),
332- Lang::Tr => format!("Son geçerlilik {date}"),
331+ Lang::En => "Expires",
332+ Lang::Tr => "Son geçerlilik",
333333 }
334334 }
335335
crates/forge-web/src/i18n/orgs.rsmodified+4 -0
@@ -120,6 +120,7 @@ pub enum K {
120120 TabStars,
121121 FilterRepos,
122122 NoReposMatch,
123+ ClearSearch,
123124 // Dashboard and landing.
124125 Dashboard,
125126 Home,
@@ -367,6 +368,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
367368 (FilterRepos, Tr) => "Depo ara",
368369 (NoReposMatch, En) => "No repositories match.",
369370 (NoReposMatch, Tr) => "Aramayla eşleşen depo yok.",
371+ (ClearSearch, En) => "Clear search",
372+ (ClearSearch, Tr) => "Aramayı temizle",
370373 (Dashboard, En) => "Dashboard",
371374 (Dashboard, Tr) => "Pano",
372375 (Home, En) => "Home",
@@ -607,6 +610,7 @@ mod tests {
607610 K::TabStars,
608611 K::FilterRepos,
609612 K::NoReposMatch,
613+ K::ClearSearch,
610614 K::Dashboard,
611615 K::Home,
612616 K::LandingTagline,
crates/forge-web/src/i18n/packages.rsmodified+3 -0
@@ -41,6 +41,7 @@ pub enum K {
4141 DeleteTagMessage,
4242 DeleteTagConfirm,
4343 NoTags,
44+ NoVersions,
4445 PackageTagCount,
4546 PackageTagCountOne,
4647 }
@@ -83,6 +84,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
8384 (DeleteTagConfirm, Tr) => "Evet, sil",
8485 (NoTags, En) => "No tags yet. Push an image to see it here.",
8586 (NoTags, Tr) => "Henüz etiket yok. Burada görmek için bir imaj gönderin.",
87+ (NoVersions, En) => "No versions published yet.",
88+ (NoVersions, Tr) => "Henüz sürüm yayımlanmadı.",
8689 (PackageTagCount, En) => "tags",
8790 (PackageTagCount, Tr) => "etiket",
8891 (PackageTagCountOne, En) => "tag",
crates/forge-web/src/i18n/push.rsmodified+8 -8
@@ -97,19 +97,19 @@ pub fn test_sent(lang: Lang, devices: usize) -> String {
9797 }
9898 }
9999
100-/// "Added 2026-10-02" and the matching delivery line.
101-pub fn added_on(lang: Lang, date: &str) -> String {
100+/// The label before a device's added time: "Added 3 days ago" with the time after it.
101+pub fn added_label(lang: Lang) -> &'static str {
102102 match lang {
103- Lang::En => format!("Added {date}"),
104- Lang::Tr => format!("Eklendi {date}"),
103+ Lang::En => "Added",
104+ Lang::Tr => "Eklendi",
105105 }
106106 }
107107
108-/// "Last delivered 2026-10-02".
109-pub fn last_delivered(lang: Lang, date: &str) -> String {
108+/// The label before a device's last delivery: "Last delivered 5 minutes ago".
109+pub fn last_delivered_label(lang: Lang) -> &'static str {
110110 match lang {
111- Lang::En => format!("Last delivered {date}"),
112- Lang::Tr => format!("Son teslim {date}"),
111+ Lang::En => "Last delivered",
112+ Lang::Tr => "Son teslim",
113113 }
114114 }
115115
crates/forge-web/src/i18n/releases_ci.rsmodified+2 -6
@@ -128,7 +128,6 @@ pub enum K {
128128 Assets,
129129 AllReleases,
130130 SourceCode,
131- Confirm,
132131 DeleteRelease,
133132 BackToRelease,
134133 UploadAsset,
@@ -347,8 +346,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
347346 (RelAssetInvalid, Tr) => {
348347 "Yüklenen dosya okunamadı. Hiçbir şey değiştirilmedi; yeniden deneyin."
349348 }
350- (RelConfirm, En) => "Tick the confirmation box to delete the release. Nothing was deleted.",
351- (RelConfirm, Tr) => "Sürümü silmek için onay kutusunu işaretleyin. Hiçbir şey silinmedi.",
349+ (RelConfirm, En) => "The delete was not confirmed. Nothing was deleted.",
350+ (RelConfirm, Tr) => "Silme onaylanmadı. Hiçbir şey silinmedi.",
352351 (RelInvalid, En) => {
353352 "Enter a title of up to 200 characters and release notes of up to 65536 characters. Nothing was changed."
354353 }
@@ -423,8 +422,6 @@ pub fn t(lang: Lang, key: K) -> &'static str {
423422 (AllReleases, Tr) => "Tüm sürümler",
424423 (SourceCode, En) => "Source code",
425424 (SourceCode, Tr) => "Kaynak kodu",
426- (Confirm, En) => "Confirm",
427- (Confirm, Tr) => "Onayla",
428425 (DeleteRelease, En) => "Delete release",
429426 (DeleteRelease, Tr) => "Sürümü sil",
430427 (BackToRelease, En) => "Back to the release",
@@ -656,7 +653,6 @@ mod tests {
656653 K::Assets,
657654 K::AllReleases,
658655 K::SourceCode,
659- K::Confirm,
660656 K::DeleteRelease,
661657 K::BackToRelease,
662658 K::UploadAsset,
crates/forge-web/src/i18n/repo_admin.rsmodified+41 -22
@@ -17,9 +17,11 @@ pub enum K {
1717 ApprovalsRange,
1818 ArchiveHeading,
1919 ArchiveHelp,
20+ ArchiveConfirm,
2021 ArchiveRepo,
2122 ArchivedHelp,
2223 ArchivedSecrets,
24+ Cancel,
2325 BadForm,
2426 BlockWhileChanges,
2527 BranchMissing,
@@ -31,7 +33,7 @@ pub enum K {
3133 BuiltinRowText,
3234 CancelRule,
3335 CancelTransfer,
34- ChangeVisibility,
36+ MakePrivate,
3537 CollabAdded,
3638 CollabRemoved,
3739 Collaborators,
@@ -58,7 +60,8 @@ pub enum K {
5860 ForcePushDesc,
5961 General,
6062 GeneralSaved,
61- IUnderstand,
63+ MakePublic,
64+ MakePublicConfirm,
6265 InvalidRole,
6366 LastUpdated,
6467 Mirrors,
@@ -140,7 +143,7 @@ pub enum K {
140143 ValueTooLarge,
141144 VisibilityChanged,
142145 VisibilityHeading,
143- VisibilityHelp,
146+ MakePrivateConfirm,
144147 Webhooks,
145148 }
146149
@@ -186,6 +189,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
186189 (ArchiveHelp, Tr) => {
187190 "Arşivleme depoyu salt okunur yapar: gönderimler reddedilir; sorunlar, etiketler ve kilometre taşları değiştirilemez. Arşivden istediğiniz zaman çıkarabilirsiniz."
188191 }
192+ (ArchiveConfirm, En) => "Archive this repository? You can unarchive it at any time.",
193+ (ArchiveConfirm, Tr) => "Depo arşivlensin mi? İstediğiniz zaman arşivden çıkarabilirsiniz.",
194+ (Cancel, En) => "Cancel",
195+ (Cancel, Tr) => "Vazgeç",
189196 (ArchiveRepo, En) => "Archive repository",
190197 (ArchiveRepo, Tr) => "Depoyu arşivle",
191198 (ArchivedHelp, En) => {
@@ -226,8 +233,8 @@ pub fn t(lang: Lang, key: K) -> &'static str {
226233 (CancelRule, Tr) => "Vazgeç",
227234 (CancelTransfer, En) => "Cancel transfer",
228235 (CancelTransfer, Tr) => "Devri iptal et",
229- (ChangeVisibility, En) => "Change visibility",
230- (ChangeVisibility, Tr) => "Görünürlüğü değiştir",
236+ (MakePrivate, En) => "Make private",
237+ (MakePrivate, Tr) => "Özel yap",
231238 (CollabAdded, En) => "Collaborator added.",
232239 (CollabAdded, Tr) => "Ortak çalışan eklendi.",
233240 (CollabRemoved, En) => "Collaborator removed.",
@@ -300,8 +307,14 @@ pub fn t(lang: Lang, key: K) -> &'static str {
300307 (General, Tr) => "Genel",
301308 (GeneralSaved, En) => "General settings saved.",
302309 (GeneralSaved, Tr) => "Genel ayarlar kaydedildi.",
303- (IUnderstand, En) => "I understand",
304- (IUnderstand, Tr) => "Anlıyorum",
310+ (MakePublic, En) => "Make public",
311+ (MakePublic, Tr) => "Herkese açık yap",
312+ (MakePublicConfirm, En) => {
313+ "Make it public? Anyone will be able to read its code, issues and pull requests. It takes effect at once."
314+ }
315+ (MakePublicConfirm, Tr) => {
316+ "Herkese açık yapılsın mı? Kodunu, sorunlarını ve çekme isteklerini herkes okuyabilir. Hemen geçerli olur."
317+ }
305318 (InvalidRole, En) => "Choose a valid role.",
306319 (InvalidRole, Tr) => "Geçerli bir rol seçin.",
307320 (LastUpdated, En) => "Last updated",
@@ -487,10 +500,10 @@ pub fn t(lang: Lang, key: K) -> &'static str {
487500 (UnarchiveRepo, En) => "Unarchive repository",
488501 (UnarchiveRepo, Tr) => "Depoyu arşivden çıkar",
489502 (UnderstandNeeded, En) => {
490- "To change the visibility, tick I understand. Nothing was changed."
503+ "The change was not confirmed. Nothing was changed."
491504 }
492505 (UnderstandNeeded, Tr) => {
493- "Görünürlüğü değiştirmek için \"Anlıyorum\" kutusunu işaretleyin. Hiçbir şey değiştirilmedi."
506+ "Değişiklik onaylanmadı. Hiçbir şey değiştirilmedi."
494507 }
495508 (UnknownUser, En) => "No user has that username.",
496509 (UnknownUser, Tr) => "Bu kullanıcı adına sahip bir kullanıcı yok.",
@@ -504,11 +517,11 @@ pub fn t(lang: Lang, key: K) -> &'static str {
504517 (VisibilityChanged, Tr) => "Görünürlük değiştirildi.",
505518 (VisibilityHeading, En) => "Visibility",
506519 (VisibilityHeading, Tr) => "Görünürlük",
507- (VisibilityHelp, En) => {
508- "Tick I understand to change the visibility. The change takes effect at once."
520+ (MakePrivateConfirm, En) => {
521+ "Make it private? Only its owner, collaborators and instance admins will see it; others get a 404. It takes effect at once."
509522 }
510- (VisibilityHelp, Tr) => {
511- "Görünürlüğü değiştirmek için \"Anlıyorum\" kutusunu işaretleyin. Değişiklik hemen geçerli olur."
523+ (MakePrivateConfirm, Tr) => {
524+ "Özel yapılsın mı? Yalnızca sahibi, ortak çalışanları ve sunucu yöneticileri görebilir; diğerleri 404 hatası alır. Hemen geçerli olur."
512525 }
513526 (Webhooks, En) => "Webhooks",
514527 (Webhooks, Tr) => "Web kancaları",
@@ -601,8 +614,7 @@ pub fn transfer_summary(
601614 to_is_org: bool,
602615 to_name: &str,
603616 started_by: &str,
604- expires_on: &str,
605-) -> String {
617+) -> (String, &'static str) {
606618 match lang {
607619 Lang::En => {
608620 let target = if to_is_org {
@@ -610,8 +622,9 @@ pub fn transfer_summary(
610622 } else {
611623 to_name.to_owned()
612624 };
613- format!(
614- "Pending transfer to {target}, started by {started_by}. It expires on {expires_on} unless accepted."
625+ (
626+ format!("Pending transfer to {target}, started by {started_by}. It expires "),
627+ " unless accepted.",
615628 )
616629 }
617630 Lang::Tr => {
@@ -620,8 +633,11 @@ pub fn transfer_summary(
620633 } else {
621634 format!("{to_name} kullanıcısı")
622635 };
623- format!(
624- "{target} için bekleyen devir, {started_by} tarafından başlatıldı. Kabul edilmezse {expires_on} tarihinde sona erer."
636+ (
637+ format!(
638+ "{target} için bekleyen devir, {started_by} tarafından başlatıldı. Kabul edilmezse "
639+ ),
640+ " sona erer.",
625641 )
626642 }
627643 }
@@ -671,9 +687,11 @@ mod tests {
671687 K::ApprovalsRange,
672688 K::ArchiveHeading,
673689 K::ArchiveHelp,
690+ K::ArchiveConfirm,
674691 K::ArchiveRepo,
675692 K::ArchivedHelp,
676693 K::ArchivedSecrets,
694+ K::Cancel,
677695 K::BadForm,
678696 K::BlockWhileChanges,
679697 K::BranchMissing,
@@ -685,7 +703,7 @@ mod tests {
685703 K::BuiltinRowText,
686704 K::CancelRule,
687705 K::CancelTransfer,
688- K::ChangeVisibility,
706+ K::MakePrivate,
689707 K::CollabAdded,
690708 K::CollabRemoved,
691709 K::Collaborators,
@@ -712,7 +730,8 @@ mod tests {
712730 K::ForcePushDesc,
713731 K::General,
714732 K::GeneralSaved,
715- K::IUnderstand,
733+ K::MakePublic,
734+ K::MakePublicConfirm,
716735 K::InvalidRole,
717736 K::LastUpdated,
718737 K::Mirrors,
@@ -794,7 +813,7 @@ mod tests {
794813 K::ValueTooLarge,
795814 K::VisibilityChanged,
796815 K::VisibilityHeading,
797- K::VisibilityHelp,
816+ K::MakePrivateConfirm,
798817 K::Webhooks,
799818 ];
800819
crates/forge-web/src/package_ops.rsmodified+31 -3
@@ -4,6 +4,7 @@
44 //! `api::packages` and the pages translate these results. Bytes go to the blob store under
55 //! `packages/<version id>`, and each change is announced on the owner's live signal.
66
7+use forge_core::authz::{Action, authorize};
78 use forge_core::cargo;
89 use forge_core::model::User;
910 use forge_core::packages::{KIND_CARGO, KIND_OCI, NewPackageVersion, Package};
@@ -49,8 +50,32 @@ pub async fn owner_named(state: &AppState, name: &str) -> Result<Option<User>, P
4950 Ok(state.store.user_by_username(name).await?)
5051 }
5152
52-/// True when `actor` may read `package`. Public packages are readable by anyone. A private one
53-/// is readable by the instance admin, the owner and the owner's org members.
53+/// True when `actor` may read the repo a package is linked to. A link to a missing repo counts
54+/// as unreadable, so a dangling link never exposes the package.
55+async fn linked_repo_readable(
56+ state: &AppState,
57+ actor: Option<&User>,
58+ repo_id: &str,
59+) -> Result<bool, PackageError> {
60+ let Some(repo) = state.store.repo_by_id(repo_id).await? else {
61+ return Ok(false);
62+ };
63+ let (role, org_role) = match actor {
64+ Some(user) => (
65+ state.store.collaborator_role(&repo.id, &user.id).await?,
66+ state
67+ .store
68+ .org_repo_role(&repo.owner_id, &user.id, &repo.id)
69+ .await?,
70+ ),
71+ None => (None, None),
72+ };
73+ Ok(authorize(actor, &repo, role, org_role, Action::Read).is_ok())
74+}
75+
76+/// True when `actor` may read `package`. A public package is readable by anyone, unless it is
77+/// linked to a repo the actor may not read. A private one is readable by the instance admin, the
78+/// owner and the owner's org members.
5479 pub async fn may_read(
5580 state: &AppState,
5681 actor: Option<&User>,
@@ -58,7 +83,10 @@ pub async fn may_read(
5883 package: &Package,
5984 ) -> Result<bool, PackageError> {
6085 if !package.private {
61- return Ok(true);
86+ return match &package.repo_id {
87+ Some(repo_id) => linked_repo_readable(state, actor, repo_id).await,
88+ None => Ok(true),
89+ };
6290 }
6391 let Some(actor) = actor else {
6492 return Ok(false);
crates/forge-web/src/pages/admin_backups.rsmodified+9 -9
@@ -5,7 +5,6 @@
55 //! A button press is audited and redirects back here with a notice.
66
77 use forge_core::store::backup_runs::{BackupRun, RunKind};
8-use forge_core::tz::format_in_tz;
98 use forge_core::{AuditAction, Error, Store, User};
109 use serde::Deserialize;
1110 use topcoat::Result;
@@ -25,7 +24,7 @@ use crate::live::{Topic, stream_changes};
2524 use crate::pages::admin_users::admin_only;
2625 use crate::pages::issues_list::stamp_unix;
2726 use crate::state::AppState;
28-use crate::views::{enc, shell};
27+use crate::views::{empty_state, enc, rel_time, shell};
2928
3029 /// Runs shown on the page.
3130 const RUN_LIMIT: u32 = 20;
@@ -109,7 +108,7 @@ fn duration_text(run: &BackupRun) -> String {
109108 }
110109 }
111110
112-fn run_row(run: &BackupRun, tz: &str, lang: Lang) -> RunRow {
111+fn run_row(run: &BackupRun, lang: Lang) -> RunRow {
113112 let (status, detail) = match (run.finished_at.is_some(), run.ok) {
114113 (false, _) => (g::t(lang, K::StatusInProgress).to_owned(), String::new()),
115114 (true, Some(true)) => (g::t(lang, K::StatusOk).to_owned(), String::new()),
@@ -121,7 +120,7 @@ fn run_row(run: &BackupRun, tz: &str, lang: Lang) -> RunRow {
121120 RunRow {
122121 kind: g::kind_name(lang, run.kind).to_owned(),
123122 trigger: g::trigger_name(lang, run.trigger).to_owned(),
124- started: format_in_tz(stamp_unix(&run.started_at), tz),
123+ started: run.started_at.clone(),
125124 duration: duration_text(run),
126125 size: run.bytes.map(human_bytes).unwrap_or_default(),
127126 status,
@@ -166,7 +165,7 @@ async fn backups_view(
166165 <p class="muted">(g::running_line(lang, kind))</p>
167166 }
168167 <div class="actions">
169- <form method="post" action="/admin/backups/run">
168+ <form id="run-backup" method="post" action="/admin/backups/run">
170169 <input type="hidden" name="csrf" value=(csrf.as_str())>
171170 <button type="submit" class="primary">(g::t(lang, K::RunBackupNow))</button>
172171 </form>
@@ -179,7 +178,9 @@ async fn backups_view(
179178 <section class="card">
180179 <h2>(g::t(lang, K::RecentRuns))</h2>
181180 if rows.is_empty() {
182- <p class="muted">(g::t(lang, K::NoRunsYet))</p>
181+ empty_state(title: g::t(lang, K::NoRunsYet), hint: Some(g::t(lang, K::BackupsEmptyHint))) {
182+ <a class="button" href="#run-backup">(g::t(lang, K::RunBackupNow))</a>
183+ }
183184 } else {
184185 <div class="table-wrap">
185186 <table class="table queue-table">
@@ -198,7 +199,7 @@ async fn backups_view(
198199 <tr>
199200 <td data-label=(g::t(lang, K::TableKind))>(row.kind.as_str())</td>
200201 <td data-label=(g::t(lang, K::TableTrigger))>(row.trigger.as_str())</td>
201- <td class="small" data-label=(g::t(lang, K::TableStarted))>(row.started.as_str())</td>
202+ <td class="small" data-label=(g::t(lang, K::TableStarted))>rel_time(lang: lang, stamp: row.started.as_str())</td>
202203 <td class="small" data-label=(g::t(lang, K::TableDuration))>(row.duration.as_str())</td>
203204 <td class="small" data-label=(g::t(lang, K::TableSize))>(row.size.as_str())</td>
204205 <td data-label=(g::t(lang, K::TableResult))>
@@ -251,8 +252,7 @@ async fn backups_page(cx: &Cx) -> Result<impl View> {
251252 let state = app_context::<AppState>(cx);
252253 let lang = i18n::lang(cx, Some(&viewer.0));
253254 let runs = state.store.recent_runs(RUN_LIMIT).await?;
254- let tz = viewer.0.timezone.as_str();
255- let rows: Vec<RunRow> = runs.iter().map(|run| run_row(run, tz, lang)).collect();
255+ let rows: Vec<RunRow> = runs.iter().map(|run| run_row(run, lang)).collect();
256256 let running = state.jobs.running();
257257 let settings = settings_view(lang, &state.config.backup);
258258 let csrf = viewer.1.csrf_token.clone();
crates/forge-web/src/pages/admin_health.rsmodified+12 -18
@@ -12,7 +12,6 @@ use forge_core::mail::MailState;
1212 use forge_core::store::backup_runs::RunKind;
1313 use forge_core::store::replication::DB_SUBJECT;
1414 use forge_core::time::stamp_to_unix;
15-use forge_core::tz::format_in_tz;
1615 use tokio::process::Command;
1716 use topcoat::Result;
1817 use topcoat::context::{Cx, app_context};
@@ -205,7 +204,7 @@ fn uptime_secs() -> Option<u64> {
205204 Some((system - start_ticks / 100.0).max(0.0) as u64)
206205 }
207206
208-async fn gather(state: &AppState, lang: Lang, tz: &str) -> Result<Health> {
207+async fn gather(state: &AppState, lang: Lang) -> Result<Health> {
209208 let live = state.live();
210209 let now = now_unix();
211210 let data_dir = live.data_dir.clone();
@@ -321,7 +320,6 @@ async fn gather(state: &AppState, lang: Lang, tz: &str) -> Result<Health> {
321320 };
322321 services.push(match backup {
323322 Some(run) => {
324- let at_unix = stamp_to_unix(&run.started_at).unwrap_or(0);
325323 let (value, dot) = match run.ok {
326324 Some(true) => (at(lang, A::Ok), Dot::Ok),
327325 Some(false) => (at(lang, A::Failed), Dot::Bad),
@@ -331,7 +329,7 @@ async fn gather(state: &AppState, lang: Lang, tz: &str) -> Result<Health> {
331329 label: at(lang, A::LastBackup),
332330 dot,
333331 value: value.to_owned(),
334- detail: format_in_tz(at_unix, tz),
332+ detail: String::new(),
335333 stamp: Some(run.started_at.clone()),
336334 }
337335 }
@@ -426,39 +424,35 @@ async fn gather(state: &AppState, lang: Lang, tz: &str) -> Result<Health> {
426424 struct AlertRow {
427425 title: String,
428426 body: String,
429- /// The raised time as the server formats it, and its stamp for the live relative time.
430- date: String,
427+ /// The raised time, as a live relative time.
431428 stamp: String,
432429 }
433430
434431 /// The alerts active now, worded for the viewer.
435-async fn alert_rows(state: &AppState, lang: Lang, tz: &str) -> Result<Vec<AlertRow>> {
436- let now = now_unix();
432+async fn alert_rows(state: &AppState, lang: Lang) -> Result<Vec<AlertRow>> {
437433 Ok(state
438434 .store
439435 .active_alerts()
440436 .await?
441437 .into_iter()
442438 .map(|alert| {
443- let raised = stamp_to_unix(&alert.raised_at).unwrap_or(now);
444439 AlertRow {
445440 title: alert_text::title(lang, &alert.kind, &alert.subject, false),
446441 body: alert_text::body(lang, &alert.kind, &alert.subject, &alert.detail, false),
447- date: format_in_tz(raised, tz),
448442 stamp: alert.raised_at.clone(),
449443 }
450444 })
451445 .collect())
452446 }
453447
454-/// The alert's raised time: "since <date> · <live time>", worded per language.
448+/// The alert's raised time as a live relative time, worded per language.
455449 #[component]
456-async fn since_line(lang: Lang, date: &str, stamp: &str) -> Result<impl View> {
450+async fn since_line(lang: Lang, stamp: &str) -> Result<impl View> {
457451 Ok(view! {
458452 if matches!(lang, Lang::Tr) {
459- (date) " · " rel_time(lang: lang, stamp: stamp) " tarihinden beri"
453+ rel_time(lang: lang, stamp: stamp) " başladı"
460454 } else {
461- "since " (date) " · " rel_time(lang: lang, stamp: stamp)
455+ "raised " rel_time(lang: lang, stamp: stamp)
462456 }
463457 })
464458 }
@@ -496,7 +490,7 @@ async fn health_view(lang: Lang, health: Health, alerts: Vec<AlertRow>) -> Resul
496490 for a in alerts.into_iter() {
497491 <li>
498492 <strong>(a.title.as_str())</strong>
499- <span class="muted small">since_line(lang: lang, date: a.date.as_str(), stamp: a.stamp.as_str())</span>
493+ <span class="muted small">since_line(lang: lang, stamp: a.stamp.as_str())</span>
500494 if !a.body.is_empty() {
501495 <div class="small">(a.body.as_str())</div>
502496 }
@@ -565,8 +559,8 @@ async fn health_page(cx: &Cx) -> Result<impl View> {
565559 let viewer = admin_only(cx).await?;
566560 let lang = i18n::lang(cx, Some(&viewer.0));
567561 let state = app_context::<AppState>(cx);
568- let health = gather(state, lang, &viewer.0.timezone).await?;
569- let alerts = alert_rows(state, lang, &viewer.0.timezone).await?;
562+ let health = gather(state, lang).await?;
563+ let alerts = alert_rows(state, lang).await?;
570564 let title = at(lang, A::Health);
571565 Ok(view! {
572566 shell(title: title, viewer: Some(&viewer), health_view(lang: lang, health: health, alerts: alerts))
@@ -583,7 +577,7 @@ async fn health_fingerprint(state: &AppState) -> Result<String> {
583577 .store
584578 .mail_state_counts(&forge_core::time::now_stamp())
585579 .await?;
586- let alerts: Vec<(String, String)> = alert_rows(state, Lang::En, "UTC")
580+ let alerts: Vec<(String, String)> = alert_rows(state, Lang::En)
587581 .await?
588582 .into_iter()
589583 .map(|alert| (alert.title, alert.body))
crates/forge-web/src/pages/admin_mail.rsmodified+15 -19
@@ -12,7 +12,6 @@ use forge_core::mail::{
1212 MailKind, MailSettings, MailSettingsUpdate, MailState, OutboxEntry, Security,
1313 };
1414 use forge_core::time::now_stamp;
15-use forge_core::tz::format_in_tz;
1615 use forge_core::{AuditAction, Error};
1716 use futures_util::{Stream, stream};
1817 use serde::Deserialize;
@@ -33,9 +32,8 @@ use crate::i18n::{self, Key, Lang};
3332 use crate::mail::{enqueue, live, templates};
3433 use crate::pages::admin_users::admin_only;
3534 use crate::pages::ci_runs::{changed_event, events_response};
36-use crate::pages::issues_list::stamp_unix;
3735 use crate::state::AppState;
38-use crate::views::{enc, shell};
36+use crate::views::{empty_state, enc, rel_time, shell};
3937
4038 /// Rows shown in the queue at most.
4139 const LIST_LIMIT: u32 = 100;
@@ -65,7 +63,7 @@ struct QueueRow {
6563 attempts: u32,
6664 error: String,
6765 created: String,
68- sent: String,
66+ sent: Option<String>,
6967 failed: bool,
7068 }
7169
@@ -126,7 +124,7 @@ fn tab_class(on: bool) -> &'static str {
126124 }
127125 }
128126
129-fn row_view(entry: &OutboxEntry, now: &str, tz: &str, lang: Lang) -> QueueRow {
127+fn row_view(entry: &OutboxEntry, now: &str, lang: Lang) -> QueueRow {
130128 let state = entry.state_at(now);
131129 QueueRow {
132130 id: entry.id.clone(),
@@ -137,12 +135,8 @@ fn row_view(entry: &OutboxEntry, now: &str, tz: &str, lang: Lang) -> QueueRow {
137135 state_class: state_class(state),
138136 attempts: entry.attempts,
139137 error: entry.last_error.clone().unwrap_or_default(),
140- created: format_in_tz(stamp_unix(&entry.created_at), tz),
141- sent: entry
142- .sent_at
143- .as_deref()
144- .map(|sent| format_in_tz(stamp_unix(sent), tz))
145- .unwrap_or_default(),
138+ created: entry.created_at.clone(),
139+ sent: entry.sent_at.clone(),
146140 failed: state == MailState::Failed,
147141 }
148142 }
@@ -150,7 +144,6 @@ fn row_view(entry: &OutboxEntry, now: &str, tz: &str, lang: Lang) -> QueueRow {
150144 /// The queue tab's data. `filter` of `None` lists every state.
151145 async fn queue_data(
152146 state: &AppState,
153- tz: &str,
154147 lang: Lang,
155148 filter: Option<MailState>,
156149 ) -> forge_core::Result<QueueData> {
@@ -176,7 +169,7 @@ async fn queue_data(
176169 .list_mail(filter, &now, LIST_LIMIT)
177170 .await?
178171 .iter()
179- .map(|entry| row_view(entry, &now, tz, lang))
172+ .map(|entry| row_view(entry, &now, lang))
180173 .collect();
181174 Ok(QueueData {
182175 chips,
@@ -187,14 +180,13 @@ async fn queue_data(
187180
188181 async fn page_data(
189182 state: &AppState,
190- tz: &str,
191183 lang: Lang,
192184 tab: Tab,
193185 filter: Option<MailState>,
194186 ) -> forge_core::Result<PageData> {
195187 let settings: MailSettings = state.store.mail_settings().await?;
196188 let queue = match tab {
197- Tab::Queue => Some(queue_data(state, tz, lang, filter).await?),
189+ Tab::Queue => Some(queue_data(state, lang, filter).await?),
198190 Tab::Settings => None,
199191 };
200192 Ok(PageData {
@@ -296,7 +288,11 @@ async fn mail_view(
296288 </div>
297289 <div data-live="/admin/mail/events">
298290 if queue.rows.is_empty() {
299- <p class="muted">(g::t(lang, K::MailNothingMatches))</p>
291+ if queue.filter_param.is_empty() {
292+ empty_state(title: g::t(lang, K::MailQueueEmpty))
293+ } else {
294+ empty_state(title: g::t(lang, K::MailNothingMatches))
295+ }
300296 } else {
301297 <div class="table-wrap">
302298 <table class="table mail-queue queue-table">
@@ -316,13 +312,13 @@ async fn mail_view(
316312 <tbody>
317313 for row in queue.rows.into_iter() {
318314 <tr>
319- <td class="small" data-label=(g::t(lang, K::TableQueued))>(row.created.as_str())</td>
315+ <td class="small" data-label=(g::t(lang, K::TableQueued))>rel_time(lang: lang, stamp: row.created.as_str())</td>
320316 <td data-label=(g::t(lang, K::TableTo))>(row.to.as_str())</td>
321317 <td data-label=(g::t(lang, K::TableKind))>(row.kind)</td>
322318 <td data-label=(g::t(lang, K::TableSubject))>(row.subject.as_str())</td>
323319 <td data-label=(g::t(lang, K::TableState))><span class=(row.state_class)>(row.state)</span></td>
324320 <td data-label=(g::t(lang, K::TableTries))>(row.attempts)</td>
325- <td class="small" data-label=(g::t(lang, K::MailSentAt))>(row.sent.as_str())</td>
321+ <td class="small" data-label=(g::t(lang, K::MailSentAt))>if let Some(sent) = row.sent.as_deref() { rel_time(lang: lang, stamp: sent) }</td>
326322 <td class="small" data-label=(g::t(lang, K::TableLastError))>(row.error.as_str())</td>
327323 <td class="mail-actions">
328324 if row.failed {
@@ -369,7 +365,7 @@ async fn mail_page(cx: &Cx) -> Result<impl View> {
369365 Tab::Settings
370366 };
371367 let filter = query.state.as_deref().and_then(MailState::parse);
372- let data = page_data(state, viewer.0.timezone.as_str(), lang, tab, filter).await?;
368+ let data = page_data(state, lang, tab, filter).await?;
373369 let csrf = viewer.1.csrf_token.clone();
374370 let title = g::t(lang, K::Mail);
375371 Ok(view! {
crates/forge-web/src/pages/admin_replication.rsmodified+20 -26
@@ -10,7 +10,6 @@ use std::time::Duration;
1010
1111 use forge_core::store::replication::{DB_SUBJECT, ReplicationStatus};
1212 use forge_core::time::stamp_ago;
13-use forge_core::tz::format_in_tz;
1413 use forge_core::{AuditAction, Error};
1514 use serde::Deserialize;
1615 use topcoat::Result;
@@ -24,12 +23,11 @@ use topcoat::view::{View, component, view};
2423 use crate::audit::{self, Actor, Target};
2524 use crate::auth::check_csrf;
2625 use crate::i18n::admin::{self as g, K};
27-use crate::i18n::{self, Key, Lang};
26+use crate::i18n::{self, Lang};
2827 use crate::live::{Topic, stream_changes};
2928 use crate::pages::admin_users::admin_only;
30-use crate::pages::issues_list::stamp_unix;
3129 use crate::state::AppState;
32-use crate::views::{enc, shell};
30+use crate::views::{empty_state, enc, rel_time_or_never, shell};
3331
3432 #[query_params(error = bad_request)]
3533 pub(crate) struct NoticeQuery {
@@ -95,7 +93,8 @@ struct RepoRow {
9593 dot: &'static str,
9694 tone: &'static str,
9795 health: &'static str,
98- last_ok: String,
96+ /// The last good copy's stamp, shown as a live relative time.
97+ last_ok: Option<String>,
9998 error: String,
10099 }
101100
@@ -105,23 +104,16 @@ struct PageData {
105104 target: String,
106105 db_dot: &'static str,
107106 db_health: &'static str,
108- db_last_ok: String,
109- db_last_attempt: String,
107+ db_last_ok: Option<String>,
108+ db_last_attempt: Option<String>,
110109 db_error: String,
111110 interval: String,
112111 healthcheck: &'static str,
113112 repos: Vec<RepoRow>,
114113 }
115114
116-fn ok_text(stamp: Option<&str>, tz: &str, lang: Lang) -> String {
117- match stamp {
118- Some(stamp) => format_in_tz(stamp_unix(stamp), tz),
119- None => i18n::t(lang, Key::Never).to_owned(),
120- }
121-}
122-
123115 /// Builds the page data from the config, the status rows and the repo list.
124-async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result<PageData> {
116+async fn page_data(state: &AppState, lang: Lang) -> forge_core::Result<PageData> {
125117 let config = &state.config.replication;
126118 let db_cutoff = stamp_ago(Duration::from_secs(config.db_snapshot_minutes * 60 * 2));
127119 let repo_cutoff = stamp_ago(Duration::from_secs(config.reconcile_minutes * 60 * 2));
@@ -149,7 +141,7 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result
149141 dot: h.dot(),
150142 tone: h.tone(),
151143 health: h.label(lang),
152- last_ok: ok_text(status.and_then(|s| s.last_ok_at.as_deref()), tz, lang),
144+ last_ok: status.and_then(|s| s.last_ok_at.clone()),
153145 error: status
154146 .and_then(|s| s.last_error.clone())
155147 .unwrap_or_default(),
@@ -164,7 +156,7 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result
164156 dot: h.dot(),
165157 tone: h.tone(),
166158 health: h.label(lang),
167- last_ok: ok_text(status.last_ok_at.as_deref(), tz, lang),
159+ last_ok: status.last_ok_at.clone(),
168160 error: status.last_error.clone().unwrap_or_default(),
169161 });
170162 }
@@ -175,8 +167,8 @@ async fn page_data(state: &AppState, tz: &str, lang: Lang) -> forge_core::Result
175167 target: config.target.clone(),
176168 db_dot: health(db, &db_cutoff).dot(),
177169 db_health: health(db, &db_cutoff).label(lang),
178- db_last_ok: ok_text(db.and_then(|s| s.last_ok_at.as_deref()), tz, lang),
179- db_last_attempt: ok_text(db.and_then(|s| s.last_attempt_at.as_deref()), tz, lang),
170+ db_last_ok: db.and_then(|s| s.last_ok_at.clone()),
171+ db_last_attempt: db.and_then(|s| s.last_attempt_at.clone()),
180172 db_error: db.and_then(|s| s.last_error.clone()).unwrap_or_default(),
181173 interval: g::interval_line(lang, config.db_snapshot_minutes, config.reconcile_minutes),
182174 healthcheck: if config.healthcheck_url.is_empty() {
@@ -214,8 +206,8 @@ async fn replication_view(
214206 <dt>(g::t(lang, K::Interval))</dt><dd>(data.interval.as_str())</dd>
215207 <dt>(g::t(lang, K::Healthcheck))</dt><dd>(data.healthcheck)</dd>
216208 <dt>(g::t(lang, K::Database))</dt><dd><span class="admin-status"><span class=(data.db_dot) aria-hidden="true"></span>(data.db_health)</span></dd>
217- <dt>(g::t(lang, K::LastDbSnapshotShipped))</dt><dd class="small">(data.db_last_ok.as_str())</dd>
218- <dt>(g::t(lang, K::LastDbAttempt))</dt><dd class="small">(data.db_last_attempt.as_str())</dd>
209+ <dt>(g::t(lang, K::LastDbSnapshotShipped))</dt><dd class="small">rel_time_or_never(lang: lang, stamp: data.db_last_ok.as_deref())</dd>
210+ <dt>(g::t(lang, K::LastDbAttempt))</dt><dd class="small">rel_time_or_never(lang: lang, stamp: data.db_last_attempt.as_deref())</dd>
219211 </dl>
220212 if !data.db_error.is_empty() {
221213 <p class="error">(g::t(lang, K::DatabaseErrorPrefix))(data.db_error.as_str())</p>
@@ -233,7 +225,9 @@ async fn replication_view(
233225 <section class="card">
234226 <h2>(g::t(lang, K::Repos))</h2>
235227 if data.repos.is_empty() {
236- <p class="muted">(g::t(lang, K::NoReposYet))</p>
228+ empty_state(title: g::t(lang, K::NoReposYet), hint: Some(g::t(lang, K::ReposEmptyHint))) {
229+ <p class="muted small">(g::t(lang, K::ReplicationConfigHint))</p>
230+ }
237231 } else {
238232 <ul class="admin-rows">
239233 for row in data.repos.into_iter() {
@@ -243,7 +237,7 @@ async fn replication_view(
243237 <span class=(row.dot) aria-hidden="true"></span>
244238 <span class="admin-row-name">(row.name.as_str())</span>
245239 </div>
246- <p class="runner-meta muted">(g::t(lang, K::LastSuccess))": "(row.last_ok.as_str())</p>
240+ <p class="runner-meta muted">(g::t(lang, K::LastSuccess))": " rel_time_or_never(lang: lang, stamp: row.last_ok.as_deref())</p>
247241 if !row.error.is_empty() {
248242 <p class="admin-row-error">(row.error.as_str())</p>
249243 }
@@ -261,14 +255,14 @@ async fn replication_view(
261255 /// What the replication page shows, as one string. The health labels are read at each wake, so a
262256 /// wake also refreshes a copy that has gone stale since the last change.
263257 async fn page_fingerprint(state: &AppState) -> Result<String> {
264- let data = page_data(state, "UTC", Lang::En).await?;
258+ let data = page_data(state, Lang::En).await?;
265259 let rows: Vec<_> = data
266260 .repos
267261 .iter()
268262 .map(|row| (&row.name, row.health, &row.last_ok, &row.error))
269263 .collect();
270264 Ok(format!(
271- "{}|{}|{}|{}|{}|{}|{:?}",
265+ "{}|{}|{:?}|{:?}|{}|{}|{:?}",
272266 data.enabled,
273267 data.db_health,
274268 data.db_last_ok,
@@ -302,7 +296,7 @@ async fn replication_page(cx: &Cx) -> Result<impl View> {
302296 let query = query_params::<NoticeQuery>(cx)?;
303297 let lang = i18n::lang(cx, Some(&viewer.0));
304298 let state = app_context::<AppState>(cx);
305- let data = page_data(state, viewer.0.timezone.as_str(), lang).await?;
299+ let data = page_data(state, lang).await?;
306300 let csrf = viewer.1.csrf_token.clone();
307301 let title = g::t(lang, K::Replication);
308302 Ok(view! {
crates/forge-web/src/pages/admin_runners.rsmodified+5 -3
@@ -30,7 +30,7 @@ use crate::pages::admin_users::admin_only;
3030 use crate::pages::ci_runs::events_response;
3131 use crate::pages::repo_mirrors::stamp_in_tz;
3232 use crate::state::AppState;
33-use crate::views::{enc, now_unix, relative_time, shell};
33+use crate::views::{empty_state, enc, now_unix, relative_time, shell};
3434
3535 path_param!(runner_id);
3636
@@ -327,7 +327,9 @@ async fn runners_view(
327327 <section class="card">
328328 <h2>(g::t(lang, K::Runners))</h2>
329329 if rows.is_empty() {
330- <p class="muted">(g::t(lang, K::NoRunnersYet))</p>
330+ empty_state(title: g::t(lang, K::NoRunnersYet), hint: Some(g::t(lang, K::RunnersEmptyHint))) {
331+ <pre><code>"forge runner register --url <forge-url> --token <token> --name <name> --labels linux,x86_64"</code></pre>
332+ }
331333 } else {
332334 <ul class="runner-list">
333335 for row in rows.iter() {
@@ -1688,8 +1690,8 @@ mod tests {
16881690 "token in the box and the command"
16891691 );
16901692 let (_, list) = send(&router, "GET", "/admin/runners", Some(ADMIN_TOKEN), None).await;
1693+ // The empty list shows the register command with a placeholder, never the token.
16911694 assert!(!list.contains(&token), "the list never shows the token");
1692- assert!(!list.contains("forge runner register"));
16931695 // Only the hash is stored, so the list and the database hold no plain token.
16941696 assert!(store.list_runners().await.expect("list").is_empty());
16951697
crates/forge-web/src/pages/admin_user_detail.rsmodified+4 -8
@@ -5,7 +5,6 @@
55 use forge_core::names::normalize_name;
66 use forge_core::store::suspension::{AccountFacts, Suspension};
77 use forge_core::store::user_delete::GHOST_USERNAME;
8-use forge_core::tz::format_in_tz;
98 use forge_core::{AuditAction, Store, User};
109 use serde::Deserialize;
1110 use topcoat::Result;
@@ -23,10 +22,9 @@ use crate::i18n::admin::{self as g, K};
2322 use crate::i18n::{self, Key, Lang};
2423 use crate::live::{Topic, stream_changes};
2524 use crate::pages::admin_users::admin_only;
26-use crate::pages::issues_list::stamp_unix;
2725 use crate::pages::passkeys::s;
2826 use crate::state::AppState;
29-use crate::views::{alert, avatar_url, enc, rel_time_or_never, shell, user_facing_message};
27+use crate::views::{alert, avatar_url, enc, rel_time, rel_time_or_never, shell, user_facing_message};
3028
3129 #[query_params(error = bad_request)]
3230 pub(crate) struct DoneQuery {
@@ -113,7 +111,6 @@ fn done_text(lang: Lang, done: &str) -> Option<&'static str> {
113111 async fn detail_body(
114112 lang: Lang,
115113 csrf: &str,
116- tz: &str,
117114 viewer_id: &str,
118115 detail: Detail,
119116 notice: Notice,
@@ -127,7 +124,6 @@ async fn detail_body(
127124 } = detail;
128125 let base = format!("/admin/users/{}", enc(&target.id));
129126 let own = target.id == viewer_id;
130- let created = format_in_tz(stamp_unix(&target.created_at), tz);
131127 let last_login = facts.last_login.clone();
132128 let repos = facts.repo_count.to_string();
133129 let suspended = suspension.is_some();
@@ -181,7 +177,7 @@ async fn detail_body(
181177 if !email.is_empty() {
182178 (email.as_str()) " · "
183179 }
184- (at(lang, A::Joined)) " " (created.as_str()) " · " (at(lang, A::LastLogin)) " " rel_time_or_never(lang: lang, stamp: last_login.as_deref())
180+ (at(lang, A::Joined)) " " rel_time(lang: lang, stamp: target.created_at.as_str()) " · " (at(lang, A::LastLogin)) " " rel_time_or_never(lang: lang, stamp: last_login.as_deref())
185181 </p>
186182 </div>
187183 </div>
@@ -384,7 +380,7 @@ async fn detail_page(cx: &Cx) -> Result<impl View> {
384380 let csrf = viewer.1.csrf_token.clone();
385381 let title = detail.target.username.clone();
386382 Ok(view! {
387- shell(title: title.as_str(), viewer: Some(&viewer), detail_body(lang: lang, csrf: csrf.as_str(), tz: viewer.0.timezone.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice))
383+ shell(title: title.as_str(), viewer: Some(&viewer), detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice))
388384 })
389385 }
390386
@@ -546,7 +542,7 @@ async fn respond(cx: &Cx, form: ActionForm, action: Action) -> Result<impl View>
546542 let csrf = viewer.1.csrf_token.clone();
547543 let title = detail.target.username.clone();
548544 Ok(view! {
549- shell(title: title.as_str(), viewer: Some(&viewer), detail_body(lang: lang, csrf: csrf.as_str(), tz: viewer.0.timezone.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice))
545+ shell(title: title.as_str(), viewer: Some(&viewer), detail_body(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), detail: detail, notice: notice))
550546 })
551547 }
552548
crates/forge-web/src/pages/admin_users.rsmodified+4 -7
@@ -2,7 +2,6 @@
22
33 use forge_core::names::{normalize_name, validate_username};
44 use forge_core::store::user_delete::{DeletionReport, GHOST_USERNAME};
5-use forge_core::tz::format_in_tz;
65 use forge_core::{AuditAction, Session, Store, User};
76 use serde::Deserialize;
87 use topcoat::Result;
@@ -18,9 +17,8 @@ use crate::auth::{check_csrf, current_user, hash_password_async};
1817 use crate::i18n::admin::{self as g, K};
1918 use crate::i18n::{self, Key, Lang};
2019 use crate::live::{Topic, stream_changes};
21-use crate::pages::issues_list::stamp_unix;
2220 use crate::state::AppState;
23-use crate::views::{alert, enc, shell, user_facing_message};
21+use crate::views::{alert, enc, rel_time, shell, user_facing_message};
2422
2523 const MIN_PASSWORD_CHARS: usize = 12;
2624 const MAX_PASSWORD_BYTES: usize = 1024;
@@ -58,7 +56,6 @@ async fn users_view(
5856 lang: Lang,
5957 csrf: &str,
6058 viewer_id: &str,
61- tz: &str,
6259 users: Vec<User>,
6360 error: Option<String>,
6461 ) -> Result<impl View> {
@@ -85,7 +82,7 @@ async fn users_view(
8582 </td>
8683 <td data-label=(i18n::t(lang, Key::Email))>(user.email.clone().unwrap_or_default())</td>
8784 <td data-label=(g::t(lang, K::Role))>(if user.is_org() { g::t(lang, K::RoleOrganization) } else if user.is_admin { g::t(lang, K::RoleAdmin) } else { g::t(lang, K::RoleUser) })</td>
88- <td class="small nowrap" data-label=(i18n::t(lang, Key::Created))>(format_in_tz(stamp_unix(&user.created_at), tz))</td>
85+ <td class="small nowrap" data-label=(i18n::t(lang, Key::Created))>rel_time(lang: lang, stamp: user.created_at.as_str())</td>
8986 <td>
9087 if user.id != viewer_id && !is_ghost(&user) {
9188 <a class="danger" href=(format!("/admin/users/{}/delete", enc(&user.id)))>(i18n::t(lang, Key::Delete))</a>
@@ -168,7 +165,7 @@ async fn users_page(cx: &Cx) -> Result<impl View> {
168165 let csrf = viewer.1.csrf_token.clone();
169166 let title = g::t(lang, K::Users);
170167 Ok(view! {
171- shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), tz: viewer.0.timezone.as_str(), users: users, error: None))
168+ shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), users: users, error: None))
172169 })
173170 }
174171
@@ -205,7 +202,7 @@ async fn users_create(cx: &Cx, Form(form): Form<CreateUserForm>) -> Result<impl
205202 let csrf = viewer.1.csrf_token.clone();
206203 let title = g::t(lang, K::Users);
207204 Ok(view! {
208- shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), tz: viewer.0.timezone.as_str(), users: users, error: Some(message)))
205+ shell(title: title, viewer: Some(&viewer), users_view(lang: lang, csrf: csrf.as_str(), viewer_id: viewer.0.id.as_str(), users: users, error: Some(message)))
209206 })
210207 }
211208 }
crates/forge-web/src/pages/audit_log.rsmodified+9 -12
@@ -2,7 +2,6 @@
22 //! own security log (`/settings/security/log`: entries the viewer acted in, or that targeted
33 //! them). Both list newest first, 50 per page, continued with a cursor.
44
5-use forge_core::tz::format_in_tz;
65 use forge_core::{AuditAction, AuditCursor, AuditEntry, AuditFilter, Store};
76 use topcoat::Result;
87 use topcoat::context::{Cx, app_context};
@@ -15,9 +14,9 @@ use crate::i18n::admin::{self as g, K};
1514 use crate::i18n::{self, Lang};
1615 use crate::live::{Topic, stream_changes};
1716 use crate::pages::admin_users::admin_only;
18-use crate::pages::issues_list::{list_href, stamp_unix};
17+use crate::pages::issues_list::list_href;
1918 use crate::state::AppState;
20-use crate::views::shell;
19+use crate::views::{empty_state, rel_time, shell};
2120
2221 /// Entries per page.
2322 const PAGE_SIZE: usize = 50;
@@ -39,7 +38,7 @@ struct RowView {
3938 details: String,
4039 }
4140
42-fn row_view(entry: &AuditEntry, tz: &str, lang: Lang) -> RowView {
41+fn row_view(entry: &AuditEntry, lang: Lang) -> RowView {
4342 let actor = match (entry.actor_name.as_str(), entry.actor_id.is_some()) {
4443 ("", _) => g::t(lang, K::Anonymous).to_owned(),
4544 (name, _) => name.to_owned(),
@@ -55,7 +54,7 @@ fn row_view(entry: &AuditEntry, tz: &str, lang: Lang) -> RowView {
5554 format!("{}: {name}", entry.target_kind)
5655 };
5756 RowView {
58- when: format_in_tz(stamp_unix(&entry.at), tz),
57+ when: entry.at.clone(),
5958 actor,
6059 action: entry.action.as_str().to_owned(),
6160 target,
@@ -94,7 +93,7 @@ async fn fetch_page(
9493 async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result<impl View> {
9594 Ok(view! {
9695 if rows.is_empty() {
97- <p class="muted">(g::t(lang, K::NoEntries))</p>
96+ empty_state(title: g::t(lang, K::NoEntries))
9897 } else {
9998 <div class="table-wrap">
10099 <table class="table audit-table queue-table">
@@ -113,7 +112,7 @@ async fn audit_table(lang: Lang, rows: Vec<RowView>, show_actor: bool) -> Result
113112 <tbody>
114113 for row in rows.into_iter() {
115114 <tr>
116- <td class="small nowrap" data-label=(g::t(lang, K::TableWhen))>(row.when.as_str())</td>
115+ <td class="small nowrap" data-label=(g::t(lang, K::TableWhen))>rel_time(lang: lang, stamp: row.when.as_str())</td>
117116 if show_actor {
118117 <td data-label=(g::t(lang, K::TableActor))>(row.actor.as_str())</td>
119118 }
@@ -233,10 +232,9 @@ async fn admin_audit_page(cx: &Cx) -> Result<impl View> {
233232 fetch_page(store, &filter, query.before.as_deref()).await?
234233 };
235234
236- let tz = viewer.0.timezone.as_str();
237235 let rows: Vec<RowView> = entries
238236 .iter()
239- .map(|entry| row_view(entry, tz, lang))
237+ .map(|entry| row_view(entry, lang))
240238 .collect();
241239 let older_href = next.map(|cursor| {
242240 list_href(
@@ -311,10 +309,9 @@ async fn own_log_page(cx: &Cx) -> Result<impl View> {
311309 };
312310 let (entries, next) = fetch_page(store, &filter, query.before.as_deref()).await?;
313311
314- let tz = viewer.0.timezone.as_str();
315312 let rows: Vec<RowView> = entries
316313 .iter()
317- .map(|entry| row_view(entry, tz, lang))
314+ .map(|entry| row_view(entry, lang))
318315 .collect();
319316 let older_href =
320317 next.map(|cursor| list_href("/settings/security/log", &[("before", cursor.as_str())]));
@@ -479,7 +476,7 @@ mod tests {
479476 fn anonymous_actor_and_target_fallbacks() {
480477 let mut entry = AuditEntry::new(AuditAction::LoginFailed);
481478 entry.target_name = "mallory".into();
482- let row = row_view(&entry, "UTC", Lang::En);
479+ let row = row_view(&entry, Lang::En);
483480 assert_eq!(row.actor, "anonymous");
484481 assert_eq!(row.target, "mallory");
485482 assert_eq!(row.details, "");
crates/forge-web/src/pages/authoring.rsmodified+3 -1
@@ -278,7 +278,9 @@ async fn download(cx: &Cx) -> Result<Response> {
278278 );
279279 h.insert(
280280 HeaderName::from_static("cache-control"),
281- HeaderValue::from_static("private, max-age=3600"),
281+ // No max-age: a repo made private must stop serving its attachments at once, so
282+ // browsers revalidate on every use instead of reusing a cached copy.
283+ HeaderValue::from_static("private, no-cache"),
282284 );
283285 Ok(res)
284286 }
crates/forge-web/src/pages/branches.rsmodified+2 -2
@@ -29,7 +29,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo};
2929 use crate::pages::tree::{LastCommit, last_commit_view};
3030 use crate::post_update::after_ref_update;
3131 use crate::state::AppState;
32-use crate::views::{alert, iso_time, now_unix, relative_time, repo_href, shell};
32+use crate::views::{alert, empty_state, iso_time, now_unix, relative_time, repo_href, shell};
3333
3434 path_param!(owner);
3535 path_param!(repo);
@@ -317,7 +317,7 @@ async fn branches_page(cx: &Cx) -> Result<impl View> {
317317 default_branch: default_branch, options: options)
318318 }
319319 if empty {
320- <p class="muted">(g::t(lang, K::NothingHere))</p>
320+ empty_state(title: g::t(lang, K::NothingHere))
321321 } else {
322322 branch_table(rows: rows, lang: lang, csrf: csrf.clone(), delete_action: delete_action, can_delete: can_write)
323323 }
crates/forge-web/src/pages/ci_job.rsmodified+25 -4
@@ -11,8 +11,8 @@ use std::sync::Arc;
1111 use std::time::Duration;
1212
1313 use bytes::Bytes;
14-use forge_core::Store;
1514 use forge_core::ci::{CiArtifact, CiJob, CiRun};
15+use forge_core::{Store, User};
1616 use futures_util::{Stream, TryStreamExt};
1717 use http::header::{CONTENT_DISPOSITION, CONTENT_LENGTH, CONTENT_TYPE};
1818 use http_body::Frame;
@@ -38,7 +38,7 @@ use crate::pages::ci_runs::{
3838 state_text,
3939 };
4040 use crate::pages::repo::repo_head;
41-use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
41+use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable};
4242 use crate::state::AppState;
4343 use crate::views::{enc, human_size, shell};
4444
@@ -161,13 +161,15 @@ async fn log_tail(path: &Path) -> Result<Tail> {
161161
162162 /// Follows a log: yields what the file holds, then sends new bytes each time the job changes (its
163163 /// log grew or its state did). The stream ends when the job is terminal and a read after seeing
164-/// that returns nothing, so every byte the runner wrote is sent. A job that is gone, or a read
165-/// error, ends the stream.
164+/// that returns nothing, so every byte the runner wrote is sent. A job that is gone, a read
165+/// error, or a repo the viewer can no longer read ends the stream.
166166 pub(crate) fn follow_log(
167167 store: Store,
168168 live: Arc<CiLive>,
169169 job_id: String,
170170 path: PathBuf,
171+ viewer: Option<User>,
172+ repo_id: String,
171173 ) -> impl Stream<Item = std::io::Result<Bytes>> + Send + 'static {
172174 struct Follow {
173175 store: Store,
@@ -177,6 +179,8 @@ pub(crate) fn follow_log(
177179 file: Option<tokio::fs::File>,
178180 /// Subscribed before the first read, so a change between the read and the wait is seen.
179181 wake: watch::Receiver<u64>,
182+ viewer: Option<User>,
183+ repo_id: String,
180184 }
181185 let wake = live.subscribe_job(&job_id);
182186 futures_util::stream::unfold(
@@ -187,9 +191,14 @@ pub(crate) fn follow_log(
187191 path,
188192 file: None,
189193 wake,
194+ viewer,
195+ repo_id,
190196 },
191197 |mut follow| async move {
192198 loop {
199+ if !still_readable(&follow.store, follow.viewer.as_ref(), &follow.repo_id).await {
200+ return None;
201+ }
193202 // Checked before the read, so a read that finds nothing after this is the end.
194203 let terminal = match follow.store.job_by_id(&follow.job_id).await {
195204 Ok(Some(job)) => job.state.is_terminal(),
@@ -524,6 +533,8 @@ async fn job_events(cx: &Cx) -> Result<Response> {
524533 primed: false,
525534 pending_fingerprint: None,
526535 pending_log: None,
536+ viewer: ctx.viewer.as_ref().map(|(user, _)| user.clone()),
537+ repo_id: ctx.repo.id.clone(),
527538 };
528539 events_response(cx, job_stream(follow))
529540 }
@@ -555,11 +566,19 @@ struct JobFollow {
555566 pending_fingerprint: Option<String>,
556567 /// The text and the offset past it.
557568 pending_log: Option<(String, u64)>,
569+ /// The viewer the stream opened for, and the repo, so each send is checked for read access.
570+ viewer: Option<User>,
571+ repo_id: String,
558572 }
559573
560574 fn job_stream(follow: JobFollow) -> impl Stream<Item = Result<Event>> + Send + 'static {
561575 futures_util::stream::unfold(follow, |mut f| async move {
562576 loop {
577+ // Checked before anything is sent, so a repo made private or a removed collaborator ends
578+ // the stream on the next wake, not when it reopens.
579+ if !still_readable(&f.store, f.viewer.as_ref(), &f.repo_id).await {
580+ return None;
581+ }
563582 if let Some(fingerprint) = f.pending_fingerprint.take() {
564583 return Some((changed_event(fingerprint), f));
565584 }
@@ -643,6 +662,8 @@ async fn job_log(cx: &Cx) -> Result<Response> {
643662 Arc::clone(&state.ci_live),
644663 job.id.clone(),
645664 path,
665+ ctx.viewer.as_ref().map(|(user, _)| user.clone()),
666+ ctx.repo.id.clone(),
646667 )
647668 .map_ok(Frame::data);
648669 let mut res = Response::new(Body::new(StreamBody::new(chunks)));
crates/forge-web/src/pages/ci_runs.rsmodified+17 -12
@@ -40,9 +40,9 @@ use crate::i18n::{
4040 };
4141 use crate::pages::refs::load_refs;
4242 use crate::pages::repo::repo_head;
43-use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
43+use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable};
4444 use crate::state::AppState;
45-use crate::views::{alert, enc, human_size, now_unix, relative_time, shell, short_oid};
45+use crate::views::{alert, empty_state, enc, human_size, now_unix, rel_time, relative_time, shell, short_oid};
4646
4747 path_param!(owner);
4848 path_param!(repo);
@@ -321,11 +321,9 @@ fn trigger_text(lang: Lang, trigger: &str) -> String {
321321 }
322322 }
323323
324-/// The next scheduled run as `2026-10-21 03:00 UTC`.
324+/// The next scheduled run as an RFC 3339 stamp, shown as a live relative time.
325325 fn next_run_text(at: i64) -> Option<String> {
326- let when = time::OffsetDateTime::from_unix_timestamp(at).ok()?;
327- let format = time::macros::format_description!("[year]-[month]-[day] [hour]:[minute]");
328- Some(format!("{} UTC", when.format(&format).ok()?))
326+ forge_core::time::stamp_from_unix(at)
329327 }
330328
331329 /// One run in the list. `bar` is its duration bar on the page's shared scale.
@@ -1662,13 +1660,10 @@ async fn runs_body(
16621660 </div>
16631661 </div>
16641662 if let Some(next) = next_scheduled.as_ref() {
1665- <p class="ci-next muted small">(g::t(lang, K::NextScheduledRun)) ": " <time>(next.as_str())</time></p>
1663+ <p class="ci-next muted small">(g::t(lang, K::NextScheduledRun)) ": " rel_time(lang: lang, stamp: next.as_str())</p>
16661664 }
16671665 if rows.is_empty() {
1668- <div class="ci-empty">
1669- <p>(g::t(lang, K::NoRunsYet))</p>
1670- <p class="muted small">(g::t(lang, K::NoRunsHint))</p>
1671- </div>
1666+ empty_state(title: g::t(lang, K::NoRunsYet), hint: Some(g::t(lang, K::NoRunsHint)))
16721667 } else {
16731668 <p class="ci-scale">(scale.as_str())</p>
16741669 <ul class="ci-run-list">
@@ -2070,10 +2065,20 @@ async fn run_events(cx: &Cx) -> Result<Response> {
20702065 let wake = state.ci_live.subscribe_run(&run.id);
20712066 let store = state.store.clone();
20722067 let run_id = run.id.clone();
2068+ let viewer = ctx.viewer.as_ref().map(|(user, _)| user.clone());
2069+ let repo_id = ctx.repo.id.clone();
20732070 let events = changed_stream(wake, false, move || {
20742071 let store = store.clone();
20752072 let run_id = run_id.clone();
2076- async move { run_status(&store, &run_id).await }
2073+ let viewer = viewer.clone();
2074+ let repo_id = repo_id.clone();
2075+ async move {
2076+ // A repo the viewer can no longer read ends the stream before the status is sent.
2077+ if !still_readable(&store, viewer.as_ref(), &repo_id).await {
2078+ return Ok(None);
2079+ }
2080+ run_status(&store, &run_id).await
2081+ }
20772082 });
20782083 events_response(cx, events)
20792084 }
crates/forge-web/src/pages/ci_tests.rsmodified+2 -0
@@ -848,6 +848,8 @@ async fn log_txt_and_log_follower() {
848848 Arc::clone(&live),
849849 job.id.clone(),
850850 path.clone(),
851+ fx.store.user_by_id(&fx.tahinli).await.expect("viewer"),
852+ run.repo_id.clone(),
851853 ));
852854 let (tx, mut chunks) = tokio::sync::mpsc::unbounded_channel();
853855 tokio::spawn(async move {
crates/forge-web/src/pages/code_search.rsmodified+2 -2
@@ -20,7 +20,7 @@ use crate::pages::commits::blocking;
2020 use crate::pages::repo::repo_head;
2121 use crate::pages::repo_ctx::load_repo;
2222 use crate::state::AppState;
23-use crate::views::{repo_href, shell};
23+use crate::views::{empty_state, repo_href, shell};
2424
2525 path_param!(owner);
2626 path_param!(repo);
@@ -260,7 +260,7 @@ async fn search_page(cx: &Cx) -> Result<impl View> {
260260 }
261261 </section>
262262 } else if searched {
263- <p class="muted">(g::t(lang, K::NoMatches))</p>
263+ empty_state(title: g::t(lang, K::NoMatches))
264264 }
265265 }
266266 )
crates/forge-web/src/pages/commits.rsmodified+6 -2
@@ -24,7 +24,7 @@ use crate::render::emoji::emojify;
2424 use crate::signatures::{self, SigBadge};
2525 use crate::state::AppState;
2626 use crate::views::commit_status::{StatusLang, StatusSummary, commit_status};
27-use crate::views::shell;
27+use crate::views::{empty_state, shell};
2828
2929 path_param!(owner);
3030 path_param!(repo);
@@ -286,7 +286,11 @@ async fn commits_page(cx: &Cx) -> Result<impl View> {
286286 <p class="muted">(g::t(lang, K::FilteredTo)) <code>(filter_text.as_str())</code> " · " <a href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a></p>
287287 }
288288 if empty {
289- <p class="muted">(g::t(lang, K::NoCommits))</p>
289+ empty_state(title: g::t(lang, K::NoCommits),
290+ if has_filter {
291+ <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilter))</a>
292+ }
293+ )
290294 } else {
291295 <ul class="commit-list">
292296 for row in rows.iter() {
crates/forge-web/src/pages/compare.rsmodified+2 -2
@@ -37,7 +37,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo};
3737 use crate::state::AppState;
3838 use crate::templates;
3939 use crate::views::diff::{DiffLang, DiffOpts, LIMITS, diff_section};
40-use crate::views::{alert, repo_href, shell, user_facing_message};
40+use crate::views::{alert, empty_state, repo_href, shell, user_facing_message};
4141 use crate::webhooks::emit::{Sender, emit_pull};
4242
4343 path_param!(owner);
@@ -337,7 +337,7 @@ async fn compare_view(
337337 <p class="muted">(g::t(lang, K::Unrelated))</p>
338338 }
339339 if nothing {
340- <p class="muted">(g::t(lang, K::NothingToCompare))</p>
340+ empty_state(title: g::t(lang, K::NothingToCompare))
341341 }
342342 if has_commits {
343343 <h3>(commits_label.as_str())</h3>
crates/forge-web/src/pages/dashboard.rsmodified+5 -3
@@ -25,7 +25,7 @@ use crate::pages::issue_parts::stamp_unix;
2525 use crate::pages::repo_settings::{notice_banner_for, take_notice};
2626 use crate::state::AppState;
2727 use crate::views::heatmap::{self, Calendar, DayDetail, contribution_calendar};
28-use crate::views::{SIDE_REPOS, display_name, now_unix, relative_time, shell};
28+use crate::views::{SIDE_REPOS, display_name, empty_state, now_unix, relative_time, shell};
2929
3030 /// How far back the calendar reads contributions: 53 weeks plus the days of the current week.
3131 const CALENDAR_DAYS: u64 = 371;
@@ -303,7 +303,9 @@ async fn dashboard(dash: Dashboard, lang: Lang) -> Result<impl View> {
303303 <a class="button primary" href="/new">(g::t(lang, K::NewRepository))</a>
304304 </div>
305305 if empty {
306- <p class="muted">(g::t(lang, K::NoReposYet))</p>
306+ empty_state(title: g::t(lang, K::NoReposYet),
307+ <a class="button primary" href="/new">(g::t(lang, K::NewRepository))</a>
308+ <a class="button" href="/new/import">(crate::i18n::migrate::t(lang, crate::i18n::migrate::K::ImportTitle))</a>)
307309 } else {
308310 <div class="table-wrap">
309311 <table class="table">
@@ -337,7 +339,7 @@ async fn dashboard(dash: Dashboard, lang: Lang) -> Result<impl View> {
337339 <h2 id="attn-h">(m::t(lang, MK::NeedsAttention))</h2>
338340 </div>
339341 if attention_empty {
340- <p class="muted">(m::t(lang, MK::NothingNeedsYou))</p>
342+ empty_state(title: m::t(lang, MK::NothingNeedsYou))
341343 } else {
342344 <ul class="attn">
343345 for item in dash.attention.into_iter() {
crates/forge-web/src/pages/discussions.rsmodified+6 -2
@@ -27,7 +27,7 @@ use crate::pages::repo::repo_head;
2727 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
2828 use crate::render::markdown::mentioned_usernames;
2929 use crate::state::AppState;
30-use crate::views::{alert, csrf_field, now_unix, repo_href, shell, user_link};
30+use crate::views::{alert, csrf_field, empty_state, now_unix, repo_href, shell, user_link};
3131
3232 path_param!(owner);
3333 path_param!(repo);
@@ -317,7 +317,11 @@ async fn discussions_list_page(cx: &Cx) -> Result<impl View> {
317317 }
318318 </div>
319319 if rows.is_empty() {
320- <p class="muted">(empty_text)</p>
320+ empty_state(title: empty_text,
321+ if can_start {
322+ <a class="button primary" href=(new_href.as_str())>(new_label)</a>
323+ }
324+ )
321325 } else {
322326 <ul class="issue-list">
323327 for row in rows.iter() {
crates/forge-web/src/pages/explore.rsmodified+7 -2
@@ -18,7 +18,7 @@ use crate::state::AppState;
1818 use crate::views::repo_list::{
1919 PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips,
2020 };
21-use crate::views::{enc, now_unix, shell};
21+use crate::views::{empty_state, enc, now_unix, shell};
2222
2323 const PER_PAGE: u64 = 30;
2424 /// Longest search text kept, in characters.
@@ -194,8 +194,10 @@ async fn explore_body(
194194 live: String,
195195 ) -> Result<impl View> {
196196 let empty = rows.is_empty();
197+ let has_search = !q.is_empty();
197198 let has_orgs = !orgs.is_empty();
198199 let (links, prev, next) = nav;
200+ let clear_href = explore_href("", sort, 1);
199201 Ok(view! {
200202 <section class="explore" data-live=(live.as_str())>
201203 <h1>(g::t(lang, K::Explore))</h1>
@@ -219,7 +221,10 @@ async fn explore_body(
219221 sort_chips(links: sort_links, lang: lang)
220222 <p class="muted small">(g::repo_count(lang, total))</p>
221223 if empty {
222- <p class="muted">(g::t(lang, K::NoPublicReposMatch))</p>
224+ empty_state(title: g::t(lang, K::NoPublicReposMatch),
225+ if has_search {
226+ <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearSearch))</a>
227+ })
223228 } else {
224229 repo_rows(rows: rows, lang: lang)
225230 }
crates/forge-web/src/pages/import.rsmodified+19 -15
@@ -5,7 +5,6 @@
55 use std::collections::HashMap;
66
77 use forge_core::store::imports::{ImportJob, ImportState};
8-use forge_core::time::stamp_to_unix;
98 use forge_core::{AuditAction, Repo, User, Visibility};
109 use forge_git::repo::{init_bare, repo_path};
1110 use futures_util::stream;
@@ -30,8 +29,9 @@ use crate::importer::{
3029 };
3130 use crate::pages::ci_runs::{changed_event, events_response};
3231 use crate::pages::new_repo::{owner_choices, repo_owner};
32+use crate::pages::repo_ctx::still_readable;
3333 use crate::state::AppState;
34-use crate::views::{alert, csrf_field, now_unix, relative_time, shell, user_facing_message};
34+use crate::views::{alert, csrf_field, empty_state, rel_time, shell, user_facing_message};
3535
3636 path_param!(job_id);
3737
@@ -682,7 +682,7 @@ async fn bulk_select(
682682 </div>
683683 </header>
684684 if empty {
685- <p class="muted">(g::t(lang, K::BulkNone))</p>
685+ empty_state(title: g::t(lang, K::BulkNone))
686686 } else {
687687 <div class="newrepo-card import-pick">
688688 <label class="inline import-pick-all">
@@ -968,8 +968,16 @@ fn stage_name(lang: Lang, stage: &str) -> &'static str {
968968 }
969969 }
970970
971-fn ago(lang: Lang, stamp: &str) -> String {
972- stamp_to_unix(stamp).map_or_else(String::new, |t| relative_time(lang, t, now_unix()))
971+/// The job's repository, once it exists and while `user` may still read it: an import into an
972+/// org the user has since left, or a repo transferred away, is not named.
973+async fn job_repo(state: &AppState, user: Option<&User>, job: &ImportJob) -> Result<Option<Repo>> {
974+ let Some(id) = &job.repo_id else {
975+ return Ok(None);
976+ };
977+ if !still_readable(&state.store, user, id).await {
978+ return Ok(None);
979+ }
980+ Ok(state.store.repo_by_id(id).await?)
973981 }
974982
975983 /// The user's newest import jobs, each with its repository once it exists.
@@ -978,13 +986,11 @@ async fn load_job_rows(
978986 user_id: &str,
979987 limit: u32,
980988 ) -> Result<Vec<(ImportJob, Option<Repo>)>> {
989+ let user = state.store.user_by_id(user_id).await?;
981990 let jobs = state.store.list_import_jobs(user_id, limit).await?;
982991 let mut rows = Vec::with_capacity(jobs.len());
983992 for job in jobs {
984- let repo = match &job.repo_id {
985- Some(id) => state.store.repo_by_id(id).await?,
986- None => None,
987- };
993+ let repo = job_repo(state, user.as_ref(), &job).await?;
988994 rows.push((job, repo));
989995 }
990996 Ok(rows)
@@ -999,7 +1005,7 @@ async fn job_rows(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<im
9991005 <li class="item import-job-row">
10001006 <div class="item-main">
10011007 <a href=(format!("/import/{}", job.id)) class="import-job-name">(job.source_ref.as_str())</a>
1002- <span class="muted small">(g::t(lang, K::JobStarted)) " " <time data-rel="true" datetime=(job.created_at.as_str())>(ago(lang, &job.created_at))</time></span>
1008+ <span class="muted small">(g::t(lang, K::JobStarted)) " " rel_time(lang: lang, stamp: job.created_at.as_str())</span>
10031009 </div>
10041010 if let Some(repo) = repo {
10051011 <a href=(format!("/{}/{}", repo.owner_name, repo.name)) class="muted small mono">(format!("{}/{}", repo.owner_name, repo.name))</a>
@@ -1042,7 +1048,8 @@ async fn jobs_list(lang: Lang, jobs: Vec<(ImportJob, Option<Repo>)>) -> Result<i
10421048 <h1>(g::t(lang, K::JobsTitle))</h1>
10431049 </section>
10441050 if empty {
1045- <p class="muted">(g::t(lang, K::NoJobs))</p>
1051+ empty_state(title: g::t(lang, K::NoJobs),
1052+ <a class="button" href="/new/import">(g::t(lang, K::ImportTitle))</a>)
10461053 } else {
10471054 <section class="card">
10481055 job_rows(lang: lang, jobs: jobs)
@@ -1195,10 +1202,7 @@ async fn job_page(cx: &Cx) -> Result<impl View> {
11951202 let lang = i18n::lang(cx, Some(&viewer.0));
11961203 let state = app_context::<AppState>(cx);
11971204 let job = owned_job(cx, &viewer.0).await?;
1198- let repo = match &job.repo_id {
1199- Some(id) => state.store.repo_by_id(id).await?,
1200- None => None,
1201- };
1205+ let repo = job_repo(state, Some(&viewer.0), &job).await?;
12021206 let log = state.store.list_import_events(&job.id, 200).await?;
12031207 let csrf = viewer.1.csrf_token.clone();
12041208 let title = job.source_ref.clone();
crates/forge-web/src/pages/issues_list.rsmodified+20 -6
@@ -26,8 +26,8 @@ use crate::pages::repo_ctx::{RepoHead, load_repo};
2626 use crate::state::AppState;
2727 use crate::templates::{self, Template};
2828 use crate::views::{
29- alert, avatar_url, csrf_field, enc, iso_time, now_unix, relative_time, repo_href, shell,
30- user_facing_message, user_link,
29+ alert, avatar_url, csrf_field, empty_state, enc, iso_time, now_unix, relative_time, repo_href,
30+ shell, user_facing_message, user_link,
3131 };
3232 use crate::webhooks::emit::{Sender, emit_issue};
3333
@@ -484,7 +484,11 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> {
484484 let labels_page_href = repo_href(&owner_name, &repo_name, "labels", "");
485485 let milestones_href = repo_href(&owner_name, &repo_name, "milestones", "");
486486 let title = g::issues_title(lang, &format!("{owner_name}/{repo_name}"));
487- let empty_text = g::t(lang, K::NoIssuesMatch);
487+ let empty_text = if has_filters {
488+ g::t(lang, K::NoIssuesMatch)
489+ } else {
490+ g::t(lang, K::NoIssuesYet)
491+ };
488492 let state_word = sel.state;
489493
490494 let live_href = list_live_url(&owner_name, &repo_name);
@@ -543,7 +547,17 @@ async fn issues_list_page(cx: &Cx) -> Result<impl View> {
543547 </section>
544548 }
545549 if rows.is_empty() {
546- <p class="muted">(empty_text)</p>
550+ if has_filters {
551+ empty_state(title: empty_text,
552+ <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a>
553+ )
554+ } else {
555+ empty_state(title: empty_text,
556+ if can_create {
557+ <a class="button primary" href=(new_href.as_str())>(g::t(lang, K::NewIssue))</a>
558+ }
559+ )
560+ }
547561 } else {
548562 <ul class="issue-list">
549563 for row in rows.iter() {
@@ -1020,7 +1034,7 @@ mod tests {
10201034 }
10211035 let empty = send(&fx.router, "GET", &base(), true, None, &[]).await;
10221036 assert_eq!(empty.status, 200, "empty list");
1023- assert!(empty.text().contains("No issues match these filters."));
1037+ assert!(empty.text().contains("No issues yet."));
10241038 assert_eq!(rows(&empty.text()), 0);
10251039 let tr = send(
10261040 &fx.router,
@@ -1033,7 +1047,7 @@ mod tests {
10331047 .await
10341048 .text();
10351049 assert!(tr.contains(">Yeni sorun</a>"), "{tr}");
1036- assert!(tr.contains("Bu filtrelerle eşleşen sorun yok."), "{tr}");
1050+ assert!(tr.contains("Henüz sorun yok."), "{tr}");
10371051
10381052 // [refusals] an empty-title draft keeps its body and creates nothing; bad CSRF is 403.
10391053 let draft = send(
crates/forge-web/src/pages/labels_page.rsmodified+11 -10
@@ -21,7 +21,7 @@ use crate::pages::issues_live::list_live_url;
2121 use crate::pages::repo::repo_head;
2222 use crate::pages::repo_ctx::load_repo;
2323 use crate::state::AppState;
24-use crate::views::{enc, shell};
24+use crate::views::{empty_state, enc, shell};
2525
2626 path_param!(owner);
2727 path_param!(repo);
@@ -88,15 +88,16 @@ async fn labels_body(
8888 <section class="card" data-live=(live.as_str()) data-live-now="">
8989 <h2>(g::t(lang, K::Labels))</h2>
9090 if empty {
91- <p class="muted">(g::t(lang, K::NoLabelsYet))</p>
92- if can_triage && !archived {
93- <form method="post" action=(defaults_action.as_str()) class="stack">
94- <input type="hidden" name="csrf" value=(csrf.as_str())>
95- <div>
96- <button type="submit">(g::t(lang, K::AddDefaultLabels))</button>
97- </div>
98- </form>
99- }
91+ empty_state(title: g::t(lang, K::NoLabelsYet),
92+ if can_triage && !archived {
93+ <form method="post" action=(defaults_action.as_str()) class="stack">
94+ <input type="hidden" name="csrf" value=(csrf.as_str())>
95+ <div>
96+ <button type="submit">(g::t(lang, K::AddDefaultLabels))</button>
97+ </div>
98+ </form>
99+ }
100+ )
100101 }
101102 <ul class="label-list">
102103 for row in rows.iter() {
crates/forge-web/src/pages/merge_queue.rsmodified+4 -12
@@ -35,7 +35,7 @@ use crate::pages::pulls_merge::ERR_NOT_OPEN;
3535 use crate::pages::repo::repo_head;
3636 use crate::pages::repo_ctx::{RepoCtx, load_repo};
3737 use crate::state::AppState;
38-use crate::views::{repo_href, shell};
38+use crate::views::{rel_time, repo_href, shell};
3939
4040 path_param!(owner);
4141 path_param!(repo);
@@ -191,21 +191,13 @@ struct QueueRow {
191191 state: &'static str,
192192 state_class: &'static str,
193193 by: String,
194- queued: String,
194+ queued_at: String,
195195 run_href: Option<String>,
196196 run_label: String,
197197 reason: String,
198198 remove: bool,
199199 }
200200
201-/// `2026-10-21T19:11:22.700Z` as `2026-10-21 19:11` (UTC), for the queue table.
202-fn stamp_minute(stamp: &str) -> String {
203- match stamp.get(..16) {
204- Some(minute) => minute.replace('T', " "),
205- None => stamp.to_owned(),
206- }
207-}
208-
209201 async fn queue_rows(
210202 state: &AppState,
211203 ctx: &RepoCtx,
@@ -282,7 +274,7 @@ async fn queue_rows(
282274 state: state_label(lang, entry.state),
283275 state_class: state_class(entry.state),
284276 by,
285- queued: stamp_minute(&entry.enqueued_at),
277+ queued_at: entry.enqueued_at.clone(),
286278 run_href,
287279 run_label,
288280 reason: entry
@@ -403,7 +395,7 @@ async fn queue_body(
403395 <td data-label=(g::t(lang, K::QueueColBranch))><code>(row.branch.as_str())</code></td>
404396 <td data-label=(g::t(lang, K::QueueColState))><span class=(row.state_class)>(row.state)</span></td>
405397 <td data-label=(g::t(lang, K::QueueColBy))>(row.by.as_str())</td>
406- <td class="muted small" data-label=(g::t(lang, K::QueueColQueued))>(row.queued.as_str())</td>
398+ <td class="muted small" data-label=(g::t(lang, K::QueueColQueued))>rel_time(lang: lang, stamp: row.queued_at.as_str())</td>
407399 <td data-label=(g::t(lang, K::QueueColRun))>
408400 if let Some(href) = row.run_href.as_ref() {
409401 <a href=(href.as_str())>(row.run_label.as_str())</a>
crates/forge-web/src/pages/milestones_page.rsmodified+7 -2
@@ -25,7 +25,7 @@ use crate::pages::repo::repo_head;
2525 use crate::pages::repo_ctx::load_repo;
2626 use crate::render::markdown::render_markdown;
2727 use crate::state::AppState;
28-use crate::views::{enc, shell};
28+use crate::views::{empty_state, enc, shell};
2929
3030 path_param!(owner);
3131 path_param!(repo);
@@ -258,6 +258,11 @@ async fn milestones_body(
258258 let can_triage = frame.can_triage;
259259 let row_csrf = csrf.clone();
260260 let header = frame.head.clone();
261+ let empty_text = if closed {
262+ g::t(lang, K::NoClosedMilestones)
263+ } else {
264+ g::t(lang, K::NoOpenMilestones)
265+ };
261266 Ok(view! {
262267 repo_head(head: header)
263268 issue_subnav(lang: lang, title: title.clone(), active: "milestones".to_owned())
@@ -267,7 +272,7 @@ async fn milestones_body(
267272 state_tabs(lang: lang, title: title.clone(), closed: closed)
268273 <section class="card" data-live=(live.as_str()) data-live-now="">
269274 if empty {
270- <p class="muted">(if closed { g::t(lang, K::NoClosedMilestones) } else { g::t(lang, K::NoOpenMilestones) })</p>
275+ empty_state(title: empty_text)
271276 }
272277 <ul class="milestone-list">
273278 for row in rows.into_iter() {
crates/forge-web/src/pages/mod.rsmodified+1 -0
@@ -79,6 +79,7 @@ pub mod org_settings;
7979 pub mod org_teams;
8080 pub mod packages;
8181 pub mod packages_oci;
82+pub mod palette;
8283 pub mod passkeys;
8384 #[cfg(test)]
8485 mod passkeys_tests;
crates/forge-web/src/pages/notifications.rsmodified+10 -8
@@ -35,7 +35,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo};
3535 use crate::pages::repo_transfer::transfer_list_for;
3636 use crate::pages::star::return_path;
3737 use crate::state::AppState;
38-use crate::views::{csrf_field, display_name, iso_time, now_unix, relative_time, repo_href, shell};
38+use crate::views::{csrf_field, display_name, empty_state, iso_time, now_unix, relative_time, repo_href, shell};
3939
4040 /// Rows per inbox page.
4141 const PAGE_SIZE: u32 = 50;
@@ -972,6 +972,11 @@ async fn inbox_list(
972972 live: String,
973973 ) -> Result<impl View> {
974974 let empty = groups.is_empty();
975+ let empty_text = if all {
976+ g::t(lang, K::NoNotificationsYet)
977+ } else {
978+ g::t(lang, K::NoUnreadNotifications)
979+ };
975980 let unread_class = if all { "" } else { "active" };
976981 let all_class = if all { "active" } else { "" };
977982 let unread_text = format!("{} ({unread_count})", g::t(lang, K::Unread));
@@ -992,13 +997,10 @@ async fn inbox_list(
992997 <a href="/review-requests">(crate::i18n::authoring::t(lang, crate::i18n::authoring::K::ReviewRequestsTab))</a>
993998 </nav>
994999 if empty {
995- <p class="muted">
996- if all {
997- (g::t(lang, K::NoNotificationsYet))
998- } else {
999- (g::t(lang, K::NoUnreadNotifications))
1000- }
1001- </p>
1000+ empty_state(title: empty_text,
1001+ if !all {
1002+ <a class="button" href="/notifications?all=1">(g::t(lang, K::ViewAllNotifications))</a>
1003+ })
10021004 }
10031005 for group in groups.into_iter() {
10041006 <section class="card notif-group">
crates/forge-web/src/pages/org_teams.rsmodified+16 -7
@@ -24,7 +24,7 @@ use crate::pages::org_ctx::{
2424 };
2525 use crate::pages::passkeys;
2626 use crate::state::AppState;
27-use crate::views::{avatar_url, display_name, repo_href, shell};
27+use crate::views::{avatar_url, display_name, empty_state, repo_href, shell};
2828
2929 path_param!(org);
3030 path_param!(team);
@@ -199,7 +199,10 @@ async fn teams_body(
199199 <h2>(g::t(lang, K::Teams))</h2>
200200 <p class="muted small">(g::t(lang, K::TeamsIntro))</p>
201201 if rows.is_empty() {
202- <p class="muted">(g::t(lang, K::NoTeamsYet))</p>
202+ empty_state(title: g::t(lang, K::NoTeamsYet),
203+ if owner {
204+ <a class="button" href="#new-team">(g::t(lang, K::NewTeam))</a>
205+ })
203206 } else {
204207 <ul class="item-list">
205208 for row in rows.iter() {
@@ -217,7 +220,7 @@ async fn teams_body(
217220 }
218221 </section>
219222 if owner {
220- <section class="card">
223+ <section class="card" id="new-team">
221224 <h3>(g::t(lang, K::NewTeam))</h3>
222225 <form method="post" action=(create_action.as_str()) class="stack">
223226 <input type="hidden" name="csrf" value=(csrf.as_str())>
@@ -347,7 +350,10 @@ async fn team_body(
347350 <section class="card">
348351 <h3>(g::t(lang, K::Members))</h3>
349352 if data.members.is_empty() {
350- <p class="muted">(g::t(lang, K::NoTeamMembers))</p>
353+ empty_state(title: g::t(lang, K::NoTeamMembers),
354+ if owner {
355+ <a class="button" href="#add-member">(g::t(lang, K::AddMember))</a>
356+ })
351357 } else {
352358 <ul class="item-list">
353359 for member in data.members.iter() {
@@ -375,7 +381,7 @@ async fn team_body(
375381 </ul>
376382 }
377383 if owner {
378- <form method="post" action=(add_member_action.as_str()) class="team-form">
384+ <form method="post" action=(add_member_action.as_str()) class="team-form" id="add-member">
379385 <input type="hidden" name="csrf" value=(csrf.as_str())>
380386 <input type="text" name="username" placeholder=(g::t(lang, K::Username)) aria-label=(g::t(lang, K::Username)) autocomplete="off" spellcheck="false" required=(true)>
381387 <button type="submit">(g::t(lang, K::AddToTeam))</button>
@@ -385,7 +391,10 @@ async fn team_body(
385391 <section class="card">
386392 <h3>(g::t(lang, K::Repositories))</h3>
387393 if data.repos.is_empty() {
388- <p class="muted">(g::t(lang, K::NoTeamRepos))</p>
394+ empty_state(title: g::t(lang, K::NoTeamRepos),
395+ if owner && has_choices {
396+ <a class="button" href="#link-repository">(g::t(lang, K::LinkRepository))</a>
397+ })
389398 } else {
390399 <ul class="item-list">
391400 for repo in data.repos.iter() {
@@ -410,7 +419,7 @@ async fn team_body(
410419 </ul>
411420 }
412421 if owner && has_choices {
413- <form method="post" action=(add_repo_action.as_str()) class="team-form">
422+ <form method="post" action=(add_repo_action.as_str()) class="team-form" id="link-repository">
414423 <input type="hidden" name="csrf" value=(csrf.as_str())>
415424 <select name="repo_id" aria-label=(g::t(lang, K::Repository))>
416425 for choice in data.choices.iter() {
crates/forge-web/src/pages/packages.rsmodified+5 -3
@@ -26,7 +26,7 @@ use crate::pages::ci_runs::{changed_event, events_response};
2626 use crate::pages::packages_oci::{self, oci_package_view};
2727 use crate::render::markdown::render_markdown;
2828 use crate::state::AppState;
29-use crate::views::{enc, shell};
29+use crate::views::{empty_state, enc, rel_time, shell};
3030
3131 path_param!(owner);
3232 path_param!(name);
@@ -163,7 +163,7 @@ async fn package_page(cx: &Cx) -> Result<impl View> {
163163 .map(|v| {
164164 (
165165 v.version.clone(),
166- v.created_at.get(..10).unwrap_or(&v.created_at).to_owned(),
166+ v.created_at.clone(),
167167 v.yanked,
168168 v.checksum.clone(),
169169 )
@@ -356,7 +356,7 @@ async fn package_view(page: PackagePage) -> Result<impl View> {
356356 <li>
357357 <span class="repo-name">(version.as_str())</span>
358358 " "
359- <span class="muted small">(date.as_str())</span>
359+ <span class="muted small">rel_time(lang: lang, stamp: date.as_str())</span>
360360 if *yanked {
361361 " "
362362 <span class="badge">(pk::t(lang, K::VersionYanked))</span>
@@ -366,6 +366,8 @@ async fn package_view(page: PackagePage) -> Result<impl View> {
366366 </li>
367367 }
368368 </ul>
369+ } else {
370+ empty_state(title: pk::t(lang, K::NoVersions))
369371 }
370372 } else {
371373 if has_readme {
crates/forge-web/src/pages/packages_oci.rsmodified+4 -4
@@ -11,7 +11,7 @@ use crate::i18n::Lang;
1111 use crate::i18n::packages::{self as pk, K};
1212 use crate::package_ops;
1313 use crate::state::AppState;
14-use crate::views::{enc, human_size};
14+use crate::views::{empty_state, enc, human_size, rel_time};
1515
1616 /// What the container package page shows, prepared by the handler.
1717 pub struct OciPage {
@@ -105,7 +105,7 @@ pub async fn oci_package_view(page: OciPage) -> Result<impl View> {
105105 short_digest(&t.digest),
106106 t.digest.clone(),
107107 human_size(lang, t.size),
108- t.created_at.get(..10).unwrap_or(&t.created_at).to_owned(),
108+ t.created_at.clone(),
109109 )
110110 })
111111 .collect();
@@ -163,7 +163,7 @@ pub async fn oci_package_view(page: OciPage) -> Result<impl View> {
163163 <td><code>(tag.as_str())</code></td>
164164 <td><code class="small" title=(full.as_str())>(short.as_str())</code></td>
165165 <td class="muted small">(size.as_str())</td>
166- <td class="muted small">(created.as_str())</td>
166+ <td class="muted small">rel_time(lang: lang, stamp: created.as_str())</td>
167167 if can_delete {
168168 <td>
169169 <details class="confirm-inline">
@@ -187,7 +187,7 @@ pub async fn oci_package_view(page: OciPage) -> Result<impl View> {
187187 </table>
188188 </div>
189189 } else {
190- <p class="muted">(pk::t(lang, K::NoTags))</p>
190+ empty_state(title: pk::t(lang, K::NoTags))
191191 }
192192 </section>
193193 </article>
crates/forge-web/src/pages/palette.rsadded+74 -0
@@ -0,0 +1,74 @@
1+//! The command palette's destinations: `GET /-/palette` lists what the signed-in viewer can jump to,
2+//! their repos, the orgs they belong to and the fixed pages (the sidebar's links, the settings pages
3+//! and, for admins, the admin pages). The palette itself, its filtering and keys live in
4+//! `assets/nav.js`.
5+
6+use http::header::{CACHE_CONTROL, CONTENT_TYPE, X_CONTENT_TYPE_OPTIONS};
7+use serde_json::{Value, json};
8+use topcoat::Result;
9+use topcoat::context::{Cx, app_context};
10+use topcoat::router::response::Response;
11+use topcoat::router::{Body, HeaderValue, StatusCode, route};
12+
13+use crate::auth::current_user;
14+use crate::i18n::community::{self as cm, K as CK};
15+use crate::i18n::orgs::{self as o, K as OK};
16+use crate::i18n::{self, Key, t};
17+use crate::state::AppState;
18+use crate::views::{admin_items, repo_href, settings_items, user_href};
19+
20+/// Repos listed at most. The palette filters in the browser, so a longer list would only cost time.
21+pub const MAX_REPOS: u64 = 500;
22+
23+/// One destination: its label, its path and what it is (`repo`, `org` or `page`).
24+fn destination(label: &str, href: &str, kind: &str) -> Value {
25+ json!({ "label": label, "href": href, "kind": kind })
26+}
27+
28+/// `{"items": [{"label", "href", "kind"}, ...]}` for the signed-in viewer. Anonymous visitors get
29+/// 401, as the other signed-in-only JSON routes do.
30+#[route(GET "/-/palette")]
31+async fn palette(cx: &Cx) -> Result<Response> {
32+ let Some((user, _)) = current_user(cx).await? else {
33+ let mut res = Response::new(Body::empty());
34+ *res.status_mut() = StatusCode::UNAUTHORIZED;
35+ return Ok(res);
36+ };
37+ let state = app_context::<AppState>(cx);
38+ let lang = i18n::lang(cx, Some(&user));
39+
40+ let mut items = Vec::new();
41+ for repo in state.store.list_viewer_repos(&user, MAX_REPOS).await? {
42+ let label = format!("{}/{}", repo.owner_name, repo.name);
43+ let href = repo_href(&repo.owner_name, &repo.name, "", "");
44+ items.push(destination(&label, &href, "repo"));
45+ }
46+ for (org, _) in state.store.orgs_for_user(&user.id).await? {
47+ items.push(destination(&org.username, &user_href(&org.username), "org"));
48+ }
49+
50+ items.push(destination(o::t(lang, OK::Dashboard), "/", "page"));
51+ items.push(destination(t(lang, Key::Explore), "/explore", "page"));
52+ items.push(destination(t(lang, Key::Notifications), "/notifications", "page"));
53+ items.push(destination(cm::t(lang, CK::Snippets), "/snippets", "page"));
54+ items.push(destination(t(lang, Key::NewRepository), "/new", "page"));
55+ for item in settings_items(lang) {
56+ items.push(destination(item.label, &item.href, "page"));
57+ }
58+ if user.is_admin {
59+ for item in admin_items(lang) {
60+ items.push(destination(item.label, &item.href, "page"));
61+ }
62+ }
63+
64+ let body = json!({ "items": items });
65+ let mut response = Response::new(Body::from(body.to_string().into_bytes()));
66+ let headers = response.headers_mut();
67+ headers.insert(
68+ CONTENT_TYPE,
69+ HeaderValue::from_static("application/json; charset=utf-8"),
70+ );
71+ headers.insert(CACHE_CONTROL, HeaderValue::from_static("private, no-cache"));
72+ headers.insert(X_CONTENT_TYPE_OPTIONS, HeaderValue::from_static("nosniff"));
73+ Ok(response)
74+}
crates/forge-web/src/pages/profile.rsmodified+4 -4
@@ -32,7 +32,7 @@ use crate::state::AppState;
3232 use crate::views::repo_list::{
3333 PageLink, RepoRow, SortLink, pager, pager_links, repo_rows, sort_chips,
3434 };
35-use crate::views::{avatar_url, enc, now_unix, repo_href, shell};
35+use crate::views::{avatar_url, empty_state, enc, now_unix, repo_href, shell};
3636
3737 path_param!(username);
3838
@@ -539,7 +539,7 @@ async fn profile_card(
539539 }
540540 </ul>
541541 } else {
542- <p class="muted">(g::t(lang, K::NoVisibleRepos))</p>
542+ empty_state(title: g::t(lang, K::NoVisibleRepos))
543543 }
544544 </section>
545545 if let Some(summary) = org {
@@ -547,7 +547,7 @@ async fn profile_card(
547547 <h2>(g::t(lang, K::Members))</h2>
548548 <p class="muted small">(g::members_and_teams(lang, summary.members.len(), summary.teams))</p>
549549 if summary.members.is_empty() {
550- <p class="muted">(g::t(lang, K::NoMembers))</p>
550+ empty_state(title: g::t(lang, K::NoMembers))
551551 } else {
552552 <ul class="item-list">
553553 for name in summary.members.iter() {
@@ -572,7 +572,7 @@ async fn profile_card(
572572 if has_rows {
573573 repo_rows(rows: rows, lang: lang)
574574 } else {
575- <p class="muted">(empty)</p>
575+ empty_state(title: empty)
576576 }
577577 pager(page: page, pages: pages, links: links, prev: prev, next: next, lang: lang)
578578 </section>
crates/forge-web/src/pages/profile_pins.rsmodified+3 -2
@@ -20,7 +20,7 @@ use crate::live::{Topic, stream_changes};
2020 use crate::pages::issue_meta::{form_all, form_field, form_pairs};
2121 use crate::pages::org_ctx::{load_org, require_form_csrf, require_owner};
2222 use crate::state::AppState;
23-use crate::views::shell;
23+use crate::views::{empty_state, shell};
2424
2525 path_param!(org);
2626
@@ -117,7 +117,8 @@ async fn pins_body(
117117 </div>
118118 </form>
119119 } else {
120- <p class="muted">(empty)</p>
120+ empty_state(title: empty,
121+ <a class="button" href="/new">(g::t(lang, K::NewRepository))</a>)
121122 }
122123 </section>
123124 })
crates/forge-web/src/pages/pulls_list.rsmodified+16 -2
@@ -22,7 +22,9 @@ use crate::pages::issues_list::{
2222 use crate::pages::repo::repo_head;
2323 use crate::pages::repo_ctx::load_repo;
2424 use crate::state::AppState;
25-use crate::views::{avatar_url, iso_time, now_unix, relative_time, repo_href, shell, user_link};
25+use crate::views::{
26+ avatar_url, empty_state, iso_time, now_unix, relative_time, repo_href, shell, user_link,
27+};
2628
2729 path_param!(owner);
2830 path_param!(repo);
@@ -300,7 +302,19 @@ async fn pulls_list_page(cx: &Cx) -> Result<impl View> {
300302 <p class="muted small">(g::t(lang, K::FiltersApplied)) <a href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a></p>
301303 }
302304 if rows.is_empty() {
303- <p class="muted">(empty_text)</p>
305+ if has_filters {
306+ empty_state(title: empty_text,
307+ <a class="button" href=(clear_href.as_str())>(g::t(lang, K::ClearFilters))</a>
308+ )
309+ } else if open_count + closed_count == 0 {
310+ empty_state(title: empty_text,
311+ if can_create {
312+ <a class="button primary" href=(compare_href.as_str())>(g::t(lang, K::NewPullRequest))</a>
313+ }
314+ )
315+ } else {
316+ empty_state(title: empty_text)
317+ }
304318 } else {
305319 <ul class="issue-list">
306320 for row in rows.iter() {
crates/forge-web/src/pages/refs.rsmodified+2 -2
@@ -18,7 +18,7 @@ use crate::pages::ref_live;
1818 use crate::pages::repo::repo_head;
1919 use crate::pages::repo_ctx::{RepoCtx, load_repo};
2020 use crate::pages::tree::{LastCommit, last_commit_view};
21-use crate::views::{RefLink, now_unix, repo_href, shell};
21+use crate::views::{RefLink, empty_state, now_unix, repo_href, shell};
2222
2323 path_param!(owner);
2424 path_param!(repo);
@@ -108,7 +108,7 @@ async fn refs_table(rows: Vec<RefRow>, kind_label: &str, lang: Lang) -> Result<i
108108 let empty = rows.is_empty();
109109 Ok(view! {
110110 if empty {
111- <p class="muted">(g::t(lang, K::NothingHere))</p>
111+ empty_state(title: g::t(lang, K::NothingHere))
112112 } else {
113113 <div class="table-wrap">
114114 <table class="table refs-table">
crates/forge-web/src/pages/releases.rsmodified+42 -30
@@ -38,11 +38,11 @@ use crate::pages::refs::load_refs;
3838 use crate::pages::releases_live;
3939 use crate::pages::repo::repo_head;
4040 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
41-use crate::pages::repo_mirrors::stamp_in_tz;
41+use crate::pages::issue_parts::When;
4242 use crate::release_ops::{self, CreateRelease, EditRelease, ReleaseError};
4343 use crate::render::markdown::render_markdown;
4444 use crate::state::AppState;
45-use crate::views::{alert, enc, shell, user_link};
45+use crate::views::{alert, empty_state, enc, now_unix, shell, user_link};
4646
4747 path_param!(owner);
4848 path_param!(repo);
@@ -179,7 +179,7 @@ pub struct ReleaseCard {
179179 pub href: String,
180180 pub edit_href: String,
181181 pub body: String,
182- pub when: String,
182+ pub(crate) when: When,
183183 pub author: String,
184184 pub draft: bool,
185185 pub prerelease: bool,
@@ -192,7 +192,7 @@ pub struct LatestRelease {
192192 pub title: String,
193193 pub tag: String,
194194 pub href: String,
195- pub when: String,
195+ pub(crate) when: When,
196196 pub assets: Vec<AssetLink>,
197197 }
198198
@@ -213,7 +213,7 @@ fn card_of(
213213 href: tag_href(&title, &release.tag),
214214 edit_href: release_edit_href(&title, &release.id),
215215 body: release.body.clone(),
216- when: stamp_in_tz(when, ctx.viewer_tz()),
216+ when: When::new(ctx.lang, when, ctx.viewer_tz(), now_unix()),
217217 author: release.author_name.clone(),
218218 draft: release.draft,
219219 prerelease: release.prerelease,
@@ -243,7 +243,7 @@ pub async fn latest_release_for_home(
243243 title: release.title.clone(),
244244 tag: release.tag.clone(),
245245 href: tag_href(&title, &release.tag),
246- when: stamp_in_tz(when, ctx.viewer_tz()),
246+ when: When::new(ctx.lang, when, ctx.viewer_tz(), now_unix()),
247247 assets: assets
248248 .iter()
249249 .map(|asset| asset_link(&title, &release.tag, asset))
@@ -475,7 +475,7 @@ pub async fn latest_card(release: LatestRelease, lang: Lang) -> Result<impl View
475475 <a href=(release.href.as_str())>(release.title.as_str())</a>
476476 " \u{b7} " <code>(release.tag.as_str())</code>
477477 </p>
478- <p class="muted small">(release.when.as_str())</p>
478+ <p class="muted small"><time data-rel="true" datetime=(release.when.iso.as_str()) title=(release.when.absolute.as_str())>(release.when.relative.as_str())</time></p>
479479 if !release.assets.is_empty() {
480480 <ul class="release-asset-list">
481481 for asset in release.assets.iter() {
@@ -509,12 +509,16 @@ async fn list_body(
509509 <section class="card" data-live=(live.as_str())>
510510 <div class="release-list-head">
511511 <h2>(g::t(lang, K::Releases))</h2>
512- if let Some(href) = new_href {
512+ if let Some(href) = &new_href {
513513 <a class="button" href=(href.as_str())>(g::t(lang, K::NewRelease))</a>
514514 }
515515 </div>
516516 if cards.is_empty() {
517- <p class="muted">(g::t(lang, K::NoReleasesYet))</p>
517+ empty_state(title: g::t(lang, K::NoReleasesYet),
518+ if let Some(href) = &new_href {
519+ <a class="button primary" href=(href.as_str())>(g::t(lang, K::NewRelease))</a>
520+ }
521+ )
518522 }
519523 for card in cards.iter() {
520524 <article class="release-card">
@@ -532,7 +536,7 @@ async fn list_body(
532536 </h3>
533537 <p class="muted small">
534538 <code>(card.tag.as_str())</code>
535- " \u{b7} " (card.when.as_str())
539+ " \u{b7} " <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time>
536540 if !card.author.is_empty() {
537541 " \u{b7} " user_link(shown: card.author.as_str(), login: card.author.as_str())
538542 }
@@ -747,7 +751,7 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> {
747751 .published_at
748752 .as_deref()
749753 .unwrap_or(&release.created_at);
750- let when = stamp_in_tz(when, ctx.viewer_tz());
754+ let when = When::new(ctx.lang, when, ctx.viewer_tz(), now_unix());
751755 let body_html = render_markdown(&release.body, None);
752756 let page_title = format!("{title} \u{b7} {}", release.title);
753757 let archive_tar = format!("/{title}/archive/{}.tar.gz", enc(&release.tag));
@@ -800,7 +804,7 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> {
800804 </h2>
801805 <p class="muted small">
802806 <code>(card.tag.as_str())</code>
803- " \u{b7} " (card.when.as_str())
807+ " \u{b7} " <time data-rel="true" datetime=(card.when.iso.as_str()) title=(card.when.absolute.as_str())>(card.when.relative.as_str())</time>
804808 if !card.author.is_empty() {
805809 " \u{b7} " user_link(shown: card.author.as_str(), login: card.author.as_str())
806810 }
@@ -830,14 +834,18 @@ async fn release_tag_page(cx: &Cx) -> Result<impl View> {
830834 if writer {
831835 <div class="release-actions">
832836 <a href=(edit_href.as_str())>(g::t(lang, K::Edit))</a>
833- <form method="post" action=(delete_href.as_str()) class="inline-form">
834- <input type="hidden" name="csrf" value=(csrf.as_str())>
835- <label class="inline">
836- <input type="checkbox" name="confirm" value="on">
837- <span>(g::t(lang, K::Confirm))</span>
838- </label>
839- <button type="submit">(g::t(lang, K::DeleteRelease))</button>
840- </form>
837+ <details class="confirm-inline">
838+ <summary class="button danger">(g::t(lang, K::DeleteRelease))</summary>
839+ <div class="confirm-pop">
840+ <p>(g::t(lang, K::DeleteReleaseHelp))</p>
841+ <form method="post" action=(delete_href.as_str())>
842+ <input type="hidden" name="csrf" value=(csrf.as_str())>
843+ <input type="hidden" name="confirm" value="on">
844+ <button type="submit" class="danger">(g::t(lang, K::YesDeleteRelease))</button>
845+ <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button>
846+ </form>
847+ </div>
848+ </details>
841849 </div>
842850 }
843851 </section>
@@ -897,16 +905,20 @@ async fn edit_body(
897905 <section class="card">
898906 <h2>(g::t(lang, K::DeleteRelease))</h2>
899907 <p class="muted small">(g::t(lang, K::DeleteReleaseHelp))</p>
900- <form method="post" action=(delete_href.as_str()) class="stack">
901- <input type="hidden" name="csrf" value=(csrf.as_str())>
902- <label class="inline">
903- <input type="checkbox" name="confirm" value="on">
904- <span>(g::t(lang, K::YesDeleteRelease))</span>
905- </label>
906- <div>
907- <button type="submit">(g::t(lang, K::DeleteRelease))</button>
908- </div>
909- </form>
908+ <div>
909+ <details class="confirm-inline">
910+ <summary class="button danger">(g::t(lang, K::DeleteRelease))</summary>
911+ <div class="confirm-pop">
912+ <p>(g::t(lang, K::DeleteReleaseHelp))</p>
913+ <form method="post" action=(delete_href.as_str())>
914+ <input type="hidden" name="csrf" value=(csrf.as_str())>
915+ <input type="hidden" name="confirm" value="on">
916+ <button type="submit" class="danger">(g::t(lang, K::YesDeleteRelease))</button>
917+ <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button>
918+ </form>
919+ </div>
920+ </details>
921+ </div>
910922 </section>
911923 })
912924 }
crates/forge-web/src/pages/repo.rsmodified+20 -7
@@ -33,7 +33,7 @@ use crate::pages::tree::{
3333 entry_rows, last_commits, latest_bar, load_readme, read_dir, readme_card, tree_table,
3434 };
3535 use crate::state::AppState;
36-use crate::views::{now_unix, ref_selector, relative_time, repo_href, repo_tabs, shell, user_link};
36+use crate::views::{now_unix, ref_selector, rel_time, relative_time, repo_href, repo_tabs, shell, user_link};
3737
3838 path_param!(owner);
3939 path_param!(repo);
@@ -136,13 +136,20 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> {
136136 let fork_count = g::forks_count(lang, forks);
137137 let search_action = repo_href(&owner, &name, "search", "");
138138 let mirror_line = mirror.as_ref().map(|source| source.url.clone());
139- let mirror_status = match mirror {
139+ // A stamp is shown as a live relative time between the two words; without one, the status is plain text.
140+ let (mirror_before, mirror_after, mirror_at, mirror_status) = match mirror {
140141 Some(source) => match (source.last_sync, source.last_ok) {
141- (Some(at), Some(true)) => g::mirror_synced(lang, &at),
142- (Some(at), _) => g::mirror_sync_failed(lang, &at),
143- (None, _) => g::t(lang, K::NotSyncedYet).to_owned(),
142+ (Some(at), Some(true)) => {
143+ let (before, after) = g::mirror_synced(lang);
144+ (before, after, Some(at), String::new())
145+ }
146+ (Some(at), _) => {
147+ let (before, after) = g::mirror_sync_failed(lang);
148+ (before, after, Some(at), String::new())
149+ }
150+ (None, _) => ("", "", None, g::t(lang, K::NotSyncedYet).to_owned()),
144151 },
145- None => String::new(),
152+ None => ("", "", None, String::new()),
146153 };
147154 let live_attr = (!live.is_empty()).then(|| live.clone());
148155 Ok(view! {
@@ -156,7 +163,13 @@ pub async fn repo_head(head: RepoHead) -> Result<impl View> {
156163 <p class="muted small">(g::t(lang, K::ForkedFrom)) <a href=(href.as_str())>(label.as_str())</a></p>
157164 }
158165 if let Some(source) = mirror_line {
159- <p class="muted small mirror-line">(g::t(lang, K::MirrorOf)) <code>(source.as_str())</code> ", " (mirror_status.as_str())</p>
166+ <p class="muted small mirror-line">(g::t(lang, K::MirrorOf)) <code>(source.as_str())</code> ", "
167+ if let Some(at) = mirror_at.as_deref() {
168+ (mirror_before) rel_time(lang: lang, stamp: at) (mirror_after)
169+ } else {
170+ (mirror_status.as_str())
171+ }
172+ </p>
160173 }
161174 </div>
162175 <div class="header-actions">
crates/forge-web/src/pages/repo_collaborators.rsmodified+4 -3
@@ -31,7 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
3131 use crate::pages::repo_settings::settings_nav_for;
3232 use crate::pages::repo_settings_live::settings_head;
3333 use crate::state::AppState;
34-use crate::views::{alert, avatar_url, display_name, shell};
34+use crate::views::{alert, avatar_url, display_name, empty_state, shell};
3535
3636 path_param!(owner);
3737 path_param!(repo);
@@ -183,7 +183,8 @@ async fn collaborators_table(
183183 ) -> Result<impl View> {
184184 Ok(view! {
185185 if rows.is_empty() {
186- <p class="muted">(g::t(lang, K::NoCollaborators))</p>
186+ empty_state(title: g::t(lang, K::NoCollaborators),
187+ <a class="button" href="#add-collaborator">(g::t(lang, K::AddCollaboratorHeading))</a>)
187188 } else {
188189 <div class="table-wrap">
189190 <table class="table collaborators members-table">
@@ -248,7 +249,7 @@ async fn collaborators_table(
248249 async fn add_form(lang: Lang, add_action: String, csrf: String) -> Result<impl View> {
249250 Ok(view! {
250251 <h3>(g::t(lang, K::AddCollaboratorHeading))</h3>
251- <form method="post" action=(add_action.as_str()) class="stack">
252+ <form method="post" action=(add_action.as_str()) class="stack" id="add-collaborator">
252253 <input type="hidden" name="csrf" value=(csrf.as_str())>
253254 <label>
254255 <span>(g::t(lang, K::Username))</span>
crates/forge-web/src/pages/repo_ctx.rsmodified+28 -6
@@ -6,7 +6,7 @@
66 use std::path::PathBuf;
77
88 use forge_core::authz::{Action, authorize};
9-use forge_core::{Repo, Role, Session, User, Visibility, WatchLevel};
9+use forge_core::{Repo, Role, Session, Store, User, Visibility, WatchLevel};
1010 use forge_git::repo::repo_path;
1111 use http::{HeaderValue, header::LOCATION};
1212 use topcoat::Result;
@@ -18,7 +18,7 @@ use topcoat::router::{Body, Layer, LayerFuture, Next, Path, StatusCode};
1818
1919 use crate::auth::current_user;
2020 use crate::i18n::{self, Lang};
21-use crate::pages::repo_mirrors::{redacted_url, stamp_in_tz};
21+use crate::pages::repo_mirrors::redacted_url;
2222 use crate::state::AppState;
2323
2424 pub struct RepoCtx {
@@ -233,10 +233,7 @@ impl RepoCtx {
233233 .await?
234234 .map(|mirror| MirrorSource {
235235 url: redacted_url(&mirror.url),
236- last_sync: mirror
237- .last_sync_at
238- .as_deref()
239- .map(|stamp| stamp_in_tz(stamp, self.viewer_tz())),
236+ last_sync: mirror.last_sync_at.clone(),
240237 last_ok: mirror.last_ok,
241238 });
242239 Ok(RepoHead {
@@ -322,6 +319,31 @@ pub async fn load_repo(cx: &Cx, owner: &str, name: &str) -> Result<RepoCtx> {
322319 })
323320 }
324321
322+/// Whether `viewer` may still read the repo, checked against the store now. A live stream calls it
323+/// after each wake, so a repo made private or a collaborator removed since the stream opened ends
324+/// it. A missing repo or a failed read counts as not readable.
325+pub async fn still_readable(store: &Store, viewer: Option<&User>, repo_id: &str) -> bool {
326+ let Ok(Some(repo)) = store.repo_by_id(repo_id).await else {
327+ return false;
328+ };
329+ let (role, org_role) = match viewer {
330+ Some(user) => {
331+ let Ok(role) = store.collaborator_role(&repo.id, &user.id).await else {
332+ return false;
333+ };
334+ let Ok(org_role) = store
335+ .org_repo_role(&repo.owner_id, &user.id, &repo.id)
336+ .await
337+ else {
338+ return false;
339+ };
340+ (role, org_role)
341+ }
342+ None => (None, None),
343+ };
344+ authorize(viewer, &repo, role, org_role, Action::Read).is_ok()
345+}
346+
325347 /// The URL to send a past owner/name to: the same path and query with the owner and name segments
326348 /// replaced. `None` unless the redirect target exists and the viewer may read it, so a hidden repo
327349 /// answers exactly like a missing one.
crates/forge-web/src/pages/repo_mirrors.rsmodified+28 -25
@@ -36,7 +36,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
3636 use crate::pages::repo_settings::settings_nav_for;
3737 use crate::pages::repo_settings_live::settings_head;
3838 use crate::state::AppState;
39-use crate::views::{alert, enc, now_unix, relative_time, shell, user_facing_message};
39+use crate::views::{alert, empty_state, enc, now_unix, rel_time_or_never, relative_time, shell, user_facing_message};
4040 use crate::webhooks::client::{WebhookPolicy, validate_url};
4141
4242 path_param!(owner);
@@ -504,13 +504,20 @@ async fn mirrors_list_body(
504504 lang: Lang,
505505 ) -> Result<impl View> {
506506 let add_action = mirrors_href(&title);
507+ let can_pull = pull_form.is_some();
507508 Ok(view! {
508509 frame_top(head: head, title: title.clone(), notice: notice, archived: archived, lang: lang)
509510 <section class="card">
510511 <h2>(g::t(lang, K::Mirrors))</h2>
511512 <p class="muted small">(g::t(lang, K::MirrorsIntro))</p>
512513 if rows.is_empty() {
513- <p class="muted">(g::t(lang, K::NoMirrors))</p>
514+ empty_state(title: g::t(lang, K::NoMirrors),
515+ if !archived {
516+ if can_pull {
517+ <a class="button" href="#add-pull-mirror">(g::t(lang, K::AddPullMirror))</a>
518+ }
519+ <a class="button" href="#add-push-mirror">(g::t(lang, K::AddPushMirror))</a>
520+ })
514521 } else {
515522 <ul class="runner-list mirror-list">
516523 for row in rows.iter() {
@@ -552,7 +559,7 @@ async fn mirrors_list_body(
552559 </section>
553560 if !archived {
554561 if let Some(pull) = pull_form {
555- <section class="card">
562+ <section class="card" id="add-pull-mirror">
556563 <h2>(g::t(lang, K::AddPullMirror))</h2>
557564 <p class="muted small">(g::t(lang, K::AddPullIntro))</p>
558565 mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: true, current_url: String::new(),
@@ -560,7 +567,7 @@ async fn mirrors_list_body(
560567 enabled: None, error: pull.error, submit: g::t(lang, K::AddPullMirror), direction: "pull", lang: lang)
561568 </section>
562569 }
563- <section class="card">
570+ <section class="card" id="add-push-mirror">
564571 <h2>(g::t(lang, K::AddPushMirror))</h2>
565572 <p class="muted small">(g::t(lang, K::AddPushIntro))</p>
566573 mirror_form(action: add_action.clone(), csrf: csrf.clone(), pull: false, current_url: String::new(),
@@ -781,11 +788,6 @@ async fn mirror_body(
781788 let sync_action = format!("{edit_action}/sync");
782789 let delete_action = format!("{edit_action}/delete");
783790 let pull = mirror.direction == MirrorDirection::Pull;
784- let last_sync = mirror
785- .last_sync_at
786- .as_deref()
787- .map(|stamp| stamp_in_tz(stamp, &draft.tz))
788- .unwrap_or_else(|| g::t(lang, K::Never).to_owned());
789791 let delete_text = if pull {
790792 g::t(lang, K::DeleteTextPull)
791793 } else {
@@ -798,7 +800,7 @@ async fn mirror_body(
798800 <h2>(mirror_kind(lang, mirror.direction))</h2>
799801 if archived {
800802 <p><code>(current_url.as_str())</code></p>
801- <p class="muted small">(g::t(lang, K::LastSync))" " (last_sync.as_str())</p>
803+ <p class="muted small">(g::t(lang, K::LastSync))" " rel_time_or_never(lang: lang, stamp: mirror.last_sync_at.as_deref())</p>
802804 if let Some(error) = mirror.last_error.clone() {
803805 <pre class="mirror-error">(error.as_str())</pre>
804806 }
@@ -821,16 +823,20 @@ async fn mirror_body(
821823 <section class="card">
822824 <h2>(g::t(lang, K::DeleteMirror))</h2>
823825 <p class="muted small">(delete_text)</p>
824- <form method="post" action=(delete_action.as_str()) class="stack">
825- <input type="hidden" name="csrf" value=(csrf.as_str())>
826- <label class="inline">
827- <input type="checkbox" name="confirm" value="on">
828- <span>(g::t(lang, K::DeleteConfirm))</span>
829- </label>
830- <div>
831- <button type="submit" class="danger">(g::t(lang, K::DeleteMirror))</button>
832- </div>
833- </form>
826+ <div>
827+ <details class="confirm-inline">
828+ <summary class="button danger">(g::t(lang, K::DeleteMirror))</summary>
829+ <div class="confirm-pop">
830+ <p>(g::t(lang, K::DeleteConfirm))</p>
831+ <form method="post" action=(delete_action.as_str())>
832+ <input type="hidden" name="csrf" value=(csrf.as_str())>
833+ <input type="hidden" name="confirm" value="on">
834+ <button type="submit" class="danger">(g::t(lang, K::DeleteMirror))</button>
835+ <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button>
836+ </form>
837+ </div>
838+ </details>
839+ </div>
834840 </section>
835841 }
836842 })
@@ -838,7 +844,6 @@ async fn mirror_body(
838844
839845 /// The edit form's values: the username and the interval as stored, or as submitted on error.
840846 struct EditDraft {
841- tz: String,
842847 username: String,
843848 interval: String,
844849 enabled: bool,
@@ -846,9 +851,8 @@ struct EditDraft {
846851 }
847852
848853 impl EditDraft {
849- fn of_mirror(mirror: &Mirror, tz: &str) -> Self {
854+ fn of_mirror(mirror: &Mirror) -> Self {
850855 Self {
851- tz: tz.to_owned(),
852856 username: mirror.username.clone(),
853857 interval: mirror.interval_minutes.to_string(),
854858 enabled: mirror.enabled,
@@ -872,7 +876,7 @@ async fn mirror_page(cx: &Cx) -> Result<impl View> {
872876 let mirror = repo_mirror(state, &ctx, id).await?;
873877 let lang = lang_of(cx, &ctx);
874878 let frame = Frame::new(&ctx, state, lang).await?;
875- let draft = EditDraft::of_mirror(&mirror, &frame.tz);
879+ let draft = EditDraft::of_mirror(&mirror);
876880 let csrf = session.csrf_token.clone();
877881 let notice = notice_from_query(cx, lang);
878882 let mirror_id = mirror.id.clone();
@@ -920,7 +924,6 @@ async fn mirror_update(cx: &Cx, Form(form): Form<EditForm>) -> Result<impl View>
920924 Err(message) => {
921925 let frame = Frame::new(&ctx, state, lang).await?;
922926 let draft = EditDraft {
923- tz: frame.tz.clone(),
924927 username: form.username.trim().to_owned(),
925928 interval: form.interval.trim().to_owned(),
926929 enabled: form.enabled.is_some(),
crates/forge-web/src/pages/repo_secrets.rsmodified+9 -8
@@ -20,11 +20,10 @@ use crate::i18n::repo_admin::{self as g, K};
2020 use crate::i18n::{self, Lang};
2121 use crate::pages::repo::repo_head;
2222 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
23-use crate::pages::repo_mirrors::stamp_in_tz;
2423 use crate::pages::repo_settings::settings_nav_for;
2524 use crate::pages::repo_settings_live::settings_head;
2625 use crate::state::AppState;
27-use crate::views::{alert, enc, shell};
26+use crate::views::{alert, empty_state, enc, rel_time, shell};
2827
2928 path_param!(owner);
3029 path_param!(repo);
@@ -113,7 +112,7 @@ fn notice_from_query(cx: &Cx) -> Option<(K, bool)> {
113112 /// One row of the list: the name and when it was last set, already formatted.
114113 struct SecretRow {
115114 name: String,
116- updated: String,
115+ updated_at: String,
117116 }
118117
119118 /// What the page shows, read once from the repo context and the store.
@@ -128,7 +127,6 @@ struct SecretsData {
128127 impl SecretsData {
129128 async fn load(state: &AppState, ctx: &RepoCtx, lang: Lang) -> Result<Self> {
130129 let title = title_of(ctx);
131- let tz = ctx.viewer_tz().to_owned();
132130 let rows = state
133131 .store
134132 .list_ci_secret_names(&ctx.repo.id)
@@ -136,7 +134,7 @@ impl SecretsData {
136134 .into_iter()
137135 .map(|(name, updated)| SecretRow {
138136 name,
139- updated: stamp_in_tz(&updated, &tz),
137+ updated_at: updated,
140138 })
141139 .collect();
142140 Ok(Self {
@@ -197,7 +195,10 @@ async fn secrets_body(
197195 <h2>(g::t(lang, K::Secrets))</h2>
198196 <p class="muted small">(g::t(lang, K::SecretsHelp))</p>
199197 if rows.is_empty() {
200- <p class="muted">(g::t(lang, K::NoSecrets))</p>
198+ empty_state(title: g::t(lang, K::NoSecrets),
199+ if !archived {
200+ <a class="button" href="#add-secret">(g::t(lang, K::AddOrUpdate))</a>
201+ })
201202 } else {
202203 <div class="table-wrap">
203204 <table class="table secrets">
@@ -212,7 +213,7 @@ async fn secrets_body(
212213 for row in rows.iter() {
213214 <tr>
214215 <td><code>(row.name.as_str())</code></td>
215- <td class="small">(row.updated.as_str())</td>
216+ <td class="small">rel_time(lang: lang, stamp: row.updated_at.as_str())</td>
216217 <td>
217218 if !archived {
218219 <form method="post" action=(delete_action.as_str()) class="inline-form">
@@ -230,7 +231,7 @@ async fn secrets_body(
230231 }
231232 </section>
232233 if !archived {
233- <section class="card">
234+ <section class="card" id="add-secret">
234235 <h2>(g::t(lang, K::AddOrUpdate))</h2>
235236 if let Some(message) = error {
236237 <p class="alert" role="alert">(message.as_str())</p>
crates/forge-web/src/pages/repo_security.rsmodified+7 -9
@@ -21,10 +21,9 @@ use crate::i18n::misc::{self as g, K};
2121 use crate::i18n::{self, Key, Lang};
2222 use crate::pages::repo::repo_head;
2323 use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
24-use crate::pages::repo_mirrors::stamp_in_tz;
2524 use crate::pages::repo_settings_live::security_live_url;
2625 use crate::state::AppState;
27-use crate::views::shell;
26+use crate::views::{empty_state, rel_time, shell};
2827
2928 path_param!(owner);
3029 path_param!(repo);
@@ -54,7 +53,7 @@ struct AlertRow {
5453 summary: String,
5554 state_text: &'static str,
5655 state_class: &'static str,
57- created: String,
56+ created_at: String,
5857 open: bool,
5958 dismissed: bool,
6059 dismiss_action: String,
@@ -76,7 +75,7 @@ pub(crate) fn can_write(ctx: &RepoCtx) -> bool {
7675 authorize(actor, &ctx.repo, ctx.role, ctx.org_role, Action::Write).is_ok()
7776 }
7877
79-fn row_of(alert: &Alert, title: &str, tz: &str, lang: Lang) -> AlertRow {
78+fn row_of(alert: &Alert, title: &str, lang: Lang) -> AlertRow {
8079 let (state_text, state_class) = match alert.state {
8180 AlertState::Open => (g::t(lang, K::StateOpen), "hook-state fail"),
8281 AlertState::Dismissed => (g::t(lang, K::StateDismissed), "hook-state"),
@@ -96,7 +95,7 @@ fn row_of(alert: &Alert, title: &str, tz: &str, lang: Lang) -> AlertRow {
9695 summary: alert.summary.clone(),
9796 state_text,
9897 state_class,
99- created: stamp_in_tz(&alert.created_at, tz),
98+ created_at: alert.created_at.clone(),
10099 open: alert.state == AlertState::Open,
101100 dismissed: alert.state == AlertState::Dismissed,
102101 dismiss_action: format!("{base}/dismiss"),
@@ -133,7 +132,7 @@ async fn security_body(
133132 </section>
134133 <section class="card">
135134 if rows.is_empty() {
136- <p class="muted">(g::t(lang, K::NoAlerts))</p>
135+ empty_state(title: g::t(lang, K::NoAlerts))
137136 } else {
138137 <div class="table-wrap">
139138 <table class="table security-alerts">
@@ -158,7 +157,7 @@ async fn security_body(
158157 <td>(row.severity.as_str())</td>
159158 <td>(row.summary.as_str())</td>
160159 <td><span class=(row.state_class)>(row.state_text)</span></td>
161- <td>(row.created.as_str())</td>
160+ <td>rel_time(lang: lang, stamp: row.created_at.as_str())</td>
162161 <td>
163162 if row.open {
164163 <form method="post" action=(row.dismiss_action.as_str()) class="inline-form">
@@ -207,13 +206,12 @@ async fn security_page(cx: &Cx) -> Result<impl View> {
207206 let mut head = ctx.head(state, "security").await?;
208207 head.live = security_live_url(&ctx.repo.owner_name, &ctx.repo.name);
209208 let dependencies = state.store.dependency_count(&ctx.repo.id).await?;
210- let tz = ctx.viewer_tz().to_owned();
211209 let rows: Vec<AlertRow> = state
212210 .store
213211 .list_alerts(&ctx.repo.id)
214212 .await?
215213 .iter()
216- .map(|alert| row_of(alert, &title, &tz, lang))
214+ .map(|alert| row_of(alert, &title, lang))
217215 .collect();
218216 let csrf = session.csrf_token.clone();
219217 let enabled = state.config.advisories.enabled;
crates/forge-web/src/pages/repo_settings.rsmodified+71 -42
@@ -90,7 +90,7 @@ struct GeneralForm {
9090 default_branch: String,
9191 }
9292
93-/// The visibility form. An unchecked "I understand" box is absent from the body.
93+/// The visibility form. `understand` is the confirm popup's hidden field; a request without it is refused.
9494 #[derive(Deserialize)]
9595 struct VisibilityForm {
9696 #[serde(default)]
@@ -340,13 +340,21 @@ async fn general_section(
340340 let general_action = format!("/{title}/settings/general");
341341 let visibility_action = format!("/{title}/settings/visibility");
342342 let archive_action = format!("/{title}/settings/archive");
343- let is_public = visibility == Visibility::Public;
344- let private_checked = !is_public;
345- let archive_value = if archived { "0" } else { "1" };
346- let archive_label = if archived {
347- g::t(lang, K::UnarchiveRepo)
343+ // The visibility row shows where the repo is now and offers the other side behind a confirm.
344+ let (current_visibility, flip_label, flip_confirm, flip_to) = if visibility == Visibility::Public {
345+ (
346+ g::t(lang, K::PublicOption),
347+ g::t(lang, K::MakePrivate),
348+ g::t(lang, K::MakePrivateConfirm),
349+ "private",
350+ )
348351 } else {
349- g::t(lang, K::ArchiveRepo)
352+ (
353+ g::t(lang, K::PrivateOption),
354+ g::t(lang, K::MakePublic),
355+ g::t(lang, K::MakePublicConfirm),
356+ "public",
357+ )
350358 };
351359 let options: Vec<(String, bool)> = branches
352360 .into_iter()
@@ -382,40 +390,61 @@ async fn general_section(
382390 </div>
383391 </form>
384392
385- <h3>(g::t(lang, K::VisibilityHeading))</h3>
386- <form method="post" action=(visibility_action) class="stack">
387- <input type="hidden" name="csrf" value=(csrf.clone())>
388- <label class="inline">
389- <input type="radio" name="visibility" value="public" checked=(is_public)>
390- <span>(g::t(lang, K::PublicOption))</span>
391- </label>
392- <label class="inline">
393- <input type="radio" name="visibility" value="private" checked=(private_checked)>
394- <span>(g::t(lang, K::PrivateOption))</span>
395- </label>
396- <label class="inline">
397- <input type="checkbox" name="understand" value="on">
398- <span>(g::t(lang, K::IUnderstand))</span>
399- </label>
400- <p class="muted small">(g::t(lang, K::VisibilityHelp))</p>
401- <div>
402- <button type="submit">(g::t(lang, K::ChangeVisibility))</button>
403- </div>
404- </form>
405-
406- <h3>(g::t(lang, K::ArchiveHeading))</h3>
407- if archived {
408- <p class="muted small">(g::t(lang, K::ArchivedHelp))</p>
409- } else {
410- <p class="muted small">(g::t(lang, K::ArchiveHelp))</p>
411- }
412- <form method="post" action=(archive_action) class="stack">
413- <input type="hidden" name="csrf" value=(csrf.clone())>
414- <input type="hidden" name="archived" value=(archive_value)>
415- <div>
416- <button type="submit">(archive_label)</button>
417- </div>
418- </form>
393+ <ul class="action-list">
394+ <li class="action-row">
395+ <div class="action-text">
396+ <h3>(g::t(lang, K::VisibilityHeading))</h3>
397+ <p class="muted small">(current_visibility)</p>
398+ </div>
399+ <div class="action-control">
400+ <details class="confirm-inline">
401+ <summary class="button">(flip_label)</summary>
402+ <div class="confirm-pop">
403+ <p>(flip_confirm)</p>
404+ <form method="post" action=(visibility_action)>
405+ <input type="hidden" name="csrf" value=(csrf.clone())>
406+ <input type="hidden" name="visibility" value=(flip_to)>
407+ <input type="hidden" name="understand" value="on">
408+ <button type="submit" class="danger">(flip_label)</button>
409+ <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button>
410+ </form>
411+ </div>
412+ </details>
413+ </div>
414+ </li>
415+ <li class="action-row">
416+ <div class="action-text">
417+ <h3>(g::t(lang, K::ArchiveHeading))</h3>
418+ if archived {
419+ <p class="muted small">(g::t(lang, K::ArchivedHelp))</p>
420+ } else {
421+ <p class="muted small">(g::t(lang, K::ArchiveHelp))</p>
422+ }
423+ </div>
424+ <div class="action-control">
425+ if archived {
426+ <form method="post" action=(archive_action.as_str())>
427+ <input type="hidden" name="csrf" value=(csrf.clone())>
428+ <input type="hidden" name="archived" value="0">
429+ <button type="submit">(g::t(lang, K::UnarchiveRepo))</button>
430+ </form>
431+ } else {
432+ <details class="confirm-inline">
433+ <summary class="button">(g::t(lang, K::ArchiveRepo))</summary>
434+ <div class="confirm-pop">
435+ <p>(g::t(lang, K::ArchiveConfirm))</p>
436+ <form method="post" action=(archive_action.as_str())>
437+ <input type="hidden" name="csrf" value=(csrf.clone())>
438+ <input type="hidden" name="archived" value="1">
439+ <button type="submit" class="danger">(g::t(lang, K::ArchiveRepo))</button>
440+ <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button>
441+ </form>
442+ </div>
443+ </details>
444+ }
445+ </div>
446+ </li>
447+ </ul>
419448 </section>
420449 })
421450 }
@@ -963,7 +992,7 @@ async fn settings_general_save(cx: &Cx, Form(form): Form<GeneralForm>) -> Result
963992 Ok(back_to_settings(&title))
964993 }
965994
966-/// Changes the visibility. Changing it needs the "I understand" box. Picking the current value
995+/// Changes the visibility. Changing it needs `understand`, which only the confirm popup sends. Picking the current value
967996 /// changes nothing.
968997 #[route(POST "/{owner}/{repo}/settings/visibility")]
969998 async fn settings_visibility_save(cx: &Cx, Form(form): Form<VisibilityForm>) -> Result<SeeOther> {
crates/forge-web/src/pages/repo_transfer.rsmodified+22 -12
@@ -26,7 +26,7 @@ use crate::pages::repo::repo_head;
2626 use crate::pages::repo_ctx::{RepoHead, load_repo};
2727 use crate::pages::repo_settings_live::{bump_settings, transfer_live_url};
2828 use crate::state::AppState;
29-use crate::views::{csrf_field, shell};
29+use crate::views::{csrf_field, rel_time, shell};
3030
3131 path_param!(owner);
3232 path_param!(repo);
@@ -39,15 +39,25 @@ struct ActionForm {
3939 }
4040
4141 /// One line describing an open transfer, for the repo page.
42-fn summary_text(lang: Lang, transfer: &PendingTransfer) -> String {
43- let until = transfer.expires_at.split('T').next().unwrap_or_default();
44- g::transfer_summary(
42+fn summary_text(lang: Lang, transfer: &PendingTransfer) -> TransferSummary {
43+ let (before, after) = g::transfer_summary(
4544 lang,
4645 transfer.to_is_org,
4746 &transfer.to_owner_name,
4847 &transfer.initiated_by_name,
49- until,
50- )
48+ );
49+ TransferSummary {
50+ before,
51+ expires_at: transfer.expires_at.clone(),
52+ after,
53+ }
54+}
55+
56+/// The pending-transfer sentence, with its expiry as a live relative time between two parts.
57+struct TransferSummary {
58+ before: String,
59+ expires_at: String,
60+ after: &'static str,
5161 }
5262
5363 /// The open transfer and the action forms the viewer may use. Each action is `None` when hidden.
@@ -55,7 +65,7 @@ fn summary_text(lang: Lang, transfer: &PendingTransfer) -> String {
5565 async fn transfer_body(
5666 lang: Lang,
5767 head: RepoHead,
58- summary: String,
68+ summary: Option<TransferSummary>,
5969 accept: Option<String>,
6070 decline: Option<String>,
6171 cancel: Option<String>,
@@ -66,8 +76,8 @@ async fn transfer_body(
6676 repo_head(head: head)
6777 <section class="card">
6878 <h2>(g::t(lang, K::TransferTitle))</h2>
69- if !summary.is_empty() {
70- <p>(summary.as_str())</p>
79+ if let Some(summary) = summary.as_ref() {
80+ <p>(summary.before.as_str()) rel_time(lang: lang, stamp: summary.expires_at.as_str()) (summary.after)</p>
7181 if let Some(action) = accept {
7282 <form method="post" action=(action.as_str()) class="stack">
7383 csrf_field(token: csrf.as_str())
@@ -93,7 +103,7 @@ async fn transfer_body(
93103 </form>
94104 }
95105 }
96- if summary.is_empty() {
106+ if summary.is_none() {
97107 <p class="muted">(g::t(lang, K::NoPendingTransfer))</p>
98108 }
99109 if let Some(href) = settings {
@@ -122,13 +132,13 @@ async fn transfer_get(cx: &Cx) -> Result<impl View> {
122132 let may_accept = state.store.can_accept_transfer(&user.id, transfer).await?;
123133 let may_cancel = may_delete || transfer.initiated_by_id == user.id;
124134 (
125- summary_text(lang, transfer),
135+ Some(summary_text(lang, transfer)),
126136 may_accept.then(|| format!("/-/transfers/{}/accept", transfer.repo_id)),
127137 may_accept.then(|| format!("/-/transfers/{}/decline", transfer.repo_id)),
128138 may_cancel.then(|| format!("/-/transfers/{}/cancel", transfer.repo_id)),
129139 )
130140 }
131- None => (String::new(), None, None, None),
141+ None => (None, None, None, None),
132142 };
133143 let settings = may_delete.then(|| format!("/{title}/settings/rename"));
134144 let mut head = ctx.head(state, "settings").await?;
crates/forge-web/src/pages/repo_webhooks.rsmodified+28 -15
@@ -31,7 +31,7 @@ use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo};
3131 use crate::pages::repo_settings::settings_nav_for;
3232 use crate::pages::repo_settings_live::settings_head;
3333 use crate::state::AppState;
34-use crate::views::{alert, enc, now_unix, relative_time, shell};
34+use crate::views::{alert, empty_state, enc, now_unix, relative_time, shell};
3535 use crate::webhooks::client::{WebhookPolicy, validate_url};
3636 use crate::webhooks::emit::emit_ping;
3737
@@ -404,7 +404,9 @@ struct DeliveryRow {
404404 state_text: &'static str,
405405 event: String,
406406 guid: String,
407- time: String,
407+ time_iso: String,
408+ time_full: String,
409+ time_rel: String,
408410 duration: String,
409411 status: String,
410412 request_headers: String,
@@ -437,7 +439,11 @@ fn delivery_row(
437439 state_text,
438440 event,
439441 guid: delivery.guid.clone(),
440- time: local_stamp(&delivery.created_at, tz),
442+ time_iso: delivery.created_at.clone(),
443+ time_full: local_stamp(&delivery.created_at, tz),
444+ time_rel: OffsetDateTime::parse(&delivery.created_at, &Rfc3339)
445+ .map(|at| relative_time(lang, at.unix_timestamp(), now_unix()))
446+ .unwrap_or_default(),
441447 duration: delivery
442448 .duration_ms
443449 .map_or_else(|| "-".to_owned(), |ms| format!("{ms} ms")),
@@ -572,7 +578,10 @@ async fn hooks_list_body(
572578 <p><a href=(new_href.as_str()) class="button">(g::t(lang, K::AddWebhook))</a></p>
573579 }
574580 if rows.is_empty() {
575- <p class="muted">(g::t(lang, K::NoWebhooks))</p>
581+ empty_state(title: g::t(lang, K::NoWebhooks),
582+ if !archived {
583+ <a class="button" href=(new_href.as_str())>(g::t(lang, K::AddWebhook))</a>
584+ })
576585 } else {
577586 <ul class="runner-list hook-list">
578587 for row in rows.iter() {
@@ -625,7 +634,7 @@ async fn delivery_list(
625634 " "
626635 <code>(row.event.as_str())</code>
627636 " "
628- <span class="muted small">(row.time.as_str())</span>
637+ <time class="muted small" data-rel="true" datetime=(row.time_iso.as_str()) title=(row.time_full.as_str())>(row.time_rel.as_str())</time>
629638 " "
630639 <span class="muted small">(row.duration.as_str())</span>
631640 " "
@@ -707,16 +716,20 @@ async fn hook_body(
707716 <section class="card">
708717 <h2>(g::t(lang, K::DeleteWebhook))</h2>
709718 <p class="muted small">(g::t(lang, K::DeleteIntro))</p>
710- <form method="post" action=(delete_action.as_str()) class="stack">
711- <input type="hidden" name="csrf" value=(csrf.as_str())>
712- <label class="inline">
713- <input type="checkbox" name="confirm" value="on">
714- <span>(g::t(lang, K::DeleteConfirm))</span>
715- </label>
716- <div>
717- <button type="submit" class="danger">(g::t(lang, K::DeleteWebhook))</button>
718- </div>
719- </form>
719+ <div>
720+ <details class="confirm-inline">
721+ <summary class="button danger">(g::t(lang, K::DeleteWebhook))</summary>
722+ <div class="confirm-pop">
723+ <p>(g::t(lang, K::DeleteConfirm))</p>
724+ <form method="post" action=(delete_action.as_str())>
725+ <input type="hidden" name="csrf" value=(csrf.as_str())>
726+ <input type="hidden" name="confirm" value="on">
727+ <button type="submit" class="danger">(g::t(lang, K::DeleteWebhook))</button>
728+ <button type="button" data-close-details="">(g::t(lang, K::Cancel))</button>
729+ </form>
730+ </div>
731+ </details>
732+ </div>
720733 </section>
721734 }
722735 })
crates/forge-web/src/pages/review_requests.rsmodified+2 -2
@@ -23,7 +23,7 @@ use crate::notify;
2323 use crate::pages::issue_parts::{ItemKind, check_write, may_change, parse_number};
2424 use crate::pages::repo_ctx::{RepoCtx, load_repo};
2525 use crate::state::AppState;
26-use crate::views::{rel_time, repo_href, shell};
26+use crate::views::{empty_state, rel_time, repo_href, shell};
2727
2828 path_param!(owner);
2929 path_param!(repo);
@@ -289,7 +289,7 @@ async fn review_requests(cx: &Cx) -> Result<impl View> {
289289 <h1>(heading)</h1>
290290 </section>
291291 if empty {
292- <p class="muted">(ga::t(lang, AK::NoReviewRequests))</p>
292+ empty_state(title: ga::t(lang, AK::NoReviewRequests))
293293 }
294294 if !empty {
295295 <section class="card">
crates/forge-web/src/pages/settings_export.rsmodified+3 -12
@@ -3,7 +3,6 @@
33 //! while an export is building, so it turns ready with no reload and no polling.
44
55 use forge_core::store::exports::{DataExport, ExportState};
6-use forge_core::time::stamp_to_unix;
76 use futures_util::{TryStreamExt, stream};
87 use http::header::{
98 CACHE_CONTROL, CONTENT_DISPOSITION, CONTENT_LENGTH, CONTENT_TYPE, HeaderValue,
@@ -27,7 +26,7 @@ use crate::i18n::migrate::{self as g, K};
2726 use crate::i18n::{self, Lang};
2827 use crate::pages::ci_runs::{changed_event, events_response};
2928 use crate::state::AppState;
30-use crate::views::{alert, csrf_field, human_size, now_unix, relative_time, shell};
29+use crate::views::{alert, csrf_field, human_size, rel_time, shell};
3130
3231 path_param!(export_id);
3332
@@ -51,14 +50,6 @@ fn signature(exports: &[DataExport]) -> String {
5150 .join(",")
5251 }
5352
54-fn ago(lang: Lang, stamp: &str) -> String {
55- stamp_to_unix(stamp).map_or_else(String::new, |t| relative_time(lang, t, now_unix()))
56-}
57-
58-fn day(stamp: &str) -> String {
59- stamp.chars().take(10).collect()
60-}
61-
6253 #[component]
6354 async fn export_view(lang: Lang, csrf: &str, exports: Vec<DataExport>) -> Result<impl View> {
6455 let building = exports.iter().any(|e| e.state == ExportState::Building);
@@ -92,11 +83,11 @@ async fn export_view(lang: Lang, csrf: &str, exports: Vec<DataExport>) -> Result
9283 for export in exports.iter() {
9384 <li class="item export-row">
9485 <div class="item-main">
95- <strong>(g::t(lang, K::ExportRequested)) " " <time data-rel="true" datetime=(export.created_at.as_str())>(ago(lang, &export.created_at))</time></strong>
86+ <strong>(g::t(lang, K::ExportRequested)) " " rel_time(lang: lang, stamp: export.created_at.as_str())</strong>
9687 if export.state == ExportState::Ready {
9788 <span class="muted small">
9889 (g::t(lang, K::ExportSize)) ": " (human_size(lang, u64::try_from(export.size).unwrap_or(0)))
99- " · " (g::expires_on(lang, &day(&export.expires_at)))
90+ " · " (g::expires_label(lang)) " " rel_time(lang: lang, stamp: export.expires_at.as_str())
10091 </span>
10192 }
10293 </div>
crates/forge-web/src/pages/settings_gpg.rsmodified+4 -3
@@ -16,7 +16,7 @@ use crate::auth::{require_csrf, require_user};
1616 use crate::i18n::{self, Key, Lang, t};
1717 use crate::signatures;
1818 use crate::state::AppState;
19-use crate::views::{added_status, alert, shell, user_facing_message};
19+use crate::views::{added_status, alert, empty_state, shell, user_facing_message};
2020
2121 #[derive(Deserialize)]
2222 struct AddKeyForm {
@@ -52,7 +52,8 @@ async fn gpg_view(
5252 }
5353 <section class="card">
5454 if keys.is_empty() {
55- <p class="muted">(t(lang, Key::NoGpgKeys))</p>
55+ empty_state(title: t(lang, Key::NoGpgKeys),
56+ <a class="button" href="#add-gpg-key">(t(lang, Key::AddGpgKeyTitle))</a>)
5657 } else {
5758 <ul class="item-list">
5859 for key in keys.into_iter() {
@@ -72,7 +73,7 @@ async fn gpg_view(
7273 </ul>
7374 }
7475 </section>
75- <section class="card">
76+ <section class="card" id="add-gpg-key">
7677 <h2>(t(lang, Key::AddGpgKeyTitle))</h2>
7778 if let Some(message) = error {
7879 alert(message: message.as_str())
crates/forge-web/src/pages/settings_keys.rsmodified+4 -3
@@ -15,7 +15,7 @@ use crate::audit::{self, Actor, Target};
1515 use crate::auth::{require_csrf, require_user};
1616 use crate::i18n::{self, Key, Lang, t, unsupported_key_type};
1717 use crate::state::AppState;
18-use crate::views::{added_status, alert, shell, user_facing_message};
18+use crate::views::{added_status, alert, empty_state, shell, user_facing_message};
1919
2020 /// Algorithms accepted for web-registered keys. `ssh-rsa` is rejected with its own message.
2121 const ACCEPTED: &[&str] = &[
@@ -149,7 +149,8 @@ async fn keys_view(
149149 </section>
150150 <section class="card">
151151 if keys.is_empty() {
152- <p class="muted">(t(lang, Key::NoSshKeys))</p>
152+ empty_state(title: t(lang, Key::NoSshKeys),
153+ <a class="button" href="#add-key">(t(lang, Key::AddSshKeyTitle))</a>)
153154 } else {
154155 <ul class="item-list">
155156 for key in keys.into_iter() {
@@ -170,7 +171,7 @@ async fn keys_view(
170171 </ul>
171172 }
172173 </section>
173- <section class="card">
174+ <section class="card" id="add-key">
174175 <h2>(t(lang, Key::AddSshKeyTitle))</h2>
175176 if let Some(message) = error {
176177 alert(message: message.as_str())
crates/forge-web/src/pages/settings_notifications.rsmodified+4 -9
@@ -18,7 +18,7 @@ use crate::auth::{require_csrf, require_user};
1818 use crate::i18n::push as push_text;
1919 use crate::i18n::{self, Key, Lang, t};
2020 use crate::state::AppState;
21-use crate::views::{csrf_field, shell};
21+use crate::views::{csrf_field, empty_state, rel_time, shell};
2222
2323 #[query_params(error = bad_request)]
2424 struct NotificationsQuery {
@@ -53,11 +53,6 @@ struct NotificationsPage {
5353 can_test: bool,
5454 }
5555
56-/// A device's date for the list: the `YYYY-MM-DD` part of its stamp.
57-fn day_of(stamp: &str) -> &str {
58- stamp.get(..10).unwrap_or(stamp)
59-}
60-
6156 #[component]
6257 async fn notifications_body(page: NotificationsPage) -> Result<impl View> {
6358 let NotificationsPage {
@@ -131,17 +126,17 @@ async fn notifications_body(page: NotificationsPage) -> Result<impl View> {
131126 <section class="card">
132127 <h2>(push_text::t(lang, push_text::K::DevicesHeading))</h2>
133128 if devices.is_empty() {
134- <p class="muted">(push_text::t(lang, push_text::K::DevicesEmpty))</p>
129+ empty_state(title: push_text::t(lang, push_text::K::DevicesEmpty))
135130 }
136131 <ul class="push-devices">
137132 for device in devices.into_iter() {
138133 <li class="push-device">
139134 <div>
140135 <strong>(device.agent_label.as_str())</strong>
141- <small class="muted">(push_text::added_on(lang, day_of(&device.created_at)))</small>
136+ <small class="muted">(push_text::added_label(lang)) " " rel_time(lang: lang, stamp: device.created_at.as_str())</small>
142137 <small class="muted">
143138 if let Some(stamp) = device.last_success_at.as_deref() {
144- (push_text::last_delivered(lang, day_of(stamp)))
139+ (push_text::last_delivered_label(lang)) " " rel_time(lang: lang, stamp: stamp)
145140 } else {
146141 (push_text::t(lang, push_text::K::NeverDelivered))
147142 }
crates/forge-web/src/pages/settings_sessions.rsmodified+3 -3
@@ -119,9 +119,9 @@ async fn session_detail_view(
119119 <div><dt>(t(lang, Key::UserAgent))</dt><dd>(user_agent.as_str())</dd></div>
120120 <div><dt>(t(lang, Key::SignInIp))</dt><dd>(sign_in_ip.as_str())</dd></div>
121121 <div><dt>(t(lang, Key::LastIp))</dt><dd>(last_ip.as_str())</dd></div>
122- <div><dt>(t(lang, Key::SignedIn))</dt><dd>rel_time(lang: lang, stamp: session.created_at.as_str()) " (" (session.created_at.as_str()) ")"</dd></div>
123- <div><dt>(t(lang, Key::LastSeenAt))</dt><dd>rel_time(lang: lang, stamp: session.last_seen.as_str()) " (" (session.last_seen.as_str()) ")"</dd></div>
124- <div><dt>(t(lang, Key::ExpiresAt))</dt><dd>rel_time(lang: lang, stamp: session.expires_at.as_str()) " (" (session.expires_at.as_str()) ")"</dd></div>
122+ <div><dt>(t(lang, Key::SignedIn))</dt><dd>rel_time(lang: lang, stamp: session.created_at.as_str())</dd></div>
123+ <div><dt>(t(lang, Key::LastSeenAt))</dt><dd>rel_time(lang: lang, stamp: session.last_seen.as_str())</dd></div>
124+ <div><dt>(t(lang, Key::ExpiresAt))</dt><dd>rel_time(lang: lang, stamp: session.expires_at.as_str())</dd></div>
125125 </dl>
126126 </section>
127127 <section class="card">
crates/forge-web/src/pages/settings_tokens.rsmodified+4 -3
@@ -24,7 +24,7 @@ use crate::i18n::releases_ci::{self as rc, K as RC};
2424 use crate::i18n::{self, Key, Lang, t, token_name_length};
2525 use crate::pages::admin_runners::confirm_post;
2626 use crate::state::AppState;
27-use crate::views::{alert, rel_time, rel_time_or_never, shell};
27+use crate::views::{alert, empty_state, rel_time, rel_time_or_never, shell};
2828
2929 /// Scopes are fixed to `repo` for M1.
3030 const SCOPES: &[&str] = &["repo"];
@@ -102,7 +102,8 @@ async fn tokens_view(
102102 }
103103 <section class="card">
104104 if tokens.is_empty() {
105- <p class="muted">(t(lang, Key::NoAccessTokens))</p>
105+ empty_state(title: t(lang, Key::NoAccessTokens),
106+ <a class="button" href="#add-token">(t(lang, Key::NewToken))</a>)
106107 } else {
107108 <ul class="item-list">
108109 for token in tokens.into_iter() {
@@ -117,7 +118,7 @@ async fn tokens_view(
117118 </ul>
118119 }
119120 </section>
120- <section class="card">
121+ <section class="card" id="add-token">
121122 <h2>(t(lang, Key::NewToken))</h2>
122123 if let Some(message) = error {
123124 alert(message: message.as_str())
crates/forge-web/src/pages/snippets.rsmodified+16 -18
@@ -27,7 +27,7 @@ use crate::pages::snippets_live::{bump_snippet, item_live_url, list_live_url};
2727 use crate::render::highlight::highlight_lines;
2828 use crate::render::markdown::render_markdown;
2929 use crate::state::AppState;
30-use crate::views::{alert, shell, user_facing_message};
30+use crate::views::{alert, empty_state, rel_time, shell, user_facing_message};
3131
3232 path_param!(id);
3333
@@ -201,7 +201,8 @@ struct ListRow {
201201 owner: String,
202202 visibility: &'static str,
203203 /// The file count and the last update, as one line.
204- meta: String,
204+ files: String,
205+ updated_at: String,
205206 }
206207
207208 fn visibility_label(lang: Lang, visibility: SnippetVisibility) -> &'static str {
@@ -237,13 +238,6 @@ fn file_view(state: &AppState, snippet: &Snippet, file: &SnippetFile) -> FileVie
237238 }
238239 }
239240
240-/// `2026-10-19T18:39:50.4389Z` as `2026-10-19 18:39`: stored timestamps carry nanoseconds.
241-fn short_time(stamp: &str) -> String {
242- stamp
243- .get(..16)
244- .map_or_else(|| stamp.to_owned(), |s| s.replace('T', " "))
245-}
246-
247241 /// The snippet if the viewer may read it, else 404.
248242 pub(crate) async fn readable(
249243 cx: &Cx,
@@ -282,7 +276,11 @@ async fn snippet_list_body(
282276 </section>
283277 <section class="card">
284278 if rows.is_empty() {
285- <p class="muted">(g::t(lang, K::NoSnippets))</p>
279+ empty_state(title: g::t(lang, K::NoSnippets),
280+ if signed_in {
281+ <a class="button primary" href="/snippets/new">(g::t(lang, K::NewSnippet))</a>
282+ }
283+ )
286284 } else {
287285 <ul class="item-list snippet-list">
288286 for row in rows.into_iter() {
@@ -290,7 +288,7 @@ async fn snippet_list_body(
290288 <div class="item-main">
291289 <a href=(format!("/snippets/{}", row.id))><strong>(row.title)</strong></a>
292290 <span class="muted small">
293- (row.owner) " · " (row.visibility) " · " (row.meta)
291+ (row.owner) " · " (row.visibility) " · " (row.files) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: row.updated_at.as_str()) (g::updated_after(lang))
294292 </span>
295293 </div>
296294 </li>
@@ -452,7 +450,7 @@ async fn snippet_body(
452450 owner: &str,
453451 description: &str,
454452 visibility: &'static str,
455- updated: &str,
453+ updated_at: &str,
456454 files: Vec<FileView>,
457455 owner_csrf: Option<String>,
458456 live: Option<String>,
@@ -464,7 +462,7 @@ async fn snippet_body(
464462 Ok(view! {
465463 <section class="page-head snippet-view-head" data-live=(live.as_deref())>
466464 <h1>(title)</h1>
467- <span class="muted small">(owner) " · " (visibility) " · " (g::updated_on(lang, updated))</span>
465+ <span class="muted small">(owner) " · " (visibility) " · " (g::updated_before(lang)) rel_time(lang: lang, stamp: updated_at) (g::updated_after(lang))</span>
468466 </section>
469467 if !description.is_empty() {
470468 <p class="snippet-description">(description)</p>
@@ -527,7 +525,7 @@ async fn revisions_body(
527525 <div class="item-main">
528526 <strong>(g::t(lang, K::RevisionLabel))(rev.number)</strong>
529527 <span class="muted small">
530- (rev.author) " · " (rev.at) " · " (rev.file_names)
528+ (rev.author) " · " rel_time(lang: lang, stamp: rev.at.as_str()) " · " (rev.file_names)
531529 </span>
532530 </div>
533531 </li>
@@ -578,7 +576,8 @@ async fn snippets_list(cx: &Cx) -> Result<impl View> {
578576 title: s.title,
579577 owner: s.owner_name,
580578 visibility: visibility_label(lang, s.visibility),
581- meta: g::files_updated(lang, s.file_count, &short_time(&s.updated_at)),
579+ files: g::files_count(lang, s.file_count),
580+ updated_at: s.updated_at,
582581 })
583582 .collect();
584583 let signed_in = viewer.is_some();
@@ -675,13 +674,12 @@ async fn snippet_view(cx: &Cx) -> Result<impl View> {
675674 Some((user, session)) if user.id == snippet.owner_id => Some(session.csrf_token.clone()),
676675 _ => None,
677676 };
678- let updated = short_time(&snippet.updated_at);
679677 let visibility = visibility_label(lang, snippet.visibility);
680678 Ok(view! {
681679 shell(title: snippet.title.as_str(), viewer: viewer.as_ref(),
682680 snippet_body(lang: lang, snippet_id: snippet.id.as_str(), title: snippet.title.as_str(),
683681 owner: snippet.owner_name.as_str(), description: snippet.description.as_str(),
684- visibility: visibility, updated: updated.as_str(), files: files,
682+ visibility: visibility, updated_at: snippet.updated_at.as_str(), files: files,
685683 owner_csrf: owner_csrf, live: Some(item_live_url(snippet.id.as_str())))
686684 )
687685 })
@@ -779,7 +777,7 @@ async fn snippet_revisions(cx: &Cx) -> Result<impl View> {
779777 .map(|(index, rev)| RevisionView {
780778 number: index + 1,
781779 author: rev.author_name,
782- at: short_time(&rev.created_at),
780+ at: rev.created_at.clone(),
783781 file_names: rev
784782 .files
785783 .iter()
crates/forge-web/src/pages/wiki.rsmodified+13 -13
@@ -8,7 +8,7 @@
88 use std::path::PathBuf;
99
1010 use forge_core::AuditAction;
11-use forge_core::tz::format_in_tz;
11+use forge_core::time::stamp_from_unix;
1212 use forge_git::repo::wiki_path;
1313 use forge_git::wiki::{self, MAX_PAGE_BYTES, PageEdit, PageRevision, valid_page_name};
1414 use serde::Deserialize;
@@ -29,7 +29,7 @@ use crate::pages::repo_ctx::{RepoCtx, load_repo};
2929 use crate::pages::wiki_live::{bump_wiki, page_live_url, wiki_live_url};
3030 use crate::render::markdown::render_markdown;
3131 use crate::state::AppState;
32-use crate::views::{alert, repo_href, shell};
32+use crate::views::{alert, empty_state, rel_time, repo_href, shell};
3333
3434 path_param!(owner);
3535 path_param!(repo);
@@ -134,13 +134,13 @@ pub struct RevisionRow {
134134 pub subject: String,
135135 }
136136
137-fn revision_rows(ctx: &RepoCtx, revs: &[PageRevision], tz: &str) -> Vec<RevisionRow> {
137+fn revision_rows(ctx: &RepoCtx, revs: &[PageRevision]) -> Vec<RevisionRow> {
138138 revs.iter()
139139 .map(|rev| RevisionRow {
140140 short: rev.oid.chars().take(10).collect(),
141141 href: repo_href(&ctx.repo.owner_name, &ctx.repo.name, "commit", &rev.oid),
142142 author: rev.author.clone(),
143- when: format_in_tz(rev.at, tz),
143+ when: stamp_from_unix(rev.at).unwrap_or_default(),
144144 subject: rev.subject.clone(),
145145 })
146146 .collect()
@@ -220,10 +220,11 @@ async fn wiki_empty_body(
220220 let new = repo_href(&owner, &repo, "wiki", "-/new");
221221 Ok(view! {
222222 <section class="card wiki-page">
223- <p class="muted">(g::t(lang, K::WikiNoPages))</p>
224- if can_write {
225- <a class="button primary" href=(new)>(g::t(lang, K::CreateFirstPage))</a>
226- }
223+ empty_state(title: g::t(lang, K::WikiNoPages),
224+ if can_write {
225+ <a class="button primary" href=(new.as_str())>(g::t(lang, K::CreateFirstPage))</a>
226+ }
227+ )
227228 </section>
228229 })
229230 }
@@ -245,7 +246,7 @@ async fn wiki_list_body(
245246 Ok(view! {
246247 <section class="card wiki-page">
247248 if rows.is_empty() {
248- <p class="muted">(g::t(lang, K::NoPagesYet))</p>
249+ empty_state(title: g::t(lang, K::NoPagesYet))
249250 } else {
250251 <ul class="item-list wiki-pages">
251252 for (title, href) in rows.into_iter() {
@@ -262,7 +263,7 @@ async fn wiki_history_body(lang: Lang, rows: Vec<RevisionRow>) -> Result<impl Vi
262263 Ok(view! {
263264 <section class="card wiki-page">
264265 if rows.is_empty() {
265- <p class="muted">(g::t(lang, K::NoChangesYet))</p>
266+ empty_state(title: g::t(lang, K::NoChangesYet))
266267 } else {
267268 <div class="table-wrap">
268269 <table class="table wiki-history">
@@ -272,7 +273,7 @@ async fn wiki_history_body(lang: Lang, rows: Vec<RevisionRow>) -> Result<impl Vi
272273 <td class="nowrap"><a href=(row.href)><code>(row.short.as_str())</code></a></td>
273274 <td>(row.subject.as_str())</td>
274275 <td class="muted small nowrap">(row.author.as_str())</td>
275- <td class="muted small nowrap">(row.when.as_str())</td>
276+ <td class="muted small nowrap">rel_time(lang: lang, stamp: row.when.as_str())</td>
276277 </tr>
277278 }
278279 </tbody>
@@ -457,8 +458,7 @@ async fn wiki_page_history(cx: &Cx) -> Result<impl View> {
457458 let dir = wiki_dir(state, &ctx)?;
458459 let git = state.git.clone();
459460 let revs = wiki::page_history(&git, &dir, &page_name).await?;
460- let tz = ctx.viewer_tz().to_owned();
461- let rows = revision_rows(&ctx, &revs, &tz);
461+ let rows = revision_rows(&ctx, &revs);
462462 let owner_name = ctx.repo.owner_name.clone();
463463 let repo_name = ctx.repo.name.clone();
464464 let lang = i18n::lang(cx, ctx.viewer.as_ref().map(|(user, _)| user));
crates/forge-web/src/raw.rsmodified+4 -2
@@ -37,8 +37,10 @@ pub(crate) const LINK_TTL_SECS: i64 = 600;
3737
3838 const CSP: &str = "default-src 'none'; img-src 'self' data:; style-src 'unsafe-inline'; sandbox";
3939 const CORP: &str = "cross-origin";
40-pub(crate) const CACHE_PRIVATE: &str = "private, max-age=300";
41-pub(crate) const CACHE_PUBLIC: &str = "public, max-age=300";
40+/// Raw responses revalidate on every use (an unchanged blob answers 304 through If-None-Match),
41+/// so a repo made private, or a reader who lost access, stops being served at once.
42+pub(crate) const CACHE_PRIVATE: &str = "private, no-cache";
43+pub(crate) const CACHE_PUBLIC: &str = "public, no-cache";
4244 pub(crate) const CACHE_NONE: &str = "no-store";
4345 const TEXT: &str = "text/plain; charset=utf-8";
4446 pub(crate) const OCTET: &str = "application/octet-stream";
crates/forge-web/src/views/heatmap.rsmodified+3 -2
@@ -209,7 +209,8 @@ struct DayView {
209209 }
210210
211211 /// The link for a calendar day: the day's contributions below the calendar, or back to the
212-/// plain calendar when the day is the selected one.
212+/// plain calendar when the day is the selected one. The anchor brings a full page load back to the
213+/// calendar; nav.js swaps in place and keeps the scroll (`data-keep-scroll`), so it is not used there.
213214 fn day_href(date: (i64, i64, i64), selected: bool) -> String {
214215 if selected {
215216 "/#contributions-h".to_owned()
@@ -461,7 +462,7 @@ pub async fn contribution_calendar(
461462 <div class="heat-grid" role="group" aria-label=(summary.as_str())>
462463 for cell in cells.into_iter() {
463464 if let Some(href) = cell.href {
464- <a class=(cell.class.as_str()) href=(href.as_str()) title=(cell.title.as_str())></a>
465+ <a class=(cell.class.as_str()) href=(href.as_str()) title=(cell.title.as_str()) data-keep-scroll="true"></a>
465466 } else {
466467 <span class=(cell.class.as_str()) title=(cell.title.as_str())></span>
467468 }
crates/forge-web/src/views/mod.rsmodified+34 -3
@@ -26,6 +26,7 @@ use topcoat::router::{Body, Next, layer};
2626 use topcoat::view::{Child, Unescaped, View, component, view};
2727
2828 use crate::i18n::admin::{self as ad, K as AK};
29+use crate::i18n::browse as br;
2930 use crate::i18n::code::{self as g, K};
3031 use crate::i18n::community::{self as cm, K as CK};
3132 use crate::i18n::link::{self as lk, K as LinkKey};
@@ -282,6 +283,7 @@ pub async fn shell(
282283 );
283284 let anonymous = viewer.is_none();
284285 let search_label = o::t(lang, OK::SearchPublicRepos);
286+ let palette_label = br::t(lang, br::K::PaletteOpen).to_owned();
285287 let notif_label = t(lang, Key::Notifications);
286288 let menu_label = t(lang, Key::SiteMenu);
287289 let side_repos_menu = side_repos.clone();
@@ -310,7 +312,7 @@ pub async fn shell(
310312 }
311313 <script src=(NAV_SCRIPT_HREF) defer="defer"></script>
312314 </head>
313- <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit))>
315+ <body data-link-restarting=(lk::t(lang, LinkKey::Restarting)) data-link-back=(lk::t(lang, LinkKey::BackSubmit)) data-done-saved=(lk::t(lang, LinkKey::Saved)) data-done-ok=(lk::t(lang, LinkKey::Done)) data-draft-restored=(lk::t(lang, LinkKey::DraftRestored)) data-draft-discard=(lk::t(lang, LinkKey::DraftDiscard))>
314316 <header class="topbar">
315317 if signed_in {
316318 <details class="nav-toggle">
@@ -361,6 +363,15 @@ pub async fn shell(
361363 </button>
362364 </form>
363365 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>
364375 <a class="icon-btn bell" href="/notifications" aria-label=(notif_label) title=(notif_label)>
365376 <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>
366377 if let Some(badge) = unread_badge {
@@ -526,7 +537,7 @@ pub struct Section {
526537 pub live: &'static str,
527538 }
528539
529-fn admin_items(lang: Lang) -> Vec<NavItem> {
540+pub fn admin_items(lang: Lang) -> Vec<NavItem> {
530541 let item = |key, href: &'static str, label, icon| NavItem {
531542 key,
532543 href: href.to_owned(),
@@ -590,7 +601,7 @@ fn org_items(lang: Lang, org: &str) -> Vec<NavItem> {
590601 ]
591602 }
592603
593-fn settings_items(lang: Lang) -> Vec<NavItem> {
604+pub fn settings_items(lang: Lang) -> Vec<NavItem> {
594605 let item = |key, href: &'static str, label, icon| NavItem {
595606 key,
596607 href: href.to_owned(),
@@ -858,6 +869,26 @@ pub async fn alert(message: &str) -> Result<impl View> {
858869 })
859870 }
860871
872+/// What a list shows when it has nothing yet: one line saying so, an optional hint, and an optional
873+/// next step as the child (a button, a link, or a command to copy). Pages use it so every empty list
874+/// reads the same way.
875+#[component]
876+pub async fn empty_state(
877+ title: &str,
878+ #[default] hint: Option<&str>,
879+ #[default] child: Child<'_>,
880+) -> Result<impl View> {
881+ Ok(view! {
882+ <div class="empty-state">
883+ <p class="empty-state-title">(title)</p>
884+ if let Some(hint) = hint {
885+ <p class="empty-state-hint">(hint)</p>
886+ }
887+ <div class="empty-state-action">(child)</div>
888+ </div>
889+ })
890+}
891+
861892 /// Owned copy of a user-facing error message, for the errors a form can recover from.
862893 /// Returns `None` for internal failures, which should propagate as 500s.
863894 pub fn user_facing_message(err: &CoreError) -> Option<String> {
style/_account_admin.scssmodified+2 -0
@@ -231,6 +231,8 @@
231231 top: calc(100% + 6px);
232232 z-index: 10;
233233 width: min(300px, calc(100vw - 32px));
234+ // The general rule caps the pop at its summary's width; here it hangs out to the left.
235+ max-width: none;
234236 padding: 12px 14px;
235237 border: 1px solid var(--border);
236238 border-radius: var(--radius-lg);
style/_drafts.scssadded+7 -0
@@ -0,0 +1,7 @@
1+// The note under a comment draft that nav.js put back into its field. Small and quiet, so it reads as
2+// a hint, not as part of the form.
3+.draft-note {
4+ margin: 4px 0 0;
5+ font-size: 0.8125rem;
6+ color: var(--muted);
7+}
style/_empty.scssadded+44 -0
@@ -0,0 +1,44 @@
1+// An empty list (views::empty_state): a quiet centred block with the next step under it.
2+.empty-state {
3+ display: flex;
4+ flex-direction: column;
5+ align-items: center;
6+ gap: 6px;
7+ padding: 28px 16px;
8+ text-align: center;
9+ color: var(--muted);
10+
11+ .empty-state-title {
12+ margin: 0;
13+ color: var(--text-2);
14+ font-weight: 600;
15+ }
16+
17+ .empty-state-hint {
18+ max-width: 52ch;
19+ margin: 0;
20+ font-size: 0.875rem;
21+ }
22+
23+ .empty-state-action {
24+ display: flex;
25+ flex-wrap: wrap;
26+ justify-content: center;
27+ gap: 8px;
28+ margin-top: 8px;
29+
30+ &:empty {
31+ display: none;
32+ }
33+
34+ > button,
35+ > .button {
36+ align-self: center;
37+ }
38+
39+ pre,
40+ code {
41+ text-align: left;
42+ }
43+ }
44+}
style/_feedback.scssadded+74 -0
@@ -0,0 +1,74 @@
1+// Submit feedback. A button whose POST is slow gets is-busy (nav.js adds it after 150 ms, and only
2+// while the request is in flight). It dims and shows a small spinner; it is never disabled. Once the
3+// server confirmed the save, a done-tick sits after the button for a moment, then fades out.
4+
5+.is-busy {
6+ cursor: progress;
7+ opacity: 0.75;
8+
9+ &::after {
10+ content: "";
11+ display: inline-block;
12+ width: 12px;
13+ height: 12px;
14+ margin-left: 8px;
15+ vertical-align: -2px;
16+ border: 2px solid currentColor;
17+ border-right-color: transparent;
18+ border-radius: 50%;
19+ animation: busy-spin 0.7s linear infinite;
20+ }
21+}
22+
23+@keyframes busy-spin {
24+ to {
25+ transform: rotate(360deg);
26+ }
27+}
28+
29+.done-tick {
30+ display: inline-flex;
31+ align-items: center;
32+ gap: 4px;
33+ margin-left: 8px;
34+ color: var(--ok);
35+ font-size: 0.875em;
36+ font-weight: 500;
37+ white-space: nowrap;
38+ animation: done-tick 2.2s ease-out both;
39+
40+ .ico {
41+ width: 14px;
42+ height: 14px;
43+ fill: none;
44+ stroke: currentColor;
45+ stroke-width: 2.2;
46+ stroke-linecap: round;
47+ stroke-linejoin: round;
48+ }
49+}
50+
51+// Quick fade in, hold, then fade out over the last part of the 2.2 s.
52+@keyframes done-tick {
53+ 0% {
54+ opacity: 0;
55+ }
56+ 12%,
57+ 78% {
58+ opacity: 1;
59+ }
60+ 100% {
61+ opacity: 0;
62+ }
63+}
64+
65+@media (prefers-reduced-motion: reduce) {
66+ // No spin: the dimmed label alone shows it is busy.
67+ .is-busy::after {
68+ display: none;
69+ }
70+
71+ .done-tick {
72+ animation: none;
73+ }
74+}
style/_motion.scssadded+70 -0
@@ -0,0 +1,70 @@
1+// Motion for what the reader does: a button they press, a menu they open, a stepper they click, the
2+// banner they dismiss. The classes below are added by nav.js on the reader's own action, never on a
3+// live re-render, so a page that updates itself does not move on its own. Inline disclosures slide in
4+// nav.js (slideDetails). Individual `translate` and `scale` are used, so a panel placed with
5+// `transform` keeps its place.
6+
7+$ease-out: cubic-bezier(0.2, 0, 0, 1);
8+
9+// A press sinks the button a little.
10+.button,
11+button {
12+ transition: background-color 0.15s ease, scale 0.1s ease;
13+
14+ &:active:not(:disabled) {
15+ scale: 0.97;
16+ }
17+}
18+
19+// A menu or popover the reader opens drops in from its summary.
20+details.pop[open] > :not(summary) {
21+ animation: pop-in 0.14s $ease-out;
22+}
23+
24+@keyframes pop-in {
25+ from {
26+ opacity: 0;
27+ translate: 0 -4px;
28+ scale: 0.98;
29+ }
30+}
31+
32+// The phone branch switcher is a sheet from the bottom: it rises instead.
33+@media (max-width: 600px) {
34+ details.ref-select.pop[open] > .ref-menu {
35+ animation: sheet-up 0.2s $ease-out;
36+ }
37+}
38+
39+@keyframes sheet-up {
40+ from {
41+ translate: 0 100%;
42+ }
43+}
44+
45+// A stepper's number flashes the accent when a click moves it.
46+input.tick {
47+ animation: tick 0.3s ease-out;
48+}
49+
50+@keyframes tick {
51+ from {
52+ color: var(--accent);
53+ }
54+}
55+
56+@media (prefers-reduced-motion: reduce) {
57+ .button,
58+ button {
59+ transition: none;
60+
61+ &:active:not(:disabled) {
62+ scale: none;
63+ }
64+ }
65+
66+ details.pop[open] > :not(summary),
67+ input.tick {
68+ animation: none;
69+ }
70+}
style/_palette.scssadded+174 -0
@@ -0,0 +1,174 @@
1+// 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.
3+
4+// The topbar button that opens it: a search icon and the shortcut, sized like the other top bar links.
5+.palette-open {
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+
43+dialog.palette {
44+ width: min(560px, calc(100vw - 32px));
45+ max-height: min(70vh, 520px);
46+ margin: 12vh auto 0;
47+ padding: 0;
48+ color: var(--text);
49+ background: var(--surface);
50+ border: 1px solid var(--border-strong);
51+ border-radius: var(--radius-lg);
52+ box-shadow: var(--shadow);
53+
54+ &::backdrop {
55+ background: rgba(20, 24, 22, 0.45);
56+ }
57+
58+ &[open] {
59+ display: flex;
60+ flex-direction: column;
61+ }
62+}
63+
64+.palette-box {
65+ display: flex;
66+ flex-direction: column;
67+ min-height: 0;
68+ flex: 1 1 auto;
69+}
70+
71+// The search row is part of the palette, not a field inside it: no box, only the divider below.
72+.palette-search {
73+ flex: none;
74+ display: flex;
75+ align-items: center;
76+ gap: 10px;
77+ padding: 0 12px;
78+ color: var(--muted);
79+ border-bottom: 1px solid var(--border);
80+
81+ &:focus-within {
82+ color: var(--accent);
83+ }
84+}
85+
86+.palette-input {
87+ flex: 1 1 auto;
88+ min-width: 0;
89+ height: 46px;
90+ padding: 0;
91+ font: inherit;
92+ font-size: 15px;
93+ color: var(--text);
94+ background: transparent;
95+ border: 0;
96+
97+ &::placeholder {
98+ color: var(--muted);
99+ }
100+
101+ &:focus,
102+ &:focus-visible {
103+ outline: none;
104+ box-shadow: none;
105+ }
106+}
107+
108+.palette-list {
109+ flex: 1 1 auto;
110+ min-height: 0;
111+ margin: 0;
112+ padding: 6px;
113+ overflow-y: auto;
114+ list-style: none;
115+ font-size: 0.875rem;
116+
117+ li {
118+ margin: 0;
119+ }
120+
121+ // Group headings: small caps like the branch switcher's, with a dashed rule between groups.
122+ .palette-head {
123+ padding: 6px 8px 4px;
124+ font-size: 11px;
125+ font-weight: 600;
126+ letter-spacing: 0.06em;
127+ text-transform: uppercase;
128+ color: var(--muted);
129+ }
130+
131+ .palette-head:not(:first-child) {
132+ margin-top: 6px;
133+ padding-top: 10px;
134+ border-top: 1px dashed var(--border);
135+ }
136+
137+ // Options: the selected row (keys or pointer) gets the soft accent fill.
138+ li[role="option"] {
139+ padding: 7px 10px;
140+ color: var(--text);
141+ border-radius: var(--radius-md);
142+ cursor: pointer;
143+ overflow-wrap: anywhere;
144+ }
145+
146+ li[aria-selected="true"] {
147+ background: var(--accent-soft);
148+ }
149+}
150+
151+.palette-note {
152+ flex: none;
153+ margin: 0;
154+ padding: 8px 12px;
155+ border-top: 1px solid var(--border);
156+}
157+
158+// Phones: the palette spans the screen width and sits at the top, with larger rows to tap.
159+@media (max-width: 600px) {
160+ dialog.palette {
161+ width: calc(100vw - 16px);
162+ max-height: calc(100vh - 16px);
163+ margin: 8px auto 0;
164+ }
165+
166+ .palette-input {
167+ height: 52px;
168+ font-size: 16px;
169+ }
170+
171+ .palette-list li[role="option"] {
172+ padding: 12px 10px;
173+ }
174+}
style/_shell.scssmodified+4 -2
@@ -415,7 +415,8 @@
415415 align-self: start;
416416 display: block;
417417 box-sizing: border-box;
418- height: calc(100vh - var(--topbar-h));
418+ // 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)));
419420 min-width: 0;
420421 padding: 16px 12px 24px;
421422 overflow-y: auto;
@@ -431,7 +432,8 @@
431432
432433 .shell:has(> .shell-sidebar) .repo-tabs {
433434 position: fixed;
434- top: var(--topbar-h);
435+ // nav.js sets --shell-top to where the page body starts, below the site banner when there is one.
436+ top: max(var(--topbar-h), var(--shell-top, 0px));
435437 bottom: 0;
436438 left: 0;
437439 z-index: 5;
style/main.scssmodified+6 -1
@@ -5759,7 +5759,7 @@ html.js form.runner-load[data-dirty-form][data-dirty] .runner-save {
57595759 top: calc(var(--topbar-h) + 16px);
57605760 display: flex;
57615761 flex-direction: column;
5762- max-height: calc(100dvh - var(--topbar-h) - 104px);
5762+ max-height: calc(100dvh - max(var(--topbar-h), var(--shell-top, 0px)) - 104px);
57635763 }
57645764
57655765 .ci-side-head,
@@ -7754,6 +7754,11 @@ button.ci-job-last {
77547754 @import "members";
77557755 @import "hooks";
77567756 @import "admin_rows";
7757+@import "motion";
7758+@import "empty";
7759+@import "feedback";
7760+@import "drafts";
7761+@import "palette";
77577762
77587763 // A monospace value with its Copy button on the right; long values wrap inside the box.
77597764 .copy-box {