From 04382ff27d31f9386c16594200e25a4b672d36b1 Mon Sep 17 00:00:00 2001 From: theBlanketBaron Date: Sat, 14 Nov 2026 13:37:07 -0500 Subject: [PATCH] RAL-193: the operator inbox folds away with an arrow From Josh (record 4311): "Lets give it an arrow that allows us to make it hidden please". An arrow beside the "Operator inbox" heading, a button with aria-expanded and aria-controls, folds the panel and its line away and back, by mouse or keyboard. Folded, the heading keeps the open and urgent counts, in the urgent colour, so nothing urgent hides. It's remembered per browser across reloads and viewer restarts in localStorage, every access in try/catch, open when storage fails. The arrow looks like the "Past rallies" disclosure marker. Web assets only. tests/browser/sign-in.mjs gains RALLY_BROWSER_RELOAD_PROBE, one more expression evaluated after a reload, for what a page keeps across one. The new browser test folds the inbox, reloads, finds it still folded with its counts, and unfolds it. Co-Authored-By: Claude Opus 5.5 --- docs/roadmap.md | 8 ++++ tests/browser/sign-in.mjs | 13 +++++- tests/web.rs | 91 +++++++++++++++++++++++++++++++++++++++ web/app.css | 9 ++++ web/app.js | 29 ++++++++++++- web/index.html | 9 ++-- 6 files changed, 154 insertions(+), 5 deletions(-) diff --git a/docs/roadmap.md b/docs/roadmap.md index 04a0031..bd47c11 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1495,3 +1495,11 @@ principles named were durable, accurate and reactive. Found in rally 0x7 by plus and each fair pool's queue by owner (RAL-188), with a one-line summary; an unreadable projects list, no project naming a lock, an unreadable lock or an unseen queue is named in `blind`, never shown as nothing running; with unit tests and a CLI test with real `flock` holders (docs/brief.md). +- [ ] **RAL-193: The operator inbox folds away.** From Josh (2026-11-14, the lamplighter's record 4311): "Lets give it + an arrow that allows us to make it hidden". Done when: an arrow beside the "Operator inbox" heading, a button with + `aria-expanded` and `aria-controls`, folds the panel and its line away and back, by mouse or keyboard; folded, the + heading still gives the open count and the urgent count, in the urgent colour, so nothing urgent hides; it's + remembered per browser across reloads and viewer restarts (localStorage, every access in try/catch, open when + storage fails); it looks like the "Past rallies" disclosure marker; web assets only; with a browser test that + folds, reloads (tests/browser/sign-in.mjs's new `RALLY_BROWSER_RELOAD_PROBE`), finds it still folded with its + counts, and unfolds it. diff --git a/tests/browser/sign-in.mjs b/tests/browser/sign-in.mjs index f4cfe06..1afb5b6 100644 --- a/tests/browser/sign-in.mjs +++ b/tests/browser/sign-in.mjs @@ -377,5 +377,16 @@ if (process.env.RALLY_BROWSER_PROBE) { } } } +// RAL-193: what a page keeps across a reload, such as a folded panel: RALLY_BROWSER_RELOAD_PROBE names a +// file holding one more expression, evaluated after the page is reloaded, printed as `reloaded`. +let reloaded; +if (process.env.RALLY_BROWSER_RELOAD_PROBE) { + const { readFileSync } = await import("node:fs"); + const expression = readFileSync(process.env.RALLY_BROWSER_RELOAD_PROBE, "utf8"); + const reload = loaded(); + await send("Page.reload", { ignoreCache: true }); + await reload; + reloaded = await evaluate(expression); +} clearTimeout(timer); -finish(0, { codePage, after, probe, probes }); +finish(0, { codePage, after, probe, probes, reloaded }); diff --git a/tests/web.rs b/tests/web.rs index 5f6cf30..82fed64 100644 --- a/tests/web.rs +++ b/tests/web.rs @@ -3517,3 +3517,94 @@ fn ticking_an_item_in_the_browser_takes_it_off_the_list() { ); inbox_status(&viewer, 2); } + +/// RAL-193, in the browser: the arrow beside the operator inbox's heading folds its panel away, by +/// a button that says whether it's open; folded, the heading still gives the counts, the urgent one +/// too, in the urgent colour; it stays folded across a reload, and unfolds again. +#[test] +fn the_operator_inbox_folds_away_and_stays_folded_across_a_reload() { + let Some(chrome) = browser() else { return }; + let viewer = start_ticking(); + inbox_status(&viewer, 3); + // Each read waits on what it reads: the board's first draw, then the inbox's rows. + let state = r##" + const wait = async (test) => { + for (let i = 0; i < 200 && !test(); i++) await new Promise((r) => setTimeout(r, 100)); + return test(); + }; + const button = () => document.getElementById("inbox-fold"); + const body = () => document.getElementById("inbox-body"); + const state = () => ({ + expanded: button().getAttribute("aria-expanded"), + controls: button().getAttribute("aria-controls"), + tag: button().tagName, + bodyHidden: body().hidden, + panelShown: document.getElementById("inbox").getBoundingClientRect().height > 0, + heading: document.getElementById("inbox-title").textContent, + urgent: document.getElementById("inbox-title").dataset.urgent, + stored: (() => { try { return localStorage.getItem("rally-inbox-folded"); } catch (e) { return "unreadable"; } })(), + }); + await wait(() => document.querySelectorAll("#inbox .inbox-item").length === 3); + "##; + let probe = format!( + r##"(async () => {{ {state} + const open = state(); + button().focus(); + button().click(); + const folded = state(); + return {{ open, folded, focused: document.activeElement === button() }}; + }})()"## + ); + let reload = format!( + r##"(async () => {{ {state} + const afterReload = state(); + button().click(); + const unfolded = state(); + return {{ afterReload, unfolded }}; + }})()"## + ); + let reload_file = tempfile::NamedTempFile::new().unwrap(); + std::fs::write(reload_file.path(), &reload).unwrap(); + let (ok, seen, stderr) = run_browser_env( + &viewer, + &chrome, + Some(&probe), + None, + None, + &[( + "RALLY_BROWSER_RELOAD_PROBE", + reload_file.path().to_str().unwrap(), + )], + ); + assert!(ok, "{seen}\n{stderr}"); + nothing_of_the_browser_survives(&seen); + let (first, again) = (&seen["probe"], &seen["reloaded"]); + // Open by default, through a button that says so and names what it controls. + let open = &first["open"]; + assert_eq!(open["tag"], "BUTTON", "{seen}"); + assert_eq!(open["expanded"], "true", "{seen}"); + assert_eq!(open["controls"], "inbox-body", "{seen}"); + assert_eq!(open["panelShown"], true, "{seen}"); + assert!(open["stored"].is_null(), "{seen}"); + // Folded: the panel is gone, the heading keeps every count and the urgent colour. + for folded in [&first["folded"], &again["afterReload"]] { + assert_eq!(folded["expanded"], "false", "{seen}"); + assert_eq!(folded["bodyHidden"], true, "{seen}"); + assert_eq!(folded["panelShown"], false, "{seen}"); + assert!( + folded["heading"] + .as_str() + .unwrap_or_default() + .contains("3 items open, 1 urgent"), + "{seen}" + ); + assert_eq!(folded["urgent"], "yes", "{seen}"); + assert_eq!(folded["stored"], "yes", "{seen}"); + } + assert_eq!(first["focused"], true, "{seen}"); + // And unfolded again, forgotten. + let unfolded = &again["unfolded"]; + assert_eq!(unfolded["expanded"], "true", "{seen}"); + assert_eq!(unfolded["panelShown"], true, "{seen}"); + assert!(unfolded["stored"].is_null(), "{seen}"); +} diff --git a/web/app.css b/web/app.css index 0b043e5..9ccf729 100644 --- a/web/app.css +++ b/web/app.css @@ -471,6 +471,15 @@ tbody tr.cue-activity, .activity li.cue-activity { animation: cue-trace 2.4s eas /* The operator's inbox (RAL-146): a quest log, urgent items first and marked. */ #inbox-title[data-urgent="yes"] { color: var(--bad); } +/* RAL-193: the fold arrow, as the "Past rallies" disclosure marker looks: a small triangle in the + secondary colour, pointing down when open, right when folded; the heading's own type and colour. */ +.fold { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; + font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; cursor: pointer; text-align: left; } +.fold-arrow { flex: none; width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 8px; + border-color: transparent transparent transparent var(--text-2); transform: rotate(90deg); transition: transform 0.15s ease; } +.fold[aria-expanded="false"] .fold-arrow { transform: none; } +.fold:hover .fold-arrow { border-left-color: var(--arc-1); } +.fold:focus-visible { outline: 2px solid var(--arc-1); outline-offset: 3px; border-radius: 2px; } .inbox { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; } .inbox-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--text-2) 30%, transparent); border-radius: 6px; } diff --git a/web/app.js b/web/app.js index ebbb551..98f37eb 100644 --- a/web/app.js +++ b/web/app.js @@ -330,8 +330,10 @@ function renderInbox(inbox, tickInfo, now) { const heading = document.getElementById("inbox-title"); const title = inboxCount(inbox).replace(/^Operator inbox: /, ""); if (heading) { + // RAL-193: the text sits beside the fold arrow, inside its button, so writing it keeps the button. + const label = document.getElementById("inbox-title-text") || heading; const text = "Operator inbox ยท " + title; - if (heading.textContent !== text) heading.textContent = text; + if (label.textContent !== text) label.textContent = text; heading.dataset.urgent = inbox && inbox.urgent ? "yes" : "no"; } if (!inbox || inbox.available === false) { @@ -1889,6 +1891,31 @@ async function refresh() { showFreshness(Date.now()); } +// RAL-193: the operator inbox folds away with the arrow beside its heading, remembered by this browser +// across reloads and restarts of the viewer. Storage that can't be read leaves it open. Folded, the +// heading still gives the counts, urgent included, so an urgent item is never silently hidden. +const INBOX_FOLDED = "rally-inbox-folded"; +function foldInbox(folded, remember) { + const button = document.getElementById("inbox-fold"); + const body = document.getElementById("inbox-body"); + if (!button || !body) return; + body.hidden = folded; + button.setAttribute("aria-expanded", String(!folded)); + button.title = folded ? "Show the operator inbox" : "Hide the operator inbox"; + if (!remember) return; + try { + if (folded) localStorage.setItem(INBOX_FOLDED, "yes"); + else localStorage.removeItem(INBOX_FOLDED); + } catch (error) { /* not remembered; it still folds for now */ } +} +(() => { + let folded = false; + try { folded = localStorage.getItem(INBOX_FOLDED) === "yes"; } catch (error) { folded = false; } + foldInbox(folded, false); + const button = document.getElementById("inbox-fold"); + if (button) button.addEventListener("click", () => foldInbox(button.getAttribute("aria-expanded") === "true", true)); +})(); + refresh(); setInterval(refresh, 30000); setInterval(tick, 1000); diff --git a/web/index.html b/web/index.html index a0c6c76..086653f 100644 --- a/web/index.html +++ b/web/index.html @@ -35,9 +35,12 @@

Rally

-

Operator inbox

-

Everything waiting on the operator, urgent first, then oldest first. Tick an item off when it's done or seen.

-
+ +

+
+

Everything waiting on the operator, urgent first, then oldest first. Tick an item off when it's done or seen.

+
+

Rally status