The launcher knew its corner, an offset, a global data-fc-bottom and one foreign fixed launcher. Everything else it could miss: any layer wider than 90% of the viewport was ignored, so on substrata /atlas at 390px it parked on the country bottom sheet; and it re-measured only on load, resize, window scroll and URL change, so a sheet mounted later was never seen. One engine now, for every width and obstacle: - placement.slotOrder: preferred corner up its near band, the mirrored corner, then the rest of each edge (pure, unit-tested). - host-scan: hit-tests each slot (launcher + 12px gap) with elementsFromPoint and judges free / surface / layer / blocked. Controls (incl. [tabindex], iframes, cursor:pointer) block; fixed/sticky bars and inner scroll panels are layers; a control >=25% of the viewport (a pannable map) is a surface. - placement.chooseSlot: first free, else least-bad, else HIDE - never sit on a control. - Re-measures on DOM mutation (throttled 1/s) and on inner-panel scroll. - Host contract: data-fc-avoid (never overlap), data-fc-place= left|right|hidden on <html> or a page region. Documented in widget/README.md. Also fixes a latent bug the browser test caught: clearing inline edges to "" let the shadow stylesheet's right:16px survive a move to a LEFT corner, so "Move to other corner" stretched the launcher across the page. Tests: widget-placement.ts (pure) and widget-host-avoid-browser.ts (real Chromium, 9 fixtures). Against the pre-fix bundle 7 assertions fail; each new rule (layer, surface) fails its fixture when mutated out. CI installs chromium-headless-shell so the browser test runs rather than skips. Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Loki feedback widget — embedding it
The bundle every site loads as <script src="https://loki.orangecat.ch/widget.js" data-fc-project="fcw_…" async></script>. Architecture, routes and history:
docs/architecture/feedback-widget.md.
This file is the part a HOST needs: where the launcher goes, and how to tell it.
Where the launcher sits
Nothing to configure for the common case. On load, on resize, after any scroll (including inner panels), on SPA navigation and on DOM changes (throttled to one pass a second) the launcher measures its candidate slots and takes the best:
- the configured corner (operator placement from boot; default bottom-right, 16px), climbing its edge up to 260px;
- the mirrored corner on the same edge, same band;
- the rest of each edge.
Each slot is hit-tested over the launcher plus a 12px gap and judged:
| verdict | what is under it | used |
|---|---|---|
| free | nothing of yours that matters (in-flow text, background) | first one wins |
| surface | a corner of a control ≥ 25% of the viewport — a pannable map, a canvas, a card-sized link | only if no slot is free |
| layer | a fixed/sticky bar, a bottom sheet, an inner scroll panel (anything < 60% of the viewport) | only if no free or surface slot |
| blocked | any control a visitor could click — links, buttons, inputs, [role=button], [tabindex], iframes, cursor:pointer — or anything marked data-fc-avoid |
never |
If every slot is blocked the launcher hides until the page changes; a
launcher that eats a click is worse than none. window.Loki.report() still
works for a host that wires its own "Report" control.
The host contract — for what the heuristics cannot see
| attribute | where | effect |
|---|---|---|
data-fc-avoid |
any element | never overlap it (checked by rectangle too, so it works on pointer-events:none overlays) |
data-fc-place="left" / "right" |
<html> or any rendered page region |
keep the launcher on that side (it may still climb that edge) |
data-fc-place="hidden" |
<html> or any rendered page region |
no launcher while that region is rendered — e.g. a checkout or a full-screen editor |
<html> sets the site default; a rendered region overrides it (the last one in
document order wins). A region that is display:none or unmounted says nothing,
so a route can carry its own directive and the launcher returns when it leaves.
Legacy, still honoured: data-fc-bottom="N" on the script tag sets the base
bottom offset. The operator's placement (corner, offsets, auto-avoid on/off) is
set per token in Loki and served by /api/widget-boot; autoAvoid: false
switches the measuring off but data-fc-place still applies.
Visitors can long-press / right-click the launcher to move it to another corner or hide it on that site; their choice outranks everything above, for them only.
Tests
scripts/test/widget-placement.ts— the pure slot order and chooser.scripts/test/widget-host-avoid-browser.ts— real Chromium fixtures (bottom sheet under the launcher, composer Send, a host Ask button, map + sheet,data-fc-avoid,data-fc-place, late-mounted sheet, a wall of controls). Mutation-proven against the pre-fix bundle:WIDGET_JS=<old bundle>fails 7.