mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-05 13:37:18 +01:00
From the phone: the header's feedback button duplicated the widget's own edge tab beside it; "+" scrolled off the right edge with two sessions open; the key deck had no way out but the faint round button it came from, and the owner refreshed the page to be rid of it; "Starting Claude in …" after Start was a sentence with no spinner and read as a dead end. - The terminal header has no feedback button. The widget's edge tab is on the page and is the one launcher. - "+" sits outside the scrolling session row and keeps its place. - The key deck's lane starts with a hide cap, and the corner button is solid when the keys are up. - After Start, a spinner and "Opening Claude in … — the session appears here in a moment". Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx Co-authored-by: Claude <noreply@anthropic.com>
153 lines
6.0 KiB
TypeScript
153 lines
6.0 KiB
TypeScript
// A user of Loki must be able to report a bug in Loki.
|
|
//
|
|
// The widget was scoped to eleven public marketing routes, on the stated
|
|
// grounds that "in-app feedback already has Loki". That was not true:
|
|
// insertSiteFeedback has exactly one caller — the widget's ingest route — and
|
|
// Loki has no feedback capability at all. So every signed-in user, on every
|
|
// app page, had no structured way to report anything. The omission was
|
|
// invisible, which is the failure mode this whole product exists to fix.
|
|
//
|
|
// The rule is now an exclusion list, so a NEW page ships with feedback by
|
|
// default instead of silently shipping without it. This test pins that
|
|
// direction: the app surfaces must be covered, the excluded ones must stay
|
|
// excluded, and Loki must not be cited as the in-app answer while it cannot
|
|
// file anything.
|
|
// Run: npx tsx scripts/test/feedback-widget-reach.ts
|
|
import { readdirSync, readFileSync } from "fs";
|
|
import { join, dirname } from "path";
|
|
import { fileURLToPath } from "url";
|
|
import {
|
|
isFeedbackWidgetRoute,
|
|
FEEDBACK_WIDGET_EXCLUDED_PREFIXES,
|
|
} from "../../src/config/feedback-widget";
|
|
|
|
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
|
|
let pass = 0;
|
|
let fail = 0;
|
|
function ok(cond: boolean, label: string) {
|
|
if (cond) {
|
|
pass++;
|
|
} else {
|
|
fail++;
|
|
console.error(`✗ ${label}`);
|
|
}
|
|
}
|
|
|
|
// The surfaces a signed-in operator actually works on. Each of these is a
|
|
// place someone can hit a bug, so each must be able to report one.
|
|
const APP_SURFACES = [
|
|
"/today",
|
|
"/control",
|
|
"/projects",
|
|
"/projects/5c0ea00f-d098-49a0-aae5-c83b8f4be79c",
|
|
"/feedback",
|
|
"/activity",
|
|
"/goals",
|
|
"/people",
|
|
"/crew",
|
|
"/money",
|
|
"/habits",
|
|
"/prompts",
|
|
"/system",
|
|
"/settings",
|
|
"/approvals",
|
|
];
|
|
for (const path of APP_SURFACES) {
|
|
ok(isFeedbackWidgetRoute(path), `widget reaches ${path}`);
|
|
}
|
|
|
|
// Public pages keep it too — that was never in question, but a rewrite of the
|
|
// matcher could easily drop them.
|
|
for (const path of ["/", "/pricing", "/thoughts", "/thoughts/some-essay"]) {
|
|
ok(isFeedbackWidgetRoute(path), `widget still reaches public ${path}`);
|
|
}
|
|
|
|
// The exclusions must actually exclude, including nested paths.
|
|
for (const p of FEEDBACK_WIDGET_EXCLUDED_PREFIXES) {
|
|
ok(!isFeedbackWidgetRoute(p), `excluded: ${p}`);
|
|
ok(!isFeedbackWidgetRoute(`${p}/nested`), `excluded: ${p}/nested`);
|
|
}
|
|
|
|
// /terminal and /loki reach the widget without a corner button over the PTY or
|
|
// the composer: both pages ask for the edge-tab shape (loki#1037). Never
|
|
// "hidden" — a page where the launcher silently is not there is exactly the
|
|
// unpredictability this rule exists to end.
|
|
for (const [route, file] of [
|
|
["/terminal", "src/app/(app)/terminal/page.tsx"],
|
|
["/loki", "src/app/(app)/loki/page.tsx"],
|
|
] as const) {
|
|
ok(isFeedbackWidgetRoute(route), `widget reaches ${route}`);
|
|
const src = readFileSync(join(ROOT, file), "utf8");
|
|
ok(/data-fc-place="tab"/.test(src), `${route} draws the launcher as the edge tab`);
|
|
ok(!/data-fc-place="hidden"/.test(src), `${route} does not hide the launcher`);
|
|
}
|
|
// …and no other page hides it either. Three did (the project workspace, the
|
|
// agent conversation, inspection — #1201, #1203, #1211), and on each the owner
|
|
// lost the launcher that says Loki is watching, or got the watch top bar
|
|
// instead: "on some pages it's one, on other pages a different looking one"
|
|
// (owner, 2026-10-18). Hidden is for an open dialog and the sign-in wall only.
|
|
{
|
|
const HIDE_ALLOWED = new Set([
|
|
"src/components/ui/modal.tsx",
|
|
"src/components/auth/AuthShell.tsx",
|
|
]);
|
|
const walk = (dir: string): string[] =>
|
|
readdirSync(join(ROOT, dir), { withFileTypes: true }).flatMap((e) =>
|
|
e.isDirectory()
|
|
? walk(`${dir}/${e.name}`)
|
|
: /\.tsx?$/.test(e.name)
|
|
? [`${dir}/${e.name}`]
|
|
: [],
|
|
);
|
|
const hiders = walk("src")
|
|
.filter((f) => !f.startsWith("src/app/docs/"))
|
|
// The literal and the expression form (`data-fc-place={x ? "hidden" : …}`).
|
|
.filter((f) =>
|
|
/data-fc-place=(?:"hidden"|\{[^}]*"hidden")/.test(readFileSync(join(ROOT, f), "utf8")),
|
|
)
|
|
.filter((f) => !HIDE_ALLOWED.has(f));
|
|
ok(hiders.length === 0, `no page hides the launcher (found: ${hiders.join(", ") || "none"})`);
|
|
}
|
|
// The terminal page reaches the panel through the widget's own edge tab,
|
|
// and nowhere else: a header button to the same panel read as a second,
|
|
// unexplained thing beside it (owner, 2026-10-19).
|
|
ok(
|
|
/data-fc-place="tab"/.test(readFileSync(join(ROOT, "src/app/(app)/terminal/page.tsx"), "utf8")),
|
|
"the terminal page shows the launcher as the edge tab",
|
|
);
|
|
ok(
|
|
!/openFeedback\(/.test(
|
|
readFileSync(join(ROOT, "src/components/terminal/TerminalMobileHeader.tsx"), "utf8"),
|
|
),
|
|
"and the terminal header has no second button to the same panel",
|
|
);
|
|
|
|
// A near-miss must NOT be excluded — prefix matching that swallows unrelated
|
|
// routes is how an allowlist quietly loses pages.
|
|
ok(isFeedbackWidgetRoute("/settings"), "/settings is an app page, not an auth page");
|
|
|
|
// /loki was excluded once, measured: at 390px the corner launcher's centre
|
|
// resolved to `textarea.ui-loki-composer-input`. The edge tab (asserted above)
|
|
// keeps it off the composer, so the page is back in.
|
|
ok(isFeedbackWidgetRoute("/lokis"), "/lokis is a page like any other");
|
|
|
|
// The claim that justified the old scoping must not silently return. If Loki
|
|
// ever does gain the ability to file feedback, this test should be revisited
|
|
// deliberately rather than the assumption creeping back.
|
|
const loki = readFileSync(join(ROOT, "src/lib/loki-core.ts"), "utf8");
|
|
ok(
|
|
!/insertSiteFeedback/.test(loki),
|
|
"loki-core still cannot file feedback — the reason the widget must reach the app",
|
|
);
|
|
|
|
// The widget mounts from the ROOT layout, so coverage is not per-page opt-in.
|
|
const layout = readFileSync(join(ROOT, "src/app/layout.tsx"), "utf8");
|
|
ok(
|
|
/DogfoodFeedbackWidget/.test(layout),
|
|
"the widget is mounted in the root layout, so new pages get it for free",
|
|
);
|
|
|
|
console.log(`${pass} passed, ${fail} failed`);
|
|
process.exit(fail === 0 ? 0 : 1);
|