fix: phones render plain data tables as stacked cards (1.5.8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-15 20:30:18 -03:00
1 parent 393a31cebe
commit bc3ce09088
8 files changed
+123 -2

No files matched your search

+4
View File
@@ -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
+55
View File
@@ -0,0 +1,55 @@
// Mobile table check: node tables.mjs <hub-url> <out-dir>
// 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);