Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/added-activity-monitor-display-stale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor display mode (`?display=1`) now says when its data is stale ([#15930](https://github.com/hivecommons/hive/issues/15930), part of [#15860](https://github.com/hivecommons/hive/issues/15860)). A wall screen used to keep showing its last payload as if it were live after the event stream or the spoke went quiet. Now the display header shows the hive id, a clock and a live dot. When the stream has been silent for more than two poll intervals, or the payload is older than two cache TTLs, the dot turns amber, the board dims and a banner reads *Stale: last update N ago*. The display recovers by itself when updates resume. After five failed reconnects it reloads on a 30 s → 10 min backoff, and it reloads once after an upgrade finishes. The URL, and so the view, survives the reload. The ordinary Activity Monitor and headless `?kiosk=1` output are unchanged.
1 change: 1 addition & 0 deletions changelog.d/added-activity-monitor-display-tv-density.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor display mode (`?display=1`) gains wall-screen options ([#15931](https://github.com/hivecommons/hive/issues/15931), part of [#15860](https://github.com/hivecommons/hive/issues/15860)). `density=tv` uses larger type and shows only each row's stage, title and actor. It shows only the rows that fit the screen, with a "+N more" footer instead of the pager. `shift=1` moves the board 1–2 px every 4 minutes to protect OLED screens from burn-in. With *reduce motion* on, a display plays no row movement and no shift. Both options are ignored without `display=1`, so the ordinary Activity Monitor and `?kiosk=1` render exactly as before. The TV layout adds nothing that changes state.
24 changes: 24 additions & 0 deletions src/docs/streaming-the-activity-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ time per view with `interval`:
- Playlists exist only in the URL. There are no named presets in `hive.yaml`,
and playlists apply only in display mode, never to `?kiosk=1`.

A display says honestly when its data is old. Its header shows the hive id,
a clock and a live dot. When the event stream has been silent for more than
two poll intervals (about a minute), or the tracker payload is older than two
server cache TTLs, the dot turns amber, the board dims and a banner reads
*Stale: last update N ago*. It recovers by itself when updates resume. If
the stream fails to reconnect five times in a row, the display reloads
itself after 30 s, doubling on each further reload up to 10 minutes; it also
reloads once after a hive upgrade finishes. A reload keeps the URL, so the
view survives. The ordinary Activity Monitor and `?kiosk=1` do not dim, and
the "updated … ago" chip behaves as before everywhere.

Two wall-screen options apply only together with `display=1` and are ignored
otherwise:

| Parameter | Effect |
|---|---|
| `density=tv` | Larger type and only the stage, title and actor of each row. No filters, row chips or pager: the rows that fit the screen, then a "+N more" footer. Recomputed when the window is resized. `tv` is the only value; anything else is ignored. |
| `shift=1` | OLED burn-in protection: the board moves 1–2 px to a new spot every 4 minutes. Off by default. |

With the operating system's *reduce motion* setting on, a display plays no
row movement, no burn-in shift and no dim transition.

Example: `/?display=1&density=tv&shift=1#section-activity-monitor-section`.

Any Activity Monitor filter can be described in the URL with `am.*`
parameters, so a display link reproduces the view in a fresh browser profile:

Expand Down
30 changes: 30 additions & 0 deletions src/pkg/dashboard/kiosk_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,36 @@ func TestDisplayModeWiring(t *testing.T) {
}
}

// TestDisplayOptionsWiring guards the display-mode wall options (#15931):
// `density=tv` and `shift=1` set their body classes only inside the
// display-mode branch of boot.js, so `?density=tv` or `?shift=1` without
// `display=1` (and any kiosk URL, where display mode is off) renders exactly
// as before, and `density` accepts only `tv`.
func TestDisplayOptionsWiring(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
`density=u.searchParams.get('density')==='tv'?'tv':'';`,
`shift=u.searchParams.get('shift')==='1';`,
`window.HIVE_DISPLAY_DENSITY=window.HIVE_DISPLAY?density:'';`,
`window.HIVE_DISPLAY_SHIFT=window.HIVE_DISPLAY&&shift;`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html missing display option wiring %q", want)
}
}
branch := "if(window.HIVE_DISPLAY){\n document.body.classList.add('display-mode');\n document.body.classList.add('ham-chromeless');\n" +
" if(window.HIVE_DISPLAY_DENSITY==='tv') document.body.classList.add('display-density-tv');\n" +
" if(window.HIVE_DISPLAY_SHIFT) document.body.classList.add('display-shift');\n"
if !strings.Contains(html, branch) {
t.Error("display-density-tv / display-shift must be added only inside boot.js's display-mode branch")
}
for _, cls := range []string{"display-density-tv", "display-shift"} {
if n := strings.Count(html, "classList.add('"+cls+"')"); n != 1 {
t.Errorf("%s added %d times; want exactly once, in the display-mode branch", cls, n)
}
}
}

// TestKioskSoundDefault guards the streamer's audio path: in kiosk mode the
// tracker sounds are on unless the URL says `&sound=off`, the context is
// resumed at init without waiting for a gesture (the streamer's Chromium
Expand Down
18 changes: 12 additions & 6 deletions src/pkg/dashboard/stage_tracker_display.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,22 @@ test('display mode wiring: header button, boot flag, chrome-less CSS and hidden
assert.match(html, /id="activity-monitor-display" data-action="toggleStageTrackerDisplay" data-stop="1" aria-pressed="false"/);
assert.ok(html.includes("display=u.searchParams.get('display')==='1'"));
assert.ok(html.includes('window.HIVE_DISPLAY=display&&!kiosk;'), 'kiosk wins');
assert.ok(html.includes("document.body.classList.add('display-mode');"));
assert.ok(html.includes("document.body.classList.add('display-mode');\n document.body.classList.add('ham-chromeless');"), 'display shares the chrome-less layout class');
for (const rule of [
'body.display-mode .hive-chat-panel, body.display-mode #welcome-overlay, body.display-mode .nps-card { display: none !important; }',
'html body.display-mode #oc-topbar[id] { display: none !important; }',
'body.display-mode #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section) { display: none !important; }',
'body.ham-chromeless #dash-notices, body.ham-chromeless #oc-agent-detail, body.ham-chromeless .hive-chat-fab,',
'body.display-mode #welcome-overlay, body.display-mode .nps-card { display: none !important; }',
'html body.ham-chromeless #oc-topbar[id] { display: none !important; }',
'body.ham-chromeless #hive-dashboard-root > [data-dashboard-section]:not(#activity-monitor-section) { display: none !important; }',
'body.display-mode #activity-monitor-section .ham-row-tools, body.display-mode #activity-monitor-selbar,',
'body.display-mode .ham-decision-acts { display: none !important; }',
'body.kiosk-mode .ham-header-tool, body.kiosk-mode .ham-popout-return { display: none !important; }',
]) assert.ok(html.includes(rule), 'missing CSS rule: ' + rule);
assert.ok(!/body\.display-mode[^{]*\{[^}]*cursor:\s*none/.test(html), 'display mode keeps the cursor');
assert.ok(!/body\.ham-chromeless[^{]*\{[^}]*cursor:\s*none/.test(html), 'the shared layout keeps the cursor');
// One shared class, not one selector copy per chrome-less view (#15956).
const popoutCss = fs.readFileSync(path.join(__dirname, 'static-src', 'css', 'popout.css'), 'utf8');
assert.ok(!popoutCss.includes('body.ham-fullscreen #hive-dashboard-root'), 'full screen rides ham-chromeless');
assert.ok(!popoutCss.includes('body.display-mode #hive-dashboard-root'), 'display rides ham-chromeless');
assert.ok(html.includes('function setLayout(mode) { if (window.hiveDisplayMode && window.hiveDisplayMode()) return; localStorage.setItem(LAYOUT_KEY, mode); }'), 'theme is never persisted from a display');
assert.ok(html.includes('function dashboardLayoutWrite(){if(window.hiveDisplayMode&&window.hiveDisplayMode())return;'), 'layout is never persisted from a display');
});
Expand Down Expand Up @@ -203,8 +209,8 @@ const controlsSrc = [
'var _stageTrackerDisplayLastPointer = 0;', 'var _stageTrackerDisplayHideTimer = null;',
'var _stageTrackerWakeLock = null;', 'var _stageTrackerWakeLockError = null;', 'var _stageTrackerWakeLockWanted = false;',
...['stageTrackerDisplayMode', 'stageTrackerDisplayUrl', 'toggleStageTrackerDisplay',
'stageTrackerFullscreenTarget', 'stageTrackerFullscreenButton', 'stageTrackerIsFullscreen', 'stageTrackerFullscreenLabel',
'stageTrackerRenderFullscreenButton', 'toggleStageTrackerFullscreen',
'stageTrackerFullscreenTarget', 'stageTrackerFullscreenButton', 'stageTrackerIsFullscreen', 'stageTrackerSetFullscreenLayout',
'stageTrackerFullscreenLabel', 'stageTrackerRenderFullscreenButton', 'toggleStageTrackerFullscreen',
'stageTrackerDisplayControlsEl', 'stageTrackerDisplayControlsSync', 'stageTrackerDisplayControlsPing',
'stageTrackerWakeLockSupported', 'stageTrackerRenderDisplayControls', 'stageTrackerWakeLockAcquire',
'stageTrackerWakeLockRelease', 'stageTrackerToggleWakeLock', 'stageTrackerWakeLockOnVisible', 'stageTrackerDisplayExit',
Expand Down
74 changes: 74 additions & 0 deletions src/pkg/dashboard/stage_tracker_display_layout.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Display-mode wall layout (hivecommons/hive#15931): `density=tv` caps the
// rows to what fits the viewport with a "+N more" footer instead of the
// pager, `shift=1` is a burn-in shift, and reduced motion turns row movement
// off on a display. The helpers are lifted by marker out of index.html so
// this runs against the shipped source.
const test = require('node:test');
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');

const html = fs.readFileSync(path.join(__dirname, 'static', 'index.html'), 'utf8');
const m = html.match(/\/\/ tracker display layout helpers begin\n([\s\S]*?)\/\/ tracker display layout helpers end/);
assert.ok(m, 'tracker display layout helpers not found');
const h = new Function(m[1] + '; return { stageTrackerDisplayRowCap, stageTrackerDisplayCapPage, stageTrackerDisplayMoreHtml, stageTrackerDisplayMotionEffect };')();

test('row cap: the rows that fit below the header', () => {
assert.strictEqual(h.stageTrackerDisplayRowCap(1080, 200, 80), 11);
assert.strictEqual(h.stageTrackerDisplayRowCap(2160, 200, 80), 24);
assert.strictEqual(h.stageTrackerDisplayRowCap(1080, 0, 100), 10);
assert.strictEqual(h.stageTrackerDisplayRowCap(1079, 0, 100), 10, 'a partial row does not count');
});

test('row cap: never below one row, and one when sizes are unknown', () => {
assert.strictEqual(h.stageTrackerDisplayRowCap(300, 400, 80), 1, 'header taller than the viewport');
assert.strictEqual(h.stageTrackerDisplayRowCap(1080, 200, 0), 1);
assert.strictEqual(h.stageTrackerDisplayRowCap(0, 0, 80), 1);
assert.strictEqual(h.stageTrackerDisplayRowCap(NaN, 0, 80), 1);
assert.strictEqual(h.stageTrackerDisplayRowCap(1080, -50, 100), 10, 'a negative header is ignored');
});

test('capped page: first rows, no pager, a correct "+N more" count', () => {
const rows = Array.from({ length: 23 }, (_, i) => i);
const p = h.stageTrackerDisplayCapPage(rows, 10);
assert.deepStrictEqual(p.rows, rows.slice(0, 10));
assert.strictEqual(p.pages, 1, 'no pager');
assert.strictEqual(p.total, 23);
assert.strictEqual(p.more, 13);
assert.strictEqual(p.from, 1);
assert.strictEqual(p.to, 10);
const all = h.stageTrackerDisplayCapPage(rows.slice(0, 4), 10);
assert.strictEqual(all.more, 0);
assert.strictEqual(all.rows.length, 4);
const none = h.stageTrackerDisplayCapPage([], 10);
assert.strictEqual(none.from, 0);
assert.strictEqual(none.more, 0);
});

test('"+N more" footer only when rows were left out', () => {
assert.strictEqual(h.stageTrackerDisplayMoreHtml(13), '<span class="ham-display-more" role="status">+13 more</span>');
assert.strictEqual(h.stageTrackerDisplayMoreHtml(0), '');
assert.strictEqual(h.stageTrackerDisplayMoreHtml(-2), '');
});

test('reduced motion turns row movement off on a display only', () => {
assert.strictEqual(h.stageTrackerDisplayMotionEffect('rm-fade', true, true), '');
assert.strictEqual(h.stageTrackerDisplayMotionEffect('wash', true, false), 'wash');
assert.strictEqual(h.stageTrackerDisplayMotionEffect('rm-fade', false, true), 'rm-fade', 'the ordinary monitor keeps its crossfade');
assert.strictEqual(h.stageTrackerDisplayMotionEffect('wash', false, false), 'wash');
});

test('wiring: density and shift are honoured only with display=1; TV replaces the pager; shift is inert under reduced motion', () => {
assert.ok(html.includes("density=u.searchParams.get('density')==='tv'?'tv':'';"), 'density accepts only tv');
assert.ok(html.includes("window.HIVE_DISPLAY_DENSITY=window.HIVE_DISPLAY?density:'';"));
assert.ok(html.includes('window.HIVE_DISPLAY_SHIFT=window.HIVE_DISPLAY&&shift;'));
assert.ok(html.includes("if(window.HIVE_DISPLAY_DENSITY==='tv') document.body.classList.add('display-density-tv');"));
assert.ok(html.includes("if(window.HIVE_DISPLAY_SHIFT) document.body.classList.add('display-shift');"));
assert.ok(html.includes("const grouping = _stageTrackerGroup === 'repo' && !tv;"));
assert.ok(html.includes('? stageTrackerDisplayCapPage(ordered, stageTrackerDisplayTvCap())'));
assert.ok(html.includes('if (foot) setIfChanged(foot, tv ? stageTrackerDisplayMoreHtml(page.more) : '));
assert.ok(html.includes("if (typeof stageTrackerDisplayEffect === 'function') effect = stageTrackerDisplayEffect(effect);"));
assert.ok(html.includes('body.display-shift #activity-monitor-section { animation: ham-display-shift 16min steps(1, end) infinite; }'));
assert.match(html, /@media \(prefers-reduced-motion: reduce\) \{\n\s*body\.display-shift #activity-monitor-section \{ animation: none; \}/);
assert.ok(html.includes('body.display-density-tv #activity-monitor-section .ham-head-pr, body.display-density-tv #activity-monitor-section .ham-badges,'), 'TV drops the PR column and chips');
});
Loading
Loading