mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:59:11 +01:00
The owner (2026-10-18): the widget looked different on different pages
and sites, it should always be clear when Loki is watching, and they want
to record comments while it watches and implement them afterwards.
One widget, everywhere
- Loki's own site draws the same panel every customer site gets, not the
chatkit view (data-fc-chat="kit" stays an opt-in).
- No Loki page hides the launcher any more: the project workspace, the
agent conversation, inspection, the project loading state and an open
/loki conversation were "hidden" — no launcher, or the watch top bar
instead. They show the edge tab. feedback-widget-reach fails on any
page that hides it, in either the literal or the expression form;
only an open dialog and the sign-in wall may.
The state in every shape
- The owner's edge tab carries the same live dot and ring as the corner
pill, at full weight.
- The owner's pill sits in a bottom corner or becomes the tab; it no
longer climbs to the middle or top of the screen (Heidi at 390px).
Record now, build later
- After a voice note the owner's card leads with Save (then Fix it now,
Ask). Saved notes lead the status line ("Watching · 3 notes saved"),
and "Build all 3 saved notes" starts each as its own build, oldest
first: POST /api/widget/owner/build, rule in lib/feedback/saved-notes.ts.
- The owner check for the widget's owner routes is one helper,
lib/widget/owner-request.ts, used by owner/changes and owner/build.
Claude-Session: https://claude.ai/code/session_01E1qoQ9syUYXCRNbyrpqPGa
Co-authored-by: Claude <noreply@anthropic.com>
65 lines
2.4 KiB
TypeScript
65 lines
2.4 KiB
TypeScript
/**
|
|
* Who may act as the site's owner in its widget: the owner and the project's
|
|
* editors — nobody else, and never for another project.
|
|
*
|
|
* Run: npx tsx scripts/test/widget-pass-holder.ts
|
|
*/
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { passAllows } from "../../src/lib/feedback/pass-rule";
|
|
|
|
const site = { projectId: "p1", userId: "owner" };
|
|
assert.ok(passAllows({ projectId: "p1", userId: "owner" }, site, false), "the owner");
|
|
assert.ok(passAllows({ projectId: "p1", userId: "editor" }, site, true), "an editor");
|
|
assert.ok(!passAllows({ projectId: "p1", userId: "viewer" }, site, false), "not a viewer");
|
|
assert.ok(
|
|
!passAllows({ projectId: "p2", userId: "owner" }, site, true),
|
|
"not another project's pass",
|
|
);
|
|
assert.ok(!passAllows(null, site, true), "not without a pass");
|
|
|
|
// Every route that honours a pass asks the same question.
|
|
for (const route of [
|
|
"src/app/api/feedback/route.ts",
|
|
"src/app/api/widget/advise/route.ts",
|
|
"src/app/api/widget/self-report/route.ts",
|
|
"src/lib/widget/owner-request.ts",
|
|
]) {
|
|
assert.match(readFileSync(route, "utf8"), /passHolder\(/, `${route} uses passHolder`);
|
|
}
|
|
// The owner-only widget routes ask through that one helper.
|
|
for (const route of [
|
|
"src/app/api/widget/owner/changes/route.ts",
|
|
"src/app/api/widget/owner/build/route.ts",
|
|
]) {
|
|
assert.match(readFileSync(route, "utf8"), /ownerRequest\(req, /, `${route} uses ownerRequest`);
|
|
}
|
|
assert.match(
|
|
readFileSync("src/app/api/widget/owner/route.ts", "utf8"),
|
|
/canActForSite\(/,
|
|
"issuing a pass uses the same rule",
|
|
);
|
|
|
|
console.log("widget-pass-holder: ok");
|
|
|
|
// Who is handed a pass on the project page — the rule behind "a Builder's
|
|
// note on the site builds at once; a viewer's waits for the owner".
|
|
import { mayHoldPass } from "../../src/lib/feedback/pass-rule";
|
|
assert.ok(mayHoldPass("owner"));
|
|
assert.ok(mayHoldPass("editor"), "a Builder holds a pass");
|
|
assert.ok(!mayHoldPass("viewer"));
|
|
assert.ok(!mayHoldPass("client"));
|
|
assert.ok(!mayHoldPass(null));
|
|
assert.match(
|
|
readFileSync("src/app/(app)/projects/[id]/page.tsx", "utf8"),
|
|
/mayHoldPass\(dossier\.viewerRole\)/,
|
|
"the project page issues passes by that rule",
|
|
);
|
|
// Who asked is recorded from the pass, so the owner's inbox and the Builder's
|
|
// own list both know it without a claim.
|
|
assert.match(
|
|
readFileSync("src/app/api/feedback/route.ts", "utf8"),
|
|
/reporterUserId: holder\?\.userId/,
|
|
"ingest records the pass holder as the reporter",
|
|
);
|