* feat(widget): one conversation with Loki; Watch is in the header for anyone who owns the site
The panel was three tools sharing a box: Request a change (a form), Ask Loki
(an advisor) and Chat, behind tabs and scope chips, each with a history that
vanished on close - and Watch could only be switched on by arriving through
one link on the project page in Loki, so an owner simply visiting their site
never saw it.
Now:
- One thread (widget/conversation.ts). Type, speak, paste a screenshot or
point at an element; Loki answers about this page (one tap: whole site).
Every suggested change, and your own message as written, has Send to
builder / Build this, which opens a confirmation card in the thread; the
receipt (building / track link) lands in the thread.
- The thread is kept per tab (widget/thread.ts, validated on restore), so it
survives the site's own page loads.
- Watch in the header: Review for the owner; for anyone else an explainer
with "This is my site - sign in with Loki", via GET /api/widget/owner,
which checks ownership of the widget's project and returns to the same
page with a pass. The return URL must be on the project's own site
(ownerReturnUrl), so the route cannot hand a pass to someone else's page;
a non-owner lands back with a plain explanation.
- data-fc-modes now only picks who answers: advisor (default), the studio
concierge (chat), or none (report). The owner always gets the advisor.
- widget/loki-api.ts holds the two calls; advise.ts and chat.ts are gone.
Tests: widget-thread (new), owner-note-builds (return-URL guard),
widget-embed-browser 41/41, widget-watch-browser 40/40,
widget-host-avoid-browser 24/24.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(widget): style guard follows the panel's real controls; comment no longer reads as an import
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(widget): Ask Loki for a second opinion; hiding is visible and reversible
Tested the embed in a real browser and found three install/hide defects:
- a `type="module"` tag rendered nothing (document.currentScript is null);
- two copies of the tag rendered two launchers;
- hiding lived only behind a long-press/right-click and was one-way: after a
reload nothing, not even the host's own Loki.report(), brought it back.
Fixes: find the tag by its attribute when currentScript is null; a boot-in-
flight guard keeps one widget per page; "Hide this button on this site" sits
at the foot of the panel with an Undo toast, and #loki, Loki.show(),
report() and ask() all restore it.
New Ask Loki mode (on by default next to "Request a change"): the person the
site was built for asks whether an element, the page or the whole site should
change and why it is the way it is. The widget builds a text outline in the
visitor's browser (a few same-origin pages for "Whole site") and POSTs it to
/api/widget/advise — same token, origin allowlist, rate limits and owner AI
budget as widget chat. The answer may say "leave it"; each recommended change
has "Request this", which prefills Report so advice becomes ordinary
Implement work. data-fc-modes="report" opts a site out.
Tests: scripts/test/widget-embed-browser.ts (real Chromium; fails on the old
bundle) and scripts/test/widget-advise.ts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsT2PtLuBKwgaaBU5pheG8
* refactor(widget): move panel pieces out of main.ts to meet the function-length ratchet
CI lint failed: the main IIFE grew to 597 lines (max-lines-per-function 510).
The success views, scope chips, mode tabs and hide toast move to
widget/panel-views.ts; the counter/Send sync is one helper. No behaviour
change — widget-embed-browser (31) and widget-host-avoid-browser (17) pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsT2PtLuBKwgaaBU5pheG8
---------
Co-authored-by: Claude <noreply@anthropic.com>