From bc3ce09088d9d15f0641b5020c80cb1b472e76d0 Mon Sep 17 00:00:00 2001 From: Lucas Rayan Date: Sun, 15 Nov 2026 20:30:18 -0300 Subject: [PATCH] fix: phones render plain data tables as stacked cards (1.5.8) Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 6 ++++ CHANGELOG.pt-BR.md | 6 ++++ internal/app/version.go | 2 +- internal/server/web/app.js | 33 ++++++++++++++++++++ internal/server/web/protocol.js | 2 +- internal/server/web/style.css | 17 ++++++++++ scripts/screenshots.sh | 4 +++ scripts/screenshots/tables.mjs | 55 +++++++++++++++++++++++++++++++++ 8 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 scripts/screenshots/tables.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index eb9a54a..6c0e501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow SemVer. +## [1.5.8] - 2026-11-15 + +### Fixed + +- Phones: plain data tables (Concentration ranking, Errors routes, MITRE techniques, Defense, Integrity sources, and any other table without its own phone layout) rendered as squeezed columns with IPs broken letter by letter or sideways scrolling. Under 768 px their rows now become stacked cards with the column name as label, right-aligned numbers and long text wrapping; desktop is unchanged. One shared rule in `style.css` plus `cardTables()` in `app.js` covers all of them. `TABLES_ONLY=1 scripts/screenshots.sh` captures every table page at 375x812 and checks for horizontal overflow. + ## [1.5.7] - 2026-11-15 ### Fixed diff --git a/CHANGELOG.pt-BR.md b/CHANGELOG.pt-BR.md index b878258..62913b2 100644 --- a/CHANGELOG.pt-BR.md +++ b/CHANGELOG.pt-BR.md @@ -4,6 +4,12 @@ Formato baseado no [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/); versionamento segue SemVer. +## [1.5.8] - 2026-11-15 + +### Corrigido + +- Celular: tabelas de dados comuns (ranking da Concentração, rotas de Erros, técnicas MITRE, Defesa, fontes da Integridade e qualquer outra sem layout próprio para celular) apareciam com colunas espremidas, IPs quebrados letra por letra ou rolagem lateral. Abaixo de 768 px as linhas agora viram cartões empilhados com o nome da coluna como rótulo, números alinhados à direita e texto longo quebrando; o desktop não muda. Uma regra única em `style.css` e `cardTables()` em `app.js` cobre todas. `TABLES_ONLY=1 scripts/screenshots.sh` captura todas as páginas com tabela em 375x812 e verifica estouro horizontal. + ## [1.5.7] - 2026-11-15 ### Corrigido diff --git a/internal/app/version.go b/internal/app/version.go index 13cf697..4d0e0e5 100644 --- a/internal/app/version.go +++ b/internal/app/version.go @@ -2,4 +2,4 @@ package app // Version is the release version (SemVer). Release builds may override it with // -ldflags "-X .../internal/app.Version=...". -var Version = "1.5.7" +var Version = "1.5.8" diff --git a/internal/server/web/app.js b/internal/server/web/app.js index aa48b32..a9f8827 100644 --- a/internal/server/web/app.js +++ b/internal/server/web/app.js @@ -2011,6 +2011,39 @@ } if (current) { try { current.page.unmount(); } catch (e) { console.error(e); } } var view = $('#view'); + // Mobile tables: every plain data table of a page gets data-label on its cells (from the header) + // and the class "mc"; style.css turns those rows into stacked cards under 768 px. Tables that + // already handle phones (stack, tbl-cards, eg-table, ipx-tbl, no-mc) and the sr-only chart tables are skipped. + function cardTables() { + var tabs = view.querySelectorAll('table:not(.sr-only):not(.stack):not(.tbl-cards):not(.eg-table):not(.ipx-tbl):not(.no-mc):not(.mc)'); + for (var i = 0; i < tabs.length; i++) { + var tb = tabs[i], hr = tb.querySelector('thead tr'); + if (!hr) continue; + var labels = [].map.call(hr.children, function (c) { return (c.textContent || '').trim(); }); + [].forEach.call(tb.tBodies, function (body) { + [].forEach.call(body.rows, function (r) { + var k = 0; + [].forEach.call(r.cells, function (c) { + if (!c.hasAttribute('data-label')) c.setAttribute('data-label', labels[k] || ''); + if (c.childNodes.length > 1) { // one flex item per cell, so mixed content flows as text + var w = document.createElement('span'); + w.className = 'mc-v'; + while (c.firstChild) w.appendChild(c.firstChild); + c.appendChild(w); + } + k += c.colSpan || 1; + }); + }); + }); + tb.classList.add('mc'); + } + } + var cardQueued = false; + new MutationObserver(function () { + if (cardQueued) return; + cardQueued = true; + requestAnimationFrame(function () { cardQueued = false; cardTables(); }); + }).observe(view, { childList: true, subtree: true }); clear(view); state.note = ''; var page = pages[id]; diff --git a/internal/server/web/protocol.js b/internal/server/web/protocol.js index fb87bbf..4ae6b98 100644 --- a/internal/server/web/protocol.js +++ b/internal/server/web/protocol.js @@ -114,7 +114,7 @@ tb.appendChild(el('tr', null, el('td', { class: 'mono' }, m.method, m.odd ? U.ui.badge(t('hl.pr.odd'), 'warn') : null, el('div', { class: 'hl-brk-m' }, brk)), el('td', { class: 'num' }, U.fmt.num(m.n)), el('td', { class: 'num' }, U.fmt.num(errs)), el('td', { class: 'hl-brk' }, brk))); }); - pm.body.appendChild(el('div', { class: 'hl-scroll' }, el('table', { class: 'hl-table' }, + pm.body.appendChild(el('div', { class: 'hl-scroll' }, el('table', { class: 'hl-table no-mc' }, el('thead', null, el('tr', null, el('th', null, t('hl.pr.col.method')), el('th', { class: 'num' }, t('hl.pr.col.n')), el('th', { class: 'num' }, t('hl.pr.col.errs')), el('th', { class: 'hl-brk' }, ''))), tb))); } function load() { diff --git a/internal/server/web/style.css b/internal/server/web/style.css index a5dfd75..84670c1 100644 --- a/internal/server/web/style.css +++ b/internal/server/web/style.css @@ -673,3 +673,20 @@ html, body { overflow-x: clip; } .unban-opt { display: flex; align-items: center; gap: 8px; } .unban-err { color: var(--bad, #b3261e); margin: 8px 0 0; } .unban-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; } + +/* Plain data tables on phones: rows become stacked cards (labels from data-label, set by cardTables() in app.js). */ +@media (max-width: 767px) { + .an-scroll, .df-scroll, .hl-scroll { overflow-x: hidden; max-width: 100%; } + .ig-scroll, .mt-tablewrap { overflow: visible; max-width: 100%; } + table.mc { min-width: 0 !important; } + table.mc thead { display: none; } + table.mc, table.mc tbody, table.mc tr, table.mc td { display: block; width: 100%; box-sizing: border-box; } + table.mc tr { margin: 6px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-raised); } + table.mc td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border: 0; padding: 2px 0; text-align: right; min-width: 0; overflow-wrap: anywhere; word-break: normal; white-space: normal; } + table.mc td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--ink-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; text-align: left; } + table.mc td[data-label=""]::before { display: none; } + table.mc td.num, table.mc td.num * { font-variant-numeric: tabular-nums; } + table.mc td.an-key, table.mc td .mono { overflow-wrap: anywhere; word-break: break-all; } + table.mc td[colspan] { display: block; text-align: left; } +} +@media (max-width: 767px) { table.mc .mc-v { min-width: 0; overflow-wrap: anywhere; word-break: normal; } } diff --git a/scripts/screenshots.sh b/scripts/screenshots.sh index fba3363..14ebeb4 100755 --- a/scripts/screenshots.sh +++ b/scripts/screenshots.sh @@ -98,6 +98,10 @@ done pids+=($!) sleep 6 +if [ -n "${TABLES_ONLY:-}" ]; then + # mobile table check (375x812) instead of the documentation pictures: TABLES_ONLY=1 OUT=/tmp/x scripts/screenshots.sh + node "$root/scripts/screenshots/tables.mjs" "http://127.0.0.1:$hub_port" "$out"; exit $? +fi node "$root/scripts/screenshots/shots.mjs" "http://127.0.0.1:$hub_port" "http://127.0.0.1:$login_port" "$out" if command -v oxipng >/dev/null; then oxipng -q -o 3 --strip safe "$out"/*.png diff --git a/scripts/screenshots/tables.mjs b/scripts/screenshots/tables.mjs new file mode 100644 index 0000000..44cabbb --- /dev/null +++ b/scripts/screenshots/tables.mjs @@ -0,0 +1,55 @@ +// Mobile table check: node tables.mjs +// Captures every page that has a visible table at 375x812 (plus one desktop control), +// and reports document scrollWidth and tables that overflow their container. +import { execFileSync } from "node:child_process"; +import { homedir } from "node:os"; + +const [hub, out] = process.argv.slice(2); +const core = process.env.PUPPETEER_CORE || `${homedir()}/.claude/tools/node_modules/puppeteer-core/lib/esm/puppeteer/puppeteer-core.js`; +const { default: puppeteer } = await import(core); +const chrome = process.env.CHROME || execFileSync("bash", ["-c", `ls -1d "$HOME"/.cache/puppeteer/chrome/*/chrome-linux64/chrome | sort -V | tail -1`], { encoding: "utf8" }).trim(); +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); +const PHONE = { width: 375, height: 812, deviceScaleFactor: 2, isMobile: true, hasTouch: true }; +const DESKTOP = { width: 1440, height: 900, deviceScaleFactor: 1 }; +const IP = "203.0.113.45"; +async function firstCampaign() { + const j = await (await fetch(`${hub}/api/v1/campaigns?range=30d`)).json(); + return encodeURIComponent(((j.campaigns || [])[0] || {}).id || ""); +} +const pages = [ + ["overview", "overview?r=7d"], ["ips", "ips?r=7d"], ["sources", "sources?r=24h"], ["ip-analysis", `ip/${IP}?r=7d`], + ["sessions", "sessions?r=7d"], ["campaigns", "campaigns?r=30d"], ["campaign-detail", async () => `campaigns/${await firstCampaign()}?r=30d`], + ["search", `search?r=7d&ip=${IP}`], ["mitre", "mitre?r=30d"], ["defense", "defense?r=7d"], ["evolution", "evolution?r=30d"], + ["concentration", "concentration?r=30d"], ["survival", "survival?r=30d"], ["errors", "errors?r=7d"], ["slo", "slo?r=7d"], + ["protocol", "protocol?r=7d"], ["integrity", "integrity?r=7d"], ["reports", "reports?r=7d"], ["egress", "egress?r=7d"], + ["incidents", "incidents"], ["geo", "geo?r=30d"], ["live", "live?r=24h"], ["replay", "replay?r=2d"], ["threats", "threats?r=24h"], ["traffic", "traffic?r=30d"], +]; +const browser = await puppeteer.launch({ executablePath: chrome, args: ["--no-sandbox", "--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader"], defaultViewport: DESKTOP }); +let bad = 0; +async function run(id, route, vp, suffix) { + const page = await browser.newPage(); + await page.setViewport(vp); + await page.evaluateOnNewDocument(() => { try { localStorage.setItem("urutau.theme", "dark"); localStorage.setItem("urutau.lang", "en"); localStorage.setItem("urutau.host", "all"); } catch {} }); + const hash = "#/" + (typeof route === "function" ? await route() : route); + await page.goto(hub + "/", { waitUntil: "domcontentloaded" }); + await page.goto(hub + "/" + hash, { waitUntil: "domcontentloaded" }); + await page.evaluate((h) => { location.hash = h; }, hash); + try { await page.waitForFunction(() => { const v = document.querySelector("#view"); return v && (v.innerText || "").trim().length > 80 && !v.querySelector(".skeleton"); }, { timeout: 20000, polling: 300 }); } catch {} + await sleep(2500); + const r = await page.evaluate(() => { + const tabs = [...document.querySelectorAll("#view table")].filter((t) => !t.classList.contains("sr-only") && t.offsetParent !== null); + const over = tabs.filter((t) => { let p = t.parentElement; return t.scrollWidth > (p ? p.clientWidth : 0) + 1 || t.getBoundingClientRect().right > innerWidth + 1; }).map((t) => t.className || "(no class)"); + return { sw: document.documentElement.scrollWidth, tables: tabs.length, over }; + }); + const ok = r.sw <= vp.width && (vp.width > 500 || r.over.length === 0); + if (!ok && vp.width < 500) bad++; + console.log(`${suffix} ${id.padEnd(16)} tables=${r.tables} scrollWidth=${r.sw} overflow=[${r.over}] ${ok ? "OK" : "BAD"}`); + if (r.tables > 0) await page.screenshot({ path: `${out}/tbl-${id}-${suffix}.png`, fullPage: true }); + await page.close(); +} +try { + for (const [id, route] of pages) await run(id, route, PHONE, "m375"); + await run("concentration", "concentration?r=30d", DESKTOP, "desktop"); + await run("ips", "ips?r=7d", DESKTOP, "desktop"); +} finally { await browser.close(); } +process.exit(bad ? 1 : 0);