Files
loki/scripts/test/widget-sheet.ts
T
CatoandClaude Opus 5.5 dffe839661 One chat across projects, and the Loki panel works with a phone keyboard (#1149)
* feat(loki): one chat across projects — the named project wins, and the switch shows

A Loki chat already moves between projects: name one and the next answer
works there, and the scope follows. Two edges remained.

- The fast paths (business plan, profile update, screenshot) put the
  selection before a project named in the message. The selection now
  follows whatever project the last answer used, so "write the business
  plan for orangecat" sent after a loki build went to loki.
  resolveFleetCommandProjectKey now lets the named project win, as
  resolveDispatchTargets already does.
- The switch was silent — only the thread header's label changed. The
  thread now draws a quiet "Now on X" rule above the message that moved
  the chat to another project (lib/loki/project-switches.ts, tested).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HsFC4ZgDDsMo61aFghG1xd

* fix(widget): on a phone, the panel stands on the keyboard; scope tabs on one row

Owner's phone, 2026-10-11: with the keyboard up, the Loki panel's "Build
it / Ask Loki" buttons were under the keys and the thread was a sliver.
Android Chrome lays the keyboard OVER the page (the layout viewport keeps
its height), so a sheet pinned to bottom:0 with a vh height sits behind it.

- sheet.ts follows the visual viewport: keyboardInset() says how much the
  keyboard covers (tested; <80px is a toolbar, not a keyboard), and the
  sheet then stands on the keyboard with its height capped to what is
  visible. While typing, the starters and the way into Loki step aside
  (.panel.kb) and come back when the keyboard goes.
- The "About · This page · Whole site · An element · Loki itself" row
  wrapped onto two lines with the label floating beside both. On phones it
  is one sideways-scrolling row; the label goes (the group keeps its
  aria-label). The rule sits after the base .seg rule, which it overrides.

Checked in Chromium at 390×800 with a simulated 330px keyboard: the panel
ends at the keyboard (470px) and Ask Loki sits at 367–399px, where it was
at 625px — under the keys — before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HsFC4ZgDDsMo61aFghG1xd

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-11 15:14:18 -07:00

26 lines
1.3 KiB
TypeScript

/**
* The phone sheet's thumb rules: up grows it, down shrinks it, a long pull
* down puts it away, a small wobble changes nothing.
*
* Run: npx tsx scripts/test/widget-sheet.ts
*/
import assert from "node:assert/strict";
import { keyboardInset, sheetSnap } from "../../widget/sheet";
assert.equal(sheetSnap("auto", -80), "full", "drag up: the whole screen");
assert.equal(sheetSnap("auto", 80), "peek", "drag down: a peek at the page");
assert.equal(sheetSnap("peek", 80), "close", "down from a peek: put away");
assert.equal(sheetSnap("auto", 200), "close", "a long pull down: put away");
assert.equal(sheetSnap("full", 200), "peek", "a long pull from full lands on a peek, not gone");
assert.equal(sheetSnap("auto", 20), "auto", "a wobble changes nothing");
assert.equal(sheetSnap("full", -80), "full");
assert.equal(sheetSnap("peek", -80), "auto");
// The keyboard lies over the page on Android: the sheet must stand on it.
assert.equal(keyboardInset(800, 800, 0), 0, "no keyboard");
assert.equal(keyboardInset(800, 760, 0), 0, "a toolbar settling is not a keyboard");
assert.equal(keyboardInset(800, 480, 0), 320, "keyboard covers the bottom 320px");
assert.equal(keyboardInset(800, 480, 40), 280, "page scrolled inside the visual viewport");
console.log("✓ widget sheet: thumb sizes the panel, and it stands on the keyboard");