forge
Explore
Log in

Don't you dare go Hollow

the Connection card reaches iz's information level: the health carries the healer's heartbeat beside the feed's — a last full pass stamp noted whenever a roster pass commits — and the card ages both moments honestly, Last event and Last pass, each reading never before its first occurrence so a feed gone quiet and a mirror stopped healing read as the two different silences they are

Browse files at this commit

64868dc13e5b8d763d75cacccad42bba0618e28cAhmet Kaan GümüşParent: 72751ff
crates/in-web/src/i18n.rsmodified+6 -0
@@ -171,6 +171,8 @@ pub enum Key {
171 ConnectionConnected,171 ConnectionConnected,
172 ConnectionReconnecting,172 ConnectionReconnecting,
173 ConnectionLastEvent,173 ConnectionLastEvent,
174+ ConnectionLastPass,
175+ Never,
174 DisplayName,176 DisplayName,
175 EmailAddress,177 EmailAddress,
176 QuotaUsage,178 QuotaUsage,
@@ -349,6 +351,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
349 ConnectionConnected => "Connected",351 ConnectionConnected => "Connected",
350 ConnectionReconnecting => "Reconnecting…",352 ConnectionReconnecting => "Reconnecting…",
351 ConnectionLastEvent => "Last event",353 ConnectionLastEvent => "Last event",
354+ ConnectionLastPass => "Last pass",
355+ Never => "never",
352 QuotaUsage => "Storage used",356 QuotaUsage => "Storage used",
353 QuotaOf => "of",357 QuotaOf => "of",
354 AdminPanel => "Everyone",358 AdminPanel => "Everyone",
@@ -520,6 +524,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
520 ConnectionConnected => "Bağlı",524 ConnectionConnected => "Bağlı",
521 ConnectionReconnecting => "Yeniden bağlanıyor…",525 ConnectionReconnecting => "Yeniden bağlanıyor…",
522 ConnectionLastEvent => "Son etkinlik",526 ConnectionLastEvent => "Son etkinlik",
527+ ConnectionLastPass => "Son tarama",
528+ Never => "hiç",
523 AdminPanel => "Herkes",529 AdminPanel => "Herkes",
524 AllUsers => "Herkes",530 AllUsers => "Herkes",
525 SetQuota => "Kotayı ayarla",531 SetQuota => "Kotayı ayarla",
crates/in-web/src/main.rsmodified+2 -0
@@ -409,6 +409,8 @@ async fn identity_sync(
409 for member in &members {409 for member in &members {
410 mirror_member(&store, member, default_quota_bytes).await;410 mirror_member(&store, member, default_quota_bytes).await;
411 }411 }
412+ // The roster pass committed: the card's healer heartbeat.
413+ health.note_pass();
412 match client.open_stream().await {414 match client.open_stream().await {
413 Ok(mut stream) => {415 Ok(mut stream) => {
414 health.connected();416 health.connected();
crates/in-web/src/server.rsmodified+21 -0
@@ -63,6 +63,11 @@ pub struct DirectoryHealth {
63 /// never. The age a card shows is derived at read time, so a stale63 /// never. The age a card shows is derived at read time, so a stale
64 /// moment ages honestly without a ticking task behind it.64 /// moment ages honestly without a ticking task behind it.
65 last_event: Arc<std::sync::atomic::AtomicI64>,65 last_event: Arc<std::sync::atomic::AtomicI64>,
66+ /// Unix seconds of the last full `/directory` pass that committed —
67+ /// the healer's heartbeat. It ticks slowly (boot, every stream end),
68+ /// which is why a card shows it: a feed gone quiet and a mirror
69+ /// stopped healing are two different silences.
70+ last_pass: Arc<std::sync::atomic::AtomicI64>,
66 }71 }
67 72
68 impl DirectoryHealth {73 impl DirectoryHealth {
@@ -70,6 +75,7 @@ impl DirectoryHealth {
70 Self {75 Self {
71 stream: Arc::new(std::sync::atomic::AtomicU8::new(0)),76 stream: Arc::new(std::sync::atomic::AtomicU8::new(0)),
72 last_event: Arc::new(std::sync::atomic::AtomicI64::new(0)),77 last_event: Arc::new(std::sync::atomic::AtomicI64::new(0)),
78+ last_pass: Arc::new(std::sync::atomic::AtomicI64::new(0)),
73 }79 }
74 }80 }
75 81
@@ -93,6 +99,13 @@ impl DirectoryHealth {
93 self.last_event.store(now_unix(), Relaxed);99 self.last_event.store(now_unix(), Relaxed);
94 }100 }
95 101
102+ /// A full roster pass committed: the mirror healed (or was already
103+ /// true), however quiet the live feed has been.
104+ pub fn note_pass(&self) {
105+ use std::sync::atomic::Ordering::Relaxed;
106+ self.last_pass.store(now_unix(), Relaxed);
107+ }
108+
96 /// Whether the card shows the green dot.109 /// Whether the card shows the green dot.
97 pub fn stream_connected(&self) -> bool {110 pub fn stream_connected(&self) -> bool {
98 use std::sync::atomic::Ordering::Relaxed;111 use std::sync::atomic::Ordering::Relaxed;
@@ -105,6 +118,14 @@ impl DirectoryHealth {
105 let at = self.last_event.load(Relaxed);118 let at = self.last_event.load(Relaxed);
106 (at > 0).then(|| (now_unix() - at).max(0))119 (at > 0).then(|| (now_unix() - at).max(0))
107 }120 }
121+
122+ /// Seconds since the last full roster pass, or `None` before the
123+ /// first one — a boot whose pass has not landed yet.
124+ pub fn last_pass_age_secs(&self) -> Option<i64> {
125+ use std::sync::atomic::Ordering::Relaxed;
126+ let at = self.last_pass.load(Relaxed);
127+ (at > 0).then(|| (now_unix() - at).max(0))
128+ }
108 }129 }
109 130
110 fn now_unix() -> i64 {131 fn now_unix() -> i64 {
crates/in-web/src/settings.rsmodified+21 -4
@@ -25,7 +25,7 @@ use crate::server::{
25 Refusal, app, back_to, require_admin, require_user, share_link_url, share_origin,25 Refusal, app, back_to, require_admin, require_user, share_link_url, share_origin,
26 };26 };
27 use crate::share::{refusal_banner, refusal_of, share_copy_script};27 use crate::share::{refusal_banner, refusal_of, share_copy_script};
28-use crate::i18n::{Key, lang, t};28+use crate::i18n::{Key, Lang, lang, t};
29 use crate::layout::{NavPage, topbar};29 use crate::layout::{NavPage, topbar};
30 30
31 /// Bytes in human units: `512 B`, `1.5 KiB`, `2.0 GiB`. One decimal past31 /// Bytes in human units: `512 B`, `1.5 KiB`, `2.0 GiB`. One decimal past
@@ -45,6 +45,16 @@ pub fn human_bytes(bytes: u64) -> String {
45 }45 }
46 }46 }
47 47
48+/// The value half of a Connection card's age line: the seconds when the
49+/// moment is known, the `never` wording before its first occurrence —
50+/// a card that went silent and a card that never spoke read differently.
51+fn age_text(age: Option<i64>, language: Lang) -> String {
52+ match age {
53+ Some(age) => format!("{age}s"),
54+ None => t(language, Key::Never).to_string(),
55+ }
56+}
57+
48 /// The share of the quota already held, for the usage bar's width.58 /// The share of the quota already held, for the usage bar's width.
49 fn quota_percent(user: &User) -> u8 {59 fn quota_percent(user: &User) -> u8 {
50 if user.quota_bytes == 0 {60 if user.quota_bytes == 0 {
@@ -308,6 +318,10 @@ async fn settings(cx: &Cx) -> Result {
308 // any path that reaches this render.318 // any path that reaches this render.
309 let connected = app.health.stream_connected();319 let connected = app.health.stream_connected();
310 let last_event = app.health.last_event_age_secs();320 let last_event = app.health.last_event_age_secs();
321+ let last_pass = app.health.last_pass_age_secs();
322+ // Both ages share one shape: the seconds when the moment is known,
323+ // the `never` wording before the first occurrence — a card that went
324+ // silent and a card that never spoke read differently.
311 // Re-read the row so the quota bar never shows a stale number.325 // Re-read the row so the quota bar never shows a stale number.
312 let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone());326 let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone());
313 let administers = fresh.admin;327 let administers = fresh.admin;
@@ -469,10 +483,13 @@ async fn settings(cx: &Cx) -> Result {
469 } else {483 } else {
470 (t(language, Key::ConnectionReconnecting))484 (t(language, Key::ConnectionReconnecting))
471 }485 }
472- if let Some(age) = last_event {
473- <span class="field-note">(format!("{} · {}s", t(language, Key::ConnectionLastEvent), age))</span>
474- }
475 </span>486 </span>
487+ <div class="field-note">
488+ (format!("{} · {}", t(language, Key::ConnectionLastEvent), age_text(last_event, language)))
489+ </div>
490+ <div class="field-note">
491+ (format!("{} · {}", t(language, Key::ConnectionLastPass), age_text(last_pass, language)))
492+ </div>
476 </div>493 </div>
477 </div>494 </div>
478 </section>495 </section>