mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 00:28:51 +01:00
* chore: add a formatter, matching the style this repo already writes singleQuote=false was chosen by counting this repo's own imports, not by fleet decree. The fleet is genuinely split and the two repos that already had a .prettierrc disagreed with each other, so there was no standard to restore. Quote style does not cross repo boundaries; having a gate does. Markdown is ignored for now — prettier rewraps prose, which would bury the real diff. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * style: format with prettier (1062 files) Mechanical. No behaviour change. This SHA is listed in .git-blame-ignore-revs so `git blame` skips it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * chore: teach git blame to skip the reformat Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(lint): reattach two guards the reformat detached Both effects were one-liners, so a trailing eslint-disable-line covered the setState call: useEffect(() => { setSelected(new Set()); }, [q.length]); // eslint-disable-line ... prettier expanded the block. The comment stayed on the closing line while the call moved above it, so the guard protected nothing and the rule its author had deliberately silenced failed the build. This is the second shape of the same defect — hirnli had the eslint-disable-NEXT-line variant. Both come from the same fact: an eslint directive binds to a line number, so reformatting can silently unbind it, which makes 'mechanical, no behaviour change' false for any bulk reformat. * chore(desktop): bump the runner version the reformat requires desktop-release-drift enforces that anything built into Fleet Runner which differs from the last released tag must carry a version ahead of that tag — main read 0.8.15 and fleet-runner-v0.8.15 already shipped. A whole-repo reformat changes bytes under desktop/, so the gate fires. The alternative was adding desktop/ to .prettierignore, which would buy a quiet PR by carving a permanent hole in the formatter's coverage — the precise shape of silent drift this test was written to catch. Bumping is what the rule asks for and costs one patch release whose only content is whitespace. * chore: merge main and re-format A whole-repo reformat conflicts with any concurrent commit, and a conflicting PR runs no checks at all while reporting nothing. Conflicts resolved to main, which is correct because this branch changes formatting and nothing else. * chore: leave desktop/ out of this reformat desktop-release-drift is right to refuse this. Everything under desktop/ is built into Fleet Runner, so changing it means shipping: bump the version AND add a FLEET_RUNNER_RELEASES entry, whose stated audience is 'person who installed Fleet Runner and wants to know what changed'. For a whitespace-only build the honest answer is 'nothing', so that release should not exist — and I should not write release notes claiming otherwise. I had bumped to 0.8.16 to get the gate green. That was the wrong direction: publishing a build to three OS runners to keep a formatting PR quiet. Reverted. desktop/ is excluded in .prettierignore with the reasoning recorded there, to be formatted alongside the next real runner change, where the bump and the notes are true anyway. --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
180 lines
6.5 KiB
JavaScript
180 lines
6.5 KiB
JavaScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { chromium } from "playwright";
|
|
|
|
const root = process.cwd();
|
|
|
|
function readLocalEnv() {
|
|
const envPath = path.join(root, ".env.local");
|
|
if (!fs.existsSync(envPath)) return;
|
|
for (const line of fs.readFileSync(envPath, "utf8").split(/\r?\n/)) {
|
|
const trimmed = line.trim();
|
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
const idx = trimmed.indexOf("=");
|
|
if (idx === -1) continue;
|
|
const key = trimmed.slice(0, idx);
|
|
const value = trimmed.slice(idx + 1).replace(/^"|"$/g, "");
|
|
if (!process.env[key]) process.env[key] = value;
|
|
}
|
|
}
|
|
|
|
readLocalEnv();
|
|
|
|
const base = process.env.BASE ?? "http://localhost:3000";
|
|
const ownerPassword = process.env.LOCAL_AUTH_PASSWORD;
|
|
const chromePath = process.env.CHROME_PATH || "/usr/bin/google-chrome";
|
|
const outDir = path.join(root, ".tmp", "activity-ssot-check");
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
|
|
async function login(page, callbackUrl = "/control") {
|
|
await page.goto(`${base}/sign-in?callbackUrl=${encodeURIComponent(callbackUrl)}`, {
|
|
waitUntil: "networkidle",
|
|
});
|
|
if (page.url().includes("/sign-in")) {
|
|
const ownerTab = page.getByRole("button", { name: /owner key/i });
|
|
if (await ownerTab.count()) await ownerTab.click();
|
|
if (!ownerPassword) throw new Error("LOCAL_AUTH_PASSWORD is not configured");
|
|
await page.locator('input[type="password"]').first().fill(ownerPassword);
|
|
await page
|
|
.getByRole("button", { name: /sign in|continue|unlock/i })
|
|
.last()
|
|
.click();
|
|
await page.waitForURL((url) => !url.pathname.startsWith("/sign-in"), { timeout: 15000 });
|
|
}
|
|
}
|
|
|
|
async function fetchJson(page, url, options) {
|
|
return page.evaluate(
|
|
async ({ url, options }) => {
|
|
const res = await fetch(url, options);
|
|
const text = await res.text();
|
|
let json = null;
|
|
try {
|
|
json = text ? JSON.parse(text) : null;
|
|
} catch {
|
|
/* caller gets raw text */
|
|
}
|
|
return { ok: res.ok, status: res.status, json, text };
|
|
},
|
|
{ url, options },
|
|
);
|
|
}
|
|
|
|
async function waitForControlPrompt(page, projectTab, token) {
|
|
const deadline = Date.now() + 15000;
|
|
let last = null;
|
|
while (Date.now() < deadline) {
|
|
const res = await fetchJson(page, "/api/control");
|
|
if (!res.ok) throw new Error(`/api/control failed: ${res.status} ${res.text.slice(0, 300)}`);
|
|
last = res.json;
|
|
const recent = last.recentActivity ?? [];
|
|
const project = (last.projects ?? []).find((p) => p.tab === projectTab);
|
|
const inRecent = recent.some((item) => item.displayText?.includes(token));
|
|
const inProject = project?.recentActivity?.some(
|
|
(item) => item.title?.includes(token) || item.detail?.includes(token),
|
|
);
|
|
if (inRecent && inProject) return { control: last, project };
|
|
await page.waitForTimeout(500);
|
|
}
|
|
throw new Error(
|
|
`Timed out waiting for prompt ${token} in /api/control; last payload keys=${Object.keys(last ?? {}).join(",")}`,
|
|
);
|
|
}
|
|
|
|
async function clickVisibleActivityToggles(page) {
|
|
await page
|
|
.getByRole("button", { name: /recent activity/i })
|
|
.first()
|
|
.waitFor({
|
|
state: "visible",
|
|
timeout: 30_000,
|
|
});
|
|
const labels = [/recent activity/i, /^activity/i];
|
|
for (const label of labels) {
|
|
const buttons = page.getByRole("button", { name: label });
|
|
const count = await buttons.count();
|
|
for (let i = 0; i < count; i += 1) {
|
|
const button = buttons.nth(i);
|
|
if (await button.isVisible().catch(() => false)) {
|
|
await button.click().catch(() => {});
|
|
await page.waitForTimeout(100);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
async function assertBodyContains(page, token, context) {
|
|
await page
|
|
.waitForFunction((needle) => document.body.innerText.includes(needle), token, {
|
|
timeout: 15000,
|
|
})
|
|
.catch(async () => {
|
|
await page.screenshot({ path: path.join(outDir, `${context}.png`), fullPage: true });
|
|
const body = await page
|
|
.locator("body")
|
|
.innerText({ timeout: 3000 })
|
|
.catch(() => "");
|
|
throw new Error(`${context} did not render ${token}. Body sample: ${body.slice(0, 500)}`);
|
|
});
|
|
}
|
|
|
|
const browser = await chromium.launch({ headless: true, executablePath: chromePath });
|
|
|
|
try {
|
|
const context = await browser.newContext({
|
|
viewport: { width: 1440, height: 950 },
|
|
deviceScaleFactor: 1,
|
|
});
|
|
const page = await context.newPage();
|
|
await login(page);
|
|
|
|
const controlRes = await fetchJson(page, "/api/control");
|
|
if (!controlRes.ok)
|
|
throw new Error(
|
|
`/api/control initial failed: ${controlRes.status} ${controlRes.text.slice(0, 300)}`,
|
|
);
|
|
const projects = controlRes.json.projects ?? [];
|
|
const project =
|
|
projects.find((p) => p.tab && p.dir && !p.readonly) ?? projects.find((p) => p.tab && p.dir);
|
|
if (!project) throw new Error("No project with tab+dir found in /api/control");
|
|
|
|
const token = `ssot-check-${Date.now()}`;
|
|
const prompt = `Activity SSOT browser regression ${token}: verify Recent Activity, Sent Prompts, and Activity page share one prompt display model.`;
|
|
const captureRes = await fetchJson(page, "/api/activity/capture", {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({ prompt, cwd: project.dir, projectKey: project.tab }),
|
|
});
|
|
if (!captureRes.ok)
|
|
throw new Error(
|
|
`/api/activity/capture failed: ${captureRes.status} ${captureRes.text.slice(0, 300)}`,
|
|
);
|
|
|
|
await waitForControlPrompt(page, project.tab, token);
|
|
|
|
await page.goto(`${base}/control`, { waitUntil: "load" });
|
|
await clickVisibleActivityToggles(page);
|
|
await assertBodyContains(page, token, "control");
|
|
await page.screenshot({ path: path.join(outDir, "control.png"), fullPage: false });
|
|
|
|
await page.goto(`${base}/activity?window=hour&density=detailed`, { waitUntil: "load" });
|
|
await assertBodyContains(page, token, "activity-hour");
|
|
await page.screenshot({ path: path.join(outDir, "activity-hour.png"), fullPage: false });
|
|
|
|
const mobile = await browser.newContext({
|
|
storageState: await context.storageState(),
|
|
viewport: { width: 390, height: 844 },
|
|
isMobile: true,
|
|
deviceScaleFactor: 1,
|
|
});
|
|
const mobilePage = await mobile.newPage();
|
|
await mobilePage.goto(`${base}/activity?window=hour&density=detailed`, { waitUntil: "load" });
|
|
await assertBodyContains(mobilePage, token, "activity-mobile");
|
|
await mobilePage.screenshot({ path: path.join(outDir, "activity-mobile.png"), fullPage: false });
|
|
await mobile.close();
|
|
|
|
console.log(`activity SSOT browser check passed for ${project.tab}: ${token}`);
|
|
} finally {
|
|
await browser.close();
|
|
}
|