Skip to content
Closed
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/fixed-16440-matrix-overlays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Keep the Matrix freshness HUD and get-started QR card above the canvas in every effect, and reserve their space when scrolling terminal rows.
2 changes: 1 addition & 1 deletion src/pkg/dashboard/kiosk_cta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ test('badge wiring: placeholder outside the root, hidden without the body class,
assert.ok(root > 0 && ph > root, 'placeholder must follow the dashboard root');
assert.ok(html.includes('#kiosk-cta { display: none; }'));
assert.ok(html.includes('body.kiosk-cta-on #kiosk-cta {'));
assert.ok(html.includes('body.matrix-mode #kiosk-cta { z-index: 100001; opacity: .85; }'));
assert.ok(html.includes('body.matrix-mode #kiosk-cta { position: fixed; right: 1rem; bottom: 1rem; z-index: 100001; opacity: .85; }'));
});
31 changes: 29 additions & 2 deletions src/pkg/dashboard/matrix_ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ func TestMatrixUIWiring(t *testing.T) {
}
}
}
// The canvas must have an explicit lower layer even when its fill is opaque.
for selector, declarations := range map[string][]string{
"body.matrix-mode .matrix-canvas": {"position: fixed", "z-index: 0"},
"body.matrix-mode .matrix-labels": {"position: fixed", "z-index: 1", "bottom: 1rem"},
"body.matrix-mode #kiosk-cta": {"position: fixed", "z-index: 100001", "bottom: 1rem"},
} {
_, after, found := strings.Cut(css, selector+" {")
rule, _, _ := strings.Cut(after, "}")
for _, declaration := range declarations {
if !found || !strings.Contains(rule, declaration+";") {
t.Errorf("%s missing overlay layout declaration %q", selector, declaration)
}
}
}
manifest := read("manifest.txt")
for _, file := range []string{"js/matrix.js", "css/matrix.css"} {
if !strings.Contains(manifest, file+"\n") {
Expand Down Expand Up @@ -77,14 +91,16 @@ const matrix = fs.readFileSync('static-src/js/matrix.js', 'utf8');
const boot = fs.readFileSync('static-src/js/boot.js', 'utf8').split('})();')[0] + '})();';
async function scenario(query, reduced = false, status = 200) {
const events = {}, docEvents = {}, raf = new Map(), timers = new Map(), requests = [], draws = [];
let id = 0, responseStatus = status, responseSeq = 1;
let id = 0, responseStatus = status, responseSeq = 1, overlayTop = 440;
const context = {clearRect(){}, fillRect(){}, fillText(...a){draws.push(a)}, drawImage(...a){draws.push(a)}};
const elements = [];
function el(tag) { const e = {tagName: tag.toUpperCase(), children: [], style: {setProperty(){}},
classList: {add(){}}, setAttribute(){}, append(...a){this.children.push(...a)},
getBoundingClientRect(){return {top: this.id === 'kiosk-cta' ? overlayTop : 500, height: this.id === 'kiosk-cta' ? (query.includes('cta=off') ? 0 : 140) : 80}},
appendChild(a){this.children.push(a)}, replaceChildren(...a){this.children = a}, getContext(){return context}};
elements.push(e); return e; }
const body = el('body');
const cta = el('aside'); cta.id = 'kiosk-cta'; body.appendChild(cta);
const doc = {body, hidden: false, createElement: el,
getElementById(id){return elements.find(e => e.id === id)},
addEventListener(n, fn){(docEvents[n] ||= []).push(fn)}};
Expand Down Expand Up @@ -122,7 +138,17 @@ async function scenario(query, reduced = false, status = 200) {
assert(draws.length > 0);
if (/cascade|ghost|terminal/.test(query)) assert(draws.some(a => a[0] === 'org/repo#2 · main.go'));
if (query.includes('ghost')) assert(draws.some(a => a[0] === 'main.go'));
if (query.includes('terminal')) assert(draws.some(a => a[0] === '+ <script>alert(1)</script>'));
if (query.includes('terminal')) {
assert(draws.some(a => a[0] === '+ <script>alert(1)</script>'));
assert(draws.every(a => a[2] <= (query.includes('cta=off') ? 500 : overlayTop) - 20), 'terminal rows must clear visible overlays');
overlayTop = 320; draws.length = 0;
const fn = [...raf.values()][0]; raf.clear(); fn(200);
assert(draws.length > 0);
assert(draws.every(a => a[2] <= (query.includes('cta=off') ? 500 : overlayTop) - 20), 'terminal must follow resized overlays');
}
assert(!byClass('matrix-labels').hidden);
assert(byClass('matrix-labels').children[1].textContent.includes('last line'));
assert.equal(win.hiveKioskCTAOn(win.location.href), !query.includes('cta=off'));
}
doc.hidden = true; docEvents.visibilitychange.forEach(fn => fn());
assert.equal(raf.size, 0); assert.equal(timers.size, 0);
Expand All @@ -142,6 +168,7 @@ async function scenario(query, reduced = false, status = 200) {
await scenario('?kiosk=1&view=matrix&mx.effect=cascade');
await scenario('?kiosk=1&view=matrix&mx.effect=ghost');
await scenario('?kiosk=1&view=matrix&mx.effect=terminal');
await scenario('?kiosk=1&view=matrix&mx.effect=terminal&cta=off');
await scenario('?kiosk=1&view=matrix', true);
for (const status of [404, 401, 403]) await scenario('?kiosk=1&view=matrix', false, status);
})().catch(e => {console.error(e); process.exit(1)});
Expand Down
6 changes: 3 additions & 3 deletions src/pkg/dashboard/static-src/css/matrix.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ body.matrix-mode #hive-matrix {
--matrix-muted: #b8ccbb;
position: fixed; inset: 0; z-index: 100000; background: var(--matrix-bg); color: var(--matrix-color, var(--matrix-fg)); font: 16px monospace;
}
body.matrix-mode .matrix-canvas { width: 100%; height: 100%; }
body.matrix-mode .matrix-labels { position: absolute; bottom: 1rem; left: 1rem; right: 1rem; padding: var(--sp-3); background: var(--matrix-surface); color: var(--matrix-text); font-size: var(--fs-base); overflow-wrap: anywhere; }
body.matrix-mode .matrix-canvas { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; }
body.matrix-mode .matrix-labels { position: fixed; z-index: 1; bottom: 1rem; left: 1rem; right: 1rem; padding: var(--sp-3); background: var(--matrix-surface); color: var(--matrix-text); font-size: var(--fs-base); overflow-wrap: anywhere; }
body.matrix-mode .matrix-notice { position: absolute; top: 2rem; left: 1rem; right: 1rem; color: var(--matrix-text); }
body.matrix-mode .matrix-list { position: absolute; inset: 4rem 1rem 8rem; overflow: hidden; }
body.matrix-mode .matrix-list pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0 1rem; }
body.matrix-mode .matrix-list small { color: var(--matrix-muted); }
body.matrix-mode #hive-matrix [hidden] { display: none !important; }
body.matrix-mode #kiosk-cta { z-index: 100001; opacity: .85; }
body.matrix-mode #kiosk-cta { position: fixed; right: 1rem; bottom: 1rem; z-index: 100001; opacity: .85; }
7 changes: 7 additions & 0 deletions src/pkg/dashboard/static-src/js/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,14 @@
if (!termRows.length) emitTerminal();
termClock += dt * 4;
while (termClock >= 1) { termClock -= 1; emitTerminal(); }
// The QR card can be taller than the freshness HUD. Reserve the full
// overlay band, including after viewport or font-size changes.
var bottom = height - 100;
[labels, document.getElementById('kiosk-cta')].forEach(function(overlay){
if (!overlay) return;
var bounds = overlay.getBoundingClientRect();
if (bounds.height) bottom = Math.min(bottom, bounds.top - rowH);
});
ctx.font = '16px monospace';
termRows.forEach(function(row, i){
var y = bottom - (termRows.length - 1 - i + termClock) * rowH;
Expand Down
13 changes: 10 additions & 3 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7035,14 +7035,14 @@
--matrix-muted: #b8ccbb;
position: fixed; inset: 0; z-index: 100000; background: var(--matrix-bg); color: var(--matrix-color, var(--matrix-fg)); font: 16px monospace;
}
body.matrix-mode .matrix-canvas { width: 100%; height: 100%; }
body.matrix-mode .matrix-labels { position: absolute; bottom: 1rem; left: 1rem; right: 1rem; padding: var(--sp-3); background: var(--matrix-surface); color: var(--matrix-text); font-size: var(--fs-base); overflow-wrap: anywhere; }
body.matrix-mode .matrix-canvas { position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; }
body.matrix-mode .matrix-labels { position: fixed; z-index: 1; bottom: 1rem; left: 1rem; right: 1rem; padding: var(--sp-3); background: var(--matrix-surface); color: var(--matrix-text); font-size: var(--fs-base); overflow-wrap: anywhere; }
body.matrix-mode .matrix-notice { position: absolute; top: 2rem; left: 1rem; right: 1rem; color: var(--matrix-text); }
body.matrix-mode .matrix-list { position: absolute; inset: 4rem 1rem 8rem; overflow: hidden; }
body.matrix-mode .matrix-list pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0 1rem; }
body.matrix-mode .matrix-list small { color: var(--matrix-muted); }
body.matrix-mode #hive-matrix [hidden] { display: none !important; }
body.matrix-mode #kiosk-cta { z-index: 100001; opacity: .85; }
body.matrix-mode #kiosk-cta { position: fixed; right: 1rem; bottom: 1rem; z-index: 100001; opacity: .85; }
.var-empty{color:var(--muted);font-size:var(--fs-sm);padding:var(--sp-2) var(--sp-0)}
.var-section{margin-top:var(--sp-6);border-top:1px solid var(--border);padding-top:var(--sp-5)}
.var-heading{font-weight:600;font-size:var(--fs-sm);margin-bottom:var(--sp-4)}
Expand Down Expand Up @@ -7262,7 +7262,14 @@
if (!termRows.length) emitTerminal();
termClock += dt * 4;
while (termClock >= 1) { termClock -= 1; emitTerminal(); }
// The QR card can be taller than the freshness HUD. Reserve the full
// overlay band, including after viewport or font-size changes.
var bottom = height - 100;
[labels, document.getElementById('kiosk-cta')].forEach(function(overlay){
if (!overlay) return;
var bounds = overlay.getBoundingClientRect();
if (bounds.height) bottom = Math.min(bottom, bounds.top - rowH);
});
ctx.font = '16px monospace';
termRows.forEach(function(row, i){
var y = bottom - (termRows.length - 1 - i + termClock) * rowH;
Expand Down
Loading