Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Notices never cover the camera or the model: they fold into one 'N notes' pill in the status strip that opens a list #310
smith/arm:smith/277-notices-never-cover-the-camera-or-the-mo → main 4 commits fork 6 threads · 6 unresolved
Software/README.md +2
| @@ -723,6 +723,8 @@ table is moved the drawing moves with it. On a stream, a joint that pushes hard | ||
| 723 | 723 | is parked where it is and follows again once the leader backs off. Jams, |
| 724 | 724 | blocks, stalls, peak loads and temperatures go to `metrics.jsonl`. |
| 725 | 725 | |
| 726 | On the page, nothing sits over the camera or the model: the room's announcement and a `warn`-zone warning fold into one "N notes" pill in the status strip, and a tap opens a list where each note can be dismissed (a dismissed warning stays gone until its text changes or it clears, so a `warn` boundary warning can be dismissed away; it comes back when the warning clears and returns, and an `enforce` hold is never a note, so it cannot be dismissed). What halts motion, a hold at the `enforce` boundary, a jam or a lost link, shows at once as one line lying over the driver's row in the strip, so nothing moves, and the E-stop keeps its banner. | |
| 727 | ||
| 726 | 728 | **Safety limits.** The arm server enforces these on every command, whoever |
| 727 | 729 | sends it and whatever the page does (`src/safety.ts`). The defaults are |
| 728 | 730 | conservative. The owner changes them in the settings panel, or with |
Software/so101/src/stop-layout.test.ts +31 −1
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; |
| 2 | import { mkdtempSync } from "node:fs"; | |
| 2 | import { mkdtempSync, readFileSync } from "node:fs"; | |
| 3 | 3 | import { tmpdir } from "node:os"; |
| 4 | 4 | import { join } from "node:path"; |
| 5 | 5 | import { FeetechBus } from "./bus.ts"; |
| @@ -110,3 +110,33 @@ describe("the served page's STOP", () => { | ||
| 110 | 110 | if (click) expect(click).toMatch(/e\.detail\s*===\s*0/); |
| 111 | 111 | }); |
| 112 | 112 | }); |
| 113 | ||
| 114 | describe("notices on the served page", () => { | |
| 115 | const css = () => flatRules([...html.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((m) => m[1]!).join("\n")); | |
| 116 | const notesJs = readFileSync(new URL("./ui/notes.js", import.meta.url), "utf8"); | |
| 117 | const notesCss = flatRules(readFileSync(new URL("./ui/notes.css", import.meta.url), "utf8")); | |
| 118 | const body = (sel: string) => [...css(), ...notesCss].filter((r) => r.selector.split(",").some((s) => s.trim() === sel)).map((r) => r.body).join(";"); | |
| 119 | ||
| 120 | test("with two notices the camera box is the same size as with none: the pill is in the strip, the list floats, nothing is in the view", () => { | |
| 121 | const markup = html.replace(/<!--[\s\S]*?-->/g, "").replace(/<(script|style)\b[\s\S]*?<\/\1>/gi, ""); | |
| 122 | const app = markup.slice(markup.indexOf('<div id="app"'), markup.indexOf('<section id="strip"')); | |
| 123 | expect(app).not.toMatch(/id="notes(Pill|List)"|id="notice"|id="holdLine"/); | |
| 124 | const strip = markup.slice(markup.indexOf('<section id="strip"'), markup.indexOf("</section>", markup.indexOf('<section id="strip"'))); | |
| 125 | expect(strip).not.toContain("notesPill"); // the module puts the pill after #turnActions, inside the strip, and the list on the body | |
| 126 | expect(notesJs).toMatch(/\$\("turnActions"\)\.after\(pill\)/); | |
| 127 | expect(markup).not.toContain('id="notice"'); | |
| 128 | // the list takes no room in any row of the grid; the pill is shorter than the strip's own minimum height | |
| 129 | expect(body("#notesList")).toMatch(/position:\s*fixed/); | |
| 130 | expect(Number(/min-height:\s*(\d+)px/.exec(body("#notesPill"))?.[1])).toBeGreaterThanOrEqual(44); | |
| 131 | expect(Number(/min-height:\s*(\d+)px/.exec(body("#notesPill"))?.[1])).toBeLessThan(Number(/min-height:\s*(\d+)px/.exec(body("#strip"))?.[1])); | |
| 132 | // the pill is styled by the page itself, so it never shows unstyled while a stylesheet loads; a hold lies over the driver's row and adds none | |
| 133 | expect(css().some((r) => r.selector.split(",").some((x) => x.trim() === "#notesPill"))).toBe(true); | |
| 134 | expect(notesCss.some((r) => r.selector.includes("notesPill"))).toBe(false); | |
| 135 | expect(body("#holdLine")).toMatch(/position:\s*absolute/); | |
| 136 | expect(body("#strip .who")).toMatch(/position:\s*relative/); | |
| 137 | expect(css().map((r) => r.selector).join("\n")).toMatch(/#holdLine:not\(:empty\)\) #driverLine/); | |
| 138 | expect(css().filter((r) => /#holdLine:not\(:empty\)\) #driverLine/.test(r.selector)).map((r) => r.body).join(";")).toMatch(/visibility:\s*hidden/); | |
| 139 | // the old over-the-video boxes only show for a stop | |
| 140 | expect(body("#banner")).toMatch(/display:\s*none/); | |
| 141 | }); | |
| 142 | }); |
Software/so101/src/ui/lobby-panel.js +2 −3
| @@ -29,7 +29,7 @@ export const backoff = (attempt) => Math.min(250 * 2 ** Math.max(0, attempt - 1) | ||
| 29 | 29 | const tell = (what) => /** @type {any} */ (globalThis).dispatchEvent?.(new Event(what)); |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | * @param {any} page what the page owns: $, el, relayed, tab(), showTab, msg, applyLock, applyStatus, noStatus, words, admin | |
| 32 | * @param {any} page what the page owns: $, el, relayed, tab(), showTab, msg, applyLock, applyStatus, noStatus, words, admin, note | |
| 33 | 33 | */ |
| 34 | 34 | export function createRoom(page) { |
| 35 | 35 | const { $, el, relayed, msg } = page; |
| @@ -111,8 +111,7 @@ export function createRoom(page) { | ||
| 111 | 111 | $("driverTag").textContent = d ? `🎮 ${d.name}${driving ? " (you)" : ""}` : ""; |
| 112 | 112 | $("strip").classList.toggle("ready", Boolean(driving && d.readyBy)); |
| 113 | 113 | alertNext(Boolean(mine && mine.place === 1 && !st.paused)); |
| 114 | $("notice").hidden = !st.announcement; | |
| 115 | $("notice").textContent = st.announcement ?? ""; | |
| 114 | page.note("notice", st.announcement); | |
| 116 | 115 | $("capLine").textContent = st.maxSpeedPercent < 100 ? `Speed limited to ${st.maxSpeedPercent}% of full` : ""; |
| 117 | 116 | $("turnActions").replaceChildren(...turnButtons()); |
| 118 | 117 | $("quiet").checked = quiet(); |
Software/so101/src/ui/lobby-panel.test.ts +3 −3
| @@ -49,7 +49,7 @@ describe("the room over /live", () => { | ||
| 49 | 49 | const page = { |
| 50 | 50 | $: (id: string) => nodes.get(id) ?? (nodes.set(id, node()), nodes.get(id)), |
| 51 | 51 | el: (tag: string, props: object = {}) => Object.assign(node(), { tag }, props), |
| 52 | relayed: true, tab: () => "chat", showTab() {}, applyLock() {}, applyStatus() {}, noStatus() {}, words() {}, admin() {}, | |
| 52 | relayed: true, tab: () => "chat", showTab() {}, applyLock() {}, applyStatus() {}, noStatus() {}, words() {}, admin() {}, note() {}, | |
| 53 | 53 | msg: (text: string, bad?: boolean) => void shown.push([text, bad]), |
| 54 | 54 | }; |
| 55 | 55 | const room = createRoom(page); |
| @@ -79,7 +79,7 @@ describe("the room over /live", () => { | ||
| 79 | 79 | const page = { |
| 80 | 80 | $: (id: string) => nodes.get(id) ?? (nodes.set(id, Object.assign(node(), { classList: classList() })), nodes.get(id)), |
| 81 | 81 | el: (tag: string, props: object = {}) => Object.assign(node(), { tag }, props), |
| 82 | relayed: true, tab: () => "chat", showTab() {}, applyLock: () => calls.push("lock"), applyStatus() {}, noStatus: () => calls.push("noStatus"), words() {}, admin() {}, | |
| 82 | relayed: true, tab: () => "chat", showTab() {}, applyLock: () => calls.push("lock"), applyStatus() {}, noStatus: () => calls.push("noStatus"), words() {}, admin() {}, note() {}, | |
| 83 | 83 | msg() {}, |
| 84 | 84 | }; |
| 85 | 85 | const room = createRoom(page); |
| @@ -127,7 +127,7 @@ describe("a deliberate reopen", () => { | ||
| 127 | 127 | const page = { |
| 128 | 128 | $: (id: string) => nodes.get(id) ?? (nodes.set(id, n()), nodes.get(id)), |
| 129 | 129 | el: (tag: string, props: object = {}) => Object.assign(n(), { tag }, props), |
| 130 | relayed: true, tab: () => "chat", showTab() {}, applyLock() {}, applyStatus() {}, noStatus: () => calls.push("noStatus"), words() {}, admin() {}, msg() {}, | |
| 130 | relayed: true, tab: () => "chat", showTab() {}, applyLock() {}, applyStatus() {}, noStatus: () => calls.push("noStatus"), words() {}, admin() {}, note() {}, msg() {}, | |
| 131 | 131 | }; |
| 132 | 132 | const room = createRoom(page); |
| 133 | 133 | room.lobbyConnect(); |
Software/so101/src/ui/notes.css added +2
| @@ -0,0 +1,2 @@ | ||
| 1 | #notesList { position: fixed; z-index: 9; left: 8px; right: 8px; bottom: calc(8px + var()); max-height: 40vh; overflow: auto; margin: 0 auto; max-width: 480px; padding: 6px; border: 1px solid var(); border-radius: 10px; background: var(); } | |
| 2 | .note { display: flex; gap: 8px; padding: 8px; border-left: 3px solid var(); font-size: 14px; overflow-wrap: anywhere; } .note span { flex: 1; } .note button { flex: none; min-height: 44px; min-width: 44px; } |
Software/so101/src/ui/notes.js added +54
| @@ -0,0 +1,54 @@ | ||
| 1 | // @ts-check | |
| 2 | /** | |
| 3 | * The page's notices (the room's #notice, the boundary warnings) as one count and one list, so none of them takes | |
| 4 | * room over the camera or the model: the status strip shows "2 notes", a tap opens the list, each can be dismissed. | |
| 5 | * A dismissed note stays gone until its text changes or it clears and comes back. Text only; the page uses textContent. | |
| 6 | */ | |
| 7 | ||
| 8 | const MAX = 240; | |
| 9 | ||
| 10 | export function createNotes() { | |
| 11 | /** @type {Map<string, string>} */ const items = new Map(); | |
| 12 | /** @type {Map<string, string>} */ const dismissed = new Map(); | |
| 13 | return { | |
| 14 | /** Set a note by key; an empty or missing text clears it (and forgets a dismissal, so it can come back). */ | |
| 15 | set(/** @type {string} */ key, /** @type {unknown} */ text) { | |
| 16 | // eslint-disable-next-line no-control-regex | |
| 17 | const t = typeof text === "string" ? text.replace(/[\u0000-\u001f\u007f]+/g, " ").trim().slice(0, MAX) : ""; | |
| 18 | if (t) items.set(key, t); else { items.delete(key); dismissed.delete(key); } | |
| 19 | }, | |
| 20 | /** @returns {Array<{ key: string, text: string }>} the notes not dismissed, in the order they were first set */ | |
| 21 | list() { return [...items].filter(([k, t]) => dismissed.get(k) !== t).map(([key, text]) => ({ key, text })); }, | |
| 22 | dismiss(/** @type {string} */ key) { const t = items.get(key); if (t !== undefined) dismissed.set(key, t); }, | |
| 23 | }; | |
| 24 | } | |
| 25 | ||
| 26 | /** | |
| 27 | * Mount the pill and the list on the page; returns set(key, text). Loaded on the first note, so a quiet page never pays for it. | |
| 28 | * @param {(id: string) => HTMLElement} $ @param {(tag: string, props?: object, ...kids: any[]) => HTMLElement} el | |
| 29 | */ | |
| 30 | export function mountNotes($, el) { | |
| 31 | document.head.append(el("link", { rel: "stylesheet", href: import.meta.url.replace(/\.js$/, ".css") })); | |
| 32 | const notes = createNotes(); | |
| 33 | const pill = el("button", { id: "notesPill", type: "button", hidden: true }), box = el("div", { id: "notesList", hidden: true }); | |
| 34 | pill.setAttribute("aria-controls", "notesList"); pill.setAttribute("aria-expanded", "false"); | |
| 35 | $("turnActions").after(pill); document.body.append(box); | |
The stylesheet is added here, after the pill is mounted. Unstyled-then-styled is a layout shift inside the strip. Put the #notesPill rule in viewer.html's CSS, or reveal the pill on the link's |
||
| 36 | function render() { | |
| 37 | const list = notes.list(); | |
| 38 | pill.hidden = !list.length; pill.textContent = pillText(list.length); | |
| 39 | if (!list.length) { box.hidden = true; pill.setAttribute("aria-expanded", "false"); } | |
| 40 | if (box.hidden) return; | |
| 41 | box.replaceChildren(...list.map((n) => { | |
| 42 | const b = el("button", { type: "button", textContent: "Dismiss", onclick: () => { notes.dismiss(n.key); render(); } }); | |
| 43 | b.setAttribute("aria-label", `Dismiss: ${n.text}`); | |
| 44 | return el("div", { className: "note" }, el("span", { textContent: n.text }), b); | |
| 45 | })); | |
| 46 | } | |
| 47 | const toggle = (/** @type {boolean} */ open) => { box.hidden = !open; pill.setAttribute("aria-expanded", String(open)); render(); }; | |
mountNotes (pill hidden when empty, aria-expanded, Escape focus return, Dismiss) has no test. Only createNotes is tested; add a small fake-DOM test. |
||
| 48 | pill.addEventListener("click", () => toggle(box.hidden)); | |
| 49 | addEventListener("keydown", (e) => { if (e.key === "Escape" && !box.hidden) { toggle(false); pill.focus(); } }); | |
| 50 | return { set(/** @type {string} */ key, /** @type {unknown} */ text) { notes.set(key, text); render(); } }; | |
| 51 | } | |
| 52 | ||
| 53 | /** @param {number} n @returns {string} the pill's words */ | |
| 54 | export const pillText = (n) => `${n} note${n === 1 ? "" : "s"}`; |
Software/so101/src/ui/notes.test.ts added +29
| @@ -0,0 +1,29 @@ | ||
| 1 | import { describe, expect, test } from "bun:test"; | |
| 2 | import { createNotes, pillText } from "./notes.js"; | |
| 3 | ||
| 4 | describe("notes", () => { | |
| 5 | test("two notices count to one pill", () => { | |
| 6 | const n = createNotes(); | |
| 7 | n.set("notice", "Back at 5"); n.set("zone", "the arm is near the table"); | |
| 8 | expect(n.list().length).toBe(2); | |
| 9 | expect(pillText(2)).toBe("2 notes"); | |
| 10 | expect(pillText(1)).toBe("1 note"); | |
| 11 | }); | |
| 12 | test("dismissed stays gone until the text changes or it clears", () => { | |
| 13 | const n = createNotes(); | |
| 14 | n.set("zone", "a"); n.dismiss("zone"); n.set("zone", "a"); | |
| 15 | expect(n.list()).toEqual([]); | |
| 16 | n.set("zone", "b"); | |
| 17 | expect(n.list().map((x) => x.text)).toEqual(["b"]); | |
| 18 | n.dismiss("zone"); n.set("zone", null); n.set("zone", "b"); | |
| 19 | expect(n.list().length).toBe(1); | |
| 20 | }); | |
| 21 | test("text is bounded and clean; non-strings clear", () => { | |
| 22 | const n = createNotes(); | |
| 23 | n.set("a", "x\ny" + "z".repeat(500)); | |
| 24 | expect(n.list()[0]!.text.length).toBe(240); | |
| 25 | expect(n.list()[0]!.text).not.toContain("\n"); | |
| 26 | n.set("a", 5); | |
| 27 | expect(n.list()).toEqual([]); | |
| 28 | }); | |
| 29 | }); |
Software/so101/src/ui/zone-notes.js added +19
| @@ -0,0 +1,19 @@ | ||
| 1 | /** Boundary and link trouble: what halts motion is a hold (the strip, at once); a warning is a note (the pill). */ | |
| 2 | export function zoneLines(d, say, names, time) { | |
| 3 | const hold = (hold) => ({ hold, note: "" }); | |
| 4 | if (d.reconnecting) return hold(`Reconnecting to the arm… showing where it was at ${time(d.seenAt)}. Driving is paused, and the arm holds where it is.`); | |
| 5 | if (typeof d.source === "string" && d.source.startsWith("simulated: offline")) return hold("The arm has been unreachable for over a minute. This is the SIMULATION, not the real arm."); | |
| 6 | if (d.jammed?.length) return hold(`jam: ${d.jammed.map((id) => names[id] ?? id).join(", ")} pushed against something and stopped — back the leader off`); | |
| 7 | if (d.blocked && d.zone === "enforce") return hold(`held at the boundary: ${say(d.blocked)}`); | |
| 8 | return { hold: "", note: d.blocked ? `warning: ${say(d.blocked)}` : d.violation ? `the arm is ${say(d.violation)} (zone: ${d.zone})` : "" }; | |
| 9 | } | |
| 10 | ||
| 11 | /** note(key, text): loads the pill on the first text; a failed load is not cached and the text goes to `fallback`. */ | |
| 12 | export function noteSink(load, fallback) { | |
| 13 | let mod = null; | |
| 14 | return (key, text = "") => { | |
| 15 | if (!mod) { if (!text) return; mod = load(); } | |
| 16 | const m = mod; | |
| 17 | m.then((n) => n.set(key, text), () => { if (mod === m) mod = null; if (text) fallback(text); }); | |
| 18 | }; | |
| 19 | } |
Software/so101/src/ui/zone-notes.test.ts added +40
| @@ -0,0 +1,40 @@ | ||
| 1 | import { describe, expect, test } from "bun:test"; | |
| 2 | import { noteSink, zoneLines } from "./zone-notes.js"; | |
| 3 | ||
| 4 | const say = (v: string) => `<${v}>`, names = { 2: "shoulder_lift" }, time = () => "12:00"; | |
| 5 | ||
| 6 | describe("zoneLines routes a status to the strip or to a note", () => { | |
| 7 | test("a reconnect, an unreachable arm, a jam and an enforce hold go to the strip", () => { | |
| 8 | expect(zoneLines({ reconnecting: true, seenAt: 1 }, say, names, time).hold).toContain("Reconnecting to the arm… showing where it was at 12:00"); | |
| 9 | expect(zoneLines({ source: "simulated: offline" }, say, names, time).hold).toContain("SIMULATION"); | |
| 10 | expect(zoneLines({ jammed: [2] }, say, names, time)).toEqual({ hold: expect.stringContaining("jam: shoulder_lift"), note: "" }); | |
| 11 | expect(zoneLines({ blocked: "table", zone: "enforce" }, say, names, time)).toEqual({ hold: "held at the boundary: <table>", note: "" }); | |
| 12 | }); | |
| 13 | test("a warn-only zone is a note, never a hold", () => { | |
| 14 | expect(zoneLines({ blocked: "table", zone: "warn" }, say, names, time)).toEqual({ hold: "", note: "warning: <table>" }); | |
| 15 | expect(zoneLines({ violation: "low", zone: "warn" }, say, names, time)).toEqual({ hold: "", note: "the arm is <low> (zone: warn)" }); | |
| 16 | expect(zoneLines({ zone: "warn" }, say, names, time)).toEqual({ hold: "", note: "" }); | |
| 17 | }); | |
| 18 | }); | |
| 19 | ||
| 20 | describe("noteSink", () => { | |
| 21 | const tick = () => new Promise((r) => setTimeout(r, 0)); | |
| 22 | test("mounts on the first text only, then reuses the mount", async () => { | |
| 23 | let loads = 0; const seen: unknown[][] = []; | |
| 24 | const note = noteSink(async () => { loads++; return { set: (k: string, t: unknown) => void seen.push([k, t]) }; }, () => {}); | |
| 25 | note("zone", ""); await tick(); | |
| 26 | expect(loads).toBe(0); | |
| 27 | note("zone", "a"); note("notice", "b"); await tick(); | |
| 28 | expect(loads).toBe(1); | |
| 29 | expect(seen).toEqual([["zone", "a"], ["notice", "b"]]); | |
| 30 | }); | |
| 31 | test("a failed load is not cached: the text is shown by the fallback and the next note loads again", async () => { | |
| 32 | let loads = 0; const shown: string[] = [], seen: unknown[][] = []; | |
| 33 | const note = noteSink(async () => { if (++loads === 1) throw new Error("offline"); return { set: (k: string, t: unknown) => void seen.push([k, t]) }; }, (t) => shown.push(t)); | |
| 34 | note("zone", "held"); await tick(); | |
| 35 | expect(shown).toEqual(["held"]); | |
| 36 | note("zone", "again"); await tick(); | |
| 37 | expect(loads).toBe(2); | |
| 38 | expect(seen).toEqual([["zone", "again"]]); | |
| 39 | }); | |
| 40 | }); |
Software/so101/src/viewer.html +16 −17
| @@ -79,17 +79,16 @@ | ||
| 79 | 79 | #link { color: #9aa4ae; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(36ch, 46vw); } #link.on { color: #3fb950; } #link.warn { color: #d29922; } #link.bad { color: #f85149; font-weight: 700; } |
| 80 | 80 | .dot { width: 8px; height: 8px; border-radius: 50%; background: #f85149; display: inline-block; flex: none; } .dot.on { background: #3fb950; } .dot.warn { background: #d29922; } |
| 81 | 81 | #banner { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); z-index: 5; width: max-content; max-width: min(640px, calc(100% - 16px)); padding: 8px 12px; border-radius: 8px; font-size: 13px; background: rgba(0,0,0,.8); border: 1px solid #30363d; display: none; } |
| 82 | #banner.bad { display: block; border-color: #f85149; color: #ffb3ad; } #banner.warn { display: block; border-color: #d29922; color: #f2cc60; } | |
| 83 | 82 | #msg { position: absolute; left: calc(8px + var()); right: calc(8px + var()); bottom: 8px; z-index: 6; margin: 0 auto; width: max-content; max-width: calc(100% - 16px); padding: 8px 12px; border-radius: 8px; font-size: 13px; background: rgba(13,17,23,.9); color: #e8eaed; border: 1px solid #30363d; } |
| 84 | 83 | #refusal { position: absolute; left: 8px; right: 8px; bottom: 52px; z-index: 6; margin: 0 auto; width: max-content; max-width: calc(100% - 16px); padding: 6px 12px; border-radius: 8px; font-size: 13px; background: rgba(13,17,23,.9); border: 1px solid #f85149; color: #ffb3ad; } #refusal:empty { display: none; } |
| 85 | 84 | #msg:empty { display: none; } #msg.bad { border-color: #f85149; color: #ffb3ad; } |
| 86 | 85 | |
| 87 | 86 | /* the status strip: who drives, your place, time left, the turn's action and the E-stop */ |
| 88 | 87 | #strip { grid-area: strip; display: flex; align-items: center; gap: 10px; padding: 8px calc(12px + var()) 8px calc(12px + var()); background: var(); border-bottom: 1px solid var(); min-height: 64px; } |
| 89 | #strip .who { flex: 1; min-width: 0; } | |
| 88 | #strip .who { flex: 1; min-width: 0; position: relative; } | |
| 90 | 89 | #driverLine { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } #driverLine.none { color: var(); font-weight: 500; } |
| 91 | 90 | #clock { color: var(); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } #clock.idle { color: var(); } |
| 92 | #capLine { color: var(); font-size: 12px; } #capLine:empty { display: none; } | |
| 91 | #capLine { color: var(); font-size: 12px; } #capLine:empty, #holdLine:empty { display: none; } | |
| 93 | 92 | #armLine { display: none; gap: 6px; align-items: center; color: var(); font-size: 12px; white-space: nowrap; } #armText { min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* shown on a phone held upright (ui/mobile.css) */ |
| 94 | 93 | #reconnect { align-self: flex-start; padding: 0 8px; border-radius: 9px; font-size: 11px; line-height: 16px; background: var(); color: #000; visibility: hidden; } #reconnect.on { visibility: visible; } |
| 95 | 94 | #driverLine.paused { color: var(); } |
| @@ -130,7 +129,9 @@ | ||
| 130 | 129 | #tabs .badge { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px; background: var(); color: var(); font-size: 11px; line-height: 18px; } |
| 131 | 130 | #tabs .badge:empty { display: none; } |
| 132 | 131 | |
| 133 | #notice { flex: none; padding: 10px calc(12px + var()) 10px calc(12px + var()); border-bottom: 1px solid var(); border-left: 3px solid var(); background: var(); font-size: 14px; overflow-wrap: anywhere; } | |
| 132 | #holdLine { position: absolute; top: 0; left: 0; right: 0; color: var(); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } | |
outdated
#holdLine takes a new row in the strip when a hold appears, and the camera shrinks. Reuse an existing row (capLine/driverLine) or reserve the line. |
||
| 133 | .who:has(#holdLine:not(:empty)) #driverLine { visibility: hidden; } | |
A single nowrap/ellipsis line is the only place a jam, reconnect or enforce hold appears, and it is clipped to the width of .who. Allow wrapping (e.g. white-space: normal with a max of 3 lines) and keep the driver name visible. |
||
| 134 | #notesPill { flex: none; min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 22px; background: var(); } | |
| 134 | 135 | |
| 135 | 136 | /* chat */ |
| 136 | 137 | #tab-chat { padding: 0; gap: 0; } |
| @@ -311,14 +312,13 @@ | ||
| 311 | 312 | |
| 312 | 313 | <section id="strip" aria-label="Who drives" aria-live="polite"> |
| 313 | 314 | <div id="ring" hidden aria-hidden="true"><span id="ringN"></span></div> |
| 314 | <div class="who"><div id="driverLine" class="none">Connecting…</div><span id="reconnect" role="status">reconnecting…</span><div id="clock" aria-live="off"></div><div id="capLine"></div><div id="armLine" aria-live="off"><span class="dot" id="armDot"></span><span id="armText"></span></div></div> | |
| 315 | <div class="who"><div id="driverLine" class="none">Connecting…</div><span id="reconnect" role="status">reconnecting…</span><div id="clock" aria-live="off"></div><div id="capLine"></div><div id="holdLine"></div><div id="armLine" aria-live="off"><span class="dot" id="armDot"></span><span id="armText"></span></div></div> | |
| 315 | 316 | <div id="turnActions"></div> |
| 316 | 317 | <button id="sheetToggle" hidden aria-controls="sheet" aria-expanded="true">Hide</button> |
| 317 | 318 | <button id="stop" class="estop" data-stop title="Stop (space or Esc): halt everything, hold with torque, until someone resumes" aria-label="Stop the arm">Stop</button> |
| 318 | 319 | </section> |
| 319 | 320 | |
| 320 | 321 | <section id="sheet" aria-label="Chat, queue and controls"> |
| 321 | <div id="notice" role="status" hidden></div> | |
| 322 | 322 | <div class="tab" id="tab-chat" role="tabpanel" aria-labelledby="t-chat"> |
| 323 | 323 | <div id="chat" role="log" aria-label="Chat"></div> |
| 324 | 324 | <button type="button" id="newMsgs" hidden>New messages ↓</button> |
| @@ -516,6 +516,7 @@ | ||
| 516 | 516 | import { cameraPlan, QUALITIES, samePlan } from "/ui/__VERSION__/camera-plan.js"; |
| 517 | 517 | import { bindSurface, canDrive, Driver, shape, UP } from "/ui/__VERSION__/drive.js"; |
| 518 | 518 | import { Frames } from "/ui/__VERSION__/frames.js"; |
| 519 | import { noteSink, zoneLines } from "/ui/__VERSION__/zone-notes.js"; | |
| 519 | 520 | import { createRoom } from "/ui/__VERSION__/lobby-panel.js"; |
| 520 | 521 | |
| 521 | 522 | const $ = (id) => document.getElementById(id); |
| @@ -1510,12 +1511,12 @@ | ||
| 1510 | 1511 | setInterval(() => { if (!$("metricsPanel").hidden) showMetrics(); }, 5000); |
| 1511 | 1512 | |
| 1512 | 1513 | // ---------------------------------------------------------------- the room: the turn, the queue and the chat over /live |
| 1513 | // Behind the hosted app's relay only the person whose turn it is may drive, and the server refuses everyone else. | |
| 1514 | // The page follows suit: the Controls tab appears on your turn. Everything here arrives on one socket. | |
| 1514 | // Behind the relay only the person whose turn it is may drive, and the server refuses the rest; the Controls tab appears on your turn. | |
| 1515 | 1515 | let wordsSent = false; |
| 1516 | 1516 | $("wordsForm").addEventListener("submit", (e) => { e.preventDefault(); wordsSent = true; say({ type: "words", words: $("wordsForm").elements.words.value.split(",").map((w) => w.trim()).filter(Boolean) }); }); |
| 1517 | const note = noteSink(() => import("/ui/__VERSION__/notes.js").then((m) => m.mountNotes($, el)), (t) => { $("holdLine").textContent = t; }); | |
| 1517 | 1518 | const room = createRoom({ |
| 1518 | $, el, relayed, msg, tab: () => tab, showTab, applyLock: () => applyLock(), applyStatus: (s) => applyStatus(s), noStatus: () => noStatus(), | |
| 1519 | $, el, relayed, msg, note, tab: () => tab, showTab, applyLock: () => applyLock(), applyStatus: (s) => applyStatus(s), noStatus: () => noStatus(), | |
| 1519 | 1520 | words(m) { const f = $("wordsForm"); if (document.activeElement !== f.elements.words) f.elements.words.value = m.words.join(", "); if (wordsSent) { wordsSent = false; msg(`Word filter saved: ${m.words.length} word${m.words.length === 1 ? "" : "s"}.`); } }, |
| 1520 | 1521 | admin: (saved) => fillAdmin(saved), |
| 1521 | 1522 | }); |
outdated
A rejected import() stays cached in notesMod, so all later notes are lost. Reset notesMod on failure. |
||
| @@ -1640,8 +1641,8 @@ | ||
| 1640 | 1641 | return `${part} is ${(-beyond).toFixed(0)} mm ${v.what === "table" ? "above the table" : "from the base"}, inside the ${marginMm} mm margin`; |
| 1641 | 1642 | }; |
| 1642 | 1643 | function banner(d) { |
| 1643 | const b = $("banner"); | |
| 1644 | const say = sayViolation; | |
| 1644 | const b = $("banner"), say = sayViolation; | |
| 1645 | $("holdLine").textContent = ""; | |
| 1645 | 1646 | if (d.estop) { |
| 1646 | 1647 | b.dataset.held = ""; |
| 1647 | 1648 | b.className = "stop"; |
| @@ -1659,12 +1660,10 @@ | ||
| 1659 | 1660 | if (mayDrive() || isOwner()) b.append(el("button", { id: "resume", textContent: resumeArmed ? "Tap again to resume" : "Resume driving", className: "go", onclick: (e) => resume(e.currentTarget) })); |
| 1660 | 1661 | return; |
| 1661 | 1662 | } |
| 1662 | if (d.reconnecting) { b.className = "warn"; b.textContent = `Reconnecting to the arm… showing where it was at ${new Date(d.seenAt).toLocaleTimeString()}. Driving is paused, and the arm holds where it is.`; return; } | |
| 1663 | if (typeof d.source === "string" && d.source.startsWith("simulated: offline")) { b.className = "bad"; b.textContent = "The arm has been unreachable for over a minute. This is the SIMULATION, not the real arm."; return; } | |
| 1664 | if (d.jammed?.length) { b.className = "bad"; b.textContent = `jam: ${d.jammed.map((id) => NAMES[id] ?? id).join(", ")} pushed against something and stopped — back the leader off`; } | |
| 1665 | else if (d.blocked) { b.className = d.zone === "enforce" ? "bad" : "warn"; b.textContent = `${d.zone === "enforce" ? "held at the boundary" : "warning"}: ${say(d.blocked)}`; } | |
| 1666 | else if (d.violation) { b.className = "warn"; b.textContent = `the arm is ${say(d.violation)} (zone: ${d.zone})`; } | |
| 1667 | else b.className = ""; | |
| 1663 | b.className = ""; | |
| 1664 | const z = zoneLines(d, say, NAMES, (t) => new Date(t).toLocaleTimeString()); | |
| 1665 | $("holdLine").textContent = z.hold; | |
| 1666 | note("zone", z.note); | |
| 1668 | 1667 | } |
| 1669 | 1668 | /** The arm's status, from /live (pushed when it changes) or, without it, from polling /status. */ |
| 1670 | 1669 | // Until the limits, the settings and the model are in, a status is kept aside, not drawn; then it is applied whole, |
dismissAll is never called and has no test. Delete it.