mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 19:27:38 +01:00
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>
89 lines
3.3 KiB
TypeScript
89 lines
3.3 KiB
TypeScript
/**
|
|
* What Loki is thinking while it watches, as sentences the owner reads.
|
|
*
|
|
* Watch used to be silent until something broke: a "Loki · watching" pill and
|
|
* then nothing, so its owner could not tell whether it was looking at
|
|
* anything at all (heidi.orangecat.ch, 2026-10-09: "It's not clear what it
|
|
* thinks when it watches"). The trail it keeps already says, step by step,
|
|
* what it saw — this turns that trail into the running notes the panel shows.
|
|
*
|
|
* Pure (scripts/test/widget-thoughts.ts). Nothing here is new information and
|
|
* nothing is invented: every line is one recorded step, worded.
|
|
*/
|
|
import type { TrailEntry } from "./watch-trail";
|
|
|
|
export type ThoughtTone = "plain" | "good" | "warn" | "bad";
|
|
export type Thought = { at: number; text: string; tone: ThoughtTone };
|
|
|
|
/** Lines the panel lists, newest first. */
|
|
export const THOUGHTS_SHOWN = 30;
|
|
|
|
function pageName(path: string): string {
|
|
return path === "/" || !path ? "the home page" : path;
|
|
}
|
|
|
|
export function thoughtFor(e: TrailEntry): Thought {
|
|
const at = e.at;
|
|
switch (e.kind) {
|
|
case "page":
|
|
return { at, tone: "plain", text: `Opened ${pageName(e.text)}` };
|
|
case "tap":
|
|
return { at, tone: "plain", text: `You tapped ${e.text}` };
|
|
case "look":
|
|
return {
|
|
at,
|
|
tone: /^nothing\b/.test(e.text) ? "good" : "warn",
|
|
text: `Looked over the page — ${e.text}`,
|
|
};
|
|
case "result": {
|
|
const nothing = /^nothing\b/.test(e.text);
|
|
return {
|
|
at,
|
|
tone: nothing ? "warn" : "plain",
|
|
text: `↳ ${nothing ? "Nothing visibly happened" : e.text.charAt(0).toUpperCase() + e.text.slice(1)}`,
|
|
};
|
|
}
|
|
case "notice":
|
|
return { at, tone: "warn", text: `Noticed: ${e.text}` };
|
|
case "error":
|
|
return { at, tone: "bad", text: `The page hit an error: ${e.text}` };
|
|
case "request": {
|
|
const failed = /→ (5\d\d|no response)/.test(e.text);
|
|
return failed
|
|
? { at, tone: "bad", text: `A request failed: ${e.text}` }
|
|
: { at, tone: "plain", text: `The page sent ${e.text}` };
|
|
}
|
|
}
|
|
}
|
|
|
|
export function thoughtsFrom(trail: TrailEntry[]): Thought[] {
|
|
return trail.slice(-THOUGHTS_SHOWN).map(thoughtFor).reverse();
|
|
}
|
|
|
|
/** The one line the collapsed row says. */
|
|
export function thoughtsSummary(trail: TrailEntry[], watching: boolean): string {
|
|
if (!watching) return "Not watching — nothing is recorded";
|
|
if (!trail.length) return "Watching — waiting for the page to settle";
|
|
const lines = trail.map(thoughtFor);
|
|
const problems = lines.filter((t) => t.tone === "warn" || t.tone === "bad").length;
|
|
const pages = trail.filter((e) => e.kind === "page").length;
|
|
const taps = trail.filter((e) => e.kind === "tap").length;
|
|
const seen = [
|
|
`${pages} ${pages === 1 ? "page" : "pages"}`,
|
|
...(taps ? [`${taps} ${taps === 1 ? "tap" : "taps"}`] : []),
|
|
].join(", ");
|
|
const verdict = problems
|
|
? `${problems} ${problems === 1 ? "thing" : "things"} to look at`
|
|
: "nothing wrong so far";
|
|
return `Watching · ${seen} · ${verdict}`;
|
|
}
|
|
|
|
/** "now", "40s", "3m" — how long ago, short enough for a line's margin. */
|
|
export function ago(at: number, now: number): string {
|
|
const s = Math.max(0, Math.round((now - at) / 1000));
|
|
if (s < 10) return "now";
|
|
if (s < 60) return `${s}s`;
|
|
const m = Math.round(s / 60);
|
|
return m < 60 ? `${m}m` : `${Math.round(m / 60)}h`;
|
|
}
|