From 475a59b5498a8e4349689a1cc017c8abaee4979b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Sep 2026 05:34:05 +0300 Subject: [PATCH] Commit the styles the last three slices wrote; the binary guards its bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The search, wrap and feed styling never reached the repo — two commits staged crates/ alone, so CI kept bundling the cdd1f28 stylesheet while serving new markup. The stylesheet is the visible half of every slice; it travels with them now. So a mixed bundle can never boot again: build.rs stamps the stylesheet's sha256 into the binary, the boot refuses a bundle whose bytes do not match, and the deploy smoke-checks the served stylesheet against the one it just uploaded. --- .github/workflows/main.yml | 21 +++ Cargo.lock | 1 + crates/izlek-web/Cargo.toml | 5 + crates/izlek-web/build.rs | 17 +- crates/izlek-web/src/main.rs | 23 ++- crates/izlek-web/src/server.rs | 58 ++++++- crates/izlek-web/tests/http.rs | 292 +++++++++++++++++++++------------ style/main.scss | 133 ++++++++++++++- 8 files changed, 433 insertions(+), 117 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cf22b00..c0b9980 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -161,5 +161,26 @@ jobs: exit 1 " + # The boot-time fingerprint guard refuses a foreign bundle, so a + # mixed generation cannot get this far unnoticed — this is the + # independent after-the-fact check: the page's stylesheet URL must + # answer with bytes byte-identical to the bundle this deploy staged. + - name: Verify the served stylesheet is this deploy's + run: | + set -euo pipefail + deploy_path="${{ secrets.DEPLOY_PATH }}" + ssh_target="${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" + listen=$(ssh "$ssh_target" "sed -n 's/^listen[[:space:]]*=[[:space:]]*\"\(.*\)\"/\1/p' '${deploy_path}/config/izlek.toml'") + url=$(ssh "$ssh_target" "curl -fsS 'http://\${listen}/'" | grep -oE '/_topcoat/assets/main-[a-f0-9]+\.css' | head -n1) + if [ -z "$url" ]; then + echo 'the served page references no stylesheet' >&2 + exit 1 + fi + ssh "$ssh_target" "curl -fsS 'http://\${listen}\${url}'" > served-stylesheet.css + staged=$(sha256sum stage/assets/main-*.css | cut -d' ' -f1) + served=$(sha256sum served-stylesheet.css | cut -d' ' -f1) + echo "served $url: staged sha256:$staged, served sha256:$served" + test "$staged" = "$served" + - name: Cleaning run: rm -rf ~/.ssh diff --git a/Cargo.lock b/Cargo.lock index 985e9a8..9e9db3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1811,6 +1811,7 @@ dependencies = [ "lettre", "serde", "serde_json", + "sha2 0.10.9", "thiserror", "time", "tokio", diff --git a/crates/izlek-web/Cargo.toml b/crates/izlek-web/Cargo.toml index 48c718b..31708be 100644 --- a/crates/izlek-web/Cargo.toml +++ b/crates/izlek-web/Cargo.toml @@ -40,9 +40,14 @@ lettre = { version = "0.11.23", default-features = false, features = [ "pool", ] } calamine = { version = "0.36.1", default-features = false } +# Hashes the compiled stylesheet against the bundle's bytes at boot, so a +# bundle from another generation refuses the boot instead of serving under +# this binary (see `server.rs`'s `stylesheet_guard`). +sha2 = "0.10" [build-dependencies] grass = "0.13" +sha2 = "0.10" [dev-dependencies] http = "1.5" diff --git a/crates/izlek-web/build.rs b/crates/izlek-web/build.rs index c904a96..e818c22 100644 --- a/crates/izlek-web/build.rs +++ b/crates/izlek-web/build.rs @@ -3,6 +3,8 @@ //! expects to find it. Crate-relative rather than `OUT_DIR`-relative so the //! asset's id does not churn with every profile/build-hash (see the topcoat //! contract sheet, (a)). +//! +use sha2::Digest; fn main() { let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); @@ -15,8 +17,19 @@ fn main() { let css = grass::from_path(&scss, &grass::Options::default()) .unwrap_or_else(|err| panic!("failed to compile {scss}: {err}")); - let out_dir = format!("{manifest_dir}/assets"); std::fs::create_dir_all(&out_dir).expect("failed to create assets/"); - std::fs::write(format!("{out_dir}/main.css"), css).expect("failed to write assets/main.css"); + std::fs::write(format!("{out_dir}/main.css"), &css).expect("failed to write assets/main.css"); + + // The binary carries the compiled stylesheet's fingerprint, so the + // running server can tell a bundle of its own generation from one left + // behind by another deploy (`server.rs`'s `stylesheet_guard` refuses the + // boot on a mismatch). The bytes hashed here are exactly the bytes the + // bundler later copies into the bundle, so the fingerprints agree. + let fingerprint = sha2::Sha256::digest(css.as_bytes()); + let mut hex = String::with_capacity(fingerprint.len() * 2); + for byte in fingerprint { + hex.push_str(&format!("{byte:02x}")); + } + println!("cargo:rustc-env=IZLEK_STYLE_FINGERPRINT=sha256:{hex}"); } diff --git a/crates/izlek-web/src/main.rs b/crates/izlek-web/src/main.rs index 54fe3e1..745932b 100644 --- a/crates/izlek-web/src/main.rs +++ b/crates/izlek-web/src/main.rs @@ -67,6 +67,27 @@ async fn main() { println!("izlek {line}"); } + // The bundle beside the executable is the only stylesheet this process + // can serve, and nothing in topcoat binds it to this binary's + // generation: a bundle left behind by another deploy loads as happily + // as the right one, and the pages then reference a stylesheet whose + // bytes are days old — the mixed generation a browser once caught on + // production. The fingerprint build.rs stamped into this binary is + // checked against the bundle's bytes, and a foreign bundle refuses the + // boot rather than serving under it. + let bundle = AssetBundle::load().unwrap_or_else(|err| { + eprintln!("izlek: the asset bundle beside the executable failed to load: {err}"); + std::process::exit(2); + }); + let stylesheet = match izlek_web::server::stylesheet_guard(&bundle) { + Ok(line) => line, + Err(problem) => { + eprintln!("izlek: {problem}"); + std::process::exit(2); + } + }; + println!("izlek {stylesheet}"); + // One process per database file: Turso is a single-writer engine and a // second process on the same file loses writes rather than queueing. // @@ -104,7 +125,7 @@ async fn main() { .at("/api/profile_photo"), ) .cookies() - .assets(AssetBundle::load().expect("failed to load the asset bundle")) + .assets(bundle) .app_context(accounts) .app_context(izlek_web::photo::PhotoStamps::default()) .app_context(izlek_web::live::LiveWindow(std::time::Duration::from_secs( diff --git a/crates/izlek-web/src/server.rs b/crates/izlek-web/src/server.rs index 9c0b1cc..133886e 100644 --- a/crates/izlek-web/src/server.rs +++ b/crates/izlek-web/src/server.rs @@ -13,6 +13,8 @@ use izlek_core::board::Transition; use izlek_core::mail::Engine; use izlek_core::store::{Freeing, User}; use serde::{Deserialize, Serialize}; +use sha2::Digest; +use topcoat::asset::AssetBundle; use topcoat::context::{Cx, app_context, memoize, try_app_context}; use topcoat::cookie::{Cookie, Cookies, SameSite, cookie, cookies}; use topcoat::router::request::headers; @@ -208,6 +210,55 @@ pub fn client_label(cx: &Cx) -> String { } } +/// The stylesheet this binary serves must be the one compiled into it. +/// +/// `asset!` embeds an asset's declaration — its id and source path — into +/// the binary, but the served bytes live in the bundle directory beside the +/// executable, and topcoat loads whatever manifest it finds there. A bundle +/// left behind by another deploy sits beside a newer binary without a word +/// of complaint, and the pages then reference a stylesheet whose bytes are +/// from another generation — the mixed generation a browser once caught on +/// production. `build.rs` stamps the compiled stylesheet's SHA-256 into the +/// binary; this hashes the bundle's bytes against it, so a foreign bundle +/// refuses the boot instead of serving under it. +/// +/// Returns the startup log line naming the served fingerprint, or the +/// reason the boot must not proceed. +pub fn stylesheet_guard(bundle: &AssetBundle) -> Result { + let expected = env!("IZLEK_STYLE_FINGERPRINT"); + let stylesheet = bundle + .catalog() + .assets() + .find(|asset| { + let name = asset.name(); + name.starts_with("main-") && name.ends_with(".css") + }) + .ok_or_else(|| { + format!( + "the asset bundle at {} carries no stylesheet", + bundle.dir().display() + ) + })?; + let bytes = std::fs::read(bundle.dir().join(stylesheet.name())).map_err(|err| { + format!( + "the bundled stylesheet {} could not be read: {err}", + stylesheet.name() + ) + })?; + let actual = format!("sha256:{:x}", sha2::Sha256::digest(&bytes)); + if actual != expected { + return Err(format!( + "the asset bundle at {} is from another build: stylesheet {} is {actual} but this binary was compiled against {expected}; run `topcoat asset bundle` and redeploy", + bundle.dir().display(), + stylesheet.name() + )); + } + Ok(format!( + "assets stylesheet {} ({actual})", + stylesheet.name() + )) +} + /// Writes the session cookie. `HttpOnly` so script cannot read it, `Secure` so /// it never crosses plain HTTP, `SameSite=Lax` so another site's form cannot /// post with it. @@ -839,10 +890,9 @@ async fn cache_directives(cx: &Cx, body: Body, next: Next<'_>) -> topcoat::Resul if !is_html || parts.headers.contains_key(header::CACHE_CONTROL) { return Ok(Response::from_parts(parts, body)); } - parts.headers.insert( - header::CACHE_CONTROL, - HeaderValue::from_static("no-cache"), - ); + parts + .headers + .insert(header::CACHE_CONTROL, HeaderValue::from_static("no-cache")); Ok(Response::from_parts(parts, body)) } diff --git a/crates/izlek-web/tests/http.rs b/crates/izlek-web/tests/http.rs index ef521fa..68df2ff 100644 --- a/crates/izlek-web/tests/http.rs +++ b/crates/izlek-web/tests/http.rs @@ -8422,7 +8422,12 @@ async fn an_empty_time_clears_the_clock_and_a_clear_clears_both() { .post( "/api/save_task", Some(&admin_cookie), - &[("task_id", &task), ("deadline", ""), ("clock_hour", ""), ("clock_minute", "")], + &[ + ("task_id", &task), + ("deadline", ""), + ("clock_hour", ""), + ("clock_minute", ""), + ], ) .await; assert!( @@ -8644,7 +8649,6 @@ async fn a_time_that_cannot_be_used_is_refused_and_saves_nothing() { assert!(facts.row.clock_at.is_none(), "a lone minute was stored"); } - #[tokio::test] async fn a_card_wears_the_clock_chip_in_the_viewers_zone_instead_of_the_deadline() { let app = App::open().await; @@ -8736,7 +8740,11 @@ async fn a_time_set_on_an_existing_day_writes_both_columns() { .post( "/api/save_task", Some(&admin_cookie), - &[("task_id", &task), ("clock_hour", "16"), ("clock_minute", "20")], + &[ + ("task_id", &task), + ("clock_hour", "16"), + ("clock_minute", "20"), + ], ) .await; assert!( @@ -8981,7 +8989,11 @@ async fn a_time_change_fires_the_deadline_rule_and_round_trips() { .post( "/api/save_task", Some(&member), - &[("task_id", &task), ("clock_hour", "9"), ("clock_minute", "30")], + &[ + ("task_id", &task), + ("clock_hour", "9"), + ("clock_minute", "30"), + ], ) .await; assert!( @@ -9100,7 +9112,9 @@ async fn an_off_step_clock_renders_itself_not_a_rounded_step() { saved.location ); - let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await; + let page = app + .get(&format!("/?task={task}"), Some(&admin_cookie)) + .await; let html = String::from_utf8_lossy(&page.bytes); assert!( html.contains(r#""#) @@ -9176,13 +9190,12 @@ async fn tag_writes_record_their_events() { let app = App::open().await; let admin_cookie = admin(&app).await; - app - .post( - "/api/create_tag", - Some(&admin_cookie), - &[("name", "Urgent")], - ) - .await; + app.post( + "/api/create_tag", + Some(&admin_cookie), + &[("name", "Urgent")], + ) + .await; let workspace_id = app.workspace_id().await; let tag = { let board = izlek_core::board::load(app.store.as_ref(), &workspace_id) @@ -9197,27 +9210,24 @@ async fn tag_writes_record_their_events() { .find(|tag| tag.name == "Urgent") .expect("the tag was created") }; - app - .post( - "/api/move_tag", - Some(&admin_cookie), - &[("tag_id", &tag.id), ("direction", "up")], - ) - .await; - app - .post( - "/api/rename_tag", - Some(&admin_cookie), - &[("tag_id", &tag.id), ("name", "High")], - ) - .await; - app - .post( - "/api/delete_tag", - Some(&admin_cookie), - &[("tag_id", &tag.id)], - ) - .await; + app.post( + "/api/move_tag", + Some(&admin_cookie), + &[("tag_id", &tag.id), ("direction", "up")], + ) + .await; + app.post( + "/api/rename_tag", + Some(&admin_cookie), + &[("tag_id", &tag.id), ("name", "High")], + ) + .await; + app.post( + "/api/delete_tag", + Some(&admin_cookie), + &[("tag_id", &tag.id)], + ) + .await; let lines = app .store @@ -9261,13 +9271,12 @@ async fn tagging_a_task_records_a_trail_line() { .unwrap(); let column = board.columns[0].column.id.clone(); let task = a_task(&app, &admin_cookie, &column, "Audit me").await; - app - .post( - "/api/create_tag", - Some(&admin_cookie), - &[("name", "Shipped")], - ) - .await; + app.post( + "/api/create_tag", + Some(&admin_cookie), + &[("name", "Shipped")], + ) + .await; let tag = { let board = izlek_core::board::load(app.store.as_ref(), &workspace_id) .await @@ -9282,13 +9291,12 @@ async fn tagging_a_task_records_a_trail_line() { .expect("the tag was created") }; - app - .post( - "/api/set_task_tag", - Some(&admin_cookie), - &[("task_id", &task), ("tag_id", &tag.id)], - ) - .await; + app.post( + "/api/set_task_tag", + Some(&admin_cookie), + &[("task_id", &task), ("tag_id", &tag.id)], + ) + .await; let lines = app .store @@ -9315,16 +9323,14 @@ async fn profile_photo_changes_record_their_events() { let app = App::open().await; let admin_cookie = admin(&app).await; - app - .post_multipart( - "/api/profile_photo", - Some(&admin_cookie), - &[], - Some(("me.png", "image/png", &PNG)), - ) - .await; - app - .post("/api/delete_profile_photo", Some(&admin_cookie), &[]) + app.post_multipart( + "/api/profile_photo", + Some(&admin_cookie), + &[], + Some(("me.png", "image/png", &PNG)), + ) + .await; + app.post("/api/delete_profile_photo", Some(&admin_cookie), &[]) .await; let lines = app @@ -9382,10 +9388,7 @@ async fn checking_the_sender_records_an_event() { /// below reads the words the pane itself would show. async fn password_pane(app: &App, cookie: &str, query: &str) -> String { let page = app - .get( - &format!("/settings?section=profile&{query}"), - Some(cookie), - ) + .get(&format!("/settings?section=profile&{query}"), Some(cookie)) .await; String::from_utf8_lossy(&page.bytes).into_owned() } @@ -9406,7 +9409,10 @@ async fn the_password_pane_names_each_failure() { "/api/change_password", Some(&admin_cookie), referer, - &[("current", "not the password"), ("new", "a whole new passphrase")], + &[ + ("current", "not the password"), + ("new", "a whole new passphrase"), + ], ) .await; let location = wrong.location.expect("a redirect location"); @@ -9433,14 +9439,15 @@ async fn the_password_pane_names_each_failure() { ) .await; let location = same.location.expect("a redirect location"); + assert!(location.contains("refusal=password-current"), "{location}"); assert!( - location.contains("refusal=password-current"), - "{location}" - ); - assert!( - password_pane(&app, &admin_cookie, "refusal=password-current&on=change_password") - .await - .contains("That's your current password.") + password_pane( + &app, + &admin_cookie, + "refusal=password-current&on=change_password" + ) + .await + .contains("That's your current password.") ); // Too short. @@ -9449,15 +9456,22 @@ async fn the_password_pane_names_each_failure() { "/api/change_password", Some(&admin_cookie), referer, - &[("current", "correct horse battery staple"), ("new", "short")], + &[ + ("current", "correct horse battery staple"), + ("new", "short"), + ], ) .await; let location = short.location.expect("a redirect location"); assert!(location.contains("refusal=password-short"), "{location}"); assert!( - password_pane(&app, &admin_cookie, "refusal=password-short&on=change_password") - .await - .contains("At least 10 characters.") + password_pane( + &app, + &admin_cookie, + "refusal=password-short&on=change_password" + ) + .await + .contains("At least 10 characters.") ); // Looks like the address the account wears. @@ -9466,15 +9480,22 @@ async fn the_password_pane_names_each_failure() { "/api/change_password", Some(&admin_cookie), referer, - &[("current", "correct horse battery staple"), ("new", "ada@izlek.sh!!")], + &[ + ("current", "correct horse battery staple"), + ("new", "ada@izlek.sh!!"), + ], ) .await; let location = you.location.expect("a redirect location"); assert!(location.contains("refusal=password-you"), "{location}"); assert!( - password_pane(&app, &admin_cookie, "refusal=password-you&on=change_password") - .await - .contains("Not your address or your name.") + password_pane( + &app, + &admin_cookie, + "refusal=password-you&on=change_password" + ) + .await + .contains("Not your address or your name.") ); // A change that works lands with the pane's own note, and the fresh @@ -9495,7 +9516,10 @@ async fn the_password_pane_names_each_failure() { assert!(location.contains("saved=change_password"), "{location}"); let fresh = right.session.clone().expect("a fresh session cookie"); let page = app - .get("/settings?section=profile&saved=change_password", Some(&fresh)) + .get( + "/settings?section=profile&saved=change_password", + Some(&fresh), + ) .await; let html = String::from_utf8_lossy(&page.bytes); assert!( @@ -9504,13 +9528,12 @@ async fn the_password_pane_names_each_failure() { ); // The same pane in Turkish names the same failures in Turkish. - app - .post( - "/api/save_profile", - Some(&fresh), - &[("display_name", "Ada Lovelace"), ("language", "tr")], - ) - .await; + app.post( + "/api/save_profile", + Some(&fresh), + &[("display_name", "Ada Lovelace"), ("language", "tr")], + ) + .await; let tr = app .get( "/settings?section=profile&refusal=password-current&on=change_password", @@ -9564,7 +9587,9 @@ async fn a_card_lists_both_dependency_directions_as_keys() { let page = app.get("/", Some(&admin)).await; let html = String::from_utf8_lossy(&page.bytes); assert!( - html.contains(&format!(r#"class="card-blocks">blocks {second_key}"#)), + html.contains(&format!( + r#"class="card-blocks">blocks {second_key}"# + )), "the blocker's card did not name what it blocks: {html}" ); assert!( @@ -9593,7 +9618,11 @@ async fn the_board_search_filters_and_composes_with_the_project_filter() { &[("task_id", &panel), ("tag_id", &aurora.id)], ) .await; - assert_eq!(answer.body, "null", "the tag did not attach: {}", answer.body); + assert_eq!( + answer.body, "null", + "the tag did not attach: {}", + answer.body + ); let panel_key = app .store .task(&panel) @@ -9654,9 +9683,7 @@ async fn queued_reset_token(app: &App, email: &str) -> Option { let body = sends .into_iter() .rev() - .find(|send| { - send.kind == SendKind::Notice && send.recipient == email - }) + .find(|send| send.kind == SendKind::Notice && send.recipient == email) .and_then(|send| send.body)?; body.rsplit_once("/reset/") .and_then(|(_, rest)| rest.split_whitespace().next()) @@ -9735,7 +9762,10 @@ async fn a_reset_link_redeems_on_its_own_screen() { .post( "/api/sign_in", None, - &[("email", "ada@izlek.sh"), ("password", "correct horse battery staple")], + &[ + ("email", "ada@izlek.sh"), + ("password", "correct horse battery staple"), + ], ) .await; assert_ne!(old.body, "null", "the old password still signed in"); @@ -9788,8 +9818,7 @@ async fn a_multi_file_picker_lands_every_part_as_its_own_attachment() { let app = App::open().await; let admin_cookie = admin(&app).await; let column = first_column(&app).await; - let task = a_task(&app, &admin_cookie, &column, "Two parts, one post") - .await; + let task = a_task(&app, &admin_cookie, &column, "Two parts, one post").await; const BOUNDARY: &str = "izlek-test-boundary"; let png = [0x89u8, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 9, 9]; @@ -9837,7 +9866,11 @@ async fn a_multi_file_picker_lands_every_part_as_its_own_attachment() { ); let snapshot = app - .post("/api/fetch_task", Some(&admin_cookie), &[("task_id", &task)]) + .post( + "/api/fetch_task", + Some(&admin_cookie), + &[("task_id", &task)], + ) .await; let png_id = attachment_id_named(&snapshot.body, "first.png"); let txt_id = attachment_id_named(&snapshot.body, "notes.txt"); @@ -9866,13 +9899,12 @@ async fn the_feed_shows_each_person_their_stake() { let deniz_id = person_id(&app, &admin_cookie, &task, "Deniz").await; // Ada assigns Deniz: the assignment names him and starts his watch. - app - .post( - "/api/assign", - Some(&admin_cookie), - &[("task_id", &task), ("user_id", &deniz_id)], - ) - .await; + app.post( + "/api/assign", + Some(&admin_cookie), + &[("task_id", &task), ("user_id", &deniz_id)], + ) + .await; // The badge rides every page's topbar while the news is unread... let board = app.get("/", Some(&member)).await; @@ -9931,3 +9963,61 @@ async fn the_build_stamp_matches_across_page_and_refetch() { "the build stamp drifted between renders: {stamps:?}" ); } + +/// The served stylesheet is the one compiled into this build: the page +/// references it, the route answers it, and the bytes are the bytes +/// build.rs wrote — not a bundle from another generation. +#[tokio::test] +async fn the_served_stylesheet_is_this_builds_bytes() { + let app = App::open().await; + let page = app.get("/", None).await; + assert_eq!(page.status, StatusCode::OK); + let html = String::from_utf8_lossy(&page.bytes); + let url = html + .split('"') + .find(|piece| piece.starts_with("/_topcoat/assets/main-") && piece.ends_with(".css")) + .expect("the page references no stylesheet") + .to_string(); + let served = app.get(&url, None).await; + assert_eq!(served.status, StatusCode::OK); + assert!(!served.bytes.is_empty()); + let compiled = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/main.css")) + .expect("the compiled stylesheet is gone"); + assert_eq!( + served.bytes, compiled, + "the server served another generation's stylesheet" + ); +} + +/// The boot guard refuses a bundle whose stylesheet bytes are not the +/// generation this binary was compiled against, and accepts its own. +#[test] +fn the_stylesheet_guard_refuses_a_foreign_bundle() { + let bundle = AssetBundle::load_dir(asset_dir()).expect("no bundle: run `topcoat asset bundle`"); + assert!(izlek_web::server::stylesheet_guard(&bundle).is_ok()); + + let foreign = std::env::temp_dir().join(format!("izlek-foreign-{}", Ulid::new())); + std::fs::create_dir_all(&foreign).unwrap(); + for entry in std::fs::read_dir(asset_dir()).unwrap().flatten() { + std::fs::copy(entry.path(), foreign.join(entry.file_name())).unwrap(); + } + let stylesheet = std::fs::read_dir(&foreign) + .unwrap() + .filter_map(|entry| { + let name = entry.ok()?.file_name().into_string().ok()?; + (name.starts_with("main-") && name.ends_with(".css")).then_some(name) + }) + .next() + .expect("no stylesheet in the copied bundle"); + std::fs::write( + foreign.join(&stylesheet), + "body { color: another-generation }", + ) + .unwrap(); + + let foreign_bundle = AssetBundle::load_dir(&foreign).expect("the copied bundle does not load"); + let problem = izlek_web::server::stylesheet_guard(&foreign_bundle) + .expect_err("a foreign bundle passed the guard"); + assert!(problem.contains("another build"), "{problem}"); + std::fs::remove_dir_all(&foreign).unwrap(); +} diff --git a/style/main.scss b/style/main.scss index 9c167f6..0b2802f 100644 --- a/style/main.scss +++ b/style/main.scss @@ -614,6 +614,24 @@ a { padding: 10px 12px; } +.auth-note { + font-size: 13px; + color: var(--muted); + background: var(--panel-sunken); + border: 1px solid var(--border-soft); + border-radius: var(--radius); + padding: 10px 12px; +} + +.auth-alt { + font-size: 12px; + color: var(--muted); + text-decoration: none; + align-self: center; + + &:hover { color: var(--accent-ink); } +} + // -- the board (Main and EmptyBoard artboards) ------------------------------- .spacer { flex-grow: 1; } @@ -703,13 +721,15 @@ a { .user-menu-item-form { display: block; } .filterbar { - height: 52px; + min-height: 52px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; + flex-wrap: wrap; + row-gap: 8px; gap: 14px; - padding: 0 24px; + padding: 8px 24px; } .segmented { @@ -1898,15 +1918,48 @@ img.avatar { white-space: nowrap; } -// The board's Sort select shares `.field-box`/`.status-select` with the -// status pickers, but those pickers are meant to shrink with their row — -// the sort select isn't, so its widest option ("Oluşturulma") stays whole -// instead of clipping like the browser's native select would under -// `flex: 1; min-width: 0`. +// The board's Sort and Project selects keep their natural width, but a +// selected project can carry any name a workspace typed. Box and select +// shrink under pressure and the label ellipsizes, instead of pushing the +// bar past the viewport; the bar itself wraps when the row still outruns +// the width. .field-box-sort { - flex: none; + flex: 0 1 auto; + min-width: 0; + + .status-select { + flex: 0 1 auto; + width: auto; + min-width: 0; + max-width: 220px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } +} + +// The board's search field wears the same recessed box as the Sort and +// Project selects; the input inside gives up its own border and height the +// way the selects do, and the box shrinks before the chips do when the +// 390px rail wraps. +.field-box-search { + flex: 0 1 190px; - .status-select { flex: none; width: auto; } + .field-text { flex: none; } + + .field-input { + flex: 1; + min-width: 0; + height: auto; + padding: 0; + border: none; + background: transparent; + + &:focus-visible { + background: transparent; + border: none; + } + } } .glyph { @@ -4028,3 +4081,65 @@ input[type="radio"] { .auth-stage { padding: 0 16px 24px; } } + +// == What changed for me (`feed.rs`) ========================================= +// +// A topbar link with the unread chip, and one viewport-locked page. The rows +// are the Logs page's own `log-list`/`log-row` anatomy — stamp · actor · +// sentence · subject, hairline separators — so there is one row idiom, not +// two. Only the shell, the empty line and the badge are the feed's own. + +body:has(.feed-shell) { + height: 100vh; + height: 100dvh; + overflow: hidden; + display: flex; + flex-direction: column; + + > * { flex: none; } + > .feed-shell { + flex: 1; + min-height: 0; + overflow-y: auto; + scrollbar-width: none; + + &::-webkit-scrollbar { display: none; } + } +} + +.feed-shell { + padding: 24px; + display: flex; + justify-content: center; + + .panel { width: min(860px, 100%); align-self: flex-start; } + + .log-row { + padding: 10px 2px; + // Narrow shells drop the subject under the sentence instead of + // squeezing the sentence out of the row. + flex-wrap: wrap; + row-gap: 2px; + + &:last-child { border-bottom: none; } + } + + .log-task { + flex-shrink: 0; + margin-left: auto; + white-space: nowrap; + + .log-key { margin-right: 6px; } + .log-title { font-weight: 600; } + } +} + +.feed-badge { + margin-left: 6px; + background: var(--accent); + color: #fff; + border-radius: 9px; + padding: 1px 6px; + font-size: 11px; + font-variant-numeric: tabular-nums; +}