mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 22:08:18 +01:00
* feat(widget): watch says what it sees, in Loki's own spiral
From the owner's phone on heidi.orangecat.ch (2026-10-09): "It's not clear
what it thinks when it watches", and the logo is barely used.
- What Loki sees: one row under the panel header ("Watching · 2 pages,
1 tap · nothing wrong so far") that opens into the trail worded as notes
— pages opened, taps, what the page sent, what it noticed. Each settled
page now records a `look` step even when clean, so "looked, all fine"
is visible instead of silent. widget/thoughts.ts (pure) +
thoughts-view.ts.
- The status light is the logo's spiral, generated from
src/config/brand-mark.ts into widget/brand-mark.generated.ts (the widget
may not import src/). It turns slowly while watching, spins while Loki
thinks (header and the pending answer), and goes still and grey when
paused — in the launcher, the panel header and the walkthrough card.
- Loki's answers render paragraphs, bullets, headings and bold
(widget/rich-text.ts) from text nodes — "* The headline …" no longer
shows its asterisks.
- Tests: widget-thoughts, widget-rich-text, widget-brand-mark (drift);
watch/embed/host-avoid browser suites pass locally.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011L2dmcydDLYAiNQwK4XcF4
* feat(widget): one surface, not a stack of boxes and buttons
"No Frankenstein elements. Integrated experience. Not a bunch of big
unaligned buttons" (owner, 2026-10-09). The panel had grown one bordered
control at a time; this is a layout pass over all of it, with one rule:
at most one filled accent button per region, every other action is
quiet text aligned in its row.
- Header: who and where, and ✕. Review and Stop watching are gone from
it — Review is the conversation's first suggestion, and watching is
shown AND paused from the notes row (Pause / Resume), status and its
control together. A visitor keeps one quiet "Watch".
- Notes and Your changes are hairline strips, not nested cards.
- Thread: Loki's words are prose on the panel; yours are a pill.
Noticed/sent remarks carry a left rule instead of a box.
- Suggested changes: a hairline list, "Build this →" as accent text at
each row's end (was five filled buttons down the right edge). "Fix
this →" and "Why does it matter?" sit on one baseline.
- Composer: ONE card — About tabs (underlined when chosen), the words,
screenshots, then tools left and Build it / Ask Loki right, compact.
- Starters and links share one pill style; buttons are compact; the
ghost button has no frame.
- Tests follow the moved controls (watch-browser: Review via the
starter, Pause/Resume via the notes row; theme test checks the new
rules). watch/embed/host-avoid browser suites pass locally.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011L2dmcydDLYAiNQwK4XcF4
---------
Co-authored-by: Claude <noreply@anthropic.com>
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
/**
|
|
* The widget's answer formatting: markdown a model writes becomes blocks the
|
|
* panel renders as text nodes — never HTML on someone else's site.
|
|
*
|
|
* Run: npx tsx scripts/test/widget-rich-text.ts
|
|
*/
|
|
import assert from "node:assert/strict";
|
|
import { parseBlocks, parseSpans } from "../../widget/rich-text";
|
|
|
|
// The answer that shipped with its asterisks showing (heidi, 2026-10-09).
|
|
const answer = [
|
|
"The page is the user's personal dashboard.",
|
|
"",
|
|
"What works",
|
|
"",
|
|
"* The headline “Mein Bereich” clearly tells the user where they are.",
|
|
"* The **“1 Tag in Folge”** section gives a clear daily goal.",
|
|
"",
|
|
"### What to change",
|
|
"1. Add a prominent button",
|
|
].join("\n");
|
|
const blocks = parseBlocks(answer);
|
|
assert.deepEqual(
|
|
blocks.map((b) => b.kind),
|
|
["p", "h", "ul", "h", "ul"],
|
|
"a short label above a list reads as its heading",
|
|
);
|
|
// A sentence above a list stays a sentence.
|
|
assert.equal(parseBlocks("Here is what I found.\n* one")[0].kind, "p");
|
|
const list = blocks[2];
|
|
assert.ok(list.kind === "ul");
|
|
assert.equal(list.items.length, 2, "each * line is one bullet");
|
|
assert.ok(!list.items[0].some((s) => s.text.startsWith("*")), "the marker is gone");
|
|
assert.deepEqual(list.items[1][1], { text: "“1 Tag in Folge”", bold: true });
|
|
|
|
assert.deepEqual(parseSpans("no markup"), [{ text: "no markup" }]);
|
|
assert.deepEqual(parseSpans("a **b** c"), [
|
|
{ text: "a " },
|
|
{ text: "b", bold: true },
|
|
{ text: " c" },
|
|
]);
|
|
// A lone asterisk is literal, not a broken bold.
|
|
assert.deepEqual(parseSpans("5 * 3"), [{ text: "5 * 3" }]);
|
|
// Markup is data: angle brackets stay text for the renderer's text nodes.
|
|
assert.equal(parseBlocks("<img src=x onerror=alert(1)>")[0].kind, "p");
|
|
|
|
console.log("✓ widget rich text: bullets, headings, bold — as data, never HTML");
|