forge
Explore
Log in

Don't you dare go Hollow

the Connection card's ages read like ages: whole seconds grew a human shape — 45s stays, minutes fold to 2m, hours to 3h, each followed by ago — and the lines name their moments exactly, Last roster event and Last full pass, with the Turkish carrying the same precision (Son dizin olayı, Son tam geçiş); never stays a sentence of its own, spoken only before the first occurrence; the http assertions follow the new shapes; found uncommitted in the tree and riding along per the standing whole-tree rule

Browse files at this commit

dc994c4a2e018c4b39b90f455a9dce4b0dc615b3Ahmet Kaan GümüşParent: 23a92ca
crates/in-web/src/i18n.rsmodified+4 -4
@@ -354,8 +354,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
354354 ConnectionStream => "Directory stream",
355355 ConnectionConnected => "Connected",
356356 ConnectionReconnecting => "Reconnecting…",
357- ConnectionLastEvent => "Last event",
358- ConnectionLastPass => "Last pass",
357+ ConnectionLastEvent => "Last roster event",
358+ ConnectionLastPass => "Last full pass",
359359 Never => "never",
360360 QuotaUsage => "Storage used",
361361 QuotaOf => "of",
@@ -529,8 +529,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
529529 ConnectionStream => "Dizin akışı",
530530 ConnectionConnected => "Bağlı",
531531 ConnectionReconnecting => "Yeniden bağlanıyor…",
532- ConnectionLastEvent => "Son etkinlik",
533- ConnectionLastPass => "Son tarama",
532+ ConnectionLastEvent => "Son dizin olayı",
533+ ConnectionLastPass => "Son tam geçiş",
534534 Never => "hiç",
535535 AdminPanel => "Herkes",
536536 AllUsers => "Herkes",
crates/in-web/src/settings.rsmodified+39 -33
@@ -25,7 +25,7 @@ use crate::server::{
2525 Refusal, app, back_to, require_admin, require_user, share_link_url, share_origin,
2626 };
2727 use crate::share::{refusal_banner, refusal_of, share_copy_script};
28-use crate::i18n::{Key, Lang, lang, t};
28+use crate::i18n::{Key, lang, t};
2929 use crate::layout::{NavPage, topbar};
3030
3131 /// Bytes in human units: `512 B`, `1.5 KiB`, `2.0 GiB`. One decimal past
@@ -45,13 +45,15 @@ pub fn human_bytes(bytes: u64) -> String {
4545 }
4646 }
4747
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 {
48+/// An age in whole seconds as the card prints it — a short number with
49+/// its unit, the same shape in every language: `45s`, `2m`, `3h`. Empty
50+/// before the first occurrence; the caller sentences it.
51+fn age_text(age: Option<i64>) -> String {
5252 match age {
53- Some(age) => format!("{age}s"),
54- None => t(language, Key::Never).to_string(),
53+ Some(secs) if secs >= 3600 => format!("{}h", secs / 3600),
54+ Some(secs) if secs >= 60 => format!("{}m", secs / 60),
55+ Some(secs) => format!("{secs}s"),
56+ None => String::new(),
5557 }
5658 }
5759
@@ -313,15 +315,25 @@ async fn settings(cx: &Cx) -> Result {
313315 let language = lang(cx).await;
314316 let app = app(cx);
315317 let store = app.store;
316- // The Connection card reads only what the config already carries and
317- // the sync task's own atomics — the client secret is never touched on
318- // any path that reaches this render.
319318 let connected = app.health.stream_connected();
320319 let last_event = app.health.last_event_age_secs();
321320 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.
321+ // Both ages share one sentence shape: the humanized age and `ago`,
322+ // or the `never` wording before the first occurrence — a card that
323+ // went silent and a card that never spoke read differently.
324+ let age_line = |age: Option<i64>| {
325+ let text = age_text(age);
326+ if text.is_empty() {
327+ t(language, Key::Never).to_string()
328+ } else {
329+ format!("{text} ago")
330+ }
331+ };
332+ let event_line = age_line(last_event);
333+ let pass_line = age_line(last_pass);
334+ // The Connection card reads only what the config already carries and
335+ // the sync task's own atomics — the client secret is never touched on
336+ // any path that reaches this render.
325337 // Re-read the row so the quota bar never shows a stale number.
326338 let fresh = store.user(&user.id).await?.unwrap_or_else(|| user.clone());
327339 let administers = fresh.admin;
@@ -466,31 +478,25 @@ async fn settings(cx: &Cx) -> Result {
466478 <h2 class="panel-title">(t(language, Key::Connection))</h2>
467479 </div>
468480 <div class="panel-body">
469- <div class="field">
470- <span class="field-label">(t(language, Key::ConnectionIssuer))</span>
471- <span class="field-static">(app.config.oidc.issuer.clone())</span>
472- </div>
473- <div class="field">
474- <span class="field-label">(t(language, Key::ConnectionClientId))</span>
475- <span class="field-static">(app.config.oidc.client_id.clone())</span>
476- </div>
477- <div class="field">
478- <span class="field-label">(t(language, Key::ConnectionStream))</span>
479- <span class="field-static">
480- <span class=(if connected { "status-dot status-dot-done" } else { "status-dot status-dot-warn" })></span>
481+ <dl class="connection-facts">
482+ <dt>(t(language, Key::ConnectionIssuer))</dt>
483+ <dd>(app.config.oidc.issuer.clone())</dd>
484+ <dt>(t(language, Key::ConnectionClientId))</dt>
485+ <dd>(app.config.oidc.client_id.clone())</dd>
486+ <dt>(t(language, Key::ConnectionStream))</dt>
487+ <dd>
488+ <span class=(if connected { "connection-dot connection-on" } else { "connection-dot connection-wait" })></span>
481489 if connected {
482490 (t(language, Key::ConnectionConnected))
483491 } else {
484492 (t(language, Key::ConnectionReconnecting))
485493 }
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>
493- </div>
494+ </dd>
495+ <dt>(t(language, Key::ConnectionLastEvent))</dt>
496+ <dd>(event_line)</dd>
497+ <dt>(t(language, Key::ConnectionLastPass))</dt>
498+ <dd>(pass_line)</dd>
499+ </dl>
494500 </div>
495501 </section>
496502 }
crates/in-web/tests/http.rsmodified+13 -17
@@ -5300,16 +5300,14 @@ async fn connection_card_shows_issuer_client_id_and_stream_state() {
53005300 "no client id: {body}"
53015301 );
53025302 assert!(body.contains("Reconnecting"), "no amber wording: {body}");
5303- assert!(body.contains("status-dot-warn"), "no amber dot: {body}");
5304- // Before the first occurrences both ages read never — the line is
5303+ assert!(body.contains("connection-wait"), "no amber dot: {body}");
5304+ // Before the first occurrences both ages read never — the row is
53055305 // there, the number is not.
5306+ assert!(body.contains("Last roster event"), "no event row: {body}");
5307+ assert!(body.contains("Last full pass"), "no pass row: {body}");
53065308 assert!(
5307- body.contains("Last pass · never"),
5308- "no never wording on the pass line: {body}"
5309- );
5310- assert!(
5311- body.contains("Last event · never"),
5312- "no never wording on the event line: {body}"
5309+ body.matches("<dd>never</dd>").count() >= 2,
5310+ "both ages must read never: {body}"
53135311 );
53145312 assert!(
53155313 !body.contains("s3cr3t"),
@@ -5324,23 +5322,21 @@ async fn connection_card_shows_issuer_client_id_and_stream_state() {
53245322 let page = app.get("/settings", Some(&cookie)).await;
53255323 let body = page.text();
53265324 assert!(body.contains("Connected"), "no green wording: {body}");
5327- assert!(body.contains("status-dot-done"), "no green dot: {body}");
5325+ assert!(body.contains("connection-on"), "no green dot: {body}");
53285326 // An age, not never — the number itself races the second boundary
5329- // between the stamp and this render, so it is not asserted.
5330- assert!(
5331- body.contains("Last event · ") && !body.contains("Last event · never"),
5332- "no event age: {body}"
5333- );
5327+ // between the stamp and this render, so only the sentence shape is
5328+ // asserted.
53345329 assert!(
5335- body.contains("Last pass · ") && !body.contains("Last pass · never"),
5336- "no pass age: {body}"
5330+ !body.contains("<dd>never</dd>"),
5331+ "ages still read never after both stamps: {body}"
53375332 );
5333+ assert!(body.matches(" ago</dd>").count() >= 2, "ages not sentenced: {body}");
53385334 // The stream ends: amber again, no event line retraction needed — the
53395335 // last event stays but the wording names the truth.
53405336 app.health.reconnecting();
53415337 let page = app.get("/settings", Some(&cookie)).await;
53425338 let body = page.text();
53435339 assert!(body.contains("Reconnecting"), "no amber return: {body}");
5344- assert!(!body.contains("status-dot-done"), "green lingered: {body}");
5340+ assert!(!body.contains("connection-on"), "green lingered: {body}");
53455341 }
53465342
style/main.scssmodified+31 -0
@@ -5484,3 +5484,34 @@ div.member-row + div.member-row {
54845484 display: none;
54855485 }
54865486 }
5487+
5488+// The Connection card's label/value rows: two columns, labels bold and
5489+// unbreaking, values free to wrap — the shape the identity card wears.
5490+.connection-facts {
5491+ display: grid;
5492+ grid-template-columns: max-content 1fr;
5493+ gap: 0.4rem 1.5rem;
5494+ margin: 0;
5495+
5496+ dt {
5497+ font-weight: 600;
5498+ white-space: nowrap;
5499+ }
5500+}
5501+
5502+.connection-dot {
5503+ display: inline-block;
5504+ width: 0.55rem;
5505+ height: 0.55rem;
5506+ border-radius: 50%;
5507+ margin-right: 0.4rem;
5508+ vertical-align: baseline;
5509+
5510+ &.connection-on {
5511+ background: #2e9e5b;
5512+ }
5513+
5514+ &.connection-wait {
5515+ background: #d99a26;
5516+ }
5517+}