From 3aaf5efc6e6aa5d8c495134443cad39e537ccf20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 1 Nov 2026 09:44:06 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20style:=20four=20passes=20over=20?= =?UTF-8?q?every=20page=20in=20both=20themes=20and=20on=20phones:=20all=20?= =?UTF-8?q?menus,=20dropdowns=20and=20popovers=20share=20one=20panel=20and?= =?UTF-8?q?=20open=20at=20once,=20selects,=20checkboxes,=20scrollbars=20an?= =?UTF-8?q?d=20disclosure=20chevrons=20replace=20the=20browser's,=20labels?= =?UTF-8?q?=20are=20tinted=20chips,=20one-pane=20settings=20and=20admin=20?= =?UTF-8?q?pages=20use=20the=20full=20width,=20sessions=20are=20one=20row?= =?UTF-8?q?=20each,=20the=20audit=20filter=20sits=20above=20its=20table,?= =?UTF-8?q?=20Create=20and=20Import=20share=20the=20page=20head,=20Compare?= =?UTF-8?q?=20is=20one=20row,=20a=20folder=20with=20no=20README=20gives=20?= =?UTF-8?q?its=20list=20the=20width,=20and=20new=20pages'=20empty=20states?= =?UTF-8?q?=20lose=20buttons=20that=20repeat=20the=20form=20beside=20them;?= =?UTF-8?q?=20=E2=9A=A1=20perf:=20a=20run=20page=20embeds=2024=20KiB=20of?= =?UTF-8?q?=20log=20rather=20than=20512,=20with=20a=20link=20to=20the=20fu?= =?UTF-8?q?ll=20log,=20and=20links=20prefetch=20on=20press,=20so=20opening?= =?UTF-8?q?=20CI=20is=20as=20quick=20as=20Issues;=20=E2=9C=A8=20feat:=20ru?= =?UTF-8?q?n=20tones=20are=20told=20apart=20at=20once,=20a=20bright=20risi?= =?UTF-8?q?ng=20chime=20for=20passed=20and=20a=20low=20double=20buzz=20for?= =?UTF-8?q?=20failed;=20=F0=9F=94=A5=20remove:=20the=20density=20setting,?= =?UTF-8?q?=20which=20changed=20nothing=20on=20the=20pages=20people=20use;?= =?UTF-8?q?=20the=20settings=20side=20switch=20says=20what=20it=20moves;?= =?UTF-8?q?=20=F0=9F=90=9B=20fix:=20file=20tree=20icons=20are=20no=20longe?= =?UTF-8?q?r=20black=20on=20dark,=20the=20site=20banner=20lines=20up=20wit?= =?UTF-8?q?h=20the=20page,=20the=20pulls=20page=20no=20longer=20scrolls=20?= =?UTF-8?q?sideways=20on=20a=20phone,=20phone=20tables=20keep=20two=20stra?= =?UTF-8?q?ight=20columns,=20blame=20stays=20readable=20in=20both=20themes?= =?UTF-8?q?,=20and=20syntax=20colours=20reach=204.5:1=20in=20light;=20a=20?= =?UTF-8?q?run=20whose=20commit=20was=20overwritten=20cannot=20be=20re-run?= =?UTF-8?q?,=20standbys=20prune=20too,=20links=20to=20pruned=20commits=20n?= =?UTF-8?q?o=20longer=20dangle,=20and=20a=20contribution=20or=20a=20stored?= =?UTF-8?q?=20run=20no=20longer=20shows=20a=20commit=20that=20is=20gone?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-core/src/store/contributions.rs | 24 + crates/forge-core/src/store/user_prefs.rs | 16 +- crates/forge-git/src/browse.rs | 44 +- crates/forge-git/src/maintenance.rs | 15 + crates/forge-web/assets/nav.js | 86 ++- crates/forge-web/src/i18n/misc.rs | 38 +- crates/forge-web/src/i18n/mod.rs | 4 +- crates/forge-web/src/i18n/releases_ci.rs | 10 + crates/forge-web/src/i18n/repo_admin.rs | 4 +- crates/forge-web/src/pages/ci_job.rs | 21 +- crates/forge-web/src/pages/ci_runs.rs | 86 ++- crates/forge-web/src/pages/ci_tests.rs | 46 +- crates/forge-web/src/pages/compare.rs | 10 +- crates/forge-web/src/pages/discussion_view.rs | 4 +- crates/forge-web/src/pages/import.rs | 12 +- crates/forge-web/src/pages/issue_parts.rs | 46 +- crates/forge-web/src/pages/issue_view.rs | 4 +- crates/forge-web/src/pages/issues_list.rs | 4 +- crates/forge-web/src/pages/labels_css.rs | 55 +- crates/forge-web/src/pages/new_repo.rs | 2 +- crates/forge-web/src/pages/notifications.rs | 2 +- crates/forge-web/src/pages/pull_view.rs | 19 +- crates/forge-web/src/pages/repo_webhooks.rs | 5 +- crates/forge-web/src/pages/review_requests.rs | 4 +- .../src/pages/settings_appearance.rs | 59 +- crates/forge-web/src/prune.rs | 52 +- crates/forge-web/src/render/highlight.rs | 70 +- crates/forge-web/src/replication/worker.rs | 42 ++ crates/forge-web/src/views/heatmap.rs | 40 +- crates/forge-web/src/views/mod.rs | 3 +- crates/forge-web/src/views/review_thread.rs | 2 +- docs/architecture.md | 2 + docs/backup.md | 4 + style/_account_admin.scss | 3 +- style/{_density.scss => _appearance.scss} | 42 -- style/_canvas_account.scss | 2 +- style/_canvas_pull.scss | 2 +- style/_canvas_repo.scss | 25 +- style/_heatmap.scss | 1 - style/_kb_rerun.scss | 10 +- style/_lang_issues.scss | 4 +- style/_language.scss | 3 +- style/_motion.scss | 28 - style/_needs.scss | 2 +- style/_pull.scss | 6 +- style/_repo.scss | 4 - style/_shell.scss | 2 - style/_system.scss | 653 ++++++++++++++++++ style/_timeline_ci.scss | 3 +- style/main.scss | 40 +- 50 files changed, 1267 insertions(+), 398 deletions(-) rename style/{_density.scss => _appearance.scss} (68%) create mode 100644 style/_system.scss diff --git a/crates/forge-core/src/store/contributions.rs b/crates/forge-core/src/store/contributions.rs index f805b01..4ccde3e 100644 --- a/crates/forge-core/src/store/contributions.rs +++ b/crates/forge-core/src/store/contributions.rs @@ -197,6 +197,30 @@ impl Store { .map_err(db_err)?; Ok(()) } + + /// The distinct commit ids in `repo_id` whose stored message is not blank. + pub async fn coauthored_oids(&self, repo_id: &str) -> Result> { + let sql = "SELECT DISTINCT commit_oid FROM coauthored_commits \ + WHERE repo_id = ?1 AND summary <> '' ORDER BY commit_oid"; + let params = vec![Value::Text(repo_id.to_string())]; + let conn = self.read_conn().await; + fetch_all(&conn, sql, params, |row| col_text(row, 0)).await + } + + /// Blanks the stored message of the commits `oids` in `repo_id`, for every user. The rows stay, + /// so contribution counts do not change. + pub async fn blank_coauthored(&self, repo_id: &str, oids: &[String]) -> Result<()> { + let conn = self.inner.conn.lock().await; + for oid in oids { + conn.execute( + "UPDATE coauthored_commits SET summary = '' WHERE repo_id = ?1 AND commit_oid = ?2", + (repo_id.to_string(), oid.clone()), + ) + .await + .map_err(db_err)?; + } + Ok(()) + } } #[cfg(test)] diff --git a/crates/forge-core/src/store/user_prefs.rs b/crates/forge-core/src/store/user_prefs.rs index 105f2eb..5f5a0f8 100644 --- a/crates/forge-core/src/store/user_prefs.rs +++ b/crates/forge-core/src/store/user_prefs.rs @@ -8,10 +8,6 @@ use super::{Store, col_text, db_err, fetch_all}; use crate::error::Result; use crate::time::now_stamp; -/// Key of the row density: `comfortable` (the default, no row) or `compact`. -pub const DENSITY: &str = "density"; -/// The densities a user may store. -pub const DENSITIES: &[&str] = &["comfortable", "compact"]; /// Key of the run-finished tone: `on` or `off` (the default, no row). pub const SOUND: &str = "sound"; /// The sound values a user may store. @@ -69,7 +65,7 @@ mod tests { use crate::store::Store; #[tokio::test] - async fn density_and_sound_round_trip_and_replace() { + async fn a_pref_round_trips_and_replaces() { let dir = tempfile::tempdir().unwrap(); let store = Store::open(&dir.path().join("forge.db")).await.unwrap(); let user = store @@ -78,18 +74,10 @@ mod tests { .unwrap(); assert!(store.user_prefs(&user.id).await.unwrap().is_empty()); - store - .set_user_pref(&user.id, DENSITY, "compact") - .await - .unwrap(); + store.set_user_pref(&user.id, SOUND, "off").await.unwrap(); store.set_user_pref(&user.id, SOUND, "on").await.unwrap(); - store - .set_user_pref(&user.id, DENSITY, "comfortable") - .await - .unwrap(); let prefs = store.user_prefs(&user.id).await.unwrap(); - assert_eq!(prefs.get(DENSITY).map(String::as_str), Some("comfortable")); assert_eq!(prefs.get(SOUND).map(String::as_str), Some("on")); } } diff --git a/crates/forge-git/src/browse.rs b/crates/forge-git/src/browse.rs index 9d8b12b..fad5f7a 100644 --- a/crates/forge-git/src/browse.rs +++ b/crates/forge-git/src/browse.rs @@ -3,6 +3,7 @@ //! Everything here is blocking; callers run it inside `spawn_blocking`. Repositories are opened //! isolated: the environment and user/system git configuration are ignored. +use std::collections::HashSet; use std::path::Path; use gix::bstr::ByteSlice; @@ -226,26 +227,31 @@ fn resolve_hex(repo: &gix::Repository, hex: &str) -> Result> { /// The refs whose history is public. A commit no ref here reaches was overwritten or deleted. const VISIBLE_REFS: [&str; 3] = ["refs/heads/", "refs/tags/", "refs/pull/"]; -/// True when a branch, tag or pull request reaches `id`. Other commits stay on disk until -/// `maintenance::prune_unreachable` runs, and must not be served by hash until then. -fn reachable(repo: &gix::Repository, id: gix::ObjectId) -> Result { +/// The commits at the tips of [`VISIBLE_REFS`]. A ref that does not peel to a commit reaches nothing. +fn visible_tips(repo: &gix::Repository) -> Result> { let refs = repo.references().map_err(gerr)?; let mut tips = Vec::new(); for prefix in VISIBLE_REFS { for reference in refs.prefixed(prefix).map_err(gerr)? { let mut reference = reference.map_err(gerr)?; - // A ref that does not peel to a commit reaches nothing. if let Ok(tip) = reference.peel_to_id() { let tip = tip.detach(); - if tip == id { - return Ok(true); - } if is_commit(repo, tip)? { tips.push(tip); } } } } + Ok(tips) +} + +/// True when a branch, tag or pull request reaches `id`. Other commits stay on disk until +/// `maintenance::prune_unreachable` runs, and must not be served by hash until then. +fn reachable(repo: &gix::Repository, id: gix::ObjectId) -> Result { + let tips = visible_tips(repo)?; + if tips.contains(&id) { + return Ok(true); + } if tips.is_empty() { return Ok(false); } @@ -257,6 +263,30 @@ fn reachable(repo: &gix::Repository, id: gix::ObjectId) -> Result { Ok(false) } +/// Those of the full commit ids `oids` that a branch, tag or pull request reaches, in one walk. +/// Malformed ids are left out. For deciding which stored hashes on a page may still link. +pub fn reachable_commits(repo: &Path, oids: &[String]) -> Result> { + let mut wanted: HashSet = + oids.iter().filter_map(|oid| parse_oid(oid).ok()).collect(); + let repo = open(repo)?; + let mut found = HashSet::new(); + wanted.retain(|id| matches!(repo.try_find_header(*id), Ok(Some(_)))); + let tips = visible_tips(&repo)?; + if wanted.is_empty() || tips.is_empty() { + return Ok(found); + } + for info in repo.rev_walk(tips).all().map_err(gerr)? { + let id = info.map_err(gerr)?.id; + if wanted.remove(&id) { + found.insert(id.to_hex().to_string()); + if wanted.is_empty() { + break; + } + } + } + Ok(found) +} + /// True when `oid` is a full commit id that a branch, tag or pull request reaches. pub fn commit_reachable(repo: &Path, oid: &str) -> Result { let repo = open(repo)?; diff --git a/crates/forge-git/src/maintenance.rs b/crates/forge-git/src/maintenance.rs index 15d7359..0f7ecb4 100644 --- a/crates/forge-git/src/maintenance.rs +++ b/crates/forge-git/src/maintenance.rs @@ -16,6 +16,9 @@ const PRUNE_TIMEOUT: Duration = Duration::from_secs(30 * 60); const PRUNE_MARK: &str = "forge-prune-due"; /// Touched after each prune. const PRUNE_STAMP: &str = "forge-pruned"; +/// Written after a prune removed objects. The standby still holds them, so its next replication +/// prunes its copy and clears this mark. +const STANDBY_PRUNE_MARK: &str = "forge-standby-prune-due"; /// A push's objects are unreachable for a moment before its ref lands, so only objects at least /// this old are removed. The mark waits this long too, so everything it stands for qualifies. const PRUNE_GRACE: Duration = Duration::from_secs(15 * 60); @@ -79,6 +82,7 @@ pub async fn prune_unreachable(env: &GitEnv, repo: &Path, prune: &'static str) - } } fs::write(repo.join(PRUNE_STAMP), b"")?; + fs::write(repo.join(STANDBY_PRUNE_MARK), b"")?; // A mark written during the prune stays for the next pass. if let Ok(marked) = marked && fs::metadata(repo.join(PRUNE_MARK)) @@ -91,6 +95,17 @@ pub async fn prune_unreachable(env: &GitEnv, repo: &Path, prune: &'static str) - Ok(()) } +/// True when a prune removed objects that the standby copy of `repo` still holds. +pub fn standby_prune_due(repo: &Path) -> bool { + repo.join(STANDBY_PRUNE_MARK).is_file() +} + +/// Clears the standby mark once the standby has been pruned. Best effort: a mark left behind only +/// causes one more harmless prune. +pub fn clear_standby_prune(repo: &Path) { + let _ = fs::remove_file(repo.join(STANDBY_PRUNE_MARK)); +} + /// Runs `cmd` with [`STEP_TIMEOUT`]. Dropping the future on timeout drops the child, /// which `GitCommand` spawns with `kill_on_drop`, so the process is killed. async fn run_bounded(cmd: GitCommand) -> Result<()> { diff --git a/crates/forge-web/assets/nav.js b/crates/forge-web/assets/nav.js index 41735be..104d341 100644 --- a/crates/forge-web/assets/nav.js +++ b/crates/forge-web/assets/nav.js @@ -2511,28 +2511,59 @@ var finishedKeys = null; // the runs the newest answer listed; null until the first one var toneCtx = null; // the AudioContext, made on first use - // The two notes of an outcome: rising C5 then G5 for a pass, falling for a failure. Each note is a - // short sine with a quick fade in and out, so nothing clicks. + // The two outcomes differ in everything an ear uses, so neither is a guess. A pass is high, clean + // and quick: a rising C major chime that rings out. A failure is low, rough and heavy: two falling + // buzzes, each a pair of notes a semitone apart that beat against each other. + var TONES = { + passed: { + wave: 'triangle', peak: 0.16, cutoff: 8000, + notes: [ + { at: 0, hz: [523.25], len: 0.16 }, + { at: 0.09, hz: [659.25], len: 0.16 }, + { at: 0.18, hz: [783.99, 1046.5], len: 0.5 } + ] + }, + failed: { + wave: 'sawtooth', peak: 0.2, cutoff: 900, + notes: [ + { at: 0, hz: [196, 207.65], len: 0.24 }, + { at: 0.26, hz: [146.83, 155.56], len: 0.46 } + ] + } + }; + + // Schedules an outcome's notes on `ctx`, fading each in and out so nothing clicks. + function scheduleTones(ctx, outcome) { + var tone = TONES[outcome] || TONES.failed; + var filter = ctx.createBiquadFilter(); + filter.type = 'lowpass'; + filter.frequency.value = tone.cutoff; + filter.connect(ctx.destination); + var start = ctx.currentTime + 0.02; + tone.notes.forEach(function (note) { + var at = start + note.at; + var gain = ctx.createGain(); + gain.gain.setValueAtTime(0.0001, at); + gain.gain.exponentialRampToValueAtTime(tone.peak, at + 0.012); + gain.gain.exponentialRampToValueAtTime(0.0001, at + note.len); + gain.connect(filter); + note.hz.forEach(function (hz) { + var osc = ctx.createOscillator(); + osc.type = tone.wave; + osc.frequency.value = hz; + osc.connect(gain); + osc.start(at); + osc.stop(at + note.len + 0.02); + }); + }); + } + function playTones(outcome) { var AC = window.AudioContext || window.webkitAudioContext; if (!AC) { return; } try { toneCtx = toneCtx || new AC(); } catch (err) { return; } if (toneCtx.state === 'suspended') { toneCtx.resume().catch(function () { }); } - var freqs = outcome === 'passed' ? [523.25, 783.99] : [783.99, 523.25]; - var start = toneCtx.currentTime + 0.02; - freqs.forEach(function (hz, i) { - var at = start + i * 0.14; - var osc = toneCtx.createOscillator(), gain = toneCtx.createGain(); - osc.type = 'sine'; - osc.frequency.value = hz; - gain.gain.setValueAtTime(0.0001, at); - gain.gain.exponentialRampToValueAtTime(0.15, at + 0.02); - gain.gain.exponentialRampToValueAtTime(0.0001, at + 0.16); - osc.connect(gain); - gain.connect(toneCtx.destination); - osc.start(at); - osc.stop(at + 0.18); - }); + scheduleTones(toneCtx, outcome); } // One tab plays for a run. Each tab writes its id under the run's key when the key is free, waits @@ -2585,12 +2616,6 @@ if (b) { playTones(b.getAttribute('data-sound-play')); } }); - // Signed-out visitors keep their density in localStorage. Signed in, the shell has set - // `data-density` on already, so nothing is read here. - if (!signedIn && !root.hasAttribute('data-density')) { - try { if (localStorage.getItem('forge-density') === 'compact') { root.setAttribute('data-density', 'compact'); } } catch (err) { } - } - // The CI log (a job page's [data-live-log]). The server sends the raw text; this turns it into // numbered lines (#L12 anchors) with ANSI colours as spans, `::group::name` / `::endgroup::` // sections as
, and a search box with highlight and next/previous. Streamed bytes go @@ -3566,7 +3591,7 @@ // Hover prefetch: a link the pointer rests on for a moment starts its page request early, so the // click that often follows finds the answer already on its way. Only what the click handler would // soft-navigate is fetched, and never a path that writes when viewed or serves a file. - var PREFETCH_DELAY = 80; // ms the pointer must rest on a link before its request starts + var PREFETCH_DELAY = 30; // ms the pointer must rest on a link before its request starts var PREFETCH_TTL = 10000; // ms a finished or running prefetch is still used by a click var PREFETCH_MAX = 4; // stored prefetches; the oldest is dropped first var NO_PREFETCH = /\/-\/|\/(live|events|stream|open|download)$|\/(archive|raw|actions|attachments|artifacts)\/|\.zip$|\.tar\.gz$|\/releases\/download\/|^\/(logout|notifications)(\/|$)/; @@ -3633,6 +3658,19 @@ }, PREFETCH_DELAY); }, true); + // A press means the click is coming: the request leaves now, not when the button comes back up. + document.addEventListener('pointerdown', function (e) { + var a = e.target && e.target.closest ? e.target.closest('a[href]') : null; + var url = a && e.button === 0 ? prefetchUrl(a) : null; + if (!url || !prefetchAllowed()) { return; } + for (var i = 0; i < prefetches.length; i++) { + if (prefetches[i].key === url.href) { return; } + } + clearTimeout(prefetchTimer); + prefetchTimer = null; + startPrefetch(url); + }, true); + // Leaving the link (not moving between its children) cancels a prefetch that has not started yet. document.addEventListener('mouseout', function (e) { var a = e.target && e.target.closest ? e.target.closest('a[href]') : null; diff --git a/crates/forge-web/src/i18n/misc.rs b/crates/forge-web/src/i18n/misc.rs index 2651174..ffcd012 100644 --- a/crates/forge-web/src/i18n/misc.rs +++ b/crates/forge-web/src/i18n/misc.rs @@ -42,12 +42,7 @@ pub enum K { SidebarLeft, SidebarRight, ChooseSidebar, - // Appearance: row density, and the run-finished tone. - DensityLabel, - DensityComfortable, - DensityCompact, - DensityHelp, - ChooseDensity, + // Appearance: the run-finished tone. SoundLabel, SoundSwitch, SoundOwnRuns, @@ -57,7 +52,6 @@ pub enum K { SoundFailedNote, SoundPlay, SoundFootOwn, - SoundFootTones, ChooseSound, // Notifications: row kinds. KindOpenIssue, @@ -228,11 +222,6 @@ const ALL: &[K] = &[ K::SidebarLeft, K::SidebarRight, K::ChooseSidebar, - K::DensityLabel, - K::DensityComfortable, - K::DensityCompact, - K::DensityHelp, - K::ChooseDensity, K::SoundLabel, K::SoundSwitch, K::SoundOwnRuns, @@ -242,7 +231,6 @@ const ALL: &[K] = &[ K::SoundFailedNote, K::SoundPlay, K::SoundFootOwn, - K::SoundFootTones, K::ChooseSound, K::KindOpenIssue, K::KindClosedIssue, @@ -424,24 +412,14 @@ pub fn t(lang: Lang, key: K) -> &'static str { (BackgroundLabel, Tr) => "Arka plan", (ChooseBase, En) => "Choose a background from the list.", (ChooseBase, Tr) => "Listeden bir arka plan seçin.", - (SidebarLabel, En) => "Sidebar position", - (SidebarLabel, Tr) => "Kenar çubuğu konumu", + (SidebarLabel, En) => "Settings menu side", + (SidebarLabel, Tr) => "Ayarlar menüsünün yanı", (SidebarLeft, En) => "Left", (SidebarLeft, Tr) => "Sol", (SidebarRight, En) => "Right", (SidebarRight, Tr) => "Sağ", (ChooseSidebar, En) => "Choose a sidebar position from the list.", (ChooseSidebar, Tr) => "Listeden bir kenar çubuğu konumu seçin.", - (DensityLabel, En) => "Density", - (DensityLabel, Tr) => "Yoğunluk", - (DensityComfortable, En) => "Comfortable", - (DensityComfortable, Tr) => "Rahat", - (DensityCompact, En) => "Compact", - (DensityCompact, Tr) => "Sıkı", - (DensityHelp, En) => "Saved to your account. Compact shows more rows on a screen.", - (DensityHelp, Tr) => "Hesabınıza kaydedilir. Sıkı görünüm ekranda daha çok satır gösterir.", - (ChooseDensity, En) => "Choose Comfortable or Compact.", - (ChooseDensity, Tr) => "Rahat ya da Sıkı seçin.", (SoundLabel, En) => "Sound", (SoundLabel, Tr) => "Ses", (SoundSwitch, En) => "Play a tone when my run finishes", @@ -450,18 +428,16 @@ pub fn t(lang: Lang, key: K) -> &'static str { (SoundOwnRuns, Tr) => "Yalnızca kendi çalıştırmalarınız", (SoundPassed, En) => "Run passed", (SoundPassed, Tr) => "Çalıştırma başarılı", - (SoundPassedNote, En) => "two rising notes", - (SoundPassedNote, Tr) => "yükselen iki nota", + (SoundPassedNote, En) => "a bright rising chime", + (SoundPassedNote, Tr) => "parlak, yükselen bir çan", (SoundFailed, En) => "Run failed", (SoundFailed, Tr) => "Çalıştırma başarısız", - (SoundFailedNote, En) => "two falling notes", - (SoundFailedNote, Tr) => "alçalan iki nota", + (SoundFailedNote, En) => "a low, rough double buzz", + (SoundFailedNote, Tr) => "pes ve sert, çift vızıltı", (SoundPlay, En) => "Play", (SoundPlay, Tr) => "Çal", (SoundFootOwn, En) => "Never for a page you are looking at.", (SoundFootOwn, Tr) => "Baktığınız sayfa için asla çalmaz.", - (SoundFootTones, En) => "Tones are made in the browser, with no audio files.", - (SoundFootTones, Tr) => "Sesler tarayıcıda üretilir, ses dosyası yoktur.", (ChooseSound, En) => "Choose on or off.", (ChooseSound, Tr) => "Açık ya da kapalı seçin.", (KindOpenIssue, En) => "Open issue", diff --git a/crates/forge-web/src/i18n/mod.rs b/crates/forge-web/src/i18n/mod.rs index 0646089..809b27f 100644 --- a/crates/forge-web/src/i18n/mod.rs +++ b/crates/forge-web/src/i18n/mod.rs @@ -1054,7 +1054,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (MailReasonComment, En) => "you commented on it", (MailReasonSubscribed, En) => "you are subscribed to it", (MailReasonWatching, En) => "you watch this repository", - (MenuNotificationEmails, En) => "Notification emails", + (MenuNotificationEmails, En) => "Notifications", (EmailNotifyLabel, En) => "Email me about notifications", (EmailNotifyHelp, En) => { "Each notification is sent to your verified address. Notifications on the site are not affected." @@ -1083,7 +1083,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (MailReasonComment, Tr) => "bunda yorum yaptınız", (MailReasonSubscribed, Tr) => "bunu takip ediyorsunuz", (MailReasonWatching, Tr) => "bu depoyu izliyorsunuz", - (MenuNotificationEmails, Tr) => "Bildirim e-postaları", + (MenuNotificationEmails, Tr) => "Bildirimler", (EmailNotifyLabel, Tr) => "Bildirimler hakkında bana e-posta gönder", (EmailNotifyHelp, Tr) => { "Her bildirim doğrulanmış adresinize gönderilir. Sitedeki bildirimler bundan etkilenmez." diff --git a/crates/forge-web/src/i18n/releases_ci.rs b/crates/forge-web/src/i18n/releases_ci.rs index af364d5..f43c9cd 100644 --- a/crates/forge-web/src/i18n/releases_ci.rs +++ b/crates/forge-web/src/i18n/releases_ci.rs @@ -38,6 +38,8 @@ pub enum K { CiNoticeNoFailed, CiNoticeNotDone, CiNoticeTooBig, + CiNoticeOverwritten, + CiCommitOverwritten, LogSearch, LogPrev, LogNext, @@ -232,6 +234,12 @@ pub fn t(lang: Lang, key: K) -> &'static str { (CiNoticeTooBig, Tr) => { "Yapıtlar tek dosya olarak indirilemeyecek kadar büyük. Tek tek indirin." } + (CiNoticeOverwritten, En) => "This commit was overwritten, so it can't be re-run.", + (CiNoticeOverwritten, Tr) => { + "Bu commit'in üzerine yazıldı, bu yüzden yeniden çalıştırılamaz." + } + (CiCommitOverwritten, En) => "This commit was overwritten by a force push.", + (CiCommitOverwritten, Tr) => "Bu commit'in üzerine yazıldı.", (LogSearch, En) => "Search the log", (LogSearch, Tr) => "Günlükte ara", (LogPrev, En) => "Previous match", @@ -624,6 +632,8 @@ mod tests { K::CiNoticeNoFailed, K::CiNoticeNotDone, K::CiNoticeTooBig, + K::CiNoticeOverwritten, + K::CiCommitOverwritten, K::LogSearch, K::LogPrev, K::LogNext, diff --git a/crates/forge-web/src/i18n/repo_admin.rs b/crates/forge-web/src/i18n/repo_admin.rs index 8f3e982..d0f7e13 100644 --- a/crates/forge-web/src/i18n/repo_admin.rs +++ b/crates/forge-web/src/i18n/repo_admin.rs @@ -339,8 +339,8 @@ pub fn t(lang: Lang, key: K) -> &'static str { } (NewRule, Tr) => "Yeni kural", (NoBranchesYet, Tr) => "Henüz dal yok. Varsayılan dal, ilk gönderimden sonra seçilebilir.", - (NoCollaborators, En) => "No collaborators yet. Add one below.", - (NoCollaborators, Tr) => "Henüz ortak çalışan yok. Aşağıdan bir ortak çalışan ekleyin.", + (NoCollaborators, En) => "No collaborators yet.", + (NoCollaborators, Tr) => "Henüz ortak çalışan yok.", (NoPendingTransfer, En) => "No transfer is pending for this repository.", (NoPendingTransfer, Tr) => "Bu depo için bekleyen bir devir yok.", (NoSecrets, En) => "No secrets yet.", diff --git a/crates/forge-web/src/pages/ci_job.rs b/crates/forge-web/src/pages/ci_job.rs index 7527ef7..b0d033f 100644 --- a/crates/forge-web/src/pages/ci_job.rs +++ b/crates/forge-web/src/pages/ci_job.rs @@ -35,8 +35,8 @@ use crate::i18n::{ releases_ci::{self as g, K}, }; use crate::pages::ci_runs::{ - age_text, can_write, changed_event, dock_bars, duration_text, events_response, job_href, - run_href, state_text, strip_ansi, + age_text, can_write, changed_event, commit_reachable_for, dock_bars, duration_text, + events_response, job_href, run_href, state_text, strip_ansi, }; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; @@ -145,6 +145,11 @@ async fn newlines_before(path: &Path, end: u64) -> Result { /// The last `TAIL_BYTES` of a log, from a line boundary. A log that does not exist yet is empty. pub(crate) async fn log_tail(path: &Path) -> Result { + log_tail_of(path, TAIL_BYTES).await +} + +/// The last `max` bytes of a log, from a line boundary. +pub(crate) async fn log_tail_of(path: &Path, max: u64) -> Result { let mut file = match tokio::fs::File::open(path).await { Ok(file) => file, Err(e) if e.kind() == std::io::ErrorKind::NotFound => { @@ -158,17 +163,17 @@ pub(crate) async fn log_tail(path: &Path) -> Result { Err(e) => return Err(forge_core::Error::Io(e).into()), }; let len = file.metadata().await.map_err(forge_core::Error::Io)?.len(); - let truncated = len > TAIL_BYTES; + let truncated = len > max; let mut start = 0; if truncated { - start = len - TAIL_BYTES; + start = len - max; file.seek(SeekFrom::Start(start)) .await .map_err(forge_core::Error::Io)?; } let mut buf = Vec::new(); (&mut file) - .take(TAIL_BYTES) + .take(max) .read_to_end(&mut buf) .await .map_err(forge_core::Error::Io)?; @@ -515,6 +520,10 @@ async fn job_page(cx: &Cx) -> Result { }; let title = title_of(&ctx); let live = format!("{}/events", job_href(&title, &job.id)); + // A job of a run whose commit was overwritten cannot be run again. The walk runs only for a writer. + let reachable = can_write(&ctx) + && job.state.is_terminal() + && commit_reachable_for(&ctx.path, &run.commit_oid).await?; let view = JobView { name: job.name.clone(), fingerprint, @@ -543,7 +552,7 @@ async fn job_page(cx: &Cx) -> Result { run_href: run_href(&title, run.number), run_number: run.number, log_href: format!("{}/log.txt", job_href(&title, &job.id)), - rerun: if job.state.is_terminal() && can_write(&ctx) { + rerun: if reachable { ctx.viewer.as_ref().map(|(_, session)| { ( format!("{}/rerun", job_href(&title, &job.id)), diff --git a/crates/forge-web/src/pages/ci_runs.rs b/crates/forge-web/src/pages/ci_runs.rs index 3a771b5..5fc27d6 100644 --- a/crates/forge-web/src/pages/ci_runs.rs +++ b/crates/forge-web/src/pages/ci_runs.rs @@ -8,14 +8,14 @@ //! `/{owner}/{repo}/ci/events`, which fires on every run created or changed in the repo, and a run or job //! page opens its own `changed` stream (`.../events`) when it is not finished. -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::future::Future; use std::path::Path; use std::time::Duration; use forge_core::ci::{CiJob, CiRun, JobSample, JobState, RunState}; use forge_core::{Action, Denied, Store, User, authorize}; -use forge_git::browse::{RefInfo, RefKind, read_commit}; +use forge_git::browse::{RefInfo, RefKind, commit_reachable, reachable_commits, read_commit}; use futures_util::{Stream, StreamExt, stream}; use serde::Deserialize; use time::OffsetDateTime; @@ -41,7 +41,7 @@ use crate::i18n::{ }; use crate::pages::ci_estimate::{self, Est, Step}; use crate::pages::ci_fail::{self, FailFirst, fail_first_block}; -use crate::pages::ci_job::{Tail, log_tail}; +use crate::pages::ci_job::{Tail, log_tail_of}; use crate::pages::refs::load_refs; use crate::pages::repo::repo_head; use crate::pages::repo_ctx::{RepoCtx, RepoHead, load_repo, still_readable}; @@ -64,7 +64,8 @@ const PER_PAGE: u32 = 25; const MAX_PAGE: u32 = 1000; /// Notice words (the only text a `?notice=` query can show), their text and whether they are errors. -const NOTICES: [(&str, K, bool); 11] = [ +const NOTICES: [(&str, K, bool); 12] = [ + ("overwritten", K::CiNoticeOverwritten, true), ("started", K::CiNoticeStarted, false), ("cancelled", K::CiNoticeCancelled, false), ("approved", K::CiNoticeApproved, false), @@ -437,7 +438,10 @@ struct RunDetail { state_class: String, trigger: String, branch: String, - commit_href: String, + /// The commit's page. None when a force push overwrote the commit. + commit_href: Option, + /// Whether a branch, tag or pull request still reaches the commit. Re-run is offered only then. + reachable: bool, commit: String, actor: String, /// The run's creation as an age, and its stamp for the `
@@ -2044,7 +2074,11 @@ async fn run_head(lang: Lang, run: &RunDetail, all_href: Option) -> Resu
(run.state.as_str()) (run.trigger.as_str()) " \u{b7} " (run.branch.as_str()) - (run.commit.as_str()) + if let Some(href) = run.commit_href.as_ref() { + (run.commit.as_str()) + } else { + (run.commit.as_str()) + } if !run.actor.is_empty() { (run.actor.as_str()) } @@ -2077,7 +2111,7 @@ async fn run_head(lang: Lang, run: &RunDetail, all_href: Option) -> Resu if run.can_rerun_failed && !run.can_approve && !run.can_cancel { action_button(action: format!("{}/rerun-failed", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::RerunFailed)) } - if !run.can_approve { + if !run.can_approve && run.reachable { action_button(action: format!("{}/rerun", run.action_base), csrf: csrf.clone(), label: g::t(lang, K::Rerun)) }
@@ -2196,9 +2230,12 @@ async fn run_log(lang: Lang, run: &RunDetail, timeline: bool) -> Result(g::t(lang, K::LogTruncated))

+

+ (crate::pages::passkeys::s(lang, "Showing the end of this log.", "Günlüğün sonu gösteriliyor.")) + " " (crate::pages::passkeys::s(lang, "Full log", "Tam günlük")) +

} -
(log.text.as_str())
+
(log.text.as_str())
} else {

(g::t(lang, K::NoJobs))

} @@ -2634,6 +2671,12 @@ async fn run_rerun(cx: &Cx, Form(form): Form) -> Result { require_write(&ctx)?; let state = app_context::(cx); let run = run_of(state, &ctx, &number).await?; + if !commit_reachable_for(&ctx.path, &run.commit_oid).await? { + return Ok(notice_redirect( + &run_href(&title_of(&ctx), run.number), + "overwritten", + )); + } let new_run = state.store.rerun(&run.id, &user.id).await?; after_change(state, &new_run.id, &[]).await?; Ok(notice_redirect( @@ -2655,6 +2698,9 @@ async fn run_rerun_failed(cx: &Cx, Form(form): Form) -> Result(cx); let run = run_of(state, &ctx, &number).await?; let href = run_href(&title_of(&ctx), run.number); + if !commit_reachable_for(&ctx.path, &run.commit_oid).await? { + return Ok(notice_redirect(&href, "overwritten")); + } match state.store.rerun_failed(&run.id, &user.id).await { Ok(new_run) => { after_change(state, &new_run.id, &[]).await?; @@ -2695,6 +2741,12 @@ async fn job_rerun(cx: &Cx, Form(form): Form) -> Result { if run.repo_id != ctx.repo.id { return Err(not_found().into()); } + if !commit_reachable_for(&ctx.path, &run.commit_oid).await? { + return Ok(notice_redirect( + &run_href(&title_of(&ctx), run.number), + "overwritten", + )); + } match state.store.rerun_job(&run.id, &job.id, &user.id).await { Ok(new_run) => { after_change(state, &new_run.id, &[]).await?; diff --git a/crates/forge-web/src/pages/ci_tests.rs b/crates/forge-web/src/pages/ci_tests.rs index e821563..f40b73e 100644 --- a/crates/forge-web/src/pages/ci_tests.rs +++ b/crates/forge-web/src/pages/ci_tests.rs @@ -18,6 +18,7 @@ use crate::ci::{CiLive, artifact_key, log_path}; use crate::test_support::{app_router, create_session, test_state}; const CSRF: &str = "ci-test-csrf"; +/// A hash no ref reaches, standing in for a commit that was overwritten. const SHA: &str = "0123456789abcdef0123456789abcdef01234567"; const SPEC: &str = r#"{"runs_on":[]}"#; const RUN_BASE: &str = "/tahinli/proj/ci"; @@ -28,6 +29,8 @@ struct Fixture { live: Arc, repo: forge_core::Repo, tahinli: String, + /// The commit `main` points at in `proj`. + head: String, data_dir: PathBuf, blobs: BlobStore, } @@ -59,6 +62,7 @@ async fn fixture(dir: &Path) -> Fixture { init_bare(&state.git, &bare, "main") .await .expect("init bare"); + let head = commit_main(&bare); store .set_collaborator(&repo.id, &bob.id, Role::Write) .await @@ -80,11 +84,31 @@ async fn fixture(dir: &Path) -> Fixture { live, repo, tahinli: tahinli.id, + head, data_dir, blobs, } } +/// Puts one empty commit on `main` and returns its hash. +fn commit_main(bare: &Path) -> String { + let git = |args: &[&str]| { + let out = std::process::Command::new("git") + .args(["-c", "user.name=t", "-c", "user.email=t@example.com", "-C"]) + .arg(bare) + .args(args) + .stdin(std::process::Stdio::null()) + .output() + .expect("git"); + assert!(out.status.success(), "{args:?}"); + String::from_utf8_lossy(&out.stdout).trim().to_owned() + }; + let tree = git(&["hash-object", "-t", "tree", "-w", "--stdin"]); + let commit = git(&["commit-tree", &tree, "-m", "first"]); + git(&["update-ref", "refs/heads/main", &commit]); + commit +} + fn cookie_for(token: &str) -> String { format!("__Host-{SESSION_COOKIE}={token}") } @@ -162,7 +186,7 @@ async fn run_with(fx: &Fixture, jobs: &[&str], needs_approval: bool) -> CiRun { &fx.repo.id, "push", "refs/heads/main", - SHA, + &fx.head, None, &fx.tahinli, needs_approval, @@ -1639,6 +1663,26 @@ async fn rerun_failed_and_rerun_job_start_partial_runs() { assert!(job_page.contains("Re-run this job")); } +#[tokio::test] +async fn a_run_on_an_overwritten_commit_cannot_be_rerun() { + let dir = tempfile::tempdir().expect("tempdir"); + let fx = fixture(dir.path()).await; + run_at(&fx, SHA).await; + finish_job(&fx).await; + let writer = cookie_for("bob-token"); + let run_url = format!("{RUN_BASE}/runs/1"); + let page = get(&fx.app, &run_url, Some(&writer)).await.text(); + assert!(!page.contains(">Re-run<")); + assert!(!page.contains(&format!("/commit/{SHA}"))); + let refused = post(&fx.app, &format!("{run_url}/rerun"), &writer, &[]).await; + assert!( + refused + .location() + .unwrap_or_default() + .ends_with("?notice=overwritten") + ); +} + #[tokio::test] async fn a_run_with_no_failed_jobs_has_nothing_to_rerun() { let dir = tempfile::tempdir().expect("tempdir"); diff --git a/crates/forge-web/src/pages/compare.rs b/crates/forge-web/src/pages/compare.rs index 4656ee3..5563591 100644 --- a/crates/forge-web/src/pages/compare.rs +++ b/crates/forge-web/src/pages/compare.rs @@ -431,17 +431,17 @@ async fn picker_view(cx: &Cx, ctx: RepoCtx, base: String, head: String) -> Resul Ok(view! { shell(title: title.as_str(), viewer: ctx.viewer.as_ref(), repo_head(head: header) -
+

(g::t(lang, K::CompareBranches))

-
-

-

+ + + for name in branches.iter() { } -

+
) diff --git a/crates/forge-web/src/pages/discussion_view.rs b/crates/forge-web/src/pages/discussion_view.rs index 5a05d86..ebab2b7 100644 --- a/crates/forge-web/src/pages/discussion_view.rs +++ b/crates/forge-web/src/pages/discussion_view.rs @@ -184,7 +184,7 @@ async fn comment_article(item: CommentView) -> Result { if deleted { (g::t(lang, K::CommentDeleted)) } else { - + user_link(shown: author.as_str(), login: login.as_str()) } @@ -424,7 +424,7 @@ async fn discussion_page(
- + user_link(shown: author.as_str(), login: author_login.as_str())
(Unescaped::new_unchecked(body_html))
diff --git a/crates/forge-web/src/pages/import.rs b/crates/forge-web/src/pages/import.rs index daa9333..4b8bab1 100644 --- a/crates/forge-web/src/pages/import.rs +++ b/crates/forge-web/src/pages/import.rs @@ -327,6 +327,7 @@ async fn import_form(

(g::t(lang, K::ImportTitle))

+ newrepo_tabs(lang: lang, active: "import")
visibility_pick(lang: lang, private: private) @@ -411,7 +412,6 @@ async fn import_home( more: bool, ) -> Result { Ok(view! { - newrepo_tabs(lang: lang, active: "import")
import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: None, owners: owners) recent_imports(lang: lang, jobs: jobs, more: more) @@ -419,7 +419,7 @@ async fn import_home( }) } -/// The import form again after a rejected submit: the tabs, then the form. +/// The import form again after a rejected submit. #[component] async fn import_error_body( lang: Lang, @@ -429,7 +429,6 @@ async fn import_error_body( owners: Vec, ) -> Result { Ok(view! { - newrepo_tabs(lang: lang, active: "import")
import_form(lang: lang, csrf: csrf.as_str(), draft: draft, error: Some(error), owners: owners)
@@ -630,7 +629,6 @@ async fn bulk_form( // A Forgejo token can list its own repositories, so the owner may stay empty. let owner_required = source != Source::Forgejo; Ok(view! { - newrepo_tabs(lang: lang, active: "import") if let Some(message) = error { alert(message: message.as_str()) } @@ -640,6 +638,7 @@ async fn bulk_form(

(g::t(lang, K::BulkTitle))

+ newrepo_tabs(lang: lang, active: "import")
@@ -695,7 +694,6 @@ async fn bulk_select( form.owner.clone() }; Ok(view! { - newrepo_tabs(lang: lang, active: "import")
csrf_field(token: csrf) @@ -705,6 +703,7 @@ async fn bulk_select(

(g::t(lang, K::BulkSelectHeading))

+ newrepo_tabs(lang: lang, active: "import")
visibility_pick(lang: lang, private: private) if !empty { @@ -1133,7 +1132,6 @@ async fn jobs_list( let empty = jobs.is_empty(); let retry = jobs.iter().any(|(job, _)| job.state == ImportState::Failed); Ok(view! { - newrepo_tabs(lang: lang, active: "import")

(g::t(lang, K::JobsTitle))

if retry { @@ -1239,7 +1237,6 @@ async fn job_view( let state_word = job.state.as_str(); let empty_log = log.is_empty(); Ok(view! { - newrepo_tabs(lang: lang, active: "import")

(job.source_ref.as_str())

@@ -1461,7 +1458,6 @@ async fn retry_list(lang: Lang, csrf: &str, rows: Vec<(ImportJob, Repo)>) -> Res let count = rows.len(); let empty = rows.is_empty(); Ok(view! { - newrepo_tabs(lang: lang, active: "import") csrf_field(token: csrf)
diff --git a/crates/forge-web/src/pages/issue_parts.rs b/crates/forge-web/src/pages/issue_parts.rs index ae5e177..04ec4fd 100644 --- a/crates/forge-web/src/pages/issue_parts.rs +++ b/crates/forge-web/src/pages/issue_parts.rs @@ -224,6 +224,17 @@ pub(crate) fn is_hex_oid(s: &str) -> bool { (4..=64).contains(&s.len()) && s.bytes().all(|b| b.is_ascii_hexdigit()) } +/// The ids in `oids` that a branch, tag or pull request still reaches, read in one git walk. A +/// failed read yields none, so no stored hash links to a page that would 404. +pub(crate) async fn reachable_among(path: &std::path::Path, oids: Vec) -> HashSet { + let path = path.to_owned(); + tokio::task::spawn_blocking(move || forge_git::browse::reachable_commits(&path, &oids)) + .await + .ok() + .and_then(|found| found.ok()) + .unwrap_or_default() +} + // Timeline /// One comment, or the item body (which uses the same item shape without a delete action). @@ -328,6 +339,7 @@ fn event_line( base_branch: &str, actor: String, when: When, + reachable: &HashSet, ) -> EventLine { let text = |key: &str| { event @@ -375,18 +387,19 @@ fn event_line( "base_changed" => g::event_base_changed(lang, &text("from"), &text("to")), other => other.to_owned(), }; + // A commit no branch, tag or pull request reaches keeps its short hash, as plain text. let (link_href, link_label) = if is_hex_oid(&commit) { - ( - Some(format!("{base}/commit/{commit}")), - short_oid(&commit).to_owned(), - ) + let href = reachable + .contains(&commit) + .then(|| format!("{base}/commit/{commit}")); + (href, short_oid(&commit).to_owned()) } else { (None, String::new()) }; let (from, to) = (text("from"), text("to")); let (before, after) = match event.kind.as_str() { kind @ ("closed" | "referenced" | "merged") => { - g::commit_event_sides(lang, kind, &before, base_branch, link_href.is_some()) + g::commit_event_sides(lang, kind, &before, base_branch, !link_label.is_empty()) } "head_updated" if !from.is_empty() && !to.is_empty() => ( before, @@ -424,7 +437,7 @@ pub(crate) async fn comment_item(lang: Lang, item: CommentView) -> Result
- + user_link(shown: author.as_str(), login: login.as_str()) if let Some(href) = history_href { @@ -544,9 +557,13 @@ pub(crate) async fn event_item(line: EventLine) -> Result { (actor.as_str()) " " (before.as_str()) - if let Some(href) = link_href { + if !link_label.is_empty() { " " - (link_label.as_str()) + if let Some(href) = link_href { + (link_label.as_str()) + } else { + (link_label.as_str()) + } } if !after.is_empty() { " " @@ -593,7 +610,7 @@ pub(crate) async fn review_item(lang: Lang, review: ReviewView) -> Result
- + user_link(shown: author.as_str(), login: login.as_str()) (verb) @@ -656,6 +673,15 @@ pub(crate) async fn load_discussion( let comments = store.list_comments(&item.id).await?; let events = store.list_events(&item.id).await?; + // Every event's commit, checked against git in one walk before any row is built. + let event_commits: Vec = events + .iter() + .filter_map(|e| e.data.get("commit").and_then(Json::as_str)) + .filter(|c| is_hex_oid(c)) + .map(str::to_owned) + .collect(); + let reachable = reachable_among(&ctx.path, event_commits).await; + // One batched lookup for every author and event actor on the page. let mut ids: Vec = std::iter::once(item.author_id.clone()) .chain(comments.iter().map(|c| c.author_id.clone())) @@ -790,7 +816,7 @@ pub(crate) async fn load_discussion( None => g::t(lang, K::System).to_owned(), }; let when = When::new(lang, &event.created_at, &tz, now); - let line = event_line(lang, event, &base, base_branch, actor, when); + let line = event_line(lang, event, &base, base_branch, actor, when, &reachable); keyed.push((event.created_at.clone(), Entry::Event(line))); } if kind == ItemKind::Pull { diff --git a/crates/forge-web/src/pages/issue_view.rs b/crates/forge-web/src/pages/issue_view.rs index e9b8054..c3fdb8c 100644 --- a/crates/forge-web/src/pages/issue_view.rs +++ b/crates/forge-web/src/pages/issue_view.rs @@ -234,7 +234,7 @@ async fn edit_item_page(
- (g::t(lang, K::Cancel)) + (g::t(lang, K::Cancel))
@@ -346,7 +346,7 @@ async fn edit_comment_page(
- (g::t(lang, K::Cancel)) + (g::t(lang, K::Cancel))
diff --git a/crates/forge-web/src/pages/issues_list.rs b/crates/forge-web/src/pages/issues_list.rs index 2d82b4e..416dde2 100644 --- a/crates/forge-web/src/pages/issues_list.rs +++ b/crates/forge-web/src/pages/issues_list.rs @@ -730,7 +730,7 @@ async fn new_issue_body( } else { if let Some(message) = draft.error { @@ -760,7 +760,7 @@ async fn new_issue_body( }
- (g::t(lang, K::Cancel)) + (g::t(lang, K::Cancel))
} diff --git a/crates/forge-web/src/pages/labels_css.rs b/crates/forge-web/src/pages/labels_css.rs index 5879061..b801362 100644 --- a/crates/forge-web/src/pages/labels_css.rs +++ b/crates/forge-web/src/pages/labels_css.rs @@ -26,29 +26,6 @@ path_param!(repo); /// Revalidate on every use: the ETag makes an unchanged stylesheet a cheap 304. const CACHE_REVALIDATE: &str = "no-cache"; -/// Relative luminance of an sRGB color, as defined by WCAG 2.x. -fn luminance(r: u8, g: u8, b: u8) -> f64 { - let linear = |c: u8| { - let c = f64::from(c) / 255.0; - if c <= 0.03928 { - c / 12.92 - } else { - ((c + 0.055) / 1.055).powf(2.4) - } - }; - 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b) -} - -/// Black or white text, whichever gives the higher contrast ratio against the background. The -/// two ratios are equal at a luminance of about 0.179, so black wins above that. -pub fn text_color(r: u8, g: u8, b: u8) -> &'static str { - if luminance(r, g, b) > 0.179 { - "#000" - } else { - "#fff" - } -} - /// `#rrggbb` to its channels. Only six hex digits with a leading `#` are accepted. fn parse_hex(color: &str) -> Option<(u8, u8, u8)> { let hex = color.strip_prefix('#')?; @@ -84,9 +61,8 @@ pub fn label_css(labels: &[Label]) -> String { // Writing to a String cannot fail. let _ = writeln!( css, - ".label-{} {{ background-color: #{r:02x}{g:02x}{b:02x}; color: {}; }}", - label.id, - text_color(r, g, b) + ".label-{} {{ --label: #{r:02x}{g:02x}{b:02x}; }}", + label.id ); } css @@ -138,7 +114,7 @@ mod tests { use forge_core::{Label, Visibility}; use http::header::{CACHE_CONTROL, CONTENT_TYPE, ETAG, IF_NONE_MATCH}; - use super::{label_css, text_color}; + use super::label_css; use crate::pages::issues_list::test_util::{OWNER, REPO, fixture, send}; fn label(id: &str, color: &str) -> Label { @@ -151,15 +127,6 @@ mod tests { } } - #[test] - fn contrast_picks_black_or_white() { - assert_eq!(text_color(255, 255, 255), "#000"); - assert_eq!(text_color(255, 255, 0), "#000"); - assert_eq!(text_color(0, 0, 0), "#fff"); - assert_eq!(text_color(0, 0, 128), "#fff"); - assert_eq!(text_color(136, 136, 136), "#000"); - } - #[test] fn css_has_colors_and_contrast() { let css = label_css(&[ @@ -168,14 +135,8 @@ mod tests { label("bad", "red"), label("x y", "#123456"), ]); - assert!( - css.contains(".label-red1 { background-color: #ff0000; color: #000; }"), - "{css}" - ); - assert!( - css.contains(".label-navy { background-color: #000080; color: #fff; }"), - "{css}" - ); + assert!(css.contains(".label-red1 { --label: #ff0000; }"), "{css}"); + assert!(css.contains(".label-navy { --label: #000080; }"), "{css}"); assert!(!css.contains(".label-bad"), "{css}"); assert!(!css.contains("x y"), "{css}"); } @@ -206,11 +167,7 @@ mod tests { Some("no-cache") ); let etag = reply.header(ETAG.as_str()).expect("etag"); - assert!( - reply - .text() - .contains("background-color: #b60205; color: #fff;") - ); + assert!(reply.text().contains("--label: #b60205;")); let reply = send( &fx.router, diff --git a/crates/forge-web/src/pages/new_repo.rs b/crates/forge-web/src/pages/new_repo.rs index 7c39b74..e004cf1 100644 --- a/crates/forge-web/src/pages/new_repo.rs +++ b/crates/forge-web/src/pages/new_repo.rs @@ -234,7 +234,6 @@ async fn new_repo_form( let draft_mirror_username = draft.mirror_username; let draft_mirror_interval = draft.mirror_interval; Ok(view! { - crate::pages::import::newrepo_tabs(lang: lang, active: "create") if let Some(message) = error { alert(message: message.as_str()) } @@ -242,6 +241,7 @@ async fn new_repo_form( csrf_field(token: csrf)

(i18n::t(lang, Key::NewRepository))

+ crate::pages::import::newrepo_tabs(lang: lang, active: "create")
(g::t(lang, K::VisibilityLegend)) diff --git a/crates/forge-web/src/pages/notifications.rs b/crates/forge-web/src/pages/notifications.rs index a281f35..b6bdb58 100644 --- a/crates/forge-web/src/pages/notifications.rs +++ b/crates/forge-web/src/pages/notifications.rs @@ -1240,7 +1240,7 @@ pub(crate) async fn watch_form( Ok(view! {
@@ -868,7 +872,14 @@ async fn pull_conversation( .as_deref() .map(|stamp| When::new(lang, stamp, ctx.viewer_tz(), now_unix())); let merge_commit = pr.merge_commit.clone().unwrap_or_default(); - let merge_commit_href = format!("/{owner}/{name}/commit/{merge_commit}"); + // Linked only while a branch, tag or pull request still reaches the merge commit. + let merge_commit_href = match merge_commit.as_str() { + "" => None, + oid => reachable_among(&ctx.path, vec![oid.to_owned()]) + .await + .contains(oid) + .then(|| format!("/{owner}/{name}/commit/{oid}")), + }; let review_error = review_error_from(lang, cx); let summary = state.store.review_summary(&pr.issue.id).await?; diff --git a/crates/forge-web/src/pages/repo_webhooks.rs b/crates/forge-web/src/pages/repo_webhooks.rs index 59e5c2c..d38eb4b 100644 --- a/crates/forge-web/src/pages/repo_webhooks.rs +++ b/crates/forge-web/src/pages/repo_webhooks.rs @@ -582,10 +582,7 @@ async fn hooks_list_body(

(g::t(lang, K::AddWebhook))

} if rows.is_empty() { - empty_state(title: g::t(lang, K::NoWebhooks), - if !archived { - (g::t(lang, K::AddWebhook)) - }) + empty_state(title: g::t(lang, K::NoWebhooks)) } else {
    for row in rows.iter() { diff --git a/crates/forge-web/src/pages/review_requests.rs b/crates/forge-web/src/pages/review_requests.rs index 98c9953..636a6b3 100644 --- a/crates/forge-web/src/pages/review_requests.rs +++ b/crates/forge-web/src/pages/review_requests.rs @@ -289,7 +289,9 @@ async fn review_requests(cx: &Cx) -> Result {

    (heading)

    if empty { - empty_state(title: ga::t(lang, AK::NoReviewRequests)) +
    + empty_state(title: ga::t(lang, AK::NoReviewRequests)) +
    } if !empty {
    diff --git a/crates/forge-web/src/pages/settings_appearance.rs b/crates/forge-web/src/pages/settings_appearance.rs index 6177260..101f225 100644 --- a/crates/forge-web/src/pages/settings_appearance.rs +++ b/crates/forge-web/src/pages/settings_appearance.rs @@ -8,7 +8,7 @@ use std::collections::HashMap; use forge_core::AuditAction; use forge_core::store::ui_prefs::{SIDEBAR_SIDES, THEMES}; -use forge_core::store::user_prefs::{DENSITIES, DENSITY, SOUND, SOUND_VALUES}; +use forge_core::store::user_prefs::{SOUND, SOUND_VALUES}; use forge_core::{Error as CoreError, Session, Store, User}; use serde::{Deserialize, Deserializer}; use topcoat::Result; @@ -70,9 +70,10 @@ struct AppearanceForm { base_dark: Option, #[serde(default, deserialize_with = "present_string")] sidebar_side: Option, - /// Sent by the density buttons and the sound switch only. Absent keeps the stored value. + /// Present when the form that holds the sound switch was posted: an unchecked switch posts + /// nothing, so this tells off from a post that never showed the switch. #[serde(default, deserialize_with = "present_string")] - density: Option, + sound_shown: Option, #[serde(default, deserialize_with = "present_string")] sound: Option, } @@ -169,18 +170,10 @@ struct AppearancePage { light: ColourGroup, dark: ColourGroup, sidebar: Vec, - density: Vec, /// Whether the run-finished tone is on: the sound switch's checked state. sound_on: bool, } -/// The `data-density` value the shell puts on ``: `compact` only. Comfortable is the -/// default, so it has no attribute. `None` for a signed-out visitor, who gets browser storage. -pub fn density_attr(prefs: Option<&HashMap>) -> Option<&'static str> { - let stored = prefs.and_then(|p| p.get(DENSITY))?; - (stored == "compact").then_some("compact") -} - /// The `data-sound` value the shell puts on ``: `on` when the viewer wants the tone. pub fn sound_attr(prefs: Option<&HashMap>) -> Option<&'static str> { let stored = prefs.and_then(|p| p.get(SOUND))?; @@ -445,7 +438,6 @@ async fn appearance_body(page: AppearancePage) -> Result { light, dark, sidebar, - density, sound_on, } = page; Ok(view! { @@ -484,21 +476,11 @@ async fn appearance_body(page: AppearancePage) -> Result { } - -
    - (g::t(lang, K::DensityLabel)) -
    - for choice in density.into_iter() { - - } -
    - (g::t(lang, K::DensityHelp)) + (crate::pages::passkeys::s(lang, "Moves the menu on settings and admin pages.", "Ayarlar ve yönetim sayfalarındaki menüyü taşır."))
    (g::t(lang, K::SoundLabel)) +
    (g::t(lang, K::SoundSwitch))
    -

    (g::t(lang, K::SoundFootTones))

    @@ -594,10 +575,6 @@ fn page_for( prefs: &HashMap, ) -> AppearancePage { let user = &viewer.0; - let density = match prefs.get(DENSITY).map(String::as_str) { - Some("compact") => "compact", - _ => "comfortable", - }; let sound_on = prefs.get(SOUND).is_some_and(|v| v == "on"); // The tab that opens first is the dark colours for a dark theme. The page script moves it to // the one the viewer sees when the theme follows the system. @@ -621,21 +598,11 @@ fn page_for( sidebar: choices(SIDEBAR_CODES, sidebar_stored(&user.sidebar_side), |code| { sidebar_label(lang, code) }), - density: choices(DENSITIES, density, |code| density_label(lang, code)), sound_on, } } -/// The label of a row density: Comfortable or Compact. -fn density_label(lang: Lang, code: &str) -> &'static str { - if code == "compact" { - g::t(lang, K::DensityCompact) - } else { - g::t(lang, K::DensityComfortable) - } -} - -/// A density or sound value a save stores. Absent (`None`) stores nothing. A present value must +/// A sound value a save stores. Absent (`None`) stores nothing. A present value must /// be one offered, so an empty or unknown value is rejected. fn pref_choice( lang: Lang, @@ -677,11 +644,9 @@ async fn appearance_save(cx: &Cx, Form(form): Form) -> Result Some("off"), (_, Some(value)) => Some(value.as_str()), (None, None) => None, @@ -691,9 +656,6 @@ async fn appearance_save(cx: &Cx, Form(form): Form) -> Result) -> Result { + // Prunes the standby soon. Does nothing when replication is off. + crate::replication::enqueue_repo(state, &id); + blank_unreachable_messages(state, &id, &dir).await; + } + Err(e) => tracing::error!(error = %e, repo_id = %id, "prune failed"), } } } + +/// Blanks the stored message of each co-authored commit the prune made unreachable. The rows stay, +/// so contribution counts do not change. Errors are logged; the prune itself already succeeded. +async fn blank_unreachable_messages(state: &AppState, repo_id: &str, dir: &Path) { + if let Err(e) = blank_unreachable_inner(state, repo_id, dir).await { + tracing::error!(error = %e, repo_id = %repo_id, "prune: blanking commit messages failed"); + } +} + +async fn blank_unreachable_inner( + state: &AppState, + repo_id: &str, + dir: &Path, +) -> Result<(), String> { + let oids = state + .store + .coauthored_oids(repo_id) + .await + .map_err(|e| e.to_string())?; + if oids.is_empty() { + return Ok(()); + } + let repo = dir.to_path_buf(); + let check = oids.clone(); + let reachable = tokio::task::spawn_blocking(move || reachable_commits(&repo, &check)) + .await + .map_err(|e| e.to_string())? + .map_err(|e| e.to_string())?; + let gone: Vec = oids + .into_iter() + .filter(|oid| !reachable.contains(oid)) + .collect(); + if gone.is_empty() { + return Ok(()); + } + state + .store + .blank_coauthored(repo_id, &gone) + .await + .map_err(|e| e.to_string()) +} diff --git a/crates/forge-web/src/render/highlight.rs b/crates/forge-web/src/render/highlight.rs index 7dbc9c9..6ae348c 100644 --- a/crates/forge-web/src/render/highlight.rs +++ b/crates/forge-web/src/render/highlight.rs @@ -22,6 +22,10 @@ const MAX_LINES: usize = 20_000; const CLASS_PREFIX: &str = "hl-"; const LIGHT_THEME: &str = "InspiredGitHub"; const DARK_THEME: &str = "base16-ocean.dark"; +/// Scope for the light rules when the page has no explicit theme. +const LIGHT_WHEN_AUTO: &str = ":root:not([data-theme=\"dark\"])"; +/// Scope for the light rules when the user picked the light theme. +const LIGHT_WHEN_FORCED: &str = ":root[data-theme=\"light\"]"; /// Scope for the dark rules when the page has no explicit theme. const DARK_WHEN_AUTO: &str = ":root:not([data-theme=\"light\"])"; /// Scope for the dark rules when the user picked the dark theme. @@ -120,19 +124,72 @@ fn build_css() -> String { .themes .get(DARK_THEME) .expect("syntect default theme base16-ocean.dark is present"); - let light_css = css_for_theme_with_class_style(light, class_style()) - .expect("generating CSS for the light theme"); + let light_css = readable_on_light( + &css_for_theme_with_class_style(light, class_style()) + .expect("generating CSS for the light theme"), + ); let dark_css = css_for_theme_with_class_style(dark, class_style()) .expect("generating CSS for the dark theme"); - // The dark rules follow the page theme: the OS preference unless `data-theme="light"` is set, - // and always when `data-theme="dark"` is set. + // Each theme follows the page theme: the OS preference unless `data-theme` is set, and always + // when it is. The light rules are scoped too: a bare light rule with more classes would beat + // a dark rule with fewer, and leave light colours on a dark page. format!( - "{light_css}\n@media (prefers-color-scheme: dark) {{\n{}}}\n{}", + "@media (prefers-color-scheme: light) {{ +{}}} +{} +@media (prefers-color-scheme: dark) {{ +{}}} +{}", + scope_css(&light_css, LIGHT_WHEN_AUTO), + scope_css(&light_css, LIGHT_WHEN_FORCED), scope_css(&dark_css, DARK_WHEN_AUTO), scope_css(&dark_css, DARK_WHEN_FORCED), ) } +/// Darkens each text colour of the light theme until it reaches 4.5:1 on the light code background, +/// #EEF2EC. Some of InspiredGitHub's colours are too pale to read there. +fn readable_on_light(css: &str) -> String { + const BACKGROUND_LUMINANCE: f32 = 0.875; + let luminance = |rgb: [u8; 3]| { + let [r, g, b] = rgb.map(|channel| { + let c = f32::from(channel) / 255.0; + if c <= 0.04045 { + c / 12.92 + } else { + ((c + 0.055) / 1.055).powf(2.4) + } + }); + 0.2126 * r + 0.7152 * g + 0.0722 * b + }; + let mut out = String::with_capacity(css.len()); + for line in css.lines() { + let hex = line + .trim() + .strip_prefix("color: #") + .and_then(|rest| rest.strip_suffix(';')); + let rgb = hex + .filter(|hex| hex.len() == 6) + .and_then(|hex| u32::from_str_radix(hex, 16).ok()) + .map(|value| value.to_be_bytes()) + .map(|[_, r, g, b]| [r, g, b]); + match rgb { + Some(mut rgb) => { + while (BACKGROUND_LUMINANCE + 0.05) / (luminance(rgb) + 0.05) < 4.5 { + rgb = rgb.map(|channel| (f32::from(channel) * 0.95) as u8); + } + let [r, g, b] = rgb; + out.push_str(&format!(" color: #{r:02x}{g:02x}{b:02x};\n")); + } + None => { + out.push_str(line); + out.push('\n'); + } + } + } + out +} + /// Prefixes every selector in a syntect stylesheet with `scope`. syntect writes each rule as a /// selector line ending in `{` (selectors separated by commas), then declarations, then `}`. fn scope_css(css: &str, scope: &str) -> String { @@ -156,8 +213,7 @@ fn scope_css(css: &str, scope: &str) -> String { out } -/// CSS for the `hl-` classes: the light theme by default, and the dark theme -/// under `prefers-color-scheme: dark`. +/// CSS for the `hl-` classes: both themes, each scoped to the page theme it belongs to. pub fn highlight_css() -> String { CSS.clone() } diff --git a/crates/forge-web/src/replication/worker.rs b/crates/forge-web/src/replication/worker.rs index 78c365e..9d33ca3 100644 --- a/crates/forge-web/src/replication/worker.rs +++ b/crates/forge-web/src/replication/worker.rs @@ -14,6 +14,7 @@ use forge_core::store::replication::DB_SUBJECT; use forge_core::store::snapshot::verify_snapshot; use forge_git::GitEnv; use forge_git::backup::refs_checksum; +use forge_git::maintenance::{clear_standby_prune, standby_prune_due}; use super::{ KEEP_SNAPSHOTS, Layout, SshTransport, StandbyTransport, Target, is_snapshot_name, push_repo, @@ -247,6 +248,17 @@ async fn replicate_dir( )); } } + if standby_prune_due(local) { + // The refs match and this worker is the only writer, so unreachable objects can go now. + ctx.transport + .run(&format!( + "git -C {} gc --quiet --prune=now", + sh_quote(remote) + )) + .await + .map_err(|e| format!("standby prune failed: {e}"))?; + clear_standby_prune(local); + } Ok(Some(local_sum)) } @@ -423,6 +435,7 @@ mod tests { use forge_core::store::snapshot::verify_snapshot; use forge_git::GitEnv; use forge_git::backup::refs_checksum; + use forge_git::maintenance::{prune_unreachable, standby_prune_due}; use super::super::{Layout, LocalTransport, remote_refs_checksum}; use super::{Ctx, ReconcileReport, reconcile_once, replicate_repo, ship_db}; @@ -544,6 +557,35 @@ mod tests { ); } + #[tokio::test] + async fn a_force_update_removes_the_standby_copy_of_the_old_commit() { + let f = fixture().await; + replicate_repo(&f.ctx, &f.repo_id) + .await + .expect("first push"); + let old = plumbing(&f.local_repo, &["rev-parse", "refs/heads/main"]); + commit_to(&f.local_repo, "refs/heads/main", "rewritten"); + prune_unreachable(&f.ctx.git, &f.local_repo, "--prune=now") + .await + .expect("local prune"); + assert!(standby_prune_due(&f.local_repo)); + + replicate_repo(&f.ctx, &f.repo_id) + .await + .expect("second push"); + let remote = f.ctx.layout.repo_dir(&f.repo_id).expect("remote dir"); + let found = std::process::Command::new("git") + .arg(format!("--git-dir={remote}")) + .args(["cat-file", "-e", &old]) + .status() + .expect("cat-file"); + assert!( + !found.success(), + "the standby still holds the overwritten commit" + ); + assert!(!standby_prune_due(&f.local_repo), "the mark is cleared"); + } + #[tokio::test] async fn a_failed_push_is_recorded_and_keeps_the_last_success() { let f = fixture().await; diff --git a/crates/forge-web/src/views/heatmap.rs b/crates/forge-web/src/views/heatmap.rs index 6ce969f..57930b2 100644 --- a/crates/forge-web/src/views/heatmap.rs +++ b/crates/forge-web/src/views/heatmap.rs @@ -189,7 +189,8 @@ struct CellView { /// One line of the selected day's list, with its strings ready for the view. struct DayRow { before: String, - href: String, + /// None when the row has no page to open: a pruned commit, whose hash stays plain text. + href: Option, link: String, after: String, updated: String, @@ -242,22 +243,25 @@ fn day_row(lang: Lang, item: &ContributionItem, now: i64) -> DayRow { let repo = item_repo(item); let (before, after) = g::day_item_words(lang, item.kind, item_branch(item), &repo); let (href, link) = match item.kind { - ContributionKind::Push => (format!("/{repo}"), repo.clone()), + ContributionKind::Push => (Some(format!("/{repo}")), repo.clone()), ContributionKind::Issue | ContributionKind::Comment => ( - format!("/{repo}/issues/{}", item.number), + Some(format!("/{repo}/issues/{}", item.number)), format!("#{} {}", item.number, item.title), ), ContributionKind::Pull => ( - format!("/{repo}/pulls/{}", item.number), + Some(format!("/{repo}/pulls/{}", item.number)), format!("#{} {}", item.number, item.title), ), ContributionKind::CoAuthored => { - let summary = if item.title.is_empty() { - item.commit.chars().take(7).collect() + // A pruned commit has its title blanked by the job that prunes it: keep the hash, unlinked. + if item.title.is_empty() { + (None, item.commit.chars().take(7).collect()) } else { - item.title.clone() - }; - (format!("/{repo}/commit/{}", item.commit), summary) + ( + Some(format!("/{repo}/commit/{}", item.commit)), + item.title.clone(), + ) + } } }; DayRow { @@ -507,7 +511,11 @@ pub async fn contribution_calendar( if entry.pushes.is_empty() {
  • (entry.row.before.as_str()) - (entry.row.link.as_str()) + if let Some(href) = entry.row.href { + (entry.row.link.as_str()) + } else { + (entry.row.link.as_str()) + } (entry.row.after.as_str())
  • @@ -516,7 +524,11 @@ pub async fn contribution_calendar(
    (entry.row.before.as_str()) - (entry.row.link.as_str()) + if let Some(href) = entry.row.href { + (entry.row.link.as_str()) + } else { + (entry.row.link.as_str()) + } (entry.row.after.as_str()) @@ -524,7 +536,11 @@ pub async fn contribution_calendar( for push in entry.pushes.into_iter() {
  • (push.before.as_str()) - (push.link.as_str()) + if let Some(href) = push.href { + (push.link.as_str()) + } else { + (push.link.as_str()) + } (push.after.as_str())
  • diff --git a/crates/forge-web/src/views/mod.rs b/crates/forge-web/src/views/mod.rs index e45b6f3..761854c 100644 --- a/crates/forge-web/src/views/mod.rs +++ b/crates/forge-web/src/views/mod.rs @@ -513,7 +513,6 @@ pub async fn shell( .as_ref() .and_then(|p| p.get(CORNER_POS)) .and_then(|v| clean_pref(CORNER_POS, v).ok().flatten()); - let density_attr = crate::pages::settings_appearance::density_attr(prefs.as_ref()); let sound_attr = crate::pages::settings_appearance::sound_attr(prefs.as_ref()); let banner_back = back.clone().unwrap_or_else(|| "/".to_owned()); let dismiss_label = crate::i18n::accounts::t(lang, crate::i18n::accounts::A::Dismiss); @@ -670,7 +669,7 @@ pub async fn shell( }); Ok(view! { - + diff --git a/crates/forge-web/src/views/review_thread.rs b/crates/forge-web/src/views/review_thread.rs index 864392e..28b4890 100644 --- a/crates/forge-web/src/views/review_thread.rs +++ b/crates/forge-web/src/views/review_thread.rs @@ -411,7 +411,7 @@ async fn thread_comment( Ok(view! {
    - + user_link(shown: author.as_str(), login: login.as_str()) if let Some(href) = history_href { diff --git a/docs/architecture.md b/docs/architecture.md index f7b2ac8..e23e362 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -351,6 +351,8 @@ Written at boot by `write_managed_gitconfig()`. Keys: A commit is served by hash only if `refs/heads/*`, `refs/tags/*` or `refs/pull/*` reaches it (`browse::resolve_commit`, `browse::commit_reachable`). Protocol v2 fetches any object that exists, so the objects are removed too: a force push, a moved tag or a deleted ref writes `forge-prune-due` in the bare repo, and the `prune` task runs `git gc --prune` once the mark is 15 minutes old. The grace period protects a push whose objects landed before its ref. Every repo is also pruned weekly, which covers mirrors and a fork's old pull heads. +After a prune, the repo is queued for replication at once. The standby is passive and never prunes on its own, so the next push writes `forge-standby-prune-due` on the standby's side too, and the worker runs `git gc --prune=now` there once the refs match. Stored co-authored commit messages that the prune made unreachable are blanked. The rows stay, so contribution counts do not change. + ### 7.3 Repo path layout `/repos///.git`, where `` is the lowercased ULID. Created with `git init --bare` through the builder. Renames are DB-only, because the path depends on the id, not the name. diff --git a/docs/backup.md b/docs/backup.md index cd41c75..ef3b7d6 100644 --- a/docs/backup.md +++ b/docs/backup.md @@ -21,6 +21,10 @@ What a set does **not** contain: - **Release assets under `data_dir/blobs/`.** A set does not copy them. Back them up with the separate `rsync` step in "Release assets" below. - **Git LFS objects under `data_dir/lfs/`.** A set does not copy them either. The `lfs_objects` rows are in the set, so a restore without the files gives LFS pointers that cannot be downloaded. Back them up with the `rsync` step in "LFS objects" below. +Deleted or overwritten history stays in old backup sets. A set holds whatever the repos held when it was made. Forge removes the history from the live server and the standby, but a set leaves backups only when your retention expires it. Plan retention with that in mind. + +A leaked secret must be rotated. Anyone who fetched it already has a copy, and deleting the commit does not change that. + Files in a set are mode 0600 and directories are mode 0700. Treat every set as private data, because it contains the full contents of every repo and the password hashes of every user. A set is written under a `.partial-…` name and renamed into place only when it is complete. A crash never leaves something that looks like a finished backup. diff --git a/style/_account_admin.scss b/style/_account_admin.scss index 314fc44..c18f246 100644 --- a/style/_account_admin.scss +++ b/style/_account_admin.scss @@ -5,7 +5,8 @@ align-items: center; justify-content: space-between; gap: 12px; - padding: 8px 16px; + margin-bottom: 16px; + padding: 8px 40px; background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--border); diff --git a/style/_density.scss b/style/_appearance.scss similarity index 68% rename from style/_density.scss rename to style/_appearance.scss index d5cc617..bb537cf 100644 --- a/style/_density.scss +++ b/style/_appearance.scss @@ -1,43 +1,3 @@ -// Row density: Comfortable (the default) or Compact. The shell puts `data-density="compact"` on -// from the viewer's account (signed-out visitors: nav.js reads localStorage). Comfortable -// keeps every element's own padding. Compact sets four tokens, and the shared list, table and -// pane classes read them, so no page repeats the numbers. - -:root[data-density="compact"] { - --row-pad-y: 6px; // top and bottom padding of a list row - --cell-pad-y: 5px; // top and bottom padding of a table cell - --head-pad-y: 4px; // top and bottom padding of a table heading - --pane-pad: 12px; // padding of a card or a one-screen pane -} - -:root[data-density="compact"] { - .item, - .repo-item, - .notif-row, - .ci-row, - .runner-row, - .security-row { - padding-top: var(--row-pad-y); - padding-bottom: var(--row-pad-y); - } - - .table th, - .table td { - padding-top: var(--cell-pad-y); - padding-bottom: var(--cell-pad-y); - } - - .table th { - padding-top: var(--head-pad-y); - padding-bottom: var(--head-pad-y); - } - - .card, - .fit-pane { - padding: var(--pane-pad); - } -} - // Appearance page layout. Below 1100px the parts stack: general controls, then the sound card, then // the colours. From 1100px: general controls and the sound card on the left, colours on the right, // so the page fits one screen. The form is `display: contents` so its two blocks join this grid. @@ -157,7 +117,6 @@ height: 16px; border-radius: 50%; background: var(--surface); - transition: transform 0.15s ease; } .sound-switch input:checked + .sound-track > .sound-knob { @@ -171,6 +130,5 @@ @media (prefers-reduced-motion: reduce) { .sound-knob { - transition: none; } } diff --git a/style/_canvas_account.scss b/style/_canvas_account.scss index cb9018f..f9616a8 100644 --- a/style/_canvas_account.scss +++ b/style/_canvas_account.scss @@ -103,7 +103,7 @@ .table.audit-table { th, td { - padding: 14px; + padding: 6px 14px; } th:first-child, diff --git a/style/_canvas_pull.scss b/style/_canvas_pull.scss index b88a145..636540f 100644 --- a/style/_canvas_pull.scss +++ b/style/_canvas_pull.scss @@ -358,7 +358,7 @@ .pull-compose .pull-input { flex: 1 1 auto; min-width: 0; - height: 36px; + height: 32px; padding: 0 12px; border: 0; border-radius: 7px; diff --git a/style/_canvas_repo.scss b/style/_canvas_repo.scss index de83cbb..9e29e96 100644 --- a/style/_canvas_repo.scss +++ b/style/_canvas_repo.scss @@ -65,7 +65,7 @@ z-index: 6; } - // The branch is a mono label, not a pill or a button. + // The branch keeps its exact spelling: a name is never upper-cased. .ref-select > summary { display: inline-flex; align-items: center; @@ -76,11 +76,9 @@ border: 0; box-shadow: none; font-family: var(--mono); - font-size: 11px; + font-size: 13px; font-weight: 500; - letter-spacing: 0.12em; - text-transform: uppercase; - color: var(--muted); + color: var(--text-2); cursor: pointer; list-style: none; } @@ -125,7 +123,7 @@ white-space: nowrap; } - // The go-to-file control is the small `t` tag at the right end; the words are for screen readers. + // The go-to-file control sits at the right end, named, with its key beside the name. .finder-open { position: relative; align-self: center; @@ -145,12 +143,9 @@ } .finder-open .finder-label { - position: absolute; - width: 1px; - height: 1px; - overflow: hidden; - clip-path: inset(50%); - white-space: nowrap; + margin-right: 6px; + font-family: var(--font); + font-size: 12px; } .finder-open kbd { @@ -499,11 +494,9 @@ margin: 0; padding-top: 2px; font-family: var(--mono); - font-size: 11px; + font-size: 12px; font-weight: 500; - letter-spacing: 0.12em; - text-transform: uppercase; - color: var(--muted); + color: var(--text-2); } .canvas-dock .history-bars { diff --git a/style/_heatmap.scss b/style/_heatmap.scss index fefa6db..ed4e043 100644 --- a/style/_heatmap.scss +++ b/style/_heatmap.scss @@ -291,7 +291,6 @@ a.cell { border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); - transition: transform 0.15s ease; } } diff --git a/style/_kb_rerun.scss b/style/_kb_rerun.scss index 99a77b2..348b4a6 100644 --- a/style/_kb_rerun.scss +++ b/style/_kb_rerun.scss @@ -12,7 +12,6 @@ right: 8px; margin: 0; opacity: 0; - transition: opacity 120ms ease; li:hover &, li:focus-within &, @@ -30,10 +29,10 @@ li:has(> .ci-row-rerun-form) .ci-row-title { } .ci-row-rerun { - padding: 1px 8px; - font-size: 0.75rem; - line-height: 1.5; - color: var(--muted); + height: 28px; + padding: 0 10px; + font-size: 13px; + color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); @@ -47,6 +46,5 @@ li:has(> .ci-row-rerun-form) .ci-row-title { @media (prefers-reduced-motion: reduce) { .ci-row-rerun-form { - transition: none; } } diff --git a/style/_lang_issues.scss b/style/_lang_issues.scss index fe38eec..2db0f27 100644 --- a/style/_lang_issues.scss +++ b/style/_lang_issues.scss @@ -75,7 +75,7 @@ button { height: 32px; padding: 0 10px; - font-size: 13px; + font-size: 14px; } } @@ -169,7 +169,7 @@ .issue-heading { overflow: hidden; margin: 0; - font-size: 20px; + font-size: 24px; line-height: 1.25; white-space: nowrap; text-overflow: ellipsis; diff --git a/style/_language.scss b/style/_language.scss index 63ff8e7..e5beb68 100644 --- a/style/_language.scss +++ b/style/_language.scss @@ -9,7 +9,8 @@ h1 { margin: 0; - font-size: 20px; + font-size: 24px; + font-weight: 700; line-height: 1.2; } } diff --git a/style/_motion.scss b/style/_motion.scss index c13ca3a..12a92ab 100644 --- a/style/_motion.scss +++ b/style/_motion.scss @@ -9,39 +9,12 @@ $ease-out: cubic-bezier(0.2, 0, 0, 1); // A press sinks the button a little. .button, button { - transition: background-color 0.15s ease, scale 0.1s ease; &:active:not(:disabled) { scale: 0.97; } } -// A menu or popover the reader opens drops in from its summary. -details.pop[open] > :not(summary) { - animation: pop-in 0.14s $ease-out; -} - -@keyframes pop-in { - from { - opacity: 0; - translate: 0 -4px; - scale: 0.98; - } -} - -// The phone branch switcher is a sheet from the bottom: it rises instead. -@media (max-width: 600px) { - details.ref-select.pop[open] > .ref-menu { - animation: sheet-up 0.2s $ease-out; - } -} - -@keyframes sheet-up { - from { - translate: 0 100%; - } -} - // A stepper's number flashes the accent when a click moves it. input.tick { animation: tick 0.3s ease-out; @@ -56,7 +29,6 @@ input.tick { @media (prefers-reduced-motion: reduce) { .button, button { - transition: none; &:active:not(:disabled) { scale: none; diff --git a/style/_needs.scss b/style/_needs.scss index 511f5c7..86c6217 100644 --- a/style/_needs.scss +++ b/style/_needs.scss @@ -18,7 +18,7 @@ padding: 10px 14px; border-bottom: 1px solid var(--border); font-family: var(--mono); - font-size: 12px; + font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; diff --git a/style/_pull.scss b/style/_pull.scss index 5da2928..5e176d8 100644 --- a/style/_pull.scss +++ b/style/_pull.scss @@ -40,8 +40,9 @@ gap: 8px; padding: 10px 0 12px; border-bottom: 0; - color: var(--muted); - font-weight: 500; + color: var(--text-2); + font-size: 14px; + font-weight: 400; white-space: nowrap; &:hover { @@ -156,7 +157,6 @@ .issue-row { padding: 14px 16px; border-top-color: var(--border); - transition: background 0.12s ease; &:hover { background: var(--surface-2); diff --git a/style/_repo.scss b/style/_repo.scss index 0cc3b1f..c7a2fd0 100644 --- a/style/_repo.scss +++ b/style/_repo.scss @@ -864,7 +864,6 @@ html.tree-resizing .repo-split::before { padding: 0 9px; border-radius: var(--radius-full); white-space: nowrap; - transition: background-color 0.2s ease, box-shadow 0.2s ease; > svg { position: static; @@ -886,7 +885,6 @@ html.tree-resizing .repo-split::before { line-height: 1; white-space: nowrap; opacity: 0; - transition: max-width 0.25s ease, padding 0.25s ease, opacity 0.2s ease; } input[type="radio"]:checked ~ span { @@ -916,7 +914,6 @@ html.tree-resizing .repo-split::before { @media (prefers-reduced-motion: reduce) { .segmented .segment, .segmented .segment > span { - transition: none; } } } @@ -1040,7 +1037,6 @@ html.tree-resizing .repo-split::before { .newrepo-chev { color: var(--muted); - transition: transform 0.15s ease; } &[open] .newrepo-chev { diff --git a/style/_shell.scss b/style/_shell.scss index 04341e9..c6dfd68 100644 --- a/style/_shell.scss +++ b/style/_shell.scss @@ -948,7 +948,6 @@ a.chip { // Below 900px the panel steps aside while the reader scrolls down (nav.js sets corner-away): it fades // out and takes no pointer, so the page under it can be read and tapped. Reduced motion skips the fade. .corner-float { - transition: opacity 0.2s ease; } .corner-float.corner-away { @@ -1249,7 +1248,6 @@ html[aria-busy="true"] body::before { } .corner-float { - transition: none; } .pill.hot .pill-dot, diff --git a/style/_system.scss b/style/_system.scss new file mode 100644 index 0000000..f239605 --- /dev/null +++ b/style/_system.scss @@ -0,0 +1,653 @@ +// The last word on the kinds that repeat on every page. A control, a chip, a section label and a tab +// each have one look, so moving between pages changes the content and nothing else. + +.button.small, +summary.button.small { + height: 28px; + padding: 0 10px; + font-size: 13px; +} + +// Table rows are list rows: 36px. +.table th, +.table td { + padding-top: 6px; + padding-bottom: 6px; + line-height: 23px; +} + +// Every menu, dropdown and popover is this one panel with these one rows. Pages reach the older +// panels with long selectors, so the panel's own look is forced here once. +:root { + --pop-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); +} + +:root[data-theme="light"] { + --pop-shadow: 0 8px 24px rgba(0, 0, 0, 0.14); +} + +@media (prefers-color-scheme: light) { + :root:not([data-theme="dark"]) { + --pop-shadow: 0 8px 24px rgba(0, 0, 0, 0.14); + } +} + +.menu-list, +.tab-more-list, +.list-more-menu, +.strip-list, +.corner-menu, +.ref-menu, +.pop-panel, +.confirm-pop, +.row-menu-panel, +.release-assets-pop, +.ci-tl-more > p, +.dock-expand > .dock-message, +details > .status-list { + background: var(--surface) !important; + border: 1px solid var(--border-strong) !important; + border-radius: var(--radius-lg) !important; + box-shadow: var(--pop-shadow) !important; +} + +.tab-more-list, +.list-more-menu, +.strip-list, +.corner-menu, +.menu-list:not(.ci-pop, .head-more-list, .watch-list) { + padding: 6px !important; +} + +.tab-more-list > a, +.list-more-menu > a, +.strip-list a, +.corner-menu > a, +.corner-link, +.menu-list > a, +.menu-list > form > button:not(.primary), +.row-menu-panel > form > button, +.row-menu-panel > button, +.row-menu-panel > a { + display: flex; + align-items: center; + justify-content: flex-start; + width: 100%; + height: 32px; + box-sizing: border-box; + padding: 0 10px; + border: 0; + border-radius: var(--radius-sm); + background: transparent; + color: var(--text); + font-family: var(--font); + font-size: 13px; + font-weight: 400; + text-decoration: none; + + &:hover { + background: var(--surface-2); + color: var(--text); + text-decoration: none; + } +} + +.watch-menu > .menu-list { + right: 0; + left: auto; +} + +.watch-option { + font-size: 13px; +} + +.pop-panel .button { + font-family: var(--font); +} + +// Native form parts are drawn here, so a select or a tick is ours and not the browser's. The arrow +// is an inline image because a stylesheet may not reach other files through the content policy. +select:not([multiple], [size]:not([size="1"])) { + appearance: none; + padding-right: 30px; + background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238b9499' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); + background-repeat: no-repeat; + background-position: right 9px center; + background-size: 14px; +} + +input[type="checkbox"] { + position: relative; + appearance: none; + flex: none; + border: 1px solid var(--border-strong); + border-radius: 4px; + background: var(--surface); + cursor: pointer; + + &:checked { + border-color: var(--accent); + background: var(--accent); + } + + &:checked::before { + content: ""; + position: absolute; + inset: 0; + background: var(--accent-text); + clip-path: polygon(22% 50%, 12% 62%, 42% 88%, 88% 28%, 76% 18%, 40% 66%); + } + + &:disabled { + opacity: 0.5; + cursor: not-allowed; + } +} + +* { + scrollbar-width: thin; + scrollbar-color: var(--border-strong) transparent; +} + +// Labels: a soft tint of the label's own colour with a readable text, in both themes. +.label-chip { + border: 0; + background: color-mix(in oklab, var(--label, var(--muted)) 20%, transparent); + box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--label, var(--muted)) 40%, transparent); + color: color-mix(in oklab, var(--label, var(--muted)) 55%, var(--text)); +} + +// An action repeated on every row of a list is quiet: red text and no box until it is pointed at. +main :is(li, tr) > form button.danger, +main :is(li, tr) > form > summary.danger, +main :is(li, tr) summary.button.small.danger, +main :is(li, tr) td button.danger { + border-color: transparent; + background: transparent; + + &:hover { + border-color: var(--danger); + } +} + +// Lists page: the filter that is on is marked like any other selected control, not in accent. +.explore-sort a.current, +.explore-sort a[aria-current="page"], +.explore-sort .seg-item.active { + background: var(--surface-2); + color: var(--text); +} + +// A pane already has padding, so the empty text inside it adds none of its own. +.card > .empty-state, +.fit-pane > .empty-state, +.lang-list > .empty-state { + padding: 14px; +} + +.card > .empty-state { + padding: 8px 0; +} + +// When the form to add one sits right beside an empty list, a second button to it is noise. +main:has(.lang-side form, .fit-side form, .settings-main form, > .card form) .empty-state-action { + display: none; +} + +.md-attach { + color: var(--text-2); + font-size: 13px; +} + +.snippet-form { + width: 100%; + max-width: none !important; +} + +.ci-scale { + display: none; +} + +.ci-log:empty::before { + content: attr(data-empty); + color: var(--muted); +} + +// Sessions: one row each. What the row says about a session is on one line. +.session-pane .item { + display: flex; + align-items: center; + gap: 12px; + min-height: 36px; + padding: 6px 0; +} + +.session-pane .item-main { + display: flex; + flex: 1 1 auto; + flex-direction: row; + align-items: center; + gap: 12px; + min-width: 0; +} + +.session-pane .item-main > a { + flex: none; +} + +.session-pane .item-main > .badge { + flex: none; + align-self: center; +} + +.session-pane .item-main > .muted { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.card.fit-pane.session-pane { + max-width: none; +} + +// Issue and pull sidebars: labels sit in two even columns, so the chips line up. +.issue-side-section form:has(> .issue-check) { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 6px 8px; +} + +.issue-check { + min-width: 0; +} + +.issue-check > .label-chip { + overflow: hidden; + max-width: 100%; + white-space: nowrap; + text-overflow: ellipsis; +} + +.history-bars > a.hs-neutral { + background: var(--border-strong); + + &:hover { + background: var(--text-2); + } +} + +// File and folder icons draw in the text colour of the theme, on every list that shows them. +.kind-icon { + flex: none; + width: 14px; + height: 14px; + fill: none; + stroke: currentColor; + stroke-width: 1.8; + stroke-linecap: round; + stroke-linejoin: round; + color: var(--muted); + + &.is-dir { + color: var(--text-2); + } +} + +// A heading that names a part of a page is a label, wherever it sits. +.issue-sidebar h2, +main .card > h3, +.needs-head, +.profile-section-head h2 { + @extend %mono-label; +} + +.profile-section-head a { + font-family: var(--font); + font-size: 13px; + font-weight: 500; + letter-spacing: 0; + text-transform: none; +} + +main fieldset > legend { + font-family: var(--mono) !important; + font-size: 11px !important; + font-weight: 500 !important; + letter-spacing: 0.12em !important; + text-transform: uppercase !important; + color: var(--muted) !important; +} + +// In a form, a fieldset of one choice is one field: its legend reads like the labels beside it. +main .side-picker > legend { + font-family: var(--font) !important; + font-size: 14px !important; + letter-spacing: 0 !important; + text-transform: none !important; + color: var(--text) !important; +} + +// Profile and organization tabs are the repo tabs. +.profile-tabs { + gap: 22px; +} + +.tabs .tab, +.profile-tabs .tab { + padding: 0; + font-size: 14px; + color: var(--text-2); + + &.active, + &[aria-current="page"] { + color: var(--text); + font-weight: 600; + } +} + +// Fingers: controls grow to a size a thumb can hit, and text fields use 16px so a phone does not +// zoom the page when one takes focus. +@media (pointer: coarse), (max-width: 700px) { + :root { + --control-h: 40px; + } + + input:not([type="checkbox"], [type="radio"], [type="color"]), + select, + textarea { + font-size: 16px; + } + + .button.small, + summary.button.small { + height: 36px; + } + + .wordmark, + .tab-more-toggle, + .md-attach { + min-height: 36px; + display: inline-flex; + align-items: center; + } + + // Bars 2px wide cannot be tapped, and a phone has no room for them. + .history-bars { + display: none; + } +} + +@media (max-width: 899px) { + .site-banner { + padding: 8px 16px; + } +} + +@media (max-width: 700px) { + // The floating profile corner must not sit over the end of a page. + .shell-body > main { + padding-bottom: 88px; + } + + // A list row keeps its title readable: the title on one line, what is known about it on the next. + .issue-pane .issue-list > .issue-row { + align-items: flex-start; + height: auto; + padding: 8px 14px; + + > .issue-state { + margin-top: 6px; + } + + > .issue-main { + flex-direction: column; + align-items: stretch; + gap: 2px; + } + + > .issue-main > .issue-title-line { + flex-wrap: wrap; + overflow: visible; + } + + > .issue-main > .issue-title-line > .issue-title { + white-space: normal; + } + + > .issue-main > .issue-meta { + flex-wrap: wrap; + margin-left: 0; + padding-left: 0; + } + + > .issue-main > .issue-meta > span:first-child { + width: auto; + text-align: left; + } + } + + .issue-pane > .issue-toolbar { + flex-wrap: wrap; + height: auto; + min-height: 0; + padding: 10px 14px; + + > .issue-tabs { + flex: 1 1 100%; + + a { + white-space: nowrap; + } + } + + > .issue-search { + flex: 1 1 100%; + + input[type="search"], + select { + height: 40px; + } + } + + > .issue-tools { + margin-left: auto; + } + } + + .ci-tl-headmain, + .ci-tl-line, + .ci-tl-meta { + flex-wrap: wrap; + min-width: 0; + } + + .ci-tl-title { + white-space: normal; + } +} + +// Settings and admin pages lay panes side by side, and the head spans that grid, which keeps two +// tracks open. A page with one pane takes both, and so does a filter with the list it filters. +@media (min-width: 900px) { + .shell-site > .shell-body > main, + .shell-site > .shell-body > main > [data-live] { + > .card:not(.card ~ .card):not(:has(~ .card)), + > .card:has(> .filter-bar), + > .card:has(> .filter-bar) ~ .card { + grid-column: 1 / -1; + } + } +} + +// A note inside a pane is a line of text, not a box in a box. +.card p.notice { + padding: 0; + background: none; + border: 0; + color: var(--text-2); +} + +// Create and Import share the page's one head row: the tabs follow the title and stand on its rule. +.page-head > .import-tabs { + flex: 1 1 auto; + align-self: stretch; + flex-wrap: nowrap; + max-width: none; + margin: 0 0 0 16px; + border-bottom: 0; +} + +.page-head > .import-tabs > .import-tab { + display: inline-flex; + align-items: center; + margin-bottom: -1px; + padding: 0 12px; + font-size: 14px; + font-weight: 400; + color: var(--text-2); +} + +.page-head > .import-tabs > .import-tab[aria-current="page"] { + color: var(--text); +} + +// Nothing has been imported yet: the form has the page to itself. +.import-home:not(:has(> .import-recent)) { + grid-template-columns: minmax(0, 1fr); +} + +// Compare: both ends and the button on one row. +.compare-pick .filter-bar input { + width: 20rem; + max-width: 100%; +} + +// Export: its live wrapper is a stack of panes, under the head. +.shell-site > .shell-body > main > .export-page { + display: flex; + flex-direction: column; + align-self: start; +} + +// The page column's rows start under the head and do not share out the window's height. +@media (min-width: 900px) { + .shell-site > .shell-body > main { + align-content: start; + } +} + +// A folder with no README: the list is what the page is for, so it takes the width and its last +// commit column comes back. +@media (min-width: 900px) { + .repo-home.canvas-repo.tree-browse:has(.canvas-body > .empty-state) { + grid-template-columns: minmax(0, 1fr) 12px 280px; + + .repo-split { + visibility: hidden; + } + + .canvas-readme .canvas-head > :not(:last-child) { + display: none; + } + } +} + +// Branch names keep their case. +.compare-detail > h2 code { + text-transform: none; + letter-spacing: 0; +} + +// The new issue form: labels are a row of the form, not a box in a pane. +.label-picker { + padding: 0; + border: 0; +} + +// Disclosure rows use the same chevron as every other menu, not the browser's triangle. +.checks-details > summary, +.commit-full-message > summary, +.ci-tl-more > summary { + display: inline-flex; + align-items: center; + gap: 4px; + list-style: none; + cursor: pointer; + + &::-webkit-details-marker { + display: none; + } + + &::before { + content: ""; + flex: none; + width: 12px; + height: 12px; + background: currentColor; + mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat; + } +} + +.checks-details[open] > summary::before, +.commit-full-message[open] > summary::before, +.ci-tl-more[open] > summary::before { + transform: rotate(180deg); +} + +.pull-compose-form > .btn { + height: var(--control-h); +} + +// A select never pushes the page wider than the phone. +@media (max-width: 700px) { + main select { + max-width: 100%; + } + + main .issue-toolbar .issue-search { + flex-wrap: wrap !important; + max-width: 100%; + } + + main .issue-toolbar .issue-search > input[type="search"] { + flex: 1 1 100% !important; + width: 100%; + } + + // Table rows that stack on a phone keep their labels and values in two straight columns. + main td[data-label] { + width: auto !important; + justify-content: flex-start !important; + text-align: left; + + > * { + margin-left: 0; + } + + &::before { + width: 6rem; + } + + &:empty { + display: none; + } + } + + // A session is its name and Revoke on one line, and its dates in full under them. + .session-pane .item { + flex-wrap: nowrap; + align-items: flex-start; + } + + .session-pane .item-main { + flex-wrap: wrap; + gap: 2px 8px; + } + + .session-pane .item-main > .muted { + order: 1; + flex-basis: 100%; + overflow: visible; + white-space: normal; + } +} diff --git a/style/_timeline_ci.scss b/style/_timeline_ci.scss index 56bd4f2..cfbe9cc 100644 --- a/style/_timeline_ci.scss +++ b/style/_timeline_ci.scss @@ -123,7 +123,7 @@ .ci-state.ci-running, .ci-state.ci-queued, .ci-state.ci-waiting_approval { - color: var(--accent); + color: var(--accent-ink); font-weight: 600; } @@ -500,7 +500,6 @@ @media (prefers-reduced-motion: reduce) { .ci-tl-job, .ci-tl-tab { - transition: none; } } diff --git a/style/main.scss b/style/main.scss index 003fcca..190c82d 100644 --- a/style/main.scss +++ b/style/main.scss @@ -124,10 +124,10 @@ // Radius scale: sm chips/badges, md every control (buttons, inputs, selects, textareas), // lg cards and panels, full pills. Nested shapes never exceed their container. --radius-sm: 6px; - --radius-md: 8px; - --radius-lg: 12px; + --radius-md: 7px; + --radius-lg: 10px; --radius-full: 999px; - --control-h: 36px; + --control-h: 32px; --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif; // Page titles and major headings only (see _look.scss); body text stays on --font. --display: "Archivo", var(--font); @@ -428,8 +428,8 @@ button { box-sizing: border-box; padding: 0 14px; font: inherit; - font-size: 0.875rem; - font-weight: 500; + font-size: 13px; + font-weight: 600; white-space: nowrap; border-radius: var(--radius-md); border: 1px solid var(--border-strong); @@ -576,6 +576,7 @@ input, select, textarea { font: inherit; + font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); @@ -627,7 +628,7 @@ select { height: var(--control-h); min-height: var(--control-h); padding: 0 12px; - font-size: 1rem; + font-size: 14px; line-height: 1.25rem; } @@ -661,7 +662,6 @@ select optgroup { select:not([multiple]):not([size])::picker-icon { color: var(--muted); - transition: rotate 0.2s ease; } select:not([multiple]):not([size]):open::picker-icon { @@ -1319,7 +1319,7 @@ code { .ref-count { padding: 0 6px; font-family: var(--mono); - font-size: 10px; + font-size: 11px; letter-spacing: 0; line-height: 16px; background: var(--surface-2); @@ -2727,7 +2727,7 @@ code { flex: none; box-sizing: border-box; width: 96px; - height: 28px; + height: var(--control-h); padding: 2px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); @@ -2919,7 +2919,6 @@ code { border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); - transition: transform 0.15s ease; } &[open] > summary .rule-chevron { @@ -3137,7 +3136,6 @@ code { border-radius: var(--radius-full); background: color-mix(in oklab, var(--text) 32%, var(--surface)); cursor: pointer; - transition: background 0.15s ease; &::after { content: ""; @@ -3148,7 +3146,6 @@ code { height: 16px; border-radius: 50%; background: var(--surface); - transition: transform 0.15s ease; } &:checked { @@ -3214,8 +3211,9 @@ code { display: inline-block; padding: 2px 10px; border-radius: var(--radius-full); - font-size: 0.8125rem; + font-size: 12px; font-weight: 600; + line-height: 16px; text-decoration: none; } @@ -3525,9 +3523,9 @@ code { display: inline-block; padding: 0 0.6rem; border-radius: var(--radius-full); - font-size: 0.8rem; + font-size: 12px; font-weight: 600; - line-height: 1.6; + line-height: 16px; text-decoration: none; } @@ -4335,8 +4333,9 @@ span.reaction { .hook-state { display: inline-block; - font-size: 0.75rem; + font-size: 12px; font-weight: 600; + line-height: 16px; padding: 2px 8px; border-radius: var(--radius-full); background: var(--private-bg); @@ -6162,7 +6161,6 @@ html.js form.runner-load[data-dirty-form][data-dirty] .runner-save { .ci-glink { color: var(--muted); pointer-events: none; - transition: opacity 0.12s ease; &.ci-hot { color: var(--accent); @@ -6190,7 +6188,6 @@ html.js form.runner-load[data-dirty-form][data-dirty] .runner-save { .ci-gbar, .ci-glead { - transition: opacity 0.12s ease; } // Hovering a job's box lights its connectors and the jobs it is linked with, and fades the rest. @@ -6221,7 +6218,6 @@ html.js form.runner-load[data-dirty-form][data-dirty] .runner-save { .ci-glink, .ci-gbar, .ci-glead { - transition: none; } } @@ -6452,7 +6448,6 @@ button.ci-job-last { border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); - transition: transform 0.12s; [aria-expanded="true"] > & { transform: rotate(45deg); @@ -7918,6 +7913,8 @@ button.ci-job-last { } .context-chip { + height: 28px; + font-size: 12px; padding: 2px 10px; border: 1px solid var(--border); border-radius: var(--radius-full); @@ -8049,7 +8046,7 @@ button.ci-job-last { @import "repo_side"; @import "ci_estimate"; @import "timeline"; -@import "density"; +@import "appearance"; @import "keyboard"; @import "kb_rerun"; @import "review_flow"; @@ -8081,3 +8078,4 @@ button.ci-job-last { @import "canvas_pull"; @import "canvas_detail"; @import "canvas_account"; +@import "system";