Files
loki/widget/continue-row.ts
CatoandClaude 8749efd100 feat(widget): say the state on screen, one button to open, a calmer panel (#1279)
The owner on their phone (2026-10-17): it should be clear on screen when
Loki is watching and when it is recording, opening it should be easy, and
the panel was too crowded and intimidating to use.

Watching
- The owner's launcher is ONE button that says its state in a word at
  every width: "● Watching" with a live dot and a ring, or "Paused". A
  tap opens Loki. Its second half, "Point", was the labelled, bigger part
  on a phone, so the obvious tap pointed instead of opening; pointing is
  "Point to area" in the composer.

Recording
- A red edge round the whole screen while Loki listens (it takes no
  taps; grey while it writes it down), a red-bordered dock that says
  "Recording 0:12", and a one-line hint instead of four.

The panel
- One status line instead of two rows: "Watching · 2 to look at · 4 live
  › Pause"; opening it shows what Loki noted and where each change is.
- One microphone: the header's "Voice note" and the composer's "Record"
  did nearly the same thing. "Talk" in the composer is talk-while-
  scrolling, which also covers plain dictation; in chatkit it takes the
  tool row in place of chatkit's own mic.
- "Fix it" and "Ask" instead of "Request a fix" and "Chat with Loki".
- "Continue in Loki" appears once something has been said.
- The visitor's phone launcher is 44px, the minimum tap target.

Docs (widget/README.md, docs/architecture/feedback-widget.md,
docs/development/contextual-voice-feedback.md) and the browser tests
follow the new controls; new pure helpers watchHeadline and
changesHeadline are unit-tested.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-17 20:44:42 +02:00

65 lines
2.5 KiB
TypeScript

/**
* The row under the composer that leads out of the card and into Loki.
*
* The panel is for saying what you want; developing it — with the project,
* its files and a run to watch — is Loki's chat or terminal. The owner asked
* for exactly this ("switch to Loki so I can develop it there with either
* chat or terminal") and the widget had no answer. Now the thread travels
* with them. Someone without a pass gets one link, because the same trip
* signs them in and finds out whether the site is theirs.
*/
import { h } from "./dom";
import { continueUrl, handoffText } from "./continue";
import type { ThreadItem } from "./thread";
export function createContinueRow(opts: {
apiBase: string;
token: string;
thread: () => readonly ThreadItem[];
owner: () => boolean;
}) {
const el = h("div", "continue");
const label = h("span", "continue-label", "Continue in Loki");
const chat = h("a", "continue-link", "Chat →");
const term = h("a", "continue-link", "Terminal →");
const mine = h("a", "continue-link", "This is my site — continue in Loki →");
for (const a of [chat, term, mine]) {
a.target = "_blank";
a.rel = "noopener";
}
chat.title = "Loki's chat on this project, with this conversation in the message box";
term.title = "The project's terminal in Loki";
mine.title = "Sign in with Loki; this conversation goes with you";
el.append(label, chat, term, mine);
/** Re-aim the links at the thread as it is now, and show the right ones. */
function sync() {
const thread = opts.thread();
const text = handoffText(thread, { title: document.title, url: location.href });
for (const [a, view] of [
[chat, "chat"],
[term, "terminal"],
[mine, "chat"],
] as const) {
a.href = continueUrl({
apiBase: opts.apiBase,
token: opts.token,
view,
text,
here: location.href,
});
}
// Once there is something to take along: on an empty thread the owner's
// two doors were one more row under the composer before a word was said
// (owner, 2026-10-17), and a visitor's link would only be a second
// sign-in button. The owner gets both doors; a visitor the one.
const owner = opts.owner();
const said = thread.some((i) => i.kind === "you");
label.style.display = chat.style.display = term.style.display = owner ? "" : "none";
mine.style.display = owner ? "none" : "";
el.style.display = said ? "" : "none";
}
return { el, sync };
}