Files
loki/scripts/test/widget-thoughts.ts
T
CatoandClaude 8757d532b6 feat(widget): fixes go as one change, watch sees what taps do, ◎ shows Loki (#1112)
The owner, on loki.orangecat.ch from a phone (2026-10-09): "if it proposes
five fixes and I click fix, where is it going? … how do I keep track?",
"I don't know when it's noticing something", "it should be easy to draw
its attention", and the panel still had a lot going on.

- Suggested changes are ONE decision (widget/suggestions.ts): every row
  ticked, a tap unticks, "Build these 3 as one change →" files one note —
  one agent, one PR, one row in Your changes. It used to be a Build per
  row: N runs queued in the project's one lane with nothing saying so.
  The owner's builds start without a confirmation card ("Edit first"
  opens it); a visitor's still confirm.
- Your changes: one summary line that opens ("1 building · 1 in line ·
  1 live"); each row is its own link. A change waiting behind another
  reads "In line" (owner-view.ts), not "Starting".
- Watch sees what a tap DID: for 1.5 s after a tap on a button or link it
  waits for the page to change, ask the server or navigate, notes which
  ("↳ It asked the server"), and says at once — after one tap, not three
  — when nothing visibly happened.
- ◎ beside the launcher while watching: point at anything on the page,
  the panel opens with it attached.
- Phone sheet (widget/sheet.ts): drag the top up for full screen, down to
  peek at the page, further to put it away.
- Shorter greeting.
- Tests: widget-suggestions, widget-sheet, widget-changes (summary, In
  line), widget-thoughts (results); watch-browser covers the tap results
  and the one-change build. Unit 360/360; watch/embed/host-avoid browser
  suites pass locally.


Claude-Session: https://claude.ai/code/session_011L2dmcydDLYAiNQwK4XcF4

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-09 05:33:56 -07:00

54 lines
2.4 KiB
TypeScript

/**
* Watch's running notes: every recorded step becomes one plain sentence, and
* "looked, nothing wrong" is said too — silence was the complaint.
*
* Run: npx tsx scripts/test/widget-thoughts.ts
*/
import assert from "node:assert/strict";
import { ago, thoughtFor, thoughtsFrom, thoughtsSummary } from "../../widget/thoughts";
import { freshTrail, type TrailEntry } from "../../widget/watch-trail";
const t0 = 1_700_000_000_000;
const trail: TrailEntry[] = [
{ at: t0, kind: "page", text: "/" },
{ at: t0 + 3_000, kind: "look", text: "nothing stands out" },
{ at: t0 + 9_000, kind: "tap", text: "button “Team anlegen”" },
{ at: t0 + 9_500, kind: "request", text: "POST /api/groups → 201" },
{ at: t0 + 12_000, kind: "page", text: "/teams" },
{ at: t0 + 15_000, kind: "look", text: "2 things stand out" },
{ at: t0 + 20_000, kind: "request", text: "GET /api/me → 500" },
];
assert.equal(thoughtFor(trail[0]).text, "Opened the home page");
assert.equal(thoughtFor(trail[1]).tone, "good", "a clean look is said, and said as good news");
assert.equal(thoughtFor(trail[5]).tone, "warn");
assert.equal(thoughtFor(trail[6]).tone, "bad");
assert.match(thoughtFor(trail[3]).text, /^The page sent POST/);
const lines = thoughtsFrom(trail);
assert.equal(lines[0].at, t0 + 20_000, "newest first");
assert.equal(lines.length, trail.length);
assert.equal(thoughtsSummary(trail, true), "Watching · 2 pages, 1 tap · 2 things to look at");
assert.equal(thoughtsSummary(trail.slice(0, 2), true), "Watching · 1 page · nothing wrong so far");
assert.match(thoughtsSummary([], true), /waiting for the page to settle/);
assert.match(thoughtsSummary(trail, false), /^Not watching/);
// `look` survives a page load like every other step.
assert.equal(freshTrail(trail, t0 + 30_000).length, trail.length);
// What a tap DID is said under it — and a tap that did nothing is flagged.
assert.equal(
thoughtFor({ at: t0, kind: "result", text: "the page changed" }).text,
"↳ The page changed",
);
const nothing = thoughtFor({ at: t0, kind: "result", text: "nothing visibly happened" });
assert.equal(nothing.tone, "warn");
assert.equal(nothing.text, "↳ Nothing visibly happened");
assert.equal(ago(t0, t0 + 2_000), "now");
assert.equal(ago(t0, t0 + 45_000), "45s");
assert.equal(ago(t0, t0 + 5 * 60_000), "5m");
console.log("✓ widget thoughts: every step a sentence, clean looks included");