forge
Explore
Log in

Don't you dare go Hollow

Filterbar wraps at every width; search folds Turkish; feed backfills watches

Browse files at this commit

9303e20adb6b9db2df9bb14a7cee1466be60d9f3Ahmet Kaan GümüşParent: 5bbedf2
The filterbar only wrapped below 620px, so a long project name pushed the
search box past the viewport edge around 840px — a document overflow the
house forbids. The bar wraps whenever it needs to now, and long trigger
labels ellipsize instead of pushing.

Search folded case with Unicode's default mapping, where İ becomes i with
a combining dot — 'iş' never matched 'İş Planı Teslimi'. Both sides fold
through a Turkish-aware map now.

Watching only began at deploy, so every existing account's feed read
'Nothing yet.' The reconcile seeds watches from history — created,
assigned, commented — once per database, and carries each person's
feed_seen_at across the rebuild instead of resetting it.
crates/izlek-core/migrations/0001_init.sqlmodified+2 -0
@@ -250,6 +250,7 @@ CREATE TABLE task_watcher (
250 user_id TEXT NOT NULL REFERENCES user(id),250 user_id TEXT NOT NULL REFERENCES user(id),
251 PRIMARY KEY (task_id, user_id)251 PRIMARY KEY (task_id, user_id)
252 );252 );
253+CREATE INDEX task_watcher_by_user ON task_watcher(user_id);
253 254
254 -- blocked_task_id is blocked by blocking_task_id. cleared_at is set when the255 -- blocked_task_id is blocked by blocking_task_id. cleared_at is set when the
255 -- blocking task finishes, which is what the "you can start now" rule reads.256 -- blocking task finishes, which is what the "you can start now" rule reads.
@@ -363,6 +364,7 @@ CREATE TABLE activity (
363 );364 );
364 CREATE INDEX activity_by_task ON activity(task_id);365 CREATE INDEX activity_by_task ON activity(task_id);
365 CREATE INDEX activity_recent ON activity(created_at);366 CREATE INDEX activity_recent ON activity(created_at);
367+CREATE INDEX activity_by_subject ON activity(subject_id);
366 368
367 -- Mail rules are written only by the admin.369 -- Mail rules are written only by the admin.
368 --370 --
crates/izlek-core/src/board.rsmodified+28 -6
@@ -275,16 +275,15 @@ impl BoardView {
275 self.cards().filter(|card| card.is_blocked()).count()275 self.cards().filter(|card| card.is_blocked()).count()
276 }276 }
277 277
278- /// Keeps only the cards whose key or title answers `query`: a literal,278+ /// Keeps only the cards whose key or title answers `query`: a literal
279- /// case-insensitive substring of either. The human key typed in any279+ /// substring of the folded key or folded title. The human key typed in
280- /// case matches; a fragment of a title matches; nothing is280+ /// any case matches; a fragment of a title matches; nothing is
281 /// pattern-matched, so there are no wildcards to escape.281 /// pattern-matched, so there are no wildcards to escape.
282 pub fn searching(&mut self, query: &str) {282 pub fn searching(&mut self, query: &str) {
283- let needle = query.to_lowercase();283+ let needle = fold(query);
284 for column in &mut self.columns {284 for column in &mut self.columns {
285 column.cards.retain(|card| {285 column.cards.retain(|card| {
286- card.task_key.to_lowercase().contains(&needle)286+ fold(&card.task_key).contains(&needle) || fold(&card.title).contains(&needle)
287- || card.title.to_lowercase().contains(&needle)
288 });287 });
289 }288 }
290 }289 }
@@ -303,6 +302,29 @@ impl BoardView {
303 }302 }
304 }303 }
305 304
305+/// Folds text for search: Turkish letters collapse to their ASCII stems
306+/// (`İ`/`I`/`ı` → `i`, `ş` → `s`, `ç` → `c`, `ğ` → `g`, `ü` → `u`, `ö` →
307+/// `o`), case flattens. A naive lowercase cannot stand in for this: it
308+/// turns `İ` into `i` plus a combining dot, and then no plain-`i` query —
309+/// `is`, say, against a card titled `İş Planı Teslimi` — can ever match.
310+/// Query and card fold through the same map, so `iş`, `İŞ`, `is`, and
311+/// `İS` all find `İş`.
312+fn fold(text: &str) -> String {
313+ let mut folded = String::with_capacity(text.len());
314+ for character in text.chars() {
315+ match character {
316+ 'İ' | 'I' | 'ı' => folded.push('i'),
317+ 'ş' | 'Ş' => folded.push('s'),
318+ 'ç' | 'Ç' => folded.push('c'),
319+ 'ğ' | 'Ğ' => folded.push('g'),
320+ 'ü' | 'Ü' => folded.push('u'),
321+ 'ö' | 'Ö' => folded.push('o'),
322+ other => folded.extend(other.to_lowercase()),
323+ }
324+ }
325+ folded
326+}
327+
306 /// `Sep 12` — the card chips are day-and-month, never a year.328 /// `Sep 12` — the card chips are day-and-month, never a year.
307 pub fn day_label(day: Date) -> String {329 pub fn day_label(day: Date) -> String {
308 let month = match day.month() {330 let month = match day.month() {
crates/izlek-core/src/store/reconcile.rsmodified+126 -32
@@ -5,8 +5,8 @@
5 //! column map, the copy is verified, and only then the files are swapped. The5 //! column map, the copy is verified, and only then the files are swapped. The
6 //! original file is kept as a timestamped backup and is never deleted.6 //! original file is kept as a timestamped backup and is never deleted.
7 7
8-use super::{Result, StoreError};
9 use super::schema::{SCHEMA, declared_fingerprint, diff_report, fingerprint};8 use super::schema::{SCHEMA, declared_fingerprint, diff_report, fingerprint};
9+use super::{Result, StoreError};
10 use turso::{Builder, Connection, params};10 use turso::{Builder, Connection, params};
11 use ulid::Ulid;11 use ulid::Ulid;
12 12
@@ -43,7 +43,9 @@ pub async fn reconcile(path: &str, opts: ReconcileOptions) -> Result<()> {
43 .build()43 .build()
44 .await44 .await
45 .map_err(|e| StoreError::Backend(e.to_string()))?;45 .map_err(|e| StoreError::Backend(e.to_string()))?;
46- let old_conn = old_db.connect().map_err(|e| StoreError::Backend(e.to_string()))?;46+ let old_conn = old_db
47+ .connect()
48+ .map_err(|e| StoreError::Backend(e.to_string()))?;
47 49
48 let old_fp = fingerprint(&old_conn).await?;50 let old_fp = fingerprint(&old_conn).await?;
49 let new_fp = declared_fingerprint().await?;51 let new_fp = declared_fingerprint().await?;
@@ -127,7 +129,10 @@ pub async fn reconcile(path: &str, opts: ReconcileOptions) -> Result<()> {
127 let _ = std::fs::remove_file(format!("{}-shm", rebuilt_path));129 let _ = std::fs::remove_file(format!("{}-shm", rebuilt_path));
128 130
129 if opts.auto {131 if opts.auto {
130- eprintln!("database rebuilt and verified; original backed up to {}", backup_path);132+ eprintln!(
133+ "database rebuilt and verified; original backed up to {}",
134+ backup_path
135+ );
131 eprintln!("rebuilt database now at {}", path);136 eprintln!("rebuilt database now at {}", path);
132 } else {137 } else {
133 println!("database rebuilt and verified");138 println!("database rebuilt and verified");
@@ -151,7 +156,9 @@ async fn rebuild(path: &str, rebuilt_path: &str, old_conn: &Connection) -> Resul
151 .build()156 .build()
152 .await157 .await
153 .map_err(|e| StoreError::Backend(e.to_string()))?;158 .map_err(|e| StoreError::Backend(e.to_string()))?;
154- let new_conn = new_db.connect().map_err(|e| StoreError::Backend(e.to_string()))?;159+ let new_conn = new_db
160+ .connect()
161+ .map_err(|e| StoreError::Backend(e.to_string()))?;
155 162
156 new_conn163 new_conn
157 .execute("PRAGMA foreign_keys = ON", ())164 .execute("PRAGMA foreign_keys = ON", ())
@@ -189,7 +196,11 @@ async fn seed_general_tags(old_conn: &Connection, new_conn: &Connection) -> Resu
189 .query("SELECT id, created_at FROM board", ())196 .query("SELECT id, created_at FROM board", ())
190 .await197 .await
191 .map_err(|e| StoreError::Backend(e.to_string()))?;198 .map_err(|e| StoreError::Backend(e.to_string()))?;
192- while let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? {199+ while let Some(row) = rows
200+ .next()
201+ .await
202+ .map_err(|e| StoreError::Backend(e.to_string()))?
203+ {
193 let board_id: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?;204 let board_id: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?;
194 let created_at: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;205 let created_at: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;
195 let id = Ulid::new().to_string();206 let id = Ulid::new().to_string();
@@ -219,6 +230,7 @@ fn build_maps(
219 old_has_batch_window: bool,230 old_has_batch_window: bool,
220 old_has_clock: bool,231 old_has_clock: bool,
221 old_has_reminder: bool,232 old_has_reminder: bool,
233+ old_has_feed_seen: bool,
222 ) -> Vec<TableMap> {234 ) -> Vec<TableMap> {
223 let mut maps = Vec::new();235 let mut maps = Vec::new();
224 236
@@ -228,7 +240,10 @@ fn build_maps(
228 ("id", "old.id".into()),240 ("id", "old.id".into()),
229 ("name", "old.name".into()),241 ("name", "old.name".into()),
230 ("created_at", "old.created_at".into()),242 ("created_at", "old.created_at".into()),
231- ("attachment_limit_bytes", "old.attachment_limit_bytes".into()),243+ (
244+ "attachment_limit_bytes",
245+ "old.attachment_limit_bytes".into(),
246+ ),
232 ("photo_limit_bytes", "old.photo_limit_bytes".into()),247 ("photo_limit_bytes", "old.photo_limit_bytes".into()),
233 ("allowed_file_types", "old.allowed_file_types".into()),248 ("allowed_file_types", "old.allowed_file_types".into()),
234 (249 (
@@ -312,12 +327,17 @@ fn build_maps(
312 "created_at",327 "created_at",
313 "last_signed_in_at",328 "last_signed_in_at",
314 ]);329 ]);
315- // The feed's read marker is new with this schema: no database old330+ // The feed's read marker: new with the feed schema, so a
316- // enough to be reconciled ever carried it, so every copied row331+ // database old enough to predate it starts unseen — and a
317- // starts unseen rather than pretending to have been read.332+ // database that already carries it keeps its marker across the
318- columns.push(("feed_seen_at", "NULL".into()));333+ // rebuild rather than having its read state wiped.
334+ columns.push(if old_has_feed_seen {
335+ ("feed_seen_at", "old.feed_seen_at".into())
336+ } else {
337+ ("feed_seen_at", "NULL".into())
338+ });
319 columns339 columns
320- }340+ },
321 });341 });
322 maps.push(TableMap {342 maps.push(TableMap {
323 name: "workspace_owner",343 name: "workspace_owner",
@@ -339,11 +359,18 @@ fn build_maps(
339 // resets did not exist to be mailed yet.359 // resets did not exist to be mailed yet.
340 columns.push(("kind", "'join'".into()));360 columns.push(("kind", "'join'".into()));
341 columns361 columns
342- }362+ },
343 });363 });
344 maps.push(TableMap {364 maps.push(TableMap {
345 name: "session",365 name: "session",
346- columns: old_cols(&["id", "user_id", "token_hash", "created_at", "expires_at", "revoked_at"]),366+ columns: old_cols(&[
367+ "id",
368+ "user_id",
369+ "token_hash",
370+ "created_at",
371+ "expires_at",
372+ "revoked_at",
373+ ]),
347 });374 });
348 maps.push(TableMap {375 maps.push(TableMap {
349 name: "auth_attempt",376 name: "auth_attempt",
@@ -521,7 +548,11 @@ async fn old_has_column(conn: &Connection, table: &str, column: &str) -> Result<
521 .query(&format!("PRAGMA table_info({table})"), ())548 .query(&format!("PRAGMA table_info({table})"), ())
522 .await549 .await
523 .map_err(|e| StoreError::Backend(e.to_string()))?;550 .map_err(|e| StoreError::Backend(e.to_string()))?;
524- while let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? {551+ while let Some(row) = rows
552+ .next()
553+ .await
554+ .map_err(|e| StoreError::Backend(e.to_string()))?
555+ {
525 let name: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;556 let name: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;
526 if name == column {557 if name == column {
527 return Ok(true);558 return Ok(true);
@@ -543,7 +574,11 @@ async fn validate_maps(conn: &Connection, maps: &[TableMap]) -> Result<()> {
543 .await574 .await
544 .map_err(|e| StoreError::Backend(e.to_string()))?;575 .map_err(|e| StoreError::Backend(e.to_string()))?;
545 let mut actual = HashSet::new();576 let mut actual = HashSet::new();
546- while let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? {577+ while let Some(row) = rows
578+ .next()
579+ .await
580+ .map_err(|e| StoreError::Backend(e.to_string()))?
581+ {
547 let name: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;582 let name: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;
548 actual.insert(name);583 actual.insert(name);
549 }584 }
@@ -578,11 +613,17 @@ async fn copy_data(old_conn: &Connection, new_conn: &Connection, path: &str) ->
578 .map_err(|e| StoreError::Backend(e.to_string()))?;613 .map_err(|e| StoreError::Backend(e.to_string()))?;
579 614
580 let has_smtp_check = old_has_column(old_conn, "workspace", "smtp_check_at").await?;615 let has_smtp_check = old_has_column(old_conn, "workspace", "smtp_check_at").await?;
581- let has_batch_window =616+ let has_batch_window = old_has_column(old_conn, "workspace", "mail_batch_minutes").await?;
582- old_has_column(old_conn, "workspace", "mail_batch_minutes").await?;
583 let has_clock = old_has_column(old_conn, "task", "clock_at").await?;617 let has_clock = old_has_column(old_conn, "task", "clock_at").await?;
584 let has_reminder = old_has_column(old_conn, "workspace", "reminder_minutes").await?;618 let has_reminder = old_has_column(old_conn, "workspace", "reminder_minutes").await?;
585- let maps = build_maps(has_smtp_check, has_batch_window, has_clock, has_reminder);619+ let has_feed_seen = old_has_column(old_conn, "user", "feed_seen_at").await?;
620+ let maps = build_maps(
621+ has_smtp_check,
622+ has_batch_window,
623+ has_clock,
624+ has_reminder,
625+ has_feed_seen,
626+ );
586 validate_maps(new_conn, &maps).await?;627 validate_maps(new_conn, &maps).await?;
587 628
588 for map in maps {629 for map in maps {
@@ -592,7 +633,12 @@ async fn copy_data(old_conn: &Connection, new_conn: &Connection, path: &str) ->
592 if map.name == "task" {633 if map.name == "task" {
593 seed_general_tags(old_conn, new_conn).await?;634 seed_general_tags(old_conn, new_conn).await?;
594 }635 }
595- let cols = map.columns.iter().map(|(c, _)| *c).collect::<Vec<_>>().join(", ");636+ let cols = map
637+ .columns
638+ .iter()
639+ .map(|(c, _)| *c)
640+ .collect::<Vec<_>>()
641+ .join(", ");
596 // `old` is the attached SCHEMA, not a table, so `old.id` in a select642 // `old` is the attached SCHEMA, not a table, so `old.id` in a select
597 // list reads as "table old, column id". The source table is aliased643 // list reads as "table old, column id". The source table is aliased
598 // and the maps' `old.` prefix rewritten onto that alias.644 // and the maps' `old.` prefix rewritten onto that alias.
@@ -606,12 +652,28 @@ async fn copy_data(old_conn: &Connection, new_conn: &Connection, path: &str) ->
606 "INSERT INTO main.{} ({}) SELECT {} FROM old.{} AS src",652 "INSERT INTO main.{} ({}) SELECT {} FROM old.{} AS src",
607 map.name, cols, exprs, map.name653 map.name, cols, exprs, map.name
608 );654 );
609- new_conn655+ new_conn.execute(&sql, ()).await.map_err(|e| {
610- .execute(&sql, ())656+ StoreError::Backend(format!("{} while copying {}: {}", e, map.name, sql))
611- .await657+ })?;
612- .map_err(|e| StoreError::Backend(format!("{} while copying {}: {}", e, map.name, sql)))?;
613 }658 }
614 659
660+ // Backfills the watches the feed reads: a watch for every task somebody
661+ // created, was assigned, or commented on, including all history. This
662+ // runs exactly once per database — the rebuild only happens on a schema
663+ // mismatch — so watches removed by an unassign after the deploy stand,
664+ // and the pass cannot fight the transactional auto-watch in the store's
665+ // own writes: nothing is being served while the rebuild runs.
666+ new_conn
667+ .execute(
668+ "INSERT OR IGNORE INTO task_watcher (task_id, user_id) \
669+ SELECT t.id, t.created_by FROM task t WHERE t.created_by IS NOT NULL \
670+ UNION SELECT task_id, user_id FROM task_assignee \
671+ UNION SELECT task_id, author_id FROM comment",
672+ (),
673+ )
674+ .await
675+ .map_err(|e| StoreError::Backend(format!("seed watches: {e}")))?;
676+
615 new_conn677 new_conn
616 .execute("DETACH DATABASE old", ())678 .execute("DETACH DATABASE old", ())
617 .await679 .await
@@ -627,7 +689,11 @@ async fn verify(old_conn: &Connection, new_conn: &Connection) -> Result<()> {
627 .await689 .await
628 .map_err(|e| StoreError::Backend(e.to_string()))?;690 .map_err(|e| StoreError::Backend(e.to_string()))?;
629 let mut fk_errors = Vec::new();691 let mut fk_errors = Vec::new();
630- while let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? {692+ while let Some(row) = rows
693+ .next()
694+ .await
695+ .map_err(|e| StoreError::Backend(e.to_string()))?
696+ {
631 let table: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?;697 let table: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?;
632 let rowid: i64 = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;698 let rowid: i64 = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?;
633 let parent: String = row.get(2).map_err(|e| StoreError::Backend(e.to_string()))?;699 let parent: String = row.get(2).map_err(|e| StoreError::Backend(e.to_string()))?;
@@ -649,7 +715,11 @@ async fn verify(old_conn: &Connection, new_conn: &Connection) -> Result<()> {
649 .await715 .await
650 .map_err(|e| StoreError::Backend(e.to_string()))?;716 .map_err(|e| StoreError::Backend(e.to_string()))?;
651 let mut integrity = Vec::new();717 let mut integrity = Vec::new();
652- while let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? {718+ while let Some(row) = rows
719+ .next()
720+ .await
721+ .map_err(|e| StoreError::Backend(e.to_string()))?
722+ {
653 let msg: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?;723 let msg: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?;
654 integrity.push(msg);724 integrity.push(msg);
655 }725 }
@@ -685,11 +755,30 @@ async fn verify(old_conn: &Connection, new_conn: &Connection) -> Result<()> {
685 for table in tables {755 for table in tables {
686 let old_count = count_rows(old_conn, table).await?;756 let old_count = count_rows(old_conn, table).await?;
687 let new_count = count_rows(new_conn, table).await?;757 let new_count = count_rows(new_conn, table).await?;
688- if old_count != new_count {758+ // task_watcher: the rebuild backfills watches from history — every
689- return Err(StoreError::Backend(format!(759+ // task somebody created, was assigned, or commented on — so the new
690- "row count mismatch for {}: old {} new {}",760+ // count is that derived set (every old watch is in it by
691- table, old_count, new_count761+ // construction), not the old count.
692- )));762+ let expected = if table == "task_watcher" {
763+ Some(count_rows(new_conn, "(SELECT t.id, t.created_by AS user_id FROM task t WHERE t.created_by IS NOT NULL UNION SELECT task_id, user_id FROM task_assignee UNION SELECT task_id, author_id FROM comment)").await?)
764+ } else {
765+ None
766+ };
767+ match expected {
768+ Some(want) if new_count != want => {
769+ return Err(StoreError::Backend(format!(
770+ "task_watcher count {} does not match the backfilled set {}",
771+ new_count, want
772+ )));
773+ }
774+ Some(_) => {}
775+ None if old_count != new_count => {
776+ return Err(StoreError::Backend(format!(
777+ "row count mismatch for {}: old {} new {}",
778+ table, old_count, new_count
779+ )));
780+ }
781+ None => {}
693 }782 }
694 }783 }
695 784
@@ -712,13 +801,18 @@ async fn count_rows(conn: &Connection, table: &str) -> Result<i64> {
712 .query(&sql, ())801 .query(&sql, ())
713 .await802 .await
714 .map_err(|e| StoreError::Backend(e.to_string()))?;803 .map_err(|e| StoreError::Backend(e.to_string()))?;
715- let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? else {804+ let Some(row) = rows
805+ .next()
806+ .await
807+ .map_err(|e| StoreError::Backend(e.to_string()))?
808+ else {
716 return Err(StoreError::Backend(format!(809 return Err(StoreError::Backend(format!(
717 "could not count rows in {}",810 "could not count rows in {}",
718 table811 table
719 )));812 )));
720 };813 };
721- row.get::<i64>(0).map_err(|e| StoreError::Backend(e.to_string()))814+ row.get::<i64>(0)
815+ .map_err(|e| StoreError::Backend(e.to_string()))
722 }816 }
723 817
724 fn cleanup_rebuilt(rebuilt_path: &str) {818 fn cleanup_rebuilt(rebuilt_path: &str) {
crates/izlek-core/tests/store.rsmodified+401 -60
@@ -803,7 +803,10 @@ async fn workspace_defaults_match_the_settings_screen() {
803 "every type until narrowed"803 "every type until narrowed"
804 );804 );
805 assert_eq!(ws.mail_batch_minutes, 5);805 assert_eq!(ws.mail_batch_minutes, 5);
806- assert_eq!(ws.reminder_minutes, 15, "a workspace starts with reminders on");806+ assert_eq!(
807+ ws.reminder_minutes, 15,
808+ "a workspace starts with reminders on"
809+ );
807 }810 }
808 811
809 /// An admin edits the sender from Settings, so the record carries host, port,812 /// An admin edits the sender from Settings, so the record carries host, port,
@@ -1076,7 +1079,10 @@ async fn limits_round_trip_including_the_file_type_list() {
1076 assert_eq!(ws.photo_limit_bytes, 512 * 1024);1079 assert_eq!(ws.photo_limit_bytes, 512 * 1024);
1077 assert_eq!(ws.allowed_file_types, types);1080 assert_eq!(ws.allowed_file_types, types);
1078 assert_eq!(ws.mail_batch_minutes, 5);1081 assert_eq!(ws.mail_batch_minutes, 5);
1079- assert_eq!(ws.reminder_minutes, 15, "the reminder lead rides the same save");1082+ assert_eq!(
1083+ ws.reminder_minutes, 15,
1084+ "the reminder lead rides the same save"
1085+ );
1080 }1086 }
1081 1087
1082 #[tokio::test]1088 #[tokio::test]
@@ -1333,7 +1339,12 @@ async fn a_signin_link_stores_only_the_hash_and_is_used_once() {
1333 let now = OffsetDateTime::now_utc();1339 let now = OffsetDateTime::now_utc();
1334 let link = scratch1340 let link = scratch
1335 .store1341 .store
1336- .create_signin_link(&user.id, "hash-of-the-token", now + Duration::days(7), izlek_core::store::LinkKind::Join)1342+ .create_signin_link(
1343+ &user.id,
1344+ "hash-of-the-token",
1345+ now + Duration::days(7),
1346+ izlek_core::store::LinkKind::Join,
1347+ )
1337 .await1348 .await
1338 .unwrap();1349 .unwrap();
1339 assert!(link.is_usable(now));1350 assert!(link.is_usable(now));
@@ -1398,7 +1409,12 @@ async fn an_expired_link_is_still_a_live_account() {
1398 let now = OffsetDateTime::now_utc();1409 let now = OffsetDateTime::now_utc();
1399 let stale = scratch1410 let stale = scratch
1400 .store1411 .store
1401- .create_signin_link(&user.id, "stale-hash", now - Duration::hours(1), izlek_core::store::LinkKind::Join)1412+ .create_signin_link(
1413+ &user.id,
1414+ "stale-hash",
1415+ now - Duration::hours(1),
1416+ izlek_core::store::LinkKind::Join,
1417+ )
1402 .await1418 .await
1403 .unwrap();1419 .unwrap();
1404 assert!(!stale.is_usable(now));1420 assert!(!stale.is_usable(now));
@@ -1406,7 +1422,12 @@ async fn an_expired_link_is_still_a_live_account() {
1406 // Resending opens the same account rather than making a new one.1422 // Resending opens the same account rather than making a new one.
1407 let fresh = scratch1423 let fresh = scratch
1408 .store1424 .store
1409- .create_signin_link(&user.id, "fresh-hash", now + Duration::days(7), izlek_core::store::LinkKind::Join)1425+ .create_signin_link(
1426+ &user.id,
1427+ "fresh-hash",
1428+ now + Duration::days(7),
1429+ izlek_core::store::LinkKind::Join,
1430+ )
1410 .await1431 .await
1411 .unwrap();1432 .unwrap();
1412 assert_eq!(fresh.user_id, stale.user_id);1433 assert_eq!(fresh.user_id, stale.user_id);
@@ -1437,7 +1458,12 @@ async fn a_prefetched_link_is_consumed_exactly_once() {
1437 let token = Token::mint();1458 let token = Token::mint();
1438 let now = OffsetDateTime::now_utc();1459 let now = OffsetDateTime::now_utc();
1439 let link = store1460 let link = store
1440- .create_signin_link(&user_id, &token.hash(), now + Duration::days(7), izlek_core::store::LinkKind::Join)1461+ .create_signin_link(
1462+ &user_id,
1463+ &token.hash(),
1464+ now + Duration::days(7),
1465+ izlek_core::store::LinkKind::Join,
1466+ )
1441 .await1467 .await
1442 .unwrap();1468 .unwrap();
1443 1469
@@ -7138,8 +7164,13 @@ async fn reconcile_carries_a_live_shaped_database_onto_the_declared_schema() {
7138 7164
7139 // The schema is now the declared one, exactly.7165 // The schema is now the declared one, exactly.
7140 let after = izlek_core::store::schema::fingerprint(&conn).await.unwrap();7166 let after = izlek_core::store::schema::fingerprint(&conn).await.unwrap();
7141- let declared = izlek_core::store::schema::declared_fingerprint().await.unwrap();7167+ let declared = izlek_core::store::schema::declared_fingerprint()
7142- assert_eq!(after, declared, "the rebuilt schema is not the declared one");7168+ .await
7169+ .unwrap();
7170+ assert_eq!(
7171+ after, declared,
7172+ "the rebuilt schema is not the declared one"
7173+ );
7143 7174
7144 // Nothing was dropped on the floor.7175 // Nothing was dropped on the floor.
7145 assert_eq!(scalar(&path, "SELECT COUNT(*) FROM user").await, 2);7176 assert_eq!(scalar(&path, "SELECT COUNT(*) FROM user").await, 2);
@@ -7173,7 +7204,11 @@ async fn reconcile_carries_a_live_shaped_database_onto_the_declared_schema() {
7173 7204
7174 // The blob survived byte for byte.7205 // The blob survived byte for byte.
7175 assert_eq!(7206 assert_eq!(
7176- scalar(&path, "SELECT length(bytes) FROM attachment WHERE id = 'F1'").await,7207+ scalar(
7208+ &path,
7209+ "SELECT length(bytes) FROM attachment WHERE id = 'F1'"
7210+ )
7211+ .await,
7177 50007212 5000
7178 );7213 );
7179 assert_eq!(7214 assert_eq!(
@@ -7190,7 +7225,11 @@ async fn reconcile_carries_a_live_shaped_database_onto_the_declared_schema() {
7190 // crosses over gets the declared default rather than a NULL the app would7225 // crosses over gets the declared default rather than a NULL the app would
7191 // have to read around.7226 // have to read around.
7192 assert_eq!(7227 assert_eq!(
7193- scalar(&path, "SELECT mail_batch_minutes FROM workspace WHERE id = 'W1'").await,7228+ scalar(
7229+ &path,
7230+ "SELECT mail_batch_minutes FROM workspace WHERE id = 'W1'"
7231+ )
7232+ .await,
7194 5,7233 5,
7195 "the workspace came across without a quiet window"7234 "the workspace came across without a quiet window"
7196 );7235 );
@@ -7198,12 +7237,20 @@ async fn reconcile_carries_a_live_shaped_database_onto_the_declared_schema() {
7198 // had either: the workspace crosses onto the declared default, and tasks7237 // had either: the workspace crosses onto the declared default, and tasks
7199 // that never carried a meeting instant arrive without one.7238 // that never carried a meeting instant arrive without one.
7200 assert_eq!(7239 assert_eq!(
7201- scalar(&path, "SELECT reminder_minutes FROM workspace WHERE id = 'W1'").await,7240+ scalar(
7241+ &path,
7242+ "SELECT reminder_minutes FROM workspace WHERE id = 'W1'"
7243+ )
7244+ .await,
7202 15,7245 15,
7203 "the workspace came across without a reminder lead"7246 "the workspace came across without a reminder lead"
7204 );7247 );
7205 assert_eq!(7248 assert_eq!(
7206- scalar(&path, "SELECT COUNT(*) FROM task WHERE clock_at IS NOT NULL").await,7249+ scalar(
7250+ &path,
7251+ "SELECT COUNT(*) FROM task WHERE clock_at IS NOT NULL"
7252+ )
7253+ .await,
7207 0,7254 0,
7208 "a task came out of the rebuild with a clock it never had"7255 "a task came out of the rebuild with a clock it never had"
7209 );7256 );
@@ -7274,7 +7321,9 @@ async fn opening_a_stale_database_repairs_it() {
7274 let conn = db.connect().unwrap();7321 let conn = db.connect().unwrap();
7275 assert_eq!(7322 assert_eq!(
7276 izlek_core::store::schema::fingerprint(&conn).await.unwrap(),7323 izlek_core::store::schema::fingerprint(&conn).await.unwrap(),
7277- izlek_core::store::schema::declared_fingerprint().await.unwrap(),7324+ izlek_core::store::schema::declared_fingerprint()
7325+ .await
7326+ .unwrap(),
7278 );7327 );
7279 assert_eq!(scalar(&path, "SELECT COUNT(*) FROM task").await, 4);7328 assert_eq!(scalar(&path, "SELECT COUNT(*) FROM task").await, 4);
7280 assert_eq!(backups_beside(&dir).len(), 1);7329 assert_eq!(backups_beside(&dir).len(), 1);
@@ -7397,9 +7446,20 @@ async fn user_stats_counts_what_a_person_holds_finished_opened_and_said() {
7397 7446
7398 let hold = add_task(store, &workspace, "Backlog", "Hold the door", None, &admin).await;7447 let hold = add_task(store, &workspace, "Backlog", "Hold the door", None, &admin).await;
7399 store.assign_task(&hold, &mem).await.unwrap();7448 store.assign_task(&hold, &mem).await.unwrap();
7400- let finished = add_task(store, &workspace, "Backlog", "Paint the frame", None, &admin).await;7449+ let finished = add_task(
7450+ store,
7451+ &workspace,
7452+ "Backlog",
7453+ "Paint the frame",
7454+ None,
7455+ &admin,
7456+ )
7457+ .await;
7401 store.assign_task(&finished, &mem).await.unwrap();7458 store.assign_task(&finished, &mem).await.unwrap();
7402- store.move_task(&finished, &backlog, &done, &admin, now).await.unwrap();7459+ store
7460+ .move_task(&finished, &backlog, &done, &admin, now)
7461+ .await
7462+ .unwrap();
7403 // One of her own that she also holds: created and assigned must each7463 // One of her own that she also holds: created and assigned must each
7404 // count it in its own column, not argue about it.7464 // count it in its own column, not argue about it.
7405 let own = add_task(store, &workspace, "Backlog", "Sweep", None, &mem).await;7465 let own = add_task(store, &workspace, "Backlog", "Sweep", None, &mem).await;
@@ -7407,12 +7467,20 @@ async fn user_stats_counts_what_a_person_holds_finished_opened_and_said() {
7407 add_task(store, &workspace, "Backlog", "Mop", None, &mem).await;7467 add_task(store, &workspace, "Backlog", "Mop", None, &mem).await;
7408 add_task(store, &workspace, "Backlog", "Dust", None, &mem).await;7468 add_task(store, &workspace, "Backlog", "Dust", None, &mem).await;
7409 for i in 0..4 {7469 for i in 0..4 {
7410- store.add_comment(&hold, &mem, "a note", now + Duration::seconds(i)).await.unwrap();7470+ store
7471+ .add_comment(&hold, &mem, "a note", now + Duration::seconds(i))
7472+ .await
7473+ .unwrap();
7411 }7474 }
7412 7475
7413 assert_eq!(7476 assert_eq!(
7414 store.user_stats(&mem).await.unwrap(),7477 store.user_stats(&mem).await.unwrap(),
7415- izlek_core::store::UserStats { assigned_open: 2, assigned_done: 1, created: 3, comments: 4 },7478+ izlek_core::store::UserStats {
7479+ assigned_open: 2,
7480+ assigned_done: 1,
7481+ created: 3,
7482+ comments: 4
7483+ },
7416 );7484 );
7417 }7485 }
7418 7486
@@ -7427,19 +7495,32 @@ async fn a_deleted_task_counts_nowhere_and_a_person_with_nothing_counts_nothing(
7427 7495
7428 assert_eq!(7496 assert_eq!(
7429 store.user_stats(&shy).await.unwrap(),7497 store.user_stats(&shy).await.unwrap(),
7430- izlek_core::store::UserStats { assigned_open: 0, assigned_done: 0, created: 0, comments: 0 },7498+ izlek_core::store::UserStats {
7499+ assigned_open: 0,
7500+ assigned_done: 0,
7501+ created: 0,
7502+ comments: 0
7503+ },
7431 );7504 );
7432 7505
7433 let doomed = add_task(store, &workspace, "Backlog", "Doomed", None, &mem).await;7506 let doomed = add_task(store, &workspace, "Backlog", "Doomed", None, &mem).await;
7434 store.assign_task(&doomed, &mem).await.unwrap();7507 store.assign_task(&doomed, &mem).await.unwrap();
7435- store.add_comment(&doomed, &mem, "a note", now).await.unwrap();7508+ store
7509+ .add_comment(&doomed, &mem, "a note", now)
7510+ .await
7511+ .unwrap();
7436 assert_eq!(store.user_stats(&mem).await.unwrap().assigned_open, 1);7512 assert_eq!(store.user_stats(&mem).await.unwrap().assigned_open, 1);
7437 assert_eq!(store.user_stats(&mem).await.unwrap().comments, 1);7513 assert_eq!(store.user_stats(&mem).await.unwrap().comments, 1);
7438 7514
7439 store.delete_task(&doomed, &admin, now).await.unwrap();7515 store.delete_task(&doomed, &admin, now).await.unwrap();
7440 assert_eq!(7516 assert_eq!(
7441 store.user_stats(&mem).await.unwrap(),7517 store.user_stats(&mem).await.unwrap(),
7442- izlek_core::store::UserStats { assigned_open: 0, assigned_done: 0, created: 0, comments: 0 },7518+ izlek_core::store::UserStats {
7519+ assigned_open: 0,
7520+ assigned_done: 0,
7521+ created: 0,
7522+ comments: 0
7523+ },
7443 "a soft-deleted task stays out of every number, its comments included",7524 "a soft-deleted task stays out of every number, its comments included",
7444 );7525 );
7445 }7526 }
@@ -7698,7 +7779,8 @@ async fn the_hold_has_a_ceiling_measured_from_the_oldest_mail() {
7698 "the push is clipped rather than granted: {due} vs {far}",7779 "the push is clipped rather than granted: {due} vs {far}",
7699 );7780 );
7700 assert_eq!(7781 assert_eq!(
7701- due, born + Duration::minutes(4),7782+ due,
7783+ born + Duration::minutes(4),
7702 "the ceiling is the oldest mail's own patience running out",7784 "the ceiling is the oldest mail's own patience running out",
7703 );7785 );
7704 let _ = std::fs::remove_dir_all(&dir);7786 let _ = std::fs::remove_dir_all(&dir);
@@ -7723,7 +7805,11 @@ async fn a_hold_never_pulls_a_leased_row_back_under_the_pass_that_took_it() {
7723 .expect("a fresh row is claimed");7805 .expect("a fresh row is claimed");
7724 // A delivery pass takes it: the lease is five minutes out.7806 // A delivery pass takes it: the lease is five minutes out.
7725 let taken = store7807 let taken = store
7726- .claim_sends_owed(now + Duration::seconds(1), now + izlek_core::mail::LEASE, 10)7808+ .claim_sends_owed(
7809+ now + Duration::seconds(1),
7810+ now + izlek_core::mail::LEASE,
7811+ 10,
7812+ )
7727 .await7813 .await
7728 .unwrap();7814 .unwrap();
7729 assert_eq!(taken.len(), 1, "the pass did not take the row");7815 assert_eq!(taken.len(), 1, "the pass did not take the row");
@@ -7815,16 +7901,28 @@ async fn a_batch_is_one_card_and_one_reader() {
7815 let mut addressed: Vec<String> = mailer7901 let mut addressed: Vec<String> = mailer
7816 .sent()7902 .sent()
7817 .into_iter()7903 .into_iter()
7818- .map(|mail| format!("{} {}", mail.to, mail.body.lines().next().unwrap_or_default()))7904+ .map(|mail| {
7905+ format!(
7906+ "{} {}",
7907+ mail.to,
7908+ mail.body.lines().next().unwrap_or_default()
7909+ )
7910+ })
7819 .collect();7911 .collect();
7820 addressed.sort();7912 addressed.sort();
7821 assert_eq!(addressed.len(), 4);7913 assert_eq!(addressed.len(), 4);
7822 assert_eq!(7914 assert_eq!(
7823- addressed.iter().filter(|line| line.contains("First")).count(),7915+ addressed
7916+ .iter()
7917+ .filter(|line| line.contains("First"))
7918+ .count(),
7824 2,7919 2,
7825 );7920 );
7826 assert_eq!(7921 assert_eq!(
7827- addressed.iter().filter(|line| line.contains("emre@izlek.sh")).count(),7922+ addressed
7923+ .iter()
7924+ .filter(|line| line.contains("emre@izlek.sh"))
7925+ .count(),
7828 2,7926 2,
7829 );7927 );
7830 let _ = std::fs::remove_dir_all(&dir);7928 let _ = std::fs::remove_dir_all(&dir);
@@ -7859,13 +7957,15 @@ async fn an_invitation_is_never_folded_into_a_batch() {
7859 .await7957 .await
7860 .unwrap();7958 .unwrap();
7861 assert_eq!(report.sent, 2, "the invitation and the card's mail");7959 assert_eq!(report.sent, 2, "the invitation and the card's mail");
7862- let subjects: Vec<String> = mailer7960+ let subjects: Vec<String> = mailer.sent().into_iter().map(|mail| mail.subject).collect();
7863- .sent()7961+ assert!(
7864- .into_iter()7962+ subjects.contains(&"Join the workspace".to_string()),
7865- .map(|mail| mail.subject)7963+ "{subjects:?}"
7866- .collect();7964+ );
7867- assert!(subjects.contains(&"Join the workspace".to_string()), "{subjects:?}");7965+ assert!(
7868- assert!(subjects.contains(&"Card is done".to_string()), "{subjects:?}");7966+ subjects.contains(&"Card is done".to_string()),
7967+ "{subjects:?}"
7968+ );
7869 let _ = std::fs::remove_dir_all(&dir);7969 let _ = std::fs::remove_dir_all(&dir);
7870 }7970 }
7871 7971
@@ -8023,7 +8123,10 @@ async fn a_clocked_task_owes_each_assignee_one_reminder_before_the_meeting() {
8023 "the workspace's default lead of fifteen minutes"8123 "the workspace's default lead of fifteen minutes"
8024 );8124 );
8025 assert!(8125 assert!(
8026- row.subject.as_deref().unwrap().starts_with("Reminder: The quarterly review ("),8126+ row.subject
8127+ .as_deref()
8128+ .unwrap()
8129+ .starts_with("Reminder: The quarterly review ("),
8027 "the subject names the meeting: {}",8130 "the subject names the meeting: {}",
8028 row.subject.as_deref().unwrap()8131 row.subject.as_deref().unwrap()
8029 );8132 );
@@ -8122,7 +8225,11 @@ async fn moving_the_clock_re_makes_the_reminders() {
8122 .filter(|r| r.state == SendState::Abandoned)8225 .filter(|r| r.state == SendState::Abandoned)
8123 .collect();8226 .collect();
8124 assert_eq!(pending.len(), 1, "exactly one reminder is still owed");8227 assert_eq!(pending.len(), 1, "exactly one reminder is still owed");
8125- assert_eq!(abandoned.len(), 1, "the promise the old clock stood on died");8228+ assert_eq!(
8229+ abandoned.len(),
8230+ 1,
8231+ "the promise the old clock stood on died"
8232+ );
8126 assert_eq!(8233 assert_eq!(
8127 pending[0].next_attempt_at.unwrap(),8234 pending[0].next_attempt_at.unwrap(),
8128 new_clock - Duration::minutes(15),8235 new_clock - Duration::minutes(15),
@@ -8206,8 +8313,8 @@ async fn an_assignee_removed_takes_their_reminder_with_them() {
8206 // Grace's warning is gone from what is owed; Emre's stands.8313 // Grace's warning is gone from what is owed; Emre's stands.
8207 let rows = reminders(&store, &task).await;8314 let rows = reminders(&store, &task).await;
8208 assert!(8315 assert!(
8209- rows.iter().any(|r| r.recipient == "grace@izlek.sh"8316+ rows.iter()
8210- && r.state == SendState::Abandoned),8317+ .any(|r| r.recipient == "grace@izlek.sh" && r.state == SendState::Abandoned),
8211 "the removed person's reminder was abandoned: {rows:?}"8318 "the removed person's reminder was abandoned: {rows:?}"
8212 );8319 );
8213 let still_owed = pending_reminders(&store, &task).await;8320 let still_owed = pending_reminders(&store, &task).await;
@@ -8334,18 +8441,39 @@ async fn each_reminder_tells_the_meeting_in_its_own_recipients_clock() {
8334 .set_preferences(&emre, "UTC+03:00", "dark", "en", "default")8441 .set_preferences(&emre, "UTC+03:00", "dark", "en", "default")
8335 .await8442 .await
8336 .unwrap();8443 .unwrap();
8337- let clock = OffsetDateTime::parse("2026-09-15T12:00:00Z", &time::format_description::well_known::Rfc3339)8444+ let clock = OffsetDateTime::parse(
8338- .unwrap();8445+ "2026-09-15T12:00:00Z",
8446+ &time::format_description::well_known::Rfc3339,
8447+ )
8448+ .unwrap();
8339 let task = clocked_task(&store, &workspace, &admin, Some(clock)).await;8449 let task = clocked_task(&store, &workspace, &admin, Some(clock)).await;
8340 store.assign_task(&task, &grace).await.unwrap();8450 store.assign_task(&task, &grace).await.unwrap();
8341 store.assign_task(&task, &emre).await.unwrap();8451 store.assign_task(&task, &emre).await.unwrap();
8342 8452
8343 let rows = pending_reminders(&store, &task).await;8453 let rows = pending_reminders(&store, &task).await;
8344 assert_eq!(rows.len(), 2);8454 assert_eq!(rows.len(), 2);
8345- let grace_body = rows.iter().find(|r| r.recipient == "grace@izlek.sh").unwrap().body.as_deref().unwrap();8455+ let grace_body = rows
8346- let emre_body = rows.iter().find(|r| r.recipient == "emre@izlek.sh").unwrap().body.as_deref().unwrap();8456+ .iter()
8347- assert!(grace_body.contains("Meets at Sep 15 12:00"), "grace: {grace_body}");8457+ .find(|r| r.recipient == "grace@izlek.sh")
8348- assert!(emre_body.contains("Meets at Sep 15 15:00"), "emre: {emre_body}");8458+ .unwrap()
8459+ .body
8460+ .as_deref()
8461+ .unwrap();
8462+ let emre_body = rows
8463+ .iter()
8464+ .find(|r| r.recipient == "emre@izlek.sh")
8465+ .unwrap()
8466+ .body
8467+ .as_deref()
8468+ .unwrap();
8469+ assert!(
8470+ grace_body.contains("Meets at Sep 15 12:00"),
8471+ "grace: {grace_body}"
8472+ );
8473+ assert!(
8474+ emre_body.contains("Meets at Sep 15 15:00"),
8475+ "emre: {emre_body}"
8476+ );
8349 let _ = std::fs::remove_dir_all(&dir);8477 let _ = std::fs::remove_dir_all(&dir);
8350 }8478 }
8351 8479
@@ -8368,7 +8496,10 @@ async fn reminder_rows_survive_a_reopen() {
8368 let reopened = TursoStore::open(&path).await.unwrap();8496 let reopened = TursoStore::open(&path).await.unwrap();
8369 let after = reminders(&reopened, &task).await;8497 let after = reminders(&reopened, &task).await;
8370 assert_eq!(after.len(), before.len());8498 assert_eq!(after.len(), before.len());
8371- assert_eq!(after[0].id, before[0].id, "the same row, not a re-minted one");8499+ assert_eq!(
8500+ after[0].id, before[0].id,
8501+ "the same row, not a re-minted one"
8502+ );
8372 assert_eq!(after[0].state, SendState::Pending);8503 assert_eq!(after[0].state, SendState::Pending);
8373 assert_eq!(after[0].next_attempt_at, before[0].next_attempt_at);8504 assert_eq!(after[0].next_attempt_at, before[0].next_attempt_at);
8374 let _ = std::fs::remove_dir_all(&dir);8505 let _ = std::fs::remove_dir_all(&dir);
@@ -8457,7 +8588,10 @@ async fn a_reminder_failing_on_retries_is_not_minted_twice() {
8457 store.assign_task(&task, &emre).await.unwrap();8588 store.assign_task(&task, &emre).await.unwrap();
8458 let rows = reminders(&store, &task).await;8589 let rows = reminders(&store, &task).await;
8459 assert_eq!(rows.len(), 2, "one row per person: {rows:?}");8590 assert_eq!(rows.len(), 2, "one row per person: {rows:?}");
8460- let grace_row = rows.iter().find(|r| r.recipient == "grace@izlek.sh").unwrap();8591+ let grace_row = rows
8592+ .iter()
8593+ .find(|r| r.recipient == "grace@izlek.sh")
8594+ .unwrap();
8461 assert_eq!(grace_row.state, SendState::Failed);8595 assert_eq!(grace_row.state, SendState::Failed);
8462 assert_eq!(grace_row.attempts, 1);8596 assert_eq!(grace_row.attempts, 1);
8463 8597
@@ -8482,7 +8616,10 @@ async fn the_reminder_never_lands_at_or_after_the_deadline() {
8482 let clock = OffsetDateTime::now_utc() + Duration::hours(2);8616 let clock = OffsetDateTime::now_utc() + Duration::hours(2);
8483 let task = clocked_task(&store, &workspace, &admin, Some(clock)).await;8617 let task = clocked_task(&store, &workspace, &admin, Some(clock)).await;
8484 store8618 store
8485- .assign_task(&task, &member(&store, &workspace, "grace@izlek.sh", "Grace").await)8619+ .assign_task(
8620+ &task,
8621+ &member(&store, &workspace, "grace@izlek.sh", "Grace").await,
8622+ )
8486 .await8623 .await
8487 .unwrap();8624 .unwrap();
8488 let rows = reminders(&store, &task).await;8625 let rows = reminders(&store, &task).await;
@@ -8500,7 +8637,10 @@ async fn the_reminder_never_lands_at_or_after_the_deadline() {
8500 let soon = OffsetDateTime::now_utc() + Duration::minutes(10);8637 let soon = OffsetDateTime::now_utc() + Duration::minutes(10);
8501 let task = clocked_task(&store, &workspace, &admin, Some(soon)).await;8638 let task = clocked_task(&store, &workspace, &admin, Some(soon)).await;
8502 store8639 store
8503- .assign_task(&task, &member(&store, &workspace, "emre@izlek.sh", "Emre").await)8640+ .assign_task(
8641+ &task,
8642+ &member(&store, &workspace, "emre@izlek.sh", "Emre").await,
8643+ )
8504 .await8644 .await
8505 .unwrap();8645 .unwrap();
8506 let rows = reminders(&store, &task).await;8646 let rows = reminders(&store, &task).await;
@@ -8551,8 +8691,24 @@ async fn a_change_back_to_the_same_password_is_refused_and_signs_nobody_out() {
8551 #[tokio::test]8691 #[tokio::test]
8552 async fn board_search_matches_keys_and_titles_in_place() {8692 async fn board_search_matches_keys_and_titles_in_place() {
8553 let (scratch, workspace, admin) = workspace_with_admin().await;8693 let (scratch, workspace, admin) = workspace_with_admin().await;
8554- let panel = add_task(&scratch.store, &workspace, "Backlog", "Panel polish", None, &admin).await;8694+ let panel = add_task(
8555- let wire = add_task(&scratch.store, &workspace, "In Progress", "Wire the exporter", None, &admin).await;8695+ &scratch.store,
8696+ &workspace,
8697+ "Backlog",
8698+ "Panel polish",
8699+ None,
8700+ &admin,
8701+ )
8702+ .await;
8703+ let wire = add_task(
8704+ &scratch.store,
8705+ &workspace,
8706+ "In Progress",
8707+ "Wire the exporter",
8708+ None,
8709+ &admin,
8710+ )
8711+ .await;
8556 let panel_key = scratch8712 let panel_key = scratch
8557 .store8713 .store
8558 .task(&panel)8714 .task(&panel)
@@ -8616,10 +8772,7 @@ async fn board_search_matches_keys_and_titles_in_place() {
8616 8772
8617 /// The reset token out of the newest notice queued for the address — the mail8773 /// The reset token out of the newest notice queued for the address — the mail
8618 /// is the token's only carrier, so the test reads it like a recipient would.8774 /// is the token's only carrier, so the test reads it like a recipient would.
8619-async fn queued_reset_token(8775+async fn queued_reset_token(store: &std::sync::Arc<dyn Store>, email: &str) -> Option<String> {
8620- store: &std::sync::Arc<dyn Store>,
8621- email: &str,
8622-) -> Option<String> {
8623 let sends = store8776 let sends = store
8624 .mail_queue(50, izlek_core::store::FeedPage::Newest)8777 .mail_queue(50, izlek_core::store::FeedPage::Newest)
8625 .await8778 .await
@@ -8627,9 +8780,7 @@ async fn queued_reset_token(
8627 let body = sends8780 let body = sends
8628 .into_iter()8781 .into_iter()
8629 .rev()8782 .rev()
8630- .find(|send| {8783+ .find(|send| send.kind == izlek_core::store::SendKind::Notice && send.recipient == email)
8631- send.kind == izlek_core::store::SendKind::Notice && send.recipient == email
8632- })
8633 .and_then(|send| send.body)?;8784 .and_then(|send| send.body)?;
8634 body.rsplit_once("/reset/")8785 body.rsplit_once("/reset/")
8635 .and_then(|(_, rest)| rest.split_whitespace().next())8786 .and_then(|(_, rest)| rest.split_whitespace().next())
@@ -8665,7 +8816,9 @@ async fn a_reset_link_is_mailed_only_to_a_known_address() {
8665 "the known address was mailed a reset link"8816 "the known address was mailed a reset link"
8666 );8817 );
8667 assert!(8818 assert!(
8668- queued_reset_token(&store, "nobody@izlek.sh").await.is_none(),8819+ queued_reset_token(&store, "nobody@izlek.sh")
8820+ .await
8821+ .is_none(),
8669 "the unknown address was mailed nothing"8822 "the unknown address was mailed nothing"
8670 );8823 );
8671 let _ = std::fs::remove_dir_all(&dir);8824 let _ = std::fs::remove_dir_all(&dir);
@@ -8707,11 +8860,17 @@ async fn a_reset_redeems_and_signs_the_other_browsers_out() {
8707 // The browser that was signed in before the reset is out; the redeeming8860 // The browser that was signed in before the reset is out; the redeeming
8708 // browser's own session is alive.8861 // browser's own session is alive.
8709 assert!(matches!(8862 assert!(matches!(
8710- accounts.authenticate(&before.session_token.expose()).await.unwrap(),8863+ accounts
8864+ .authenticate(&before.session_token.expose())
8865+ .await
8866+ .unwrap(),
8711 None8867 None
8712 ));8868 ));
8713 assert!(matches!(8869 assert!(matches!(
8714- accounts.authenticate(&after.session_token.expose()).await.unwrap(),8870+ accounts
8871+ .authenticate(&after.session_token.expose())
8872+ .await
8873+ .unwrap(),
8715 Some(_)8874 Some(_)
8716 ));8875 ));
8717 }8876 }
@@ -8909,7 +9068,12 @@ async fn the_personal_feed_follows_watches_names_and_the_marker() {
8909 9068
8910 // Ada's comment lands on a task Grace watches, after her marker: news.9069 // Ada's comment lands on a task Grace watches, after her marker: news.
8911 store9070 store
8912- .add_comment(&task, &admin, "Thanks — ship it", now + Duration::seconds(6))9071+ .add_comment(
9072+ &task,
9073+ &admin,
9074+ "Thanks — ship it",
9075+ now + Duration::seconds(6),
9076+ )
8913 .await9077 .await
8914 .unwrap();9078 .unwrap();
8915 assert_eq!(store.count_feed_unseen(&grace).await.unwrap(), 1);9079 assert_eq!(store.count_feed_unseen(&grace).await.unwrap(), 1);
@@ -8979,7 +9143,10 @@ async fn a_delivered_reminder_writes_the_reminded_event() {
8979 assert_eq!(about, 1, "the line is about the reminded person");9143 assert_eq!(about, 1, "the line is about the reminded person");
8980 9144
8981 // Sweeping again re-sends nothing and writes nothing.9145 // Sweeping again re-sends nothing and writes nothing.
8982- engine.deliver_owed(later + Duration::minutes(1), 10).await.unwrap();9146+ engine
9147+ .deliver_owed(later + Duration::minutes(1), 10)
9148+ .await
9149+ .unwrap();
8983 let events = scalar(9150 let events = scalar(
8984 &path,9151 &path,
8985 "SELECT COUNT(*) FROM activity WHERE kind = 'reminded'",9152 "SELECT COUNT(*) FROM activity WHERE kind = 'reminded'",
@@ -8988,3 +9155,177 @@ async fn a_delivered_reminder_writes_the_reminded_event() {
8988 assert_eq!(events, 1);9155 assert_eq!(events, 1);
8989 let _ = std::fs::remove_dir_all(&dir);9156 let _ = std::fs::remove_dir_all(&dir);
8990 }9157 }
9158+
9159+/// The search fold survives Turkish: a naive lowercase turns `İ` into `i`
9160+/// plus a combining dot, and then no plain-`i` query — `is` against a card
9161+/// titled `İş Planı Teslimi` — can ever match. Query and title fold
9162+/// through the same map instead.
9163+#[tokio::test]
9164+async fn board_search_folds_turkish_case() {
9165+ let (scratch, workspace, admin) = workspace_with_admin().await;
9166+ let is_plan = add_task(
9167+ &scratch.store,
9168+ &workspace,
9169+ "Backlog",
9170+ "İş Planı Teslimi",
9171+ None,
9172+ &admin,
9173+ )
9174+ .await;
9175+ let wire = add_task(
9176+ &scratch.store,
9177+ &workspace,
9178+ "In Progress",
9179+ "Wire the exporter",
9180+ None,
9181+ &admin,
9182+ )
9183+ .await;
9184+ let key = scratch
9185+ .store
9186+ .task(&is_plan)
9187+ .await
9188+ .unwrap()
9189+ .expect("task gone")
9190+ .row
9191+ .task_key;
9192+
9193+ for query in ["iş", "İŞ", "is", "İS", "plan", "PLAN"] {
9194+ let mut board = izlek_core::board::load(&scratch.store, &workspace)
9195+ .await
9196+ .unwrap()
9197+ .unwrap();
9198+ board.searching(query);
9199+ assert_eq!(
9200+ board.task_count(),
9201+ 1,
9202+ "query {query:?} matched the wrong set"
9203+ );
9204+ let card = board.columns.iter().flat_map(|c| &c.cards).next().unwrap();
9205+ assert_eq!(card.id, is_plan);
9206+ }
9207+
9208+ // ASCII titles still answer, any case.
9209+ let mut board = izlek_core::board::load(&scratch.store, &workspace)
9210+ .await
9211+ .unwrap()
9212+ .unwrap();
9213+ board.searching("WIRE");
9214+ assert_eq!(board.task_count(), 1);
9215+ let card = board.columns.iter().flat_map(|c| &c.cards).next().unwrap();
9216+ assert_eq!(card.id, wire);
9217+
9218+ // The key keeps answering whatever case it is typed in.
9219+ let mut board = izlek_core::board::load(&scratch.store, &workspace)
9220+ .await
9221+ .unwrap()
9222+ .unwrap();
9223+ board.searching(&key.to_lowercase());
9224+ assert_eq!(board.task_count(), 1);
9225+ let card = board.columns.iter().flat_map(|c| &c.cards).next().unwrap();
9226+ assert_eq!(card.id, is_plan);
9227+}
9228+
9229+/// The watch backfill rides the reconcile rebuild: a database from before
9230+/// the feed opens with a watch for every task somebody created, was
9231+/// assigned, or commented on — soft-deleted tasks included, history
9232+/// included. The pass can never run twice (it lives behind the fingerprint
9233+/// gate), so an unassign after the deploy keeps its watch off across
9234+/// restarts.
9235+#[tokio::test]
9236+async fn reconcile_backfills_watches_from_history_exactly_once() {
9237+ let (dir, path) = live_shaped_database().await;
9238+
9239+ // A historical comment — the third watch-worthy fact — on a task that
9240+ // already carries creation and assignment history.
9241+ {
9242+ let db = turso::Builder::new_local(&path).build().await.unwrap();
9243+ let conn = db.connect().unwrap();
9244+ conn.execute(
9245+ "INSERT INTO comment (id, task_id, author_id, body, created_at) \
9246+ VALUES ('CM1', 'T2', 'U1', 'on it', '2026-08-30T12:00:01Z')",
9247+ (),
9248+ )
9249+ .await
9250+ .unwrap();
9251+ }
9252+
9253+ izlek_core::store::reconcile(
9254+ &path,
9255+ izlek_core::store::ReconcileOptions {
9256+ dry_run: false,
9257+ yes: true,
9258+ auto: true,
9259+ },
9260+ )
9261+ .await
9262+ .expect("reconcile refused the backfill");
9263+
9264+ // T1: created by U1, assigned to U2. T2: created U1, assigned U2,
9265+ // commented U1. T3: created U1, assigned U2. T4 (soft-deleted): created
9266+ // U1. Distinct (task, watcher) pairs: 2 + 2 + 2 + 1.
9267+ assert_eq!(scalar(&path, "SELECT COUNT(*) FROM task_watcher").await, 7);
9268+ assert_eq!(
9269+ scalar(
9270+ &path,
9271+ "SELECT COUNT(*) FROM task_watcher WHERE user_id = 'U2'"
9272+ )
9273+ .await,
9274+ 3,
9275+ "the assignee watches every task they are on"
9276+ );
9277+ assert_eq!(
9278+ scalar(
9279+ &path,
9280+ "SELECT COUNT(*) FROM task_watcher WHERE user_id = 'U1'"
9281+ )
9282+ .await,
9283+ 4,
9284+ "the creator watches every task they made, soft-deleted included"
9285+ );
9286+
9287+ // The deploy happens; THEN Deniz unassigns — here, the same write the
9288+ // store makes. The pass never re-runs (the shape matches now), so the
9289+ // watch stays off across a restart and a second reconcile.
9290+ {
9291+ let db = turso::Builder::new_local(&path).build().await.unwrap();
9292+ let conn = db.connect().unwrap();
9293+ conn.execute(
9294+ "DELETE FROM task_watcher WHERE task_id = 'T1' AND user_id = 'U2'",
9295+ (),
9296+ )
9297+ .await
9298+ .unwrap();
9299+ }
9300+ izlek_core::store::reconcile(
9301+ &path,
9302+ izlek_core::store::ReconcileOptions {
9303+ dry_run: false,
9304+ yes: true,
9305+ auto: true,
9306+ },
9307+ )
9308+ .await
9309+ .unwrap();
9310+ assert_eq!(
9311+ scalar(
9312+ &path,
9313+ "SELECT COUNT(*) FROM task_watcher WHERE task_id = 'T1'"
9314+ )
9315+ .await,
9316+ 1,
9317+ "the unassigned watch was resurrected"
9318+ );
9319+ let _store = TursoStore::open(&path).await.unwrap();
9320+ assert_eq!(
9321+ scalar(
9322+ &path,
9323+ "SELECT COUNT(*) FROM task_watcher WHERE task_id = 'T1'"
9324+ )
9325+ .await,
9326+ 1,
9327+ "a restart resurrected the unassigned watch"
9328+ );
9329+
9330+ let _ = std::fs::remove_dir_all(&dir);
9331+}