Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

workbenchthis machine

Slow mode is an admin setting: slowModeSeconds, 0-300, on /admin (after #211 makes main's tests green) #229

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

smith/arm:smith/214-slow-mode-is-an-admin-setting-slowmodese → main 3 commits fork 1 thread · 1 unresolved

  • Merged. smith/214-slow-mode-is-an-admin-setting-slowmodese was merged into main as b8ef3fd.

Review

Sign in to review this change.
4 files changed +19 −2
Software/so101/src/admin-page.ts +1
@@ -133,6 +133,7 @@ ${field("turnSeconds", "Turn length", "seconds, 30–3600", s.turnSeconds, 30, 3
133133 ${field("idleSeconds", "Idle timeout", "seconds without a command, 10–600", s.idleSeconds, 10, 600, off)}
134134 ${field("maxSpeedPercent", "Max speed", "percent of full, on top of the safety limits", s.maxSpeedPercent, 5, 100, off)}
135135 ${field("maxQueue", "Max queue length", "people waiting, 0–100", s.maxQueue, 0, 100, off)}
136 ${field("slowModeSeconds", "Slow mode", "seconds between a person's chat messages, 0 for none, 0–300", s.slowModeSeconds, 0, 300, off)}
136137 <label class="wide">Announcement<small>shown to everyone above the queue; empty for none</small><textarea name="announcement" maxlength="${ANNOUNCEMENT_CHARS}"${off}>${esc(s.announcement)}</textarea></label>
137138 <label class="wide">Arm server<small>where the arm and its cameras are, http://host:port; empty uses ARM_SERVER from the environment, else the simulation; takes effect at once</small><input name="armServer" maxlength="200" value="${esc(s.armServer)}"${off}></label>
138139 </div>
Software/so101/src/admin.test.ts +12
@@ -20,6 +20,18 @@ describe("admin settings", () => {
2020 expect(validateChange({ announcement: "‮\u0007" })).toEqual({ announcement: "" });
2121 });
2222
23 test("slow mode is a whole number of seconds from 0 to 300, and persists", () => {
24 expect(DEFAULT_ADMIN.slowModeSeconds).toBe(0);
25 for (const bad of [-1, 301, 1.5, "5"]) expect(() => validateChange({ slowModeSeconds: bad })).toThrow("slow mode (s) must be a whole number from 0 to 300");
26 expect(validateChange({ slowModeSeconds: 300 })).toEqual({ slowModeSeconds: 300 });
27 expect(changeFromForm(new URLSearchParams("slowModeSeconds=10"))).toEqual({ slowModeSeconds: 10 });
28 const file = join(dir(), "admin.json");
29 expect(new Admin({ file }).set(owner, { slowModeSeconds: 12 })).toEqual(["slowModeSeconds"]);
30 const b = new Admin({ file });
31 expect(b.settings.slowModeSeconds).toBe(12);
32 expect(b.log.at(-1)?.what).toBe("slow mode (s) → 12");
33 });
34
2335 test("a form's numbers arrive as text and are read strictly", () => {
2436 expect(changeFromForm(new URLSearchParams("turnSeconds=90&idleSeconds=20&maxSpeedPercent=40&maxQueue=5&announcement=hi"))).toEqual({ turnSeconds: 90, idleSeconds: 20, maxSpeedPercent: 40, maxQueue: 5, announcement: "hi" });
2537 expect(() => changeFromForm(new URLSearchParams("turnSeconds=1e3"))).toThrow("must be a whole number");
Software/so101/src/admin.ts +5 −1
@@ -19,6 +19,8 @@ export interface AdminSettings {
1919 maxSpeedPercent: number;
2020 /** How many may wait in line. */
2121 maxQueue: number;
22 /** Seconds a person waits between chat messages; 0 is no slow mode. Enforced elsewhere. */
23 slowModeSeconds: number;
2224 /** Shown to everyone above the queue; empty for none. */
2325 announcement: string;
2426 /** Where the arm and its cameras are (http://host:port); empty uses ARM_SERVER from the environment, else the simulation. */
@@ -27,7 +29,7 @@ export interface AdminSettings {
2729 moderators: string[];
2830 }
2931
30 export const DEFAULT_ADMIN: AdminSettings = { paused: false, turnSeconds: 180, idleSeconds: 30, maxSpeedPercent: 100, maxQueue: 20, announcement: "", armServer: "", moderators: [] };
32 export const DEFAULT_ADMIN: AdminSettings = { paused: false, turnSeconds: 180, idleSeconds: 30, maxSpeedPercent: 100, maxQueue: 20, slowModeSeconds: 0, announcement: "", armServer: "", moderators: [] };
3133
3234 const NAME = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/;
3335 export const MAX_MODERATORS = 50;
@@ -38,6 +40,7 @@ const RANGES = {
3840 idleSeconds: [10, 600],
3941 maxSpeedPercent: [5, 100],
4042 maxQueue: [0, 100],
43 slowModeSeconds: [0, 300],
4144 } as const satisfies Partial<Record<keyof AdminSettings, readonly [number, number]>>;
4245 const LABELS: Record<keyof AdminSettings, string> = {
4346 paused: "paused",
@@ -45,6 +48,7 @@ const LABELS: Record<keyof AdminSettings, string> = {
4548 idleSeconds: "idle timeout (s)",
4649 maxSpeedPercent: "max speed (%)",
4750 maxQueue: "max queue length",
51 slowModeSeconds: "slow mode (s)",
4852 announcement: "announcement",
4953 armServer: "arm server",
5054 moderators: "moderators",
forge.json +1 −1
@@ -1,6 +1,6 @@
11 {
22 "app": {
3 "install": "bun install --cwd Software/so101 --frozen-lockfile",
3 "install": "bun install --cwd Software/so101 --frozen-lockfile --network-concurrency 4",

Out of scope for the issue, but needed for the install to pass under the 8-connection egress cap; mention it in the pull description and move it to its own change if the cap is raised.

44 "run": "bun run Software/so101/bench/fake-serve.ts",
55 "tty": "bun run Software/so101/src/tty.ts",
66 "test": "bun --cwd Software/so101 test",

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs