mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 04:36:59 +01:00
* fix(prompts): one card per saved prompt, schedules in words, dialogs that say why
What the owner found on /prompts from an Android phone, item by item:
1. Saved prompts: saving the same name + words again no longer inserts a
row — POST /api/prompts answers with the prompt already saved
(existing: true); the form opens it, the default's save button says
"Already in your prompts". A card that stands for identical copies says
how many and offers "Remove N extra copies" — one explicit tap, the
caller's own rows only, the same soft delete as Delete
(DELETE /api/prompts/<id>/copies). Same name with different words says
"2 versions with this name, worded differently".
2. Filters: the scope filter is a <Segmented> (All / Any project / One
project) sitting with the category row on the list they both filter,
under "Loki's prompts". Category counts follow the scope. Filter chip
rows on a phone get a wider fade, snap to a chip's start and leave room
after the last chip, so the edge reads as "more" rather than a cut word.
3. New prompt: Create stays disabled until there is a name and a prompt,
and says what is missing beside it. Opening or closing the form never
saved anything; the copy glyph on every default card did, in one tap
with no label on a phone — it is now a labelled "save a copy" button.
4. Schedule: pick Every day / Weekdays / Every week / Every month, a day
and a time; Loki writes the cron (lib/cron-words), with "Write it as a
cron line instead" for experts. The schedule reads back in words with
the time zone it runs in ("Every Monday at 10:00, Zurich time
(Europe/Zurich)") and a link to change it; the zone is sent with the
job. The API refuses a cron line the scheduler cannot read, in words.
Create is the primary button and says why when it cannot be pressed.
5. Run: a prompt that names {{project_name}} asks for a project whatever
its scope (a saved copy is global), defaulting to the project in use;
the prompt is shown only once complete. Each action says in one line
who does the work; Send to terminal works for any of your projects
(tab-inject starts or queues the session) and says why when it cannot.
Project pickers list projectTitle(), not folder keys.
6. Category chips are neutral (ui-tag-neutral); the ui-cat-* rainbow and
the featured star's amber are gone. "control" was a second id for the
fleet prompts — one category now, "Fleet control".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* fix(voice): spoken sentences start with a capital and name a repeated project once
The briefing read "one run is waiting for a builder: loki ... three runs
failed: loki, loki and loki". Sentences now open with a capital, and the
runs' projects are said once each: "Three runs failed on loki.", "Four runs
failed: loki three times and heidi once." The same for runs waiting for a
builder, agents working, and the announcements between turns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* fix(voice): say why the studio voice is off, with the link that fixes it
POST /api/voice/speak answered 502 with Groq's reason only in the server
console, and the phone fell back to its own voice in silence, so every voice
in the picker sounded the same. Groq's refusal is now classified
(lib/voice/tts-failure: terms gate, bad key, limit, model gone, vendor down,
no key) into one plain sentence and, where one exists, the link that fixes
it — for the Orpheus terms gate, Groq's voice page and "press Accept". The
route returns it in the 502/503 body and records it in debug_logs (once per
reason per half hour) so System shows it. The speaker reports the fallback
to the page; useStudioVoiceStatus keeps it for the tab's session and
StudioVoiceNotice shows it. The phone-voice fallback stays.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* feat(voice): change Loki's voice by saying so, and answer questions about voice mode truthfully
"I don't like your voice, can I change your voice" was answered like a
generic chatbot ("in most voice-enabled AI chat apps... look in settings").
Now "use Troy", "change your voice to Diana", "other voice" and
"switch voice" are a spoken command (config/no-screen.ts, lib/voice/commands)
that the phone answers itself; with no name it lists the voices. A question
that does reach Loki carries voiceModeContext (lib/voice/self.ts), built from
the SSOT: the voices by name, how to change one, the three switches with the
same one-line notes the screen shows (NO_SCREEN_OPTIONS), every command, the
current settings and why studio voices are off, if they are.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* fix(voice): a music bed a phone can actually play, and keep its sound awake
The bed sat at about -38 dBFS RMS alone and -50 under the voice, every note
98-370 Hz behind a 900 Hz low-pass: below what a phone speaker or many
earbuds reproduce, so "music bed on" was silence. It is now an octave
higher (196-740 Hz), about 12 dB louder, ducks by 10 dB instead of 11 more on
top, and earcons sit above it. The AudioContext is resumed inside the Start
tap, on every tap on the circle or headphone button, on return to the page,
and when the phone suspends it mid-session.
useSoundscape also returned a new object every render, so effects keyed on
it re-ran ~20 times a second while listening: the gain was re-ramped every
frame and the 20-second fleet poll was cleared before it could fire. It is
memoized now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* fix(voice): one h1 per screen, End clear of the feedback launcher, voices as an even grid
- Speaking screen: an h1 below md, where the app top bar steps aside; the
start screen's big "Voice" is no longer a second h1 beside the top bar's.
- The speaking screen sets data-fc-place="tab", so the feedback launcher
and its Watching pill become the slim edge handle instead of sitting on
End; End is larger, with room below it, and the stage scrolls rather than
pushing End off a short screen.
- The voice picker is a <Segmented> grid of four columns (seven voices as
4 + 3, the last two cells wide) instead of a chip row cut off at the edge;
the setting groups have real headings.
- The unclear note under the switches is one short line under each switch,
shared with what Loki is told about itself.
- The page wires the studio-voice notice (under the picker and under the
circle, said aloud once), the spoken voice change, the page's state sent
with each question, and the sound resume on every tap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* fix(widget): one card per finding, settled page checks, honest fix status, a count that means what needs you
Watching on Loki's own /voice from an Android phone showed six problems in
one panel. Each is fixed where it starts:
- Notices no longer stack. A page's checks own ONE card (checksSlot), which
each new reading replaces in place and a clean reading takes back
(thread.ts pushNoticed / dropNoticed); a remark whose words are already on
screen is not said again; a finding's signature ignores its count and its
placeholder example (findingKind), and the card names its page.
- The heading miscount: the check counted headings inside aria-hidden and
inert subtrees, and measured the page once, mid-swap — /voice's setup
screen (top bar h1 + page h1) leaving for its speaking screen (immersive
mode hides the top bar: no h1). Checks now count only rendered elements and
run once the page has held still, twice, keeping only what both readings
agree on (settledPageChecks / stableChecks). The Voice page itself now has
one h1 on each screen.
- A fix Watch started that failed no longer promises it "goes live by
itself": it says the fix did not finish, and "Open it in Loki to see why"
is a real link to that run's Watch page (owner-view ownerTap; watch-fix
now resolves a failed run's Watch page even without a live page).
- Self-watch: "I couldn't check on your changes just now" replaces the old
sentence; a request that lived through the page being put away (a phone
locking) is never a failure; background reads count only after three
failures in a row; the changes route always answers with CORS headers and
logs what failed.
- The header's one number is what waits on the owner's decision (failed
attempts, saved notes, notes not started, changes said but not saved),
counted by the server over ALL of the owner's rows, not inside the newest
twelve; the open list shows every one of them first. Nothing waiting:
just "Watching".
- The save receipt never quotes a cut sentence: several changes are listed
one per line under it, clamped to whole lines with "Show all".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
* docs(changelog): voice, Watching and Prompts fixes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx
---------
Co-authored-by: Claude <noreply@anthropic.com>
295 lines
12 KiB
TypeScript
295 lines
12 KiB
TypeScript
// Watch mode's trail and reports: privacy by construction (labels, never
|
|
// values; paths, never query strings), one report per distinct failure, and a
|
|
// report that names what broke before what led there.
|
|
// Run: npx tsx scripts/test/widget-watch.ts
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
describeControl,
|
|
describeRequest,
|
|
failureSignature,
|
|
freshTrail,
|
|
isFailedRequest,
|
|
isNoiseError,
|
|
isNoticeableRequest,
|
|
nextTapStreak,
|
|
noticeCount,
|
|
pushTrail,
|
|
REVIEW_SESSION_MAX,
|
|
sessionForReview,
|
|
SLOW_REQUEST_MS,
|
|
TRAIL_MAX,
|
|
TRAIL_MAX_AGE_MS,
|
|
watchReport,
|
|
explainChecks,
|
|
checksSignature,
|
|
checksSlot,
|
|
findingKind,
|
|
stableChecks,
|
|
explainNotice,
|
|
noticeSignature,
|
|
type TrailEntry,
|
|
} from "../../widget/watch-trail";
|
|
import { buildSuggestion } from "../../widget/report-payload";
|
|
|
|
let n = 0;
|
|
const check = (fn: () => void) => {
|
|
fn();
|
|
n++;
|
|
};
|
|
|
|
check(() => {
|
|
assert.equal(
|
|
describeControl({ tag: "BUTTON", text: " Save\n project " }),
|
|
"button “Save project”",
|
|
);
|
|
assert.equal(describeControl({ tag: "a", label: "Open profile" }), "link “Open profile”");
|
|
// An input is named by its placeholder — what was typed never appears.
|
|
assert.equal(
|
|
describeControl({ tag: "input", type: "email", placeholder: "Your email" }),
|
|
"email field “Your email”",
|
|
);
|
|
assert.equal(describeControl({ tag: "div", role: "button" }), "button");
|
|
});
|
|
check(() => {
|
|
assert.equal(
|
|
describeRequest("post", "https://orangecat.ch/api/projects?token=secret", 500),
|
|
"POST /api/projects → 500",
|
|
);
|
|
assert.equal(describeRequest("get", "/shop/x", null), "GET /shop/x → no response");
|
|
assert.equal(isFailedRequest(500), true);
|
|
assert.equal(isFailedRequest(null), true);
|
|
assert.equal(isFailedRequest(404), false);
|
|
});
|
|
check(() => {
|
|
let t: TrailEntry[] = [];
|
|
for (let i = 0; i < TRAIL_MAX + 5; i++) t = pushTrail(t, { at: i, kind: "tap", text: `b${i}` });
|
|
assert.equal(t.length, TRAIL_MAX);
|
|
const before = t.length;
|
|
t = pushTrail(t, { at: 99, kind: "tap", text: `b${TRAIL_MAX + 4}` });
|
|
assert.equal(t.length, before, "a repeat of the last entry is one fact");
|
|
});
|
|
check(() => {
|
|
assert.equal(isNoiseError("ResizeObserver loop limit exceeded"), true);
|
|
assert.equal(isNoiseError("Script error."), true);
|
|
assert.equal(isNoiseError("TypeError: cannot read properties of undefined"), false);
|
|
assert.equal(
|
|
failureSignature({ kind: "request", text: "GET /api/projects/123 → 500" }),
|
|
failureSignature({ kind: "request", text: "GET /api/projects/456 → 500" }),
|
|
);
|
|
});
|
|
check(() => {
|
|
const trail: TrailEntry[] = [
|
|
{ at: 1000, kind: "page", text: "/projects" },
|
|
{ at: 3000, kind: "tap", text: "button “Create”" },
|
|
];
|
|
const r = watchReport({ kind: "request", text: "POST /api/projects → 500" }, trail, 5000);
|
|
assert.match(r.message, /request failed: POST \/api\/projects → 500/);
|
|
assert.equal(r.diagnostics["step 2"], "tap button “Create” (2s ago)");
|
|
const s = buildSuggestion(r.message, r.diagnostics, 2000);
|
|
assert.ok(s.length <= 2000 && s.includes("failure: POST /api/projects → 500"));
|
|
});
|
|
|
|
check(() => {
|
|
// Three taps on one button inside the window: dead. A field, a gap, or a
|
|
// different button in between: not.
|
|
let r = nextTapStreak(null, "button “Pay”", 0);
|
|
r = nextTapStreak(r.streak, "button “Pay”", 1000);
|
|
assert.equal(r.dead, false);
|
|
r = nextTapStreak(r.streak, "button “Pay”", 2000);
|
|
assert.equal(r.dead, true);
|
|
let f = nextTapStreak(null, "email field “Your email”", 0);
|
|
f = nextTapStreak(f.streak, "email field “Your email”", 100);
|
|
f = nextTapStreak(f.streak, "email field “Your email”", 200);
|
|
assert.equal(f.dead, false, "fields are tapped to focus");
|
|
let g = nextTapStreak(null, "button “Pay”", 0);
|
|
g = nextTapStreak(g.streak, "button “Pay”", 1000);
|
|
g = nextTapStreak(g.streak, "button “Pay”", 9000);
|
|
assert.equal(g.dead, false, "outside the window it starts again");
|
|
const rep = watchReport({ kind: "dead-tap", text: "button “Pay”" }, [], 0);
|
|
assert.match(rep.message, /pressed button “Pay” three times and nothing happened/);
|
|
});
|
|
|
|
// ---- Review: what a reviewer remarks on that is not a failure ----
|
|
check(() => {
|
|
assert.equal(describeRequest("get", "/a?x=1", 200, 4230), "GET /a → 200 in 4.2s");
|
|
assert.equal(isNoticeableRequest(404, 50), true, "a 404 is worth a remark");
|
|
assert.equal(isNoticeableRequest(200, SLOW_REQUEST_MS), true, "so is a slow answer");
|
|
assert.equal(isNoticeableRequest(200, 120), false);
|
|
// 5xx and no-answer are failures (they file a fix) — never also a remark.
|
|
assert.equal(isNoticeableRequest(500, 9000), false);
|
|
assert.equal(isNoticeableRequest(null, 9000), false);
|
|
});
|
|
|
|
check(() => {
|
|
const now = 10_000_000;
|
|
const kept = freshTrail(
|
|
[
|
|
{ at: now - TRAIL_MAX_AGE_MS - 1, kind: "tap", text: "yesterday" },
|
|
{ at: now - 1000, kind: "tap", text: "button “Go”" },
|
|
{ at: now - 500, kind: "bogus", text: "x" },
|
|
{ at: "soon", kind: "tap", text: "x" },
|
|
{ at: now + 60_000, kind: "tap", text: "from the future" },
|
|
null,
|
|
],
|
|
now,
|
|
);
|
|
assert.deepEqual(kept, [{ at: now - 1000, kind: "tap", text: "button “Go”" }]);
|
|
assert.deepEqual(freshTrail("not json array", now), [], "stored garbage is an empty trail");
|
|
});
|
|
|
|
check(() => {
|
|
const t: TrailEntry[] = [
|
|
{ at: 0, kind: "page", text: "/shop" },
|
|
{ at: 1_000, kind: "tap", text: "button “Buy”" },
|
|
{ at: 1_200, kind: "notice", text: "POST /cart → 404 in 0.2s" },
|
|
{ at: 45_000, kind: "tap", text: "link “Help”" },
|
|
];
|
|
assert.equal(noticeCount(t), 1);
|
|
const s = sessionForReview(t, ["2 image(s) have no alt text"], 90_000);
|
|
assert.match(s, /page \/shop\ntap button “Buy”\nnotice POST \/cart → 404/);
|
|
assert.match(s, /\(paused 44s\)\ntap link “Help”/, "a long stop before a step is written out");
|
|
assert.match(s, /nothing for 45s, then asked for this review/);
|
|
assert.match(s, /Checks on the page they are on now:\n- 2 image\(s\) have no alt text/);
|
|
});
|
|
|
|
check(() => {
|
|
// 2026-10-15: minutes spent talking to Loki in the panel reached Review as
|
|
// silence and came back as "the page never responded for 194 s". A talk
|
|
// step makes that time what it was, and survives a page load's restore.
|
|
const t: TrailEntry[] = [
|
|
{ at: 0, kind: "page", text: "/stellen/1/bearbeiten" },
|
|
{ at: 2_000, kind: "talk", text: "«there's no way to speak into this field»" },
|
|
{ at: 196_000, kind: "talk", text: "«are we using the packages?»" },
|
|
];
|
|
const s = sessionForReview(t, [], 200_000);
|
|
assert.match(s, /talk «there's no way to speak into this field»/);
|
|
assert.ok(!/nothing for 19\ds/.test(s), "the conversation is not the site going quiet");
|
|
assert.equal(freshTrail(t, 200_000).length, 3, "talk steps survive a restore");
|
|
});
|
|
|
|
check(() => {
|
|
// Too long: the OLDEST steps go, the checks and the newest steps stay.
|
|
const t: TrailEntry[] = Array.from({ length: TRAIL_MAX }, (_, i) => ({
|
|
at: i,
|
|
kind: "tap" as const,
|
|
text: `button “${String(i).padStart(3, "0")} ${"x".repeat(140)}”`,
|
|
}));
|
|
const s = sessionForReview(t, ["check A"], TRAIL_MAX);
|
|
assert.ok(s.length <= REVIEW_SESSION_MAX, `capped (${s.length})`);
|
|
assert.ok(s.includes(`button “${String(TRAIL_MAX - 1).padStart(3, "0")}`), "newest kept");
|
|
assert.ok(!s.includes("button “000"), "oldest dropped");
|
|
assert.ok(s.endsWith("- check A"), "checks survive the cut");
|
|
});
|
|
|
|
// ---- Loki speaks up: each remark in plain words, with the fix it would send ----
|
|
check(() => {
|
|
const nf = explainNotice({
|
|
kind: "4xx",
|
|
text: "GET /hours → 404",
|
|
after: "button “Opening hours”",
|
|
});
|
|
assert.equal(
|
|
nf.say,
|
|
"After you pressed button “Opening hours”, the page asked for /hours and it found nothing there (404).",
|
|
);
|
|
assert.match(
|
|
nf.fix,
|
|
/^Fix the request to \/hours after pressing button “Opening hours”: it answers 404\.$/,
|
|
);
|
|
// No tap to blame: the sentence still stands on its own.
|
|
assert.match(
|
|
explainNotice({ kind: "4xx", text: "POST /cart → 403" }).say,
|
|
/^the page asked for \/cart and it was refused — not allowed\.$/,
|
|
);
|
|
assert.match(
|
|
explainNotice({ kind: "4xx", text: "GET /x → 418" }).say,
|
|
/was rejected \(418\)/,
|
|
"an unlisted status still reads",
|
|
);
|
|
assert.match(
|
|
explainNotice({ kind: "slow", text: "GET /api/menu → 200 in 4.2s" }).say,
|
|
/waited 4\.2s for \/api\/menu/,
|
|
);
|
|
assert.match(
|
|
explainNotice({ kind: "console", text: "console error: x is undefined" }).say,
|
|
/“x is undefined”/,
|
|
);
|
|
assert.match(
|
|
explainNotice({ kind: "load", text: "this page took 4.1s to load" }).say,
|
|
/it took 4\.1s to load/,
|
|
);
|
|
const freeze = explainNotice({
|
|
kind: "longtask",
|
|
text: "after button “Load more” the page froze for 450ms (taps go unanswered meanwhile)",
|
|
});
|
|
assert.match(freeze.say, /^After button “Load more” the page froze for 450ms/);
|
|
assert.equal(freeze.fix, "Stop the page freezing after button “Load more”.");
|
|
assert.match(explainNotice({ kind: "cls", text: "content jumped around" }).fix, /jumping around/);
|
|
});
|
|
|
|
check(() => {
|
|
assert.equal(explainChecks([]), null, "a clean page gets no remark — silence is right");
|
|
// One finding, two counts, two examples: one signature.
|
|
assert.equal(
|
|
checksSignature("/p", ["30 piece(s) of text are under 12px (e.g. “Partners” at 11.84px)"]),
|
|
checksSignature("/p", [
|
|
"6 piece(s) of text are under 12px (e.g. “AI-native studio” at 11.5px)",
|
|
]),
|
|
"the same kind of finding is said once, whatever the count or example",
|
|
);
|
|
assert.notEqual(
|
|
checksSignature("/p", ["2 image(s) have no alt text"]),
|
|
checksSignature("/p", ["The page has no main heading (h1)"]),
|
|
"a different finding is a different signature",
|
|
);
|
|
assert.notEqual(checksSignature("/p", ["x"]), checksSignature("/q", ["x"]), "per path");
|
|
const c = explainChecks(["2 image(s) have no alt text", "The page has no main heading (h1)"])!;
|
|
assert.match(
|
|
c.say,
|
|
/2 things stand out:\n• 2 pictures have no description[^\n]*\n• The page has no main title/,
|
|
);
|
|
assert.match(c.fix, /^Fix these on this page:\n• 2 image/);
|
|
assert.equal(
|
|
c.short,
|
|
"2 things on this page could be better",
|
|
"the bar's one line never ends on a colon",
|
|
);
|
|
// One remark per cause per page: numbers do not make it new, another page does.
|
|
const a = noticeSignature("/shop", { kind: "slow", text: "GET /a → 200 in 4.2s" });
|
|
assert.equal(a, noticeSignature("/shop", { kind: "slow", text: "GET /a → 200 in 5.9s" }));
|
|
assert.notEqual(a, noticeSignature("/cart", { kind: "slow", text: "GET /a → 200 in 4.2s" }));
|
|
});
|
|
|
|
// The miscount, reproduced from the readings the operator's phone took on
|
|
// /voice (2026-10-20): the page swaps its setup screen for its speaking
|
|
// screen, and readings taken across the swap disagree about the title.
|
|
check(() => {
|
|
const two = "The page has 2 main headings (h1), so none of them is THE title";
|
|
const none = "The page has no main heading (h1) — what it is about is never stated";
|
|
const field1 =
|
|
"1 form field(s) have no label — only a placeholder like “Ask”, which vanishes once typing starts";
|
|
const field2 = "2 form field(s) have no label";
|
|
// Mid-swap: both screens' h1, then neither. Not one of them is said.
|
|
assert.deepEqual(stableChecks([two, field1], [none, field2]), [field2]);
|
|
// Held still: what both readings found is said, in the later words.
|
|
assert.deepEqual(stableChecks([none, field1], [none, field2]), [none, field2]);
|
|
assert.deepEqual(stableChecks([], [none]), [], "a first reading alone says nothing");
|
|
// A finding's kind leaves out its count and its example.
|
|
assert.equal(findingKind(field1), findingKind(field2));
|
|
assert.equal(findingKind(two), findingKind(none), "the title is one finding, whatever the count");
|
|
// So the page's card has ONE signature for either reading of a field, and
|
|
// the title's two readings never become two cards.
|
|
assert.equal(checksSignature("/voice", [field1]), checksSignature("/voice", [field2]));
|
|
assert.equal(checksSignature("/voice", [two]), checksSignature("/voice", [none]));
|
|
assert.ok(checksSignature("/voice", [none]).startsWith(`${checksSlot("/voice")}|`));
|
|
// The card names its page: three "Looking at this page" cards from three
|
|
// pages read as one remark said three times.
|
|
assert.match(
|
|
explainChecks([none], "Voice")!.say,
|
|
/^Looking at the Voice page, one thing stands out:/,
|
|
);
|
|
assert.match(explainChecks([none])!.say, /^Looking at this page,/);
|
|
});
|
|
|
|
console.log(`${n} widget-watch cases passed`);
|