forge
Explore
Log in

Don't you dare go Hollow

Commit the styles the last three slices wrote; the binary guards its bundle

Browse files at this commit

475a59b5498a8e4349689a1cc017c8abaee4979bAhmet Kaan GümüşParent: e7bf52a
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.ymlmodified+21 -0
@@ -161,5 +161,26 @@ jobs:
161 exit 1161 exit 1
162 "162 "
163 163
164+ # The boot-time fingerprint guard refuses a foreign bundle, so a
165+ # mixed generation cannot get this far unnoticed — this is the
166+ # independent after-the-fact check: the page's stylesheet URL must
167+ # answer with bytes byte-identical to the bundle this deploy staged.
168+ - name: Verify the served stylesheet is this deploy's
169+ run: |
170+ set -euo pipefail
171+ deploy_path="${{ secrets.DEPLOY_PATH }}"
172+ ssh_target="${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}"
173+ listen=$(ssh "$ssh_target" "sed -n 's/^listen[[:space:]]*=[[:space:]]*\"\(.*\)\"/\1/p' '${deploy_path}/config/izlek.toml'")
174+ url=$(ssh "$ssh_target" "curl -fsS 'http://\${listen}/'" | grep -oE '/_topcoat/assets/main-[a-f0-9]+\.css' | head -n1)
175+ if [ -z "$url" ]; then
176+ echo 'the served page references no stylesheet' >&2
177+ exit 1
178+ fi
179+ ssh "$ssh_target" "curl -fsS 'http://\${listen}\${url}'" > served-stylesheet.css
180+ staged=$(sha256sum stage/assets/main-*.css | cut -d' ' -f1)
181+ served=$(sha256sum served-stylesheet.css | cut -d' ' -f1)
182+ echo "served $url: staged sha256:$staged, served sha256:$served"
183+ test "$staged" = "$served"
184+
164 - name: Cleaning185 - name: Cleaning
165 run: rm -rf ~/.ssh186 run: rm -rf ~/.ssh
Cargo.lockmodified+1 -0
@@ -1811,6 +1811,7 @@ dependencies = [
1811 "lettre",1811 "lettre",
1812 "serde",1812 "serde",
1813 "serde_json",1813 "serde_json",
1814+ "sha2 0.10.9",
1814 "thiserror",1815 "thiserror",
1815 "time",1816 "time",
1816 "tokio",1817 "tokio",
crates/izlek-web/Cargo.tomlmodified+5 -0
@@ -40,9 +40,14 @@ lettre = { version = "0.11.23", default-features = false, features = [
40 "pool",40 "pool",
41 ] }41 ] }
42 calamine = { version = "0.36.1", default-features = false }42 calamine = { version = "0.36.1", default-features = false }
43+# Hashes the compiled stylesheet against the bundle's bytes at boot, so a
44+# bundle from another generation refuses the boot instead of serving under
45+# this binary (see `server.rs`'s `stylesheet_guard`).
46+sha2 = "0.10"
43 47
44 [build-dependencies]48 [build-dependencies]
45 grass = "0.13"49 grass = "0.13"
50+sha2 = "0.10"
46 51
47 [dev-dependencies]52 [dev-dependencies]
48 http = "1.5"53 http = "1.5"
crates/izlek-web/build.rsmodified+15 -2
@@ -3,6 +3,8 @@
3 //! expects to find it. Crate-relative rather than `OUT_DIR`-relative so the3 //! expects to find it. Crate-relative rather than `OUT_DIR`-relative so the
4 //! asset's id does not churn with every profile/build-hash (see the topcoat4 //! asset's id does not churn with every profile/build-hash (see the topcoat
5 //! contract sheet, (a)).5 //! contract sheet, (a)).
6+//!
7+use sha2::Digest;
6 8
7 fn main() {9 fn main() {
8 let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();10 let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
@@ -15,8 +17,19 @@ fn main() {
15 17
16 let css = grass::from_path(&scss, &grass::Options::default())18 let css = grass::from_path(&scss, &grass::Options::default())
17 .unwrap_or_else(|err| panic!("failed to compile {scss}: {err}"));19 .unwrap_or_else(|err| panic!("failed to compile {scss}: {err}"));
18-
19 let out_dir = format!("{manifest_dir}/assets");20 let out_dir = format!("{manifest_dir}/assets");
20 std::fs::create_dir_all(&out_dir).expect("failed to create assets/");21 std::fs::create_dir_all(&out_dir).expect("failed to create assets/");
21- std::fs::write(format!("{out_dir}/main.css"), css).expect("failed to write assets/main.css");22+ std::fs::write(format!("{out_dir}/main.css"), &css).expect("failed to write assets/main.css");
23+
24+ // The binary carries the compiled stylesheet's fingerprint, so the
25+ // running server can tell a bundle of its own generation from one left
26+ // behind by another deploy (`server.rs`'s `stylesheet_guard` refuses the
27+ // boot on a mismatch). The bytes hashed here are exactly the bytes the
28+ // bundler later copies into the bundle, so the fingerprints agree.
29+ let fingerprint = sha2::Sha256::digest(css.as_bytes());
30+ let mut hex = String::with_capacity(fingerprint.len() * 2);
31+ for byte in fingerprint {
32+ hex.push_str(&format!("{byte:02x}"));
33+ }
34+ println!("cargo:rustc-env=IZLEK_STYLE_FINGERPRINT=sha256:{hex}");
22 }35 }
crates/izlek-web/src/main.rsmodified+22 -1
@@ -67,6 +67,27 @@ async fn main() {
67 println!("izlek {line}");67 println!("izlek {line}");
68 }68 }
69 69
70+ // The bundle beside the executable is the only stylesheet this process
71+ // can serve, and nothing in topcoat binds it to this binary's
72+ // generation: a bundle left behind by another deploy loads as happily
73+ // as the right one, and the pages then reference a stylesheet whose
74+ // bytes are days old — the mixed generation a browser once caught on
75+ // production. The fingerprint build.rs stamped into this binary is
76+ // checked against the bundle's bytes, and a foreign bundle refuses the
77+ // boot rather than serving under it.
78+ let bundle = AssetBundle::load().unwrap_or_else(|err| {
79+ eprintln!("izlek: the asset bundle beside the executable failed to load: {err}");
80+ std::process::exit(2);
81+ });
82+ let stylesheet = match izlek_web::server::stylesheet_guard(&bundle) {
83+ Ok(line) => line,
84+ Err(problem) => {
85+ eprintln!("izlek: {problem}");
86+ std::process::exit(2);
87+ }
88+ };
89+ println!("izlek {stylesheet}");
90+
70 // One process per database file: Turso is a single-writer engine and a91 // One process per database file: Turso is a single-writer engine and a
71 // second process on the same file loses writes rather than queueing.92 // second process on the same file loses writes rather than queueing.
72 //93 //
@@ -104,7 +125,7 @@ async fn main() {
104 .at("/api/profile_photo"),125 .at("/api/profile_photo"),
105 )126 )
106 .cookies()127 .cookies()
107- .assets(AssetBundle::load().expect("failed to load the asset bundle"))128+ .assets(bundle)
108 .app_context(accounts)129 .app_context(accounts)
109 .app_context(izlek_web::photo::PhotoStamps::default())130 .app_context(izlek_web::photo::PhotoStamps::default())
110 .app_context(izlek_web::live::LiveWindow(std::time::Duration::from_secs(131 .app_context(izlek_web::live::LiveWindow(std::time::Duration::from_secs(
crates/izlek-web/src/server.rsmodified+54 -4
@@ -13,6 +13,8 @@ use izlek_core::board::Transition;
13 use izlek_core::mail::Engine;13 use izlek_core::mail::Engine;
14 use izlek_core::store::{Freeing, User};14 use izlek_core::store::{Freeing, User};
15 use serde::{Deserialize, Serialize};15 use serde::{Deserialize, Serialize};
16+use sha2::Digest;
17+use topcoat::asset::AssetBundle;
16 use topcoat::context::{Cx, app_context, memoize, try_app_context};18 use topcoat::context::{Cx, app_context, memoize, try_app_context};
17 use topcoat::cookie::{Cookie, Cookies, SameSite, cookie, cookies};19 use topcoat::cookie::{Cookie, Cookies, SameSite, cookie, cookies};
18 use topcoat::router::request::headers;20 use topcoat::router::request::headers;
@@ -208,6 +210,55 @@ pub fn client_label(cx: &Cx) -> String {
208 }210 }
209 }211 }
210 212
213+/// The stylesheet this binary serves must be the one compiled into it.
214+///
215+/// `asset!` embeds an asset's declaration — its id and source path — into
216+/// the binary, but the served bytes live in the bundle directory beside the
217+/// executable, and topcoat loads whatever manifest it finds there. A bundle
218+/// left behind by another deploy sits beside a newer binary without a word
219+/// of complaint, and the pages then reference a stylesheet whose bytes are
220+/// from another generation — the mixed generation a browser once caught on
221+/// production. `build.rs` stamps the compiled stylesheet's SHA-256 into the
222+/// binary; this hashes the bundle's bytes against it, so a foreign bundle
223+/// refuses the boot instead of serving under it.
224+///
225+/// Returns the startup log line naming the served fingerprint, or the
226+/// reason the boot must not proceed.
227+pub fn stylesheet_guard(bundle: &AssetBundle) -> Result<String, String> {
228+ let expected = env!("IZLEK_STYLE_FINGERPRINT");
229+ let stylesheet = bundle
230+ .catalog()
231+ .assets()
232+ .find(|asset| {
233+ let name = asset.name();
234+ name.starts_with("main-") && name.ends_with(".css")
235+ })
236+ .ok_or_else(|| {
237+ format!(
238+ "the asset bundle at {} carries no stylesheet",
239+ bundle.dir().display()
240+ )
241+ })?;
242+ let bytes = std::fs::read(bundle.dir().join(stylesheet.name())).map_err(|err| {
243+ format!(
244+ "the bundled stylesheet {} could not be read: {err}",
245+ stylesheet.name()
246+ )
247+ })?;
248+ let actual = format!("sha256:{:x}", sha2::Sha256::digest(&bytes));
249+ if actual != expected {
250+ return Err(format!(
251+ "the asset bundle at {} is from another build: stylesheet {} is {actual} but this binary was compiled against {expected}; run `topcoat asset bundle` and redeploy",
252+ bundle.dir().display(),
253+ stylesheet.name()
254+ ));
255+ }
256+ Ok(format!(
257+ "assets stylesheet {} ({actual})",
258+ stylesheet.name()
259+ ))
260+}
261+
211 /// Writes the session cookie. `HttpOnly` so script cannot read it, `Secure` so262 /// Writes the session cookie. `HttpOnly` so script cannot read it, `Secure` so
212 /// it never crosses plain HTTP, `SameSite=Lax` so another site's form cannot263 /// it never crosses plain HTTP, `SameSite=Lax` so another site's form cannot
213 /// post with it.264 /// post with it.
@@ -839,10 +890,9 @@ async fn cache_directives(cx: &Cx, body: Body, next: Next<'_>) -> topcoat::Resul
839 if !is_html || parts.headers.contains_key(header::CACHE_CONTROL) {890 if !is_html || parts.headers.contains_key(header::CACHE_CONTROL) {
840 return Ok(Response::from_parts(parts, body));891 return Ok(Response::from_parts(parts, body));
841 }892 }
842- parts.headers.insert(893+ parts
843- header::CACHE_CONTROL,894+ .headers
844- HeaderValue::from_static("no-cache"),895+ .insert(header::CACHE_CONTROL, HeaderValue::from_static("no-cache"));
845- );
846 Ok(Response::from_parts(parts, body))896 Ok(Response::from_parts(parts, body))
847 }897 }
848 898
crates/izlek-web/tests/http.rsmodified+191 -101
@@ -8422,7 +8422,12 @@ async fn an_empty_time_clears_the_clock_and_a_clear_clears_both() {
8422 .post(8422 .post(
8423 "/api/save_task",8423 "/api/save_task",
8424 Some(&admin_cookie),8424 Some(&admin_cookie),
8425- &[("task_id", &task), ("deadline", ""), ("clock_hour", ""), ("clock_minute", "")],8425+ &[
8426+ ("task_id", &task),
8427+ ("deadline", ""),
8428+ ("clock_hour", ""),
8429+ ("clock_minute", ""),
8430+ ],
8426 )8431 )
8427 .await;8432 .await;
8428 assert!(8433 assert!(
@@ -8644,7 +8649,6 @@ async fn a_time_that_cannot_be_used_is_refused_and_saves_nothing() {
8644 assert!(facts.row.clock_at.is_none(), "a lone minute was stored");8649 assert!(facts.row.clock_at.is_none(), "a lone minute was stored");
8645 }8650 }
8646 8651
8647-
8648 #[tokio::test]8652 #[tokio::test]
8649 async fn a_card_wears_the_clock_chip_in_the_viewers_zone_instead_of_the_deadline() {8653 async fn a_card_wears_the_clock_chip_in_the_viewers_zone_instead_of_the_deadline() {
8650 let app = App::open().await;8654 let app = App::open().await;
@@ -8736,7 +8740,11 @@ async fn a_time_set_on_an_existing_day_writes_both_columns() {
8736 .post(8740 .post(
8737 "/api/save_task",8741 "/api/save_task",
8738 Some(&admin_cookie),8742 Some(&admin_cookie),
8739- &[("task_id", &task), ("clock_hour", "16"), ("clock_minute", "20")],8743+ &[
8744+ ("task_id", &task),
8745+ ("clock_hour", "16"),
8746+ ("clock_minute", "20"),
8747+ ],
8740 )8748 )
8741 .await;8749 .await;
8742 assert!(8750 assert!(
@@ -8981,7 +8989,11 @@ async fn a_time_change_fires_the_deadline_rule_and_round_trips() {
8981 .post(8989 .post(
8982 "/api/save_task",8990 "/api/save_task",
8983 Some(&member),8991 Some(&member),
8984- &[("task_id", &task), ("clock_hour", "9"), ("clock_minute", "30")],8992+ &[
8993+ ("task_id", &task),
8994+ ("clock_hour", "9"),
8995+ ("clock_minute", "30"),
8996+ ],
8985 )8997 )
8986 .await;8998 .await;
8987 assert!(8999 assert!(
@@ -9100,7 +9112,9 @@ async fn an_off_step_clock_renders_itself_not_a_rounded_step() {
9100 saved.location9112 saved.location
9101 );9113 );
9102 9114
9103- let page = app.get(&format!("/?task={task}"), Some(&admin_cookie)).await;9115+ let page = app
9116+ .get(&format!("/?task={task}"), Some(&admin_cookie))
9117+ .await;
9104 let html = String::from_utf8_lossy(&page.bytes);9118 let html = String::from_utf8_lossy(&page.bytes);
9105 assert!(9119 assert!(
9106 html.contains(r#"<option value="11" selected="">11</option>"#)9120 html.contains(r#"<option value="11" selected="">11</option>"#)
@@ -9176,13 +9190,12 @@ async fn tag_writes_record_their_events() {
9176 let app = App::open().await;9190 let app = App::open().await;
9177 let admin_cookie = admin(&app).await;9191 let admin_cookie = admin(&app).await;
9178 9192
9179- app9193+ app.post(
9180- .post(9194+ "/api/create_tag",
9181- "/api/create_tag",9195+ Some(&admin_cookie),
9182- Some(&admin_cookie),9196+ &[("name", "Urgent")],
9183- &[("name", "Urgent")],9197+ )
9184- )9198+ .await;
9185- .await;
9186 let workspace_id = app.workspace_id().await;9199 let workspace_id = app.workspace_id().await;
9187 let tag = {9200 let tag = {
9188 let board = izlek_core::board::load(app.store.as_ref(), &workspace_id)9201 let board = izlek_core::board::load(app.store.as_ref(), &workspace_id)
@@ -9197,27 +9210,24 @@ async fn tag_writes_record_their_events() {
9197 .find(|tag| tag.name == "Urgent")9210 .find(|tag| tag.name == "Urgent")
9198 .expect("the tag was created")9211 .expect("the tag was created")
9199 };9212 };
9200- app9213+ app.post(
9201- .post(9214+ "/api/move_tag",
9202- "/api/move_tag",9215+ Some(&admin_cookie),
9203- Some(&admin_cookie),9216+ &[("tag_id", &tag.id), ("direction", "up")],
9204- &[("tag_id", &tag.id), ("direction", "up")],9217+ )
9205- )9218+ .await;
9206- .await;9219+ app.post(
9207- app9220+ "/api/rename_tag",
9208- .post(9221+ Some(&admin_cookie),
9209- "/api/rename_tag",9222+ &[("tag_id", &tag.id), ("name", "High")],
9210- Some(&admin_cookie),9223+ )
9211- &[("tag_id", &tag.id), ("name", "High")],9224+ .await;
9212- )9225+ app.post(
9213- .await;9226+ "/api/delete_tag",
9214- app9227+ Some(&admin_cookie),
9215- .post(9228+ &[("tag_id", &tag.id)],
9216- "/api/delete_tag",9229+ )
9217- Some(&admin_cookie),9230+ .await;
9218- &[("tag_id", &tag.id)],
9219- )
9220- .await;
9221 9231
9222 let lines = app9232 let lines = app
9223 .store9233 .store
@@ -9261,13 +9271,12 @@ async fn tagging_a_task_records_a_trail_line() {
9261 .unwrap();9271 .unwrap();
9262 let column = board.columns[0].column.id.clone();9272 let column = board.columns[0].column.id.clone();
9263 let task = a_task(&app, &admin_cookie, &column, "Audit me").await;9273 let task = a_task(&app, &admin_cookie, &column, "Audit me").await;
9264- app9274+ app.post(
9265- .post(9275+ "/api/create_tag",
9266- "/api/create_tag",9276+ Some(&admin_cookie),
9267- Some(&admin_cookie),9277+ &[("name", "Shipped")],
9268- &[("name", "Shipped")],9278+ )
9269- )9279+ .await;
9270- .await;
9271 let tag = {9280 let tag = {
9272 let board = izlek_core::board::load(app.store.as_ref(), &workspace_id)9281 let board = izlek_core::board::load(app.store.as_ref(), &workspace_id)
9273 .await9282 .await
@@ -9282,13 +9291,12 @@ async fn tagging_a_task_records_a_trail_line() {
9282 .expect("the tag was created")9291 .expect("the tag was created")
9283 };9292 };
9284 9293
9285- app9294+ app.post(
9286- .post(9295+ "/api/set_task_tag",
9287- "/api/set_task_tag",9296+ Some(&admin_cookie),
9288- Some(&admin_cookie),9297+ &[("task_id", &task), ("tag_id", &tag.id)],
9289- &[("task_id", &task), ("tag_id", &tag.id)],9298+ )
9290- )9299+ .await;
9291- .await;
9292 9300
9293 let lines = app9301 let lines = app
9294 .store9302 .store
@@ -9315,16 +9323,14 @@ async fn profile_photo_changes_record_their_events() {
9315 let app = App::open().await;9323 let app = App::open().await;
9316 let admin_cookie = admin(&app).await;9324 let admin_cookie = admin(&app).await;
9317 9325
9318- app9326+ app.post_multipart(
9319- .post_multipart(9327+ "/api/profile_photo",
9320- "/api/profile_photo",9328+ Some(&admin_cookie),
9321- Some(&admin_cookie),9329+ &[],
9322- &[],9330+ Some(("me.png", "image/png", &PNG)),
9323- Some(("me.png", "image/png", &PNG)),9331+ )
9324- )9332+ .await;
9325- .await;9333+ app.post("/api/delete_profile_photo", Some(&admin_cookie), &[])
9326- app
9327- .post("/api/delete_profile_photo", Some(&admin_cookie), &[])
9328 .await;9334 .await;
9329 9335
9330 let lines = app9336 let lines = app
@@ -9382,10 +9388,7 @@ async fn checking_the_sender_records_an_event() {
9382 /// below reads the words the pane itself would show.9388 /// below reads the words the pane itself would show.
9383 async fn password_pane(app: &App, cookie: &str, query: &str) -> String {9389 async fn password_pane(app: &App, cookie: &str, query: &str) -> String {
9384 let page = app9390 let page = app
9385- .get(9391+ .get(&format!("/settings?section=profile&{query}"), Some(cookie))
9386- &format!("/settings?section=profile&{query}"),
9387- Some(cookie),
9388- )
9389 .await;9392 .await;
9390 String::from_utf8_lossy(&page.bytes).into_owned()9393 String::from_utf8_lossy(&page.bytes).into_owned()
9391 }9394 }
@@ -9406,7 +9409,10 @@ async fn the_password_pane_names_each_failure() {
9406 "/api/change_password",9409 "/api/change_password",
9407 Some(&admin_cookie),9410 Some(&admin_cookie),
9408 referer,9411 referer,
9409- &[("current", "not the password"), ("new", "a whole new passphrase")],9412+ &[
9413+ ("current", "not the password"),
9414+ ("new", "a whole new passphrase"),
9415+ ],
9410 )9416 )
9411 .await;9417 .await;
9412 let location = wrong.location.expect("a redirect location");9418 let location = wrong.location.expect("a redirect location");
@@ -9433,14 +9439,15 @@ async fn the_password_pane_names_each_failure() {
9433 )9439 )
9434 .await;9440 .await;
9435 let location = same.location.expect("a redirect location");9441 let location = same.location.expect("a redirect location");
9442+ assert!(location.contains("refusal=password-current"), "{location}");
9436 assert!(9443 assert!(
9437- location.contains("refusal=password-current"),9444+ password_pane(
9438- "{location}"9445+ &app,
9439- );9446+ &admin_cookie,
9440- assert!(9447+ "refusal=password-current&on=change_password"
9441- password_pane(&app, &admin_cookie, "refusal=password-current&on=change_password")9448+ )
9442- .await9449+ .await
9443- .contains("That's your current password.")9450+ .contains("That's your current password.")
9444 );9451 );
9445 9452
9446 // Too short.9453 // Too short.
@@ -9449,15 +9456,22 @@ async fn the_password_pane_names_each_failure() {
9449 "/api/change_password",9456 "/api/change_password",
9450 Some(&admin_cookie),9457 Some(&admin_cookie),
9451 referer,9458 referer,
9452- &[("current", "correct horse battery staple"), ("new", "short")],9459+ &[
9460+ ("current", "correct horse battery staple"),
9461+ ("new", "short"),
9462+ ],
9453 )9463 )
9454 .await;9464 .await;
9455 let location = short.location.expect("a redirect location");9465 let location = short.location.expect("a redirect location");
9456 assert!(location.contains("refusal=password-short"), "{location}");9466 assert!(location.contains("refusal=password-short"), "{location}");
9457 assert!(9467 assert!(
9458- password_pane(&app, &admin_cookie, "refusal=password-short&on=change_password")9468+ password_pane(
9459- .await9469+ &app,
9460- .contains("At least 10 characters.")9470+ &admin_cookie,
9471+ "refusal=password-short&on=change_password"
9472+ )
9473+ .await
9474+ .contains("At least 10 characters.")
9461 );9475 );
9462 9476
9463 // Looks like the address the account wears.9477 // Looks like the address the account wears.
@@ -9466,15 +9480,22 @@ async fn the_password_pane_names_each_failure() {
9466 "/api/change_password",9480 "/api/change_password",
9467 Some(&admin_cookie),9481 Some(&admin_cookie),
9468 referer,9482 referer,
9469- &[("current", "correct horse battery staple"), ("new", "ada@izlek.sh!!")],9483+ &[
9484+ ("current", "correct horse battery staple"),
9485+ ("new", "ada@izlek.sh!!"),
9486+ ],
9470 )9487 )
9471 .await;9488 .await;
9472 let location = you.location.expect("a redirect location");9489 let location = you.location.expect("a redirect location");
9473 assert!(location.contains("refusal=password-you"), "{location}");9490 assert!(location.contains("refusal=password-you"), "{location}");
9474 assert!(9491 assert!(
9475- password_pane(&app, &admin_cookie, "refusal=password-you&on=change_password")9492+ password_pane(
9476- .await9493+ &app,
9477- .contains("Not your address or your name.")9494+ &admin_cookie,
9495+ "refusal=password-you&on=change_password"
9496+ )
9497+ .await
9498+ .contains("Not your address or your name.")
9478 );9499 );
9479 9500
9480 // A change that works lands with the pane's own note, and the fresh9501 // 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() {
9495 assert!(location.contains("saved=change_password"), "{location}");9516 assert!(location.contains("saved=change_password"), "{location}");
9496 let fresh = right.session.clone().expect("a fresh session cookie");9517 let fresh = right.session.clone().expect("a fresh session cookie");
9497 let page = app9518 let page = app
9498- .get("/settings?section=profile&saved=change_password", Some(&fresh))9519+ .get(
9520+ "/settings?section=profile&saved=change_password",
9521+ Some(&fresh),
9522+ )
9499 .await;9523 .await;
9500 let html = String::from_utf8_lossy(&page.bytes);9524 let html = String::from_utf8_lossy(&page.bytes);
9501 assert!(9525 assert!(
@@ -9504,13 +9528,12 @@ async fn the_password_pane_names_each_failure() {
9504 );9528 );
9505 9529
9506 // The same pane in Turkish names the same failures in Turkish.9530 // The same pane in Turkish names the same failures in Turkish.
9507- app9531+ app.post(
9508- .post(9532+ "/api/save_profile",
9509- "/api/save_profile",9533+ Some(&fresh),
9510- Some(&fresh),9534+ &[("display_name", "Ada Lovelace"), ("language", "tr")],
9511- &[("display_name", "Ada Lovelace"), ("language", "tr")],9535+ )
9512- )9536+ .await;
9513- .await;
9514 let tr = app9537 let tr = app
9515 .get(9538 .get(
9516 "/settings?section=profile&refusal=password-current&on=change_password",9539 "/settings?section=profile&refusal=password-current&on=change_password",
@@ -9564,7 +9587,9 @@ async fn a_card_lists_both_dependency_directions_as_keys() {
9564 let page = app.get("/", Some(&admin)).await;9587 let page = app.get("/", Some(&admin)).await;
9565 let html = String::from_utf8_lossy(&page.bytes);9588 let html = String::from_utf8_lossy(&page.bytes);
9566 assert!(9589 assert!(
9567- html.contains(&format!(r#"class="card-blocks">blocks {second_key}</span>"#)),9590+ html.contains(&format!(
9591+ r#"class="card-blocks">blocks {second_key}</span>"#
9592+ )),
9568 "the blocker's card did not name what it blocks: {html}"9593 "the blocker's card did not name what it blocks: {html}"
9569 );9594 );
9570 assert!(9595 assert!(
@@ -9593,7 +9618,11 @@ async fn the_board_search_filters_and_composes_with_the_project_filter() {
9593 &[("task_id", &panel), ("tag_id", &aurora.id)],9618 &[("task_id", &panel), ("tag_id", &aurora.id)],
9594 )9619 )
9595 .await;9620 .await;
9596- assert_eq!(answer.body, "null", "the tag did not attach: {}", answer.body);9621+ assert_eq!(
9622+ answer.body, "null",
9623+ "the tag did not attach: {}",
9624+ answer.body
9625+ );
9597 let panel_key = app9626 let panel_key = app
9598 .store9627 .store
9599 .task(&panel)9628 .task(&panel)
@@ -9654,9 +9683,7 @@ async fn queued_reset_token(app: &App, email: &str) -> Option<String> {
9654 let body = sends9683 let body = sends
9655 .into_iter()9684 .into_iter()
9656 .rev()9685 .rev()
9657- .find(|send| {9686+ .find(|send| send.kind == SendKind::Notice && send.recipient == email)
9658- send.kind == SendKind::Notice && send.recipient == email
9659- })
9660 .and_then(|send| send.body)?;9687 .and_then(|send| send.body)?;
9661 body.rsplit_once("/reset/")9688 body.rsplit_once("/reset/")
9662 .and_then(|(_, rest)| rest.split_whitespace().next())9689 .and_then(|(_, rest)| rest.split_whitespace().next())
@@ -9735,7 +9762,10 @@ async fn a_reset_link_redeems_on_its_own_screen() {
9735 .post(9762 .post(
9736 "/api/sign_in",9763 "/api/sign_in",
9737 None,9764 None,
9738- &[("email", "ada@izlek.sh"), ("password", "correct horse battery staple")],9765+ &[
9766+ ("email", "ada@izlek.sh"),
9767+ ("password", "correct horse battery staple"),
9768+ ],
9739 )9769 )
9740 .await;9770 .await;
9741 assert_ne!(old.body, "null", "the old password still signed in");9771 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() {
9788 let app = App::open().await;9818 let app = App::open().await;
9789 let admin_cookie = admin(&app).await;9819 let admin_cookie = admin(&app).await;
9790 let column = first_column(&app).await;9820 let column = first_column(&app).await;
9791- let task = a_task(&app, &admin_cookie, &column, "Two parts, one post")9821+ let task = a_task(&app, &admin_cookie, &column, "Two parts, one post").await;
9792- .await;
9793 9822
9794 const BOUNDARY: &str = "izlek-test-boundary";9823 const BOUNDARY: &str = "izlek-test-boundary";
9795 let png = [0x89u8, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 9, 9];9824 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() {
9837 );9866 );
9838 9867
9839 let snapshot = app9868 let snapshot = app
9840- .post("/api/fetch_task", Some(&admin_cookie), &[("task_id", &task)])9869+ .post(
9870+ "/api/fetch_task",
9871+ Some(&admin_cookie),
9872+ &[("task_id", &task)],
9873+ )
9841 .await;9874 .await;
9842 let png_id = attachment_id_named(&snapshot.body, "first.png");9875 let png_id = attachment_id_named(&snapshot.body, "first.png");
9843 let txt_id = attachment_id_named(&snapshot.body, "notes.txt");9876 let txt_id = attachment_id_named(&snapshot.body, "notes.txt");
@@ -9866,13 +9899,12 @@ async fn the_feed_shows_each_person_their_stake() {
9866 let deniz_id = person_id(&app, &admin_cookie, &task, "Deniz").await;9899 let deniz_id = person_id(&app, &admin_cookie, &task, "Deniz").await;
9867 9900
9868 // Ada assigns Deniz: the assignment names him and starts his watch.9901 // Ada assigns Deniz: the assignment names him and starts his watch.
9869- app9902+ app.post(
9870- .post(9903+ "/api/assign",
9871- "/api/assign",9904+ Some(&admin_cookie),
9872- Some(&admin_cookie),9905+ &[("task_id", &task), ("user_id", &deniz_id)],
9873- &[("task_id", &task), ("user_id", &deniz_id)],9906+ )
9874- )9907+ .await;
9875- .await;
9876 9908
9877 // The badge rides every page's topbar while the news is unread...9909 // The badge rides every page's topbar while the news is unread...
9878 let board = app.get("/", Some(&member)).await;9910 let board = app.get("/", Some(&member)).await;
@@ -9931,3 +9963,61 @@ async fn the_build_stamp_matches_across_page_and_refetch() {
9931 "the build stamp drifted between renders: {stamps:?}"9963 "the build stamp drifted between renders: {stamps:?}"
9932 );9964 );
9933 }9965 }
9966+
9967+/// The served stylesheet is the one compiled into this build: the page
9968+/// references it, the route answers it, and the bytes are the bytes
9969+/// build.rs wrote — not a bundle from another generation.
9970+#[tokio::test]
9971+async fn the_served_stylesheet_is_this_builds_bytes() {
9972+ let app = App::open().await;
9973+ let page = app.get("/", None).await;
9974+ assert_eq!(page.status, StatusCode::OK);
9975+ let html = String::from_utf8_lossy(&page.bytes);
9976+ let url = html
9977+ .split('"')
9978+ .find(|piece| piece.starts_with("/_topcoat/assets/main-") && piece.ends_with(".css"))
9979+ .expect("the page references no stylesheet")
9980+ .to_string();
9981+ let served = app.get(&url, None).await;
9982+ assert_eq!(served.status, StatusCode::OK);
9983+ assert!(!served.bytes.is_empty());
9984+ let compiled = std::fs::read(concat!(env!("CARGO_MANIFEST_DIR"), "/assets/main.css"))
9985+ .expect("the compiled stylesheet is gone");
9986+ assert_eq!(
9987+ served.bytes, compiled,
9988+ "the server served another generation's stylesheet"
9989+ );
9990+}
9991+
9992+/// The boot guard refuses a bundle whose stylesheet bytes are not the
9993+/// generation this binary was compiled against, and accepts its own.
9994+#[test]
9995+fn the_stylesheet_guard_refuses_a_foreign_bundle() {
9996+ let bundle = AssetBundle::load_dir(asset_dir()).expect("no bundle: run `topcoat asset bundle`");
9997+ assert!(izlek_web::server::stylesheet_guard(&bundle).is_ok());
9998+
9999+ let foreign = std::env::temp_dir().join(format!("izlek-foreign-{}", Ulid::new()));
10000+ std::fs::create_dir_all(&foreign).unwrap();
10001+ for entry in std::fs::read_dir(asset_dir()).unwrap().flatten() {
10002+ std::fs::copy(entry.path(), foreign.join(entry.file_name())).unwrap();
10003+ }
10004+ let stylesheet = std::fs::read_dir(&foreign)
10005+ .unwrap()
10006+ .filter_map(|entry| {
10007+ let name = entry.ok()?.file_name().into_string().ok()?;
10008+ (name.starts_with("main-") && name.ends_with(".css")).then_some(name)
10009+ })
10010+ .next()
10011+ .expect("no stylesheet in the copied bundle");
10012+ std::fs::write(
10013+ foreign.join(&stylesheet),
10014+ "body { color: another-generation }",
10015+ )
10016+ .unwrap();
10017+
10018+ let foreign_bundle = AssetBundle::load_dir(&foreign).expect("the copied bundle does not load");
10019+ let problem = izlek_web::server::stylesheet_guard(&foreign_bundle)
10020+ .expect_err("a foreign bundle passed the guard");
10021+ assert!(problem.contains("another build"), "{problem}");
10022+ std::fs::remove_dir_all(&foreign).unwrap();
10023+}
style/main.scssmodified+124 -9
@@ -614,6 +614,24 @@ a {
614 padding: 10px 12px;614 padding: 10px 12px;
615 }615 }
616 616
617+.auth-note {
618+ font-size: 13px;
619+ color: var(--muted);
620+ background: var(--panel-sunken);
621+ border: 1px solid var(--border-soft);
622+ border-radius: var(--radius);
623+ padding: 10px 12px;
624+}
625+
626+.auth-alt {
627+ font-size: 12px;
628+ color: var(--muted);
629+ text-decoration: none;
630+ align-self: center;
631+
632+ &:hover { color: var(--accent-ink); }
633+}
634+
617 // -- the board (Main and EmptyBoard artboards) -------------------------------635 // -- the board (Main and EmptyBoard artboards) -------------------------------
618 636
619 .spacer { flex-grow: 1; }637 .spacer { flex-grow: 1; }
@@ -703,13 +721,15 @@ a {
703 .user-menu-item-form { display: block; }721 .user-menu-item-form { display: block; }
704 722
705 .filterbar {723 .filterbar {
706- height: 52px;724+ min-height: 52px;
707 background: var(--surface);725 background: var(--surface);
708 border-bottom: 1px solid var(--border);726 border-bottom: 1px solid var(--border);
709 display: flex;727 display: flex;
710 align-items: center;728 align-items: center;
729+ flex-wrap: wrap;
730+ row-gap: 8px;
711 gap: 14px;731 gap: 14px;
712- padding: 0 24px;732+ padding: 8px 24px;
713 }733 }
714 734
715 .segmented {735 .segmented {
@@ -1898,15 +1918,48 @@ img.avatar {
1898 white-space: nowrap;1918 white-space: nowrap;
1899 }1919 }
1900 1920
1901-// The board's Sort select shares `.field-box`/`.status-select` with the1921+// The board's Sort and Project selects keep their natural width, but a
1902-// status pickers, but those pickers are meant to shrink with their row —1922+// selected project can carry any name a workspace typed. Box and select
1903-// the sort select isn't, so its widest option ("Oluşturulma") stays whole1923+// shrink under pressure and the label ellipsizes, instead of pushing the
1904-// instead of clipping like the browser's native select would under1924+// bar past the viewport; the bar itself wraps when the row still outruns
1905-// `flex: 1; min-width: 0`.1925+// the width.
1906 .field-box-sort {1926 .field-box-sort {
1907- flex: none;1927+ flex: 0 1 auto;
1928+ min-width: 0;
1929+
1930+ .status-select {
1931+ flex: 0 1 auto;
1932+ width: auto;
1933+ min-width: 0;
1934+ max-width: 220px;
1935+ overflow: hidden;
1936+ text-overflow: ellipsis;
1937+ white-space: nowrap;
1938+ }
1939+}
1940+
1941+// The board's search field wears the same recessed box as the Sort and
1942+// Project selects; the input inside gives up its own border and height the
1943+// way the selects do, and the box shrinks before the chips do when the
1944+// 390px rail wraps.
1945+.field-box-search {
1946+ flex: 0 1 190px;
1908 1947
1909- .status-select { flex: none; width: auto; }1948+ .field-text { flex: none; }
1949+
1950+ .field-input {
1951+ flex: 1;
1952+ min-width: 0;
1953+ height: auto;
1954+ padding: 0;
1955+ border: none;
1956+ background: transparent;
1957+
1958+ &:focus-visible {
1959+ background: transparent;
1960+ border: none;
1961+ }
1962+ }
1910 }1963 }
1911 1964
1912 .glyph {1965 .glyph {
@@ -4028,3 +4081,65 @@ input[type="radio"] {
4028 4081
4029 .auth-stage { padding: 0 16px 24px; }4082 .auth-stage { padding: 0 16px 24px; }
4030 }4083 }
4084+
4085+// == What changed for me (`feed.rs`) =========================================
4086+//
4087+// A topbar link with the unread chip, and one viewport-locked page. The rows
4088+// are the Logs page's own `log-list`/`log-row` anatomy — stamp · actor ·
4089+// sentence · subject, hairline separators — so there is one row idiom, not
4090+// two. Only the shell, the empty line and the badge are the feed's own.
4091+
4092+body:has(.feed-shell) {
4093+ height: 100vh;
4094+ height: 100dvh;
4095+ overflow: hidden;
4096+ display: flex;
4097+ flex-direction: column;
4098+
4099+ > * { flex: none; }
4100+ > .feed-shell {
4101+ flex: 1;
4102+ min-height: 0;
4103+ overflow-y: auto;
4104+ scrollbar-width: none;
4105+
4106+ &::-webkit-scrollbar { display: none; }
4107+ }
4108+}
4109+
4110+.feed-shell {
4111+ padding: 24px;
4112+ display: flex;
4113+ justify-content: center;
4114+
4115+ .panel { width: min(860px, 100%); align-self: flex-start; }
4116+
4117+ .log-row {
4118+ padding: 10px 2px;
4119+ // Narrow shells drop the subject under the sentence instead of
4120+ // squeezing the sentence out of the row.
4121+ flex-wrap: wrap;
4122+ row-gap: 2px;
4123+
4124+ &:last-child { border-bottom: none; }
4125+ }
4126+
4127+ .log-task {
4128+ flex-shrink: 0;
4129+ margin-left: auto;
4130+ white-space: nowrap;
4131+
4132+ .log-key { margin-right: 6px; }
4133+ .log-title { font-weight: 600; }
4134+ }
4135+}
4136+
4137+.feed-badge {
4138+ margin-left: 6px;
4139+ background: var(--accent);
4140+ color: #fff;
4141+ border-radius: 9px;
4142+ padding: 1px 6px;
4143+ font-size: 11px;
4144+ font-variant-numeric: tabular-nums;
4145+}