mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 11:33:28 +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>
87 lines
2.6 KiB
TypeScript
87 lines
2.6 KiB
TypeScript
/**
|
|
* The panel as a phone sheet you can size with your thumb: drag its top edge
|
|
* up for the whole screen, down for a peek, further down to put it away.
|
|
* Desktop keeps the corner card — there the page is beside it, not under it.
|
|
*
|
|
* Pure decision (sheetSnap) is tested in scripts/test/widget-sheet.ts.
|
|
*/
|
|
import { h } from "./dom";
|
|
|
|
export type SheetSize = "peek" | "auto" | "full";
|
|
|
|
/** Where a drag of `dy` px (down is positive) from `from` should settle. */
|
|
export function sheetSnap(from: SheetSize, dy: number): SheetSize | "close" {
|
|
const order: SheetSize[] = ["peek", "auto", "full"];
|
|
if (dy > 160 && from !== "full") return "close";
|
|
if (dy > 160) return "peek";
|
|
if (Math.abs(dy) < 40) return from;
|
|
const i = order.indexOf(from) + (dy < 0 ? 1 : -1);
|
|
if (i < 0) return "close";
|
|
return order[Math.min(i, order.length - 1)];
|
|
}
|
|
|
|
const HEIGHT: Record<SheetSize, string> = {
|
|
peek: "42vh",
|
|
auto: "",
|
|
full: "calc(100vh - 16px)",
|
|
};
|
|
|
|
export function attachSheet(opts: {
|
|
panel: HTMLElement;
|
|
/** The header — dragging it moves the sheet; its buttons still work. */
|
|
handle: HTMLElement;
|
|
onClose: () => void;
|
|
}): { reset: () => void } {
|
|
const { panel, handle } = opts;
|
|
const grip = h("div", "grip");
|
|
grip.setAttribute("aria-hidden", "true");
|
|
panel.prepend(grip);
|
|
let size: SheetSize = "auto";
|
|
const phone = () => window.matchMedia("(max-width: 480px)").matches;
|
|
const apply = () => {
|
|
panel.style.height = HEIGHT[size];
|
|
panel.style.maxHeight = size === "full" ? "none" : "";
|
|
};
|
|
|
|
let startY: number | null = null;
|
|
let dy = 0;
|
|
const down = (e: PointerEvent) => {
|
|
if (!phone() || (e.target as Element).closest("button,a,input,textarea")) return;
|
|
startY = e.clientY;
|
|
dy = 0;
|
|
panel.style.transition = "none";
|
|
};
|
|
const move = (e: PointerEvent) => {
|
|
if (startY === null) return;
|
|
dy = e.clientY - startY;
|
|
// Follow the thumb downward; upward is a resize, shown on release.
|
|
panel.style.transform = dy > 0 ? `translateY(${dy}px)` : "";
|
|
};
|
|
const up = () => {
|
|
if (startY === null) return;
|
|
startY = null;
|
|
panel.style.transition = "";
|
|
panel.style.transform = "";
|
|
const next = sheetSnap(size, dy);
|
|
if (next === "close") {
|
|
size = "auto";
|
|
apply();
|
|
opts.onClose();
|
|
return;
|
|
}
|
|
size = next;
|
|
apply();
|
|
};
|
|
for (const el of [grip, handle]) el.addEventListener("pointerdown", down);
|
|
window.addEventListener("pointermove", move);
|
|
window.addEventListener("pointerup", up);
|
|
window.addEventListener("pointercancel", up);
|
|
|
|
return {
|
|
reset() {
|
|
size = "auto";
|
|
apply();
|
|
},
|
|
};
|
|
}
|