mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 15:28:27 +01:00
* feat(widget): the owner's way into Loki — Continue in Loki, an advisor that knows whose site it is, a header that fits a phone On 2026-10-09 the owner of heidi.orangecat.ch opened the widget on their phone and asked for one new page. The widget treated them as a stranger: it told them which heading to insert and to "keep the structure in a data file (JSON/YAML)", wrote five invented sentences in the site's own language, and answered "switch to Loki so I can develop it there with either chat or terminal" with the same advice a third time. The owner's sign-in lived only behind "Watch". Once signed in, Review + Stop watching pushed ✕ off the right edge of the screen. - widget/continue.ts + src/lib/widget/continue.ts: the thread as one message (newest kept, ≤1800 chars) and where it lands in Loki. - GET /api/widget/continue: signs the person in if needed, checks getProjectAccess on the widget's project, resolves the project key and redirects into /loki?project=&q= or /terminal?project=&view=terminal; a stranger goes back to the site with #loki-owner-denied. - widget/conversation.ts: "Continue in Loki · Chat → · Terminal →" under the composer for the owner; one sign-in link for anyone else after their first message; "This is my site — sign in with Loki →" under Loki's greeting, on the first screen. The owner pass travels with each question. - /api/widget/advise + advisor.ts: the pass is verified as ingest verifies it; with it the advisor knows the person OWNS the site and Build this builds. For everyone, four hands-off rules: never explain how to edit the site, never write its content, a build request becomes the one change to tap, and "take this into Loki" is answered with where that control is. - widget/theme.ts: the header's text column shrinks before the actions do; Stop watching stays on one line; the continue row wraps on a phone. - widget/main.ts: the owner is not offered to hide their own tool. - scripts/test/widget-continue.ts (new), widget-advise.ts: pinned. - docs/architecture/feedback-widget.md: the row and the route. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * feat(widget): the loop closes on the site — Your changes, a live announcement, an honest Follow link "On it — Loki tells you when" was the end of the widget's story, and on the site Loki never told anyone: the telling went to push and Telegram, the page the owner came back to said nothing, and "Follow the build" toured the unchanged page with "let me show you what changed". - widget/changes.ts: "Your changes" above the thread for the owner — the project's recent changes with one word each (Building · On its way · Live · Needs you …), See it → once live, Open in Loki → when something needs them, asked for on arrival and every 30 s while something moves. A change this browser saw building that is now live is announced once: in the thread when the panel is open, beside the launcher (bubble + unread) when it is not. - POST /api/widget/owner/changes: the one read with the owner pass. Same attachFeedbackWork the inbox uses, then src/lib/feedback/owner-view.ts writes the owner's words; the work view never leaves the server. No valid pass → no rows. - /feedback/<id>/watch-fix lands on the inbox row while the change is still being built; the walkthrough only once it is live. - The owner's repeated note keeps its follow link. - widget/continue-row.ts, widget/greeting.ts: split out of createConversation (the lint rule caps it at 510 lines; CI caught it at 543). - scripts/test/widget-changes.ts (new); widget-continue.ts updated. - docs/architecture/feedback-widget.md. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * fix(widget): the owner's door is not an .act — the embed test counts those widget-embed-browser asserts exactly one "as written" link (.act) under the visitor's last message; the sign-in door under the greeting shared the class and made it two. Its own class, same look. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * feat(public): three ways in — build it yourself, with a partner, or let the studio — and every stranger's door ends at /build The ways to get something built were scattered: the landing page offered only "Start a project", hiring the studio was a word in the nav, the partner directory was reachable from OrangeCat's careers page and nowhere here, and a stranger who watched a fix land on someone else's site was sent to a bare homepage. "Start a project" at the bottom of six marketing pages went to sign-IN, and so did a stranger arriving with a brief. - src/config/build-paths.ts: the one list — yourself (sign-up), with a partner (bitbaum.orangecat.ch/partners/), the studio (the commission config's hire address) — plus buildPageHref/fromHost. - /build (public, allowlisted): the invitation, naming the site the person came from (validated host only) and the three doors (BuildPaths cards). - Landing: the "Three ways in" section after "Who it is for"; the closing line and FinalCta name the other two ways; FinalCta → sign-up. - /change and /take send a signed-out person to sign-up with the brief kept. - Widget: "Made with Loki — build something of your own →" as the last line for anyone who is not the owner (/build?from=<host>); the tour's "Get this for your site" lands on /build naming the site; the concierge gets the same door (appended last — the test addresses the others by index). - scripts/test/build-paths.ts pins all of it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * fix(widget): /api/widget/continue is public — it signs the person in itself Live, the merged route answered a bare 401: the session middleware caught it before the route could send the person to sign-in. Same list entry as /api/widget/owner, pinned by widget-continue.ts. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * test(audit): /build is measured by the responsive audit A new page has to be a decision — measured, or excluded with a reason. Measured: it is a public page a stranger lands on from a phone. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * fix(widget): yours means yours, a review that picks three, the composer above the keyboard From the owner's phone on 2026-10-09: - "Your changes" listed a stranger's "so nice picture!" as the owner's own request. The strip now shows what the owner asked for and what Loki filed itself; visitors' notes are counted ("3 notes from visitors, in Loki →"). - Review answered with five nits (alt text, a renamed button, a table) and five identical buttons. The rubric now asks for at most three changes a visitor would notice or that fix something broken, and says none is fine. - With the keyboard open the box being typed into sat half behind it; it scrolls into view once the keyboard has settled. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * feat: the first day is the whole product — your website in onboarding, Loki on it, help doors when a build stalls, the terminal hand-off with its text, a launcher that stays in the corner From the owner's phone on 2026-10-09, and the three follow-ups named then: - Onboarding asks for the website (optional). A project created with one (`liveUrl` on POST /api/user-projects) gets its widget token at once, so the token's origin is the site's; the new step "Put Loki on your site" shows the one line to paste, lets an agent add it when there is a repo, and opens the site with the owner pass (`openSiteUrl` on the token route). Finishing lands on the project, not Control. A refused project no longer advances the step in silence. - A stalled build and a failed kickoff offer the other two ways to get it built — find a partner, hire the studio — from the same list as the landing page (GetHelpLine), the studio with the brief. - "Continue in Loki → Terminal" carries the thread: /terminal?q= prefills the rail's composer as an unsent draft, and opens the rail sheet on a phone (the same path ?explain=1 takes). - The launcher stays in the corner: a near slot over plain text beats a free slot mid-page (heidi.orangecat.ch: the site's own bar took one corner and the launcher floated beside a heading). A near sheet still sends it climbing. - Page checks: a small-caps label by design is not a defect, 11.84px is not under 12, and one kind of finding is one card (the signature drops counts and examples; "30 pieces" then "6 pieces" were two cards). Tests: onboarding-site-step.ts (new), widget-placement.ts, widget-watch.ts, widget-continue.ts, build-paths.ts; all widget browser suites pass locally. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * refactor(widget): keepInViewOnFocus lives in dom.ts — createConversation back under the 510-line cap after the merge Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z * fix(widget): import keepInViewOnFocus — the panel threw at mount and boot swallowed it An unimported identifier compiles fine with esbuild and fails at run time; boot's catch hid it, so the launcher rendered and the panel never opened. Caught by widget-embed-browser. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1Yw4cCwXWRP2S5Hj62u2Z --------- Co-authored-by: Claude <noreply@anthropic.com>
116 lines
4.6 KiB
TypeScript
116 lines
4.6 KiB
TypeScript
// The three ways to get something built — yourself, with a partner, by the
|
|
// studio — are one list (config/build-paths.ts), and every door a newcomer
|
|
// meets ends in it. Pinned here: the list is exactly those three and each
|
|
// points at a real address; /build is public and names the site the person
|
|
// came from without trusting it; the landing page and the final CTA carry the
|
|
// doors; the tour's "Get this for your site" and the widget's "made with"
|
|
// line both land on /build; and no "Start a project" sends a newcomer to
|
|
// sign-IN (it did, on six marketing pages, for months).
|
|
// Run: npx tsx scripts/test/build-paths.ts
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { BUILD_PAGE, BUILD_PATHS, buildPageHref, fromHost } from "@/config/build-paths";
|
|
import { COMMISSION } from "@/config/commission";
|
|
import { ROUTES } from "@/config/auth";
|
|
import { STUDIO_DOORS } from "@/lib/widget-chat/concierge";
|
|
|
|
// ---- the list ----
|
|
assert.deepEqual(
|
|
BUILD_PATHS.map((p) => p.id),
|
|
["yourself", "partner", "studio"],
|
|
"three ways, in the order a person would try them",
|
|
);
|
|
const byId = Object.fromEntries(BUILD_PATHS.map((p) => [p.id, p]));
|
|
assert.equal(
|
|
byId.yourself.href,
|
|
ROUTES.SIGN_UP,
|
|
"doing it yourself starts at sign-up, not sign-in",
|
|
);
|
|
assert.equal(
|
|
byId.partner.href,
|
|
"https://bitbaum.orangecat.ch/partners/",
|
|
"the partner directory is the one list, on bitbaum",
|
|
);
|
|
assert.equal(
|
|
byId.studio.href,
|
|
COMMISSION.studioHireUrl,
|
|
"hiring the studio is the commission config's address",
|
|
);
|
|
for (const p of BUILD_PATHS) {
|
|
for (const field of ["who", "title", "body", "cta"] as const)
|
|
assert.ok(p[field].trim(), `${p.id}.${field}`);
|
|
assert.ok(!/\bsats?\b|crypto/i.test(p.body), "house words");
|
|
}
|
|
|
|
// ---- /build and the link to it ----
|
|
assert.equal(BUILD_PAGE.path, "/build");
|
|
assert.equal(
|
|
buildPageHref("https://loki.test", "heidi.orangecat.ch"),
|
|
"https://loki.test/build?from=heidi.orangecat.ch",
|
|
);
|
|
assert.equal(
|
|
buildPageHref("https://loki.test", "https://heidi.orangecat.ch/de/situations/x"),
|
|
"https://loki.test/build?from=heidi.orangecat.ch",
|
|
"an origin or a URL is reduced to its host",
|
|
);
|
|
assert.equal(buildPageHref("https://loki.test", null), "https://loki.test/build");
|
|
assert.equal(
|
|
buildPageHref("https://loki.test", "<script>"),
|
|
"https://loki.test/build",
|
|
"junk is dropped, not carried",
|
|
);
|
|
assert.equal(fromHost("heidi.orangecat.ch"), "heidi.orangecat.ch");
|
|
assert.equal(fromHost("evil.example/path"), null, "only a hostname is named on the page");
|
|
assert.equal(fromHost(["a.b", "c.d"]), "a.b");
|
|
assert.equal(fromHost("localhost"), null, "a bare word is not a site");
|
|
|
|
// ---- every door ends here ----
|
|
const proxy = readFileSync("src/proxy.ts", "utf8");
|
|
assert.match(proxy, /\|build\(\?:\/\|\$\)\|/, "/build is public");
|
|
const landing = readFileSync("src/app/page.tsx", "utf8");
|
|
assert.match(landing, /<BuildPaths /, "the landing page shows the three doors");
|
|
assert.match(landing, /href=\{BUILD_PAGE\.path\}/, "and the closing line names the other two ways");
|
|
const finalCta = readFileSync("src/components/public/FinalCta.tsx", "utf8");
|
|
assert.match(finalCta, /ROUTES\.SIGN_UP/, "Start a project goes to sign-up");
|
|
assert.ok(!/ROUTES\.SIGN_IN/.test(finalCta), "never to sign-in");
|
|
for (const brief of [
|
|
"src/components/public/TakeRepoBrief.tsx",
|
|
"src/components/public/WebsiteChangeBrief.tsx",
|
|
]) {
|
|
const src = readFileSync(brief, "utf8");
|
|
assert.ok(
|
|
!/ROUTES\.SIGN_IN\}\?callbackUrl/.test(src),
|
|
`${brief}: a stranger with a brief is sent to sign-up`,
|
|
);
|
|
assert.match(src, /ROUTES\.SIGN_UP\}\?callbackUrl/, `${brief}: with the brief kept`);
|
|
}
|
|
const tour = readFileSync("src/app/api/widget/tour/route.ts", "utf8");
|
|
assert.match(
|
|
tour,
|
|
/buildPageHref\(appUrl\(\), from\)/,
|
|
"a viewer who watched a fix land is invited to /build, naming the site",
|
|
);
|
|
const main = readFileSync("widget/main.ts", "utf8");
|
|
assert.match(
|
|
main,
|
|
/\/build\?from=\$\{encodeURIComponent\(location\.hostname\)\}/,
|
|
"the widget's made-with line lands on /build",
|
|
);
|
|
assert.match(
|
|
main,
|
|
/madeWith\.style\.display = ownerPass \? "none" : ""/,
|
|
"and the owner does not see it",
|
|
);
|
|
const door = STUDIO_DOORS.find((d) => d.label === "Build something of your own");
|
|
assert.ok(door, "the concierge can hand out Loki's own door");
|
|
assert.ok(door!.url.endsWith("/build"), door!.url);
|
|
assert.equal(
|
|
STUDIO_DOORS[STUDIO_DOORS.length - 1],
|
|
door,
|
|
"appended last: the concierge test addresses the others by index",
|
|
);
|
|
const page = readFileSync("src/app/build/page.tsx", "utf8");
|
|
assert.match(page, /fromHost\(from\)/, "the page names only a validated host");
|
|
|
|
console.log("build-paths: ok");
|