Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit ab826955a9cd23960e5b26b1f44e4f4832527b60
parent 3e74942b1d9020a214b93f059793f8c26f72ab13
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 24 Oct 2026 03:05:13 -0400

umtool on a phone: the place bar, the dock, sheets; Work as cards; the page is one document

Below md (768 px) the shell is rebuilt for one thumb; md and up is the desk,
unchanged.

- The place bar (44 px, fixed): back, the trail in mono, ⋯ for the page's
  actions. It hides on a scroll down and returns on a scroll up (a
  transform), and says the title once the page's own has scrolled away.
- The title, meta and stage row are in flow and scroll away; the window is
  the scroller (no `.deck-main` pane on a phone).
- The dock (56 px + the safe area): Inbox · Research · Work · Tools, and
  ≡ More (Settings, + Create, Jump to…, the theme) as a bottom sheet. The
  rail and its narrow strip are not drawn on a phone.
- The ⋯ sheet is the head's actions and note in ONE element (inline on the
  desk, a sheet on a phone), so nothing is on the page twice. A piece's
  lifecycle there is three labelled buttons (Active / Parked / Done, the
  current one marked); Done or Parked closes the sheet and shows the Undo
  bar above the dock. The ⋯ items lay out flat; the policy chip joins them.
- A piece's stepper is Work's stage pips with the lifecycle word; its tabs
  are one sideways strip that snaps, starts at the current tab, and sticks
  under the place bar (or the top, once the bar has gone).
- Work: rows are cards (title, kind · site, pips) that open the piece on a
  tap anywhere and carry no lifecycle control; no table head; the facets
  fold into one summary line that opens them in a sheet with "Show N".
- Inbox: Park and Mute are behind each line's ⋯ (a sheet, names spelled
  out) on a phone. On the desk a line's lifecycle and mute buttons take a
  press only on the lit line, so a press that lights a line never parks it.
- A menu's panel is a bottom sheet on a phone.
- viewport-fit=cover, so env(safe-area-inset-bottom) pads the dock.
- No sideways scroll at 360 px: wide tables scroll in their own box with a
  shaded edge; paths break; grids that sized to a long word are one column.

e2e: phone.spec (390×844 with touch, 360×740 for overflow, and the desk's
head unchanged); work.spec's interim phone block moved there.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/app/globals.css | 351+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
Mumtool/app/layout.tsx | 12+++++++++++-
Mumtool/app/settings/system/page.tsx | 2+-
Mumtool/app/tools/sources/page.tsx | 2++
Mumtool/app/work/page.tsx | 56+++++++++++++++++++++++++++++++++++++++++++-------------
Mumtool/components/ThumbBench.tsx | 2+-
Mumtool/components/articles/ArticleTable.tsx | 3+++
Mumtool/components/articles/IterationsTab.tsx | 2+-
Mumtool/components/articles/WorkspacePanel.tsx | 4++--
Mumtool/components/inbox/InboxList.tsx | 40+++++++++++++++++++++++++++++++++++-----
Mumtool/components/piece/Lifecycle.tsx | 2+-
Mumtool/components/piece/LifecycleChip.tsx | 44++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/piece/Menu.tsx | 25++++++++++++++++++++++++-
Mumtool/components/piece/PieceFrame.tsx | 15+++++++++++++--
Mumtool/components/piece/PolicyChip.tsx | 10++++++++--
Aumtool/components/piece/StagePips.tsx | 29+++++++++++++++++++++++++++++
Mumtool/components/projects/ProjectGrid.tsx | 2+-
Mumtool/components/projects/song/CutsTab.tsx | 4++--
Mumtool/components/shell/AppHeader.tsx | 39+++++++++++++++++++++++++++++++--------
Mumtool/components/shell/AppRail.tsx | 9++++++++-
Mumtool/components/shell/AppShell.tsx | 8++++++++
Aumtool/components/shell/FilterSheet.tsx | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/PageActions.tsx | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/PhoneDock.tsx | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/PlaceBar.tsx | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/shell/RailCount.tsx | 9++++++++-
Aumtool/components/shell/Sheet.tsx | 155+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aumtool/components/shell/phone.tsx | 44++++++++++++++++++++++++++++++++++++++++++++
Mumtool/components/system/Maintenance.tsx | 2+-
Mumtool/components/tools/ToolList.tsx | 12+++++++++---
Mumtool/components/ui/table.tsx | 2+-
Mumtool/components/ui/tabs.tsx | 5++++-
Aumtool/e2e/phone.spec.ts | 362+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/e2e/work.spec.ts | 75++++-----------------------------------------------------------------------
34 files changed, 1483 insertions(+), 209 deletions(-)

diff --git a/umtool/app/globals.css b/umtool/app/globals.css @@ -436,29 +436,8 @@ canvas.grabbable { border-right: 1px solid var(--seam); } - /* Below a laptop the rail stops being a column and becomes the top strip - (two compact rows; the rules that must beat the rail's Tailwind utilities - are in the utilities layer, "the narrow strip", below). */ - @media (max-width: 760px) { - body:has(.app-rail) { - padding-left: 0; - } - .app-rail { - position: static; - width: auto; - flex-direction: row; - flex-wrap: wrap; - align-items: center; - overflow: visible; - border-right: 0; - border-bottom: 1px solid var(--seam); - } - .app-rail [data-rail-section="pins"], - .app-rail [data-rail-section="running"], - .app-rail [data-rail-section="jump"] { - display: none; - } - } + /* Below md the rail is not drawn: the phone dock carries the places + ("phone: the shell", at the end of this file). */ .app-places > a, .app-places > [data-nav-group] > button { @@ -617,6 +596,14 @@ canvas.grabbable { .lit-line:hover [data-lit-act] { opacity: 1; } + /* A line's STATE CHANGES (a piece's lifecycle, a mute) take a press only on + the lit line. Shown on hover they are still drawn, but a press on a line + that is not lit lights it and does nothing else: hidden, they were + pressable before they were drawn, and a tap that meant "this one" parked + a piece. The keys reach them as before -- focus lights the line. */ + .lit-line:not([data-lit]) [data-lit-act] :is([data-lifecycle-to], [data-mute]) { + pointer-events: none; + } /* The cite thread shows on the lit line only: on every row it was a barcode. */ .lit-line [data-lit-only] { display: none; @@ -775,73 +762,7 @@ canvas.grabbable { type into. A control's edge is seam-2 (the canvas's .btn), whatever its class says. In the utilities layer, element + attribute, so it beats the bare border utility and loses to every hover/focus/state variant. */ -/* ── the narrow strip (≤ 760 px): the rail as two compact rows ── - Row 1: the wordmark, + Create and the theme (pushed right). Row 2: the places - in one line, scrolling sideways when the window is narrower still, the place - you are in underlined (the lit edge turned on its side). Jump, Pinned and - Running are not drawn here, nor a tool's sub-list (Tools is one click away). - In the UTILITIES layer, more specific than a class: the rail's elements carry - Tailwind utilities (flex, grid, margins), which beat the components layer. */ @layer utilities { - @media (max-width: 760px) { - .app-rail { - flex-wrap: wrap; - gap: 0 6px; - padding: 6px 8px 0; - } - .app-rail [data-rail-home] { - order: 0; - padding: 6px 6px; - } - .app-rail [data-rail-create] { - order: 1; - margin: 0; - padding: 4px 10px; - } - .app-rail [data-rail-section="theme"] { - order: 2; - margin-left: auto; - padding: 0; - } - .app-rail [data-rail-section="jump"], - .app-rail [data-rail-section="pins"], - .app-rail [data-rail-section="running"], - .app-rail .app-sub { - display: none; - } - .app-rail .app-places { - order: 3; - flex: 1 0 100%; - display: flex; - flex-wrap: nowrap; - gap: 2px; - margin-top: 4px; - padding: 0; - overflow-x: auto; - scrollbar-width: none; - } - .app-rail .app-places > a, - .app-rail .app-places > [data-nav-group] > button { - width: auto; - flex: none; - white-space: nowrap; - padding: 7px 10px 9px; - border-radius: 3px 3px 0 0; - } - .app-rail .app-places .rail-n { - margin-left: 6px; - } - .app-rail .app-places > a[aria-current]::before, - .app-rail .app-places > [data-nav-group] > button[aria-current="page"]::before { - top: auto; - bottom: 0; - left: 8px; - right: 8px; - width: auto; - height: 2px; - } - } - /* The ONE primary action of a list line (canvas `.ln .act .btn.go`): an outline at rest, filled Signal on the lit line only -- Signal is the lit line's and the one primary action's, never every row's. In the utilities @@ -864,3 +785,255 @@ canvas.grabbable { } } + +/* ---- phone: the shell ---- + Below md (768 px) is a PHONE; md and up is the desk, exactly as it was. Every + rule here is inside the phone's media query (bar the sheet's backdrop, which + only a phone ever opens), and UNLAYERED, so it beats the utilities a + component carries for the desk without anyone's class list changing. + + The shell on a phone (components/shell/): the place bar fixed at the top + (44 px: back, the trail, ⋯ -- it hides on a scroll down), the title IN FLOW, + a piece's tab strip sticky under the bar, and the dock fixed at the foot + (56 px + the safe area: the rail's places, ≡ More). The page is ONE + document: the window scrolls, never a pane inside it. Pinned while reading: + the bar (0 once hidden) + a tab strip 40 + the dock 56. + + Anything that does not fit goes in a BOTTOM SHEET (components/shell/Sheet.tsx), + at most 80% of the screen, its body the one inner scroll a phone page has. + No motion but the place bar's slide, on the lit line's own glide. */ + +.sheet-backdrop { + display: none; +} + +@media (max-width: 767.98px) { + /* The rail is the desk's; the dock carries the places. */ + .app-rail { + display: none; + } + body:has(.app-rail) { + padding-left: 0; + } + + /* One document: the window scrolls. A page's column stays `h-full`, which + against an auto-height body is its content's height; a list that was the + scroller (`.deck-main`) is in flow. */ + html:has(.phone-dock), + html:has(.phone-dock) body { + height: auto; + min-height: 100%; + } + body:has(.phone-dock) { + --dock-h: calc(56px + env(safe-area-inset-bottom)); + padding-bottom: var(--dock-h); + } + body:has(.phone-dock) .deck-main { + overflow: visible; + } + /* Nothing pushes the page sideways: a path breaks where it must, a picker + is as wide as the screen at most. A table that cannot fit scrolls in its + own box (`.scroll-x`), its cut edge shaded so it reads as more. */ + body:has(.phone-dock) main :is(code, kbd + code) { + overflow-wrap: anywhere; + } + body:has(.phone-dock) main :is(select, img, video) { + max-width: 100%; + } + .scroll-x { + overflow-x: auto; + background: + linear-gradient(to right, var(--ground) 30%, transparent) left / 24px 100% no-repeat local, + linear-gradient(to left, var(--ground) 30%, transparent) right / 24px 100% no-repeat local, + radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--text) 22%, transparent), transparent) left / 10px 100% no-repeat scroll, + radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--text) 22%, transparent), transparent) right / 10px 100% no-repeat scroll; + } + body:has([data-place-bar]) { + --place-top: 44px; + padding-top: 44px; + } + html[data-place-hidden] body { + --place-top: 0px; + } + /* A sheet is open: the page under it holds still. */ + html[data-sheet-open] { + overflow: hidden; + } + + /* ── the place bar ── */ + .place-bar { + position: fixed; + top: 0; + inset-inline: 0; + z-index: 30; + display: flex; + height: 44px; + align-items: center; + gap: 2px; + padding: 0 4px; + background: var(--panel); + border-bottom: 1px solid var(--seam); + transition: transform var(--glide); + } + html[data-place-hidden] .place-bar { + transform: translateY(-100%); + } + .place-bar-btn { + display: inline-flex; + flex: none; + width: 44px; + height: 44px; + align-items: center; + justify-content: center; + color: var(--text-2); + text-decoration: none; + } + + /* ── a tab strip: one row, sideways, snapping; a piece's sticks under the bar ── */ + .tab-strip { + flex-wrap: nowrap; + overflow-x: auto; + overscroll-behavior-x: contain; + scroll-snap-type: x proximity; + scrollbar-width: none; + } + .tab-strip > a { + flex: none; + margin-bottom: 0; + scroll-snap-align: start; + white-space: nowrap; + } + [data-piece-tabs] { + position: sticky; + top: var(--place-top, 0px); + z-index: 20; + background: var(--ground); + transition: top var(--glide); + } + + /* ── the dock ── */ + .phone-dock { + position: fixed; + inset-inline: 0; + bottom: 0; + z-index: 30; + display: flex; + padding-bottom: env(safe-area-inset-bottom); + background: var(--panel); + border-top: 1px solid var(--seam); + } + .dock-item { + position: relative; + display: flex; + min-width: 0; + height: 56px; + flex: 1 1 0; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 1px; + font-size: 12px; + color: var(--muted-2); + text-decoration: none; + } + .dock-item[aria-current] { + color: var(--text); + font-weight: 600; + } + /* The lit edge, on its side: Signal along the top of the place you are in. */ + .dock-item[aria-current]::before { + content: ""; + position: absolute; + top: -1px; + left: 20%; + right: 20%; + height: 2px; + background: var(--signal); + } + + /* ── the bottom sheet ── */ + .sheet-backdrop { + display: block; + position: fixed; + inset: 0; + z-index: 40; + background: color-mix(in srgb, var(--ground) 72%, transparent); + } + .sheet-panel, + .page-actions[data-open], + .filter-sheet[data-open] { + position: fixed; + inset-inline: 0; + bottom: 0; + z-index: 41; + display: flex; + max-height: 80vh; + max-height: 80dvh; + flex-direction: column; + align-items: stretch; + gap: 8px; + margin: 0; + padding: 0 16px calc(16px + env(safe-area-inset-bottom)); + overflow-y: auto; + overscroll-behavior: contain; + background: var(--panel); + border-top: 1px solid var(--seam-2); + border-radius: 10px 10px 0 0; + box-shadow: 0 -10px 30px rgb(0 0 0 / 0.28); + outline: none; + } + .sheet-head { + position: sticky; + top: 0; + z-index: 1; + display: flex; + min-height: 52px; + align-items: center; + gap: 10px; + margin: 0 -16px; + padding: 8px 6px 0 16px; + background: var(--panel); + border-bottom: 1px solid var(--seam); + touch-action: none; + } + .sheet-grip { + position: absolute; + top: 6px; + left: 50%; + width: 36px; + height: 4px; + margin-left: -18px; + border-radius: 2px; + background: var(--seam-2); + } + .sheet-close { + min-height: 44px; + margin-left: auto; + padding: 0 12px; + font-size: 13px; + color: var(--text-2); + } + /* Every control in a sheet is a thumb's target. */ + :is(.sheet-panel, .page-actions[data-open], .filter-sheet[data-open]) :is(a, button, select):not(.sheet-close) { + min-height: 44px; + } + /* In the page's sheet the lifecycle comes first: it is what a piece's ⋯ is for. */ + .page-actions[data-open] > [data-lifecycle-choice] { + order: -1; + } + .sheet-item { + display: flex; + min-height: 44px; + align-items: center; + padding: 0 4px; + font-size: 15px; + color: var(--text-2); + text-align: left; + text-decoration: none; + } + .sheet-item[aria-current] { + color: var(--text); + font-weight: 600; + } +} +/* ---- end phone: the shell ---- */ diff --git a/umtool/app/layout.tsx b/umtool/app/layout.tsx @@ -1,4 +1,4 @@ -import type { Metadata } from "next"; +import type { Metadata, Viewport } from "next"; import { cookies } from "next/headers"; import "./globals.css"; import { fontVariables } from "./fonts"; @@ -11,6 +11,16 @@ export const metadata: Metadata = { description: "Report videos, songs and sweeps: what is running, what is waiting, what is built.", }; +// `viewport-fit=cover`: the page runs under a phone's home indicator, so the +// dock (and anything else pinned to the bottom) can pad by +// env(safe-area-inset-bottom) -- which is 0 without it. Width and scale are +// Next's defaults, said again because this object replaces them. +export const viewport: Viewport = { + width: "device-width", + initialScale: 1, + viewportFit: "cover", +}; + // Deliberately no loading.tsx anywhere in this app. In this Next it turns // notFound() 404s into 200s and never shows on a client sibling navigation -- // see the note in editor/next.config.ts. diff --git a/umtool/app/settings/system/page.tsx b/umtool/app/settings/system/page.tsx @@ -56,7 +56,7 @@ export default async function SystemPage() { } /> <main className="deck-main flex-1 p-4"> - <div className="grid gap-3 lg:grid-cols-2 2xl:grid-cols-3"> + <div className="grid gap-3 max-md:grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3"> <ToolsPanel initial={tools} freeBytes={free} /> <RootsPanel roots={roots} /> <IndexPanel index={{ ok: prune.ok, records: prune.records, path: prune.path, builtAt: prune.builtAt, stale: prune.stale.length }} /> diff --git a/umtool/app/tools/sources/page.tsx b/umtool/app/tools/sources/page.tsx @@ -54,6 +54,7 @@ export default async function SourcesPage() { {/* Placements (runtime an episode supplies) and clips (palette) are different units: both are shown, never summed. No lead paragraph. */} + <div className="scroll-x"> <table className="w-full border-collapse text-[12px]"> <thead> <tr className="micro"> @@ -112,6 +113,7 @@ export default async function SourcesPage() { ))} </tbody> </table> + </div> </> )} </main> diff --git a/umtool/app/work/page.tsx b/umtool/app/work/page.tsx @@ -1,6 +1,7 @@ import Link from "next/link"; import { UndoBar, LifecycleButton } from "@/components/piece/Lifecycle"; import Menu from "@/components/piece/Menu"; +import FilterSheet from "@/components/shell/FilterSheet"; import SlashFocus from "@/components/shell/SlashFocus"; import AppShell from "@/components/shell/AppShell"; import { badgeVariants } from "@/components/ui/badge"; @@ -36,8 +37,13 @@ export const dynamic = "force-dynamic"; // A row's Park / Mark done sit behind its own ⋯ menu, never on the line: a // lit line's actions are clickable before they are drawn, and on a phone the // buttons landed on the stage pips, so a tap on the row marked a piece done. -// Below md the row is the piece and its stage only (Kind, Lifecycle and Open -// are facets above), so the title keeps its column. +// +// ON A PHONE (below md; the desk unchanged) a row is a CARD: the title (two +// lines at most), `kind · site` in mono, the stage pips and the stage's word. +// A tap anywhere on it opens the piece, and it carries NO lifecycle control -- +// that is the piece's ⋯ sheet, with its Undo. No table head (it overprinted). +// The facets fold into one summary line that opens them in a sheet +// (FilterSheet.tsx); the search stays in flow. // --------------------------------------------------------------------------- type Search = { [K in keyof WorkQuery]?: string }; @@ -72,6 +78,15 @@ export default async function WorkPage({ searchParams }: { searchParams: Promise (k) => all.some((r) => r.kinds.includes(k.id)), ); const bySite = sp.by === "site"; + // The phone's one line for the facets: "Active · any stage · any kind". + const summary = [ + life ? LIFE_LABEL[life] : "Every lifecycle", + sp.stage ? STAGE_LABEL[sp.stage] ?? sp.stage : "any stage", + sp.kind ? (kinds.find((k) => k.id === sp.kind)?.label ?? sp.kind) : "any kind", + ...(sp.site ? [sp.site] : []), + ...(sp.recurring === "1" ? ["recurring"] : []), + ...EXTRA.filter((e) => sp[e.key]).map((e) => `${e.label}: ${sp[e.key]}`), + ].join(" · "); const groups = bySite ? groupBySite(shown) : [{ key: "", title: null as React.ReactNode, rows: shown }]; return ( @@ -80,7 +95,7 @@ export default async function WorkPage({ searchParams }: { searchParams: Promise active="work" crumbs={[{ label: "Work" }]} meta={ - <span data-work-count={shown.length}> + <span data-work-count={shown.length} className="max-md:hidden"> {shown.length} piece{shown.length === 1 ? "" : "s"} shown · {life ?? "every lifecycle"} </span> } @@ -95,7 +110,7 @@ export default async function WorkPage({ searchParams }: { searchParams: Promise <Toolbar aria-label="Filters" className="px-4"> {/* A GET form, so a search is a pasteable URL; the other keys ride along. */} - <form method="get" action={workHref()} className="flex items-center gap-1.5" role="search"> + <form method="get" action={workHref()} className="flex items-center gap-1.5 max-md:basis-full" role="search"> {(Object.keys(sp) as (keyof Search)[]) .filter((k) => k !== "q" && k !== "deleted" && k !== "freed" && sp[k]) .map((k) => ( @@ -108,15 +123,19 @@ export default async function WorkPage({ searchParams }: { searchParams: Promise placeholder="Find a piece" aria-label="Find a piece" data-work-search="" - className="w-56 py-[3px] text-[12.5px]" + className="w-56 py-[3px] text-[12.5px] max-md:min-h-11 max-md:w-auto max-md:flex-1 max-md:text-[15px]" /> - <kbd aria-hidden="true">/</kbd> + {/* No `/` key on a phone; kbd's own display is unlayered, so the span hides it. */} + <span className="max-md:hidden"> + <kbd aria-hidden="true">/</kbd> + </span> {sp.q && ( <Link href={href({ q: "" })} className="ink-link text-[12px]"> clear </Link> )} </form> + <FilterSheet summary={summary} count={shown.length}> <ToolbarGroup label="Stage" data-facet="stage"> <Chip href={href({ stage: "" })} on={!sp.stage} label="Any" /> {STAGES.map((s) => ( @@ -175,6 +194,7 @@ export default async function WorkPage({ searchParams }: { searchParams: Promise ))} </ToolbarGroup> )} + </FilterSheet> </Toolbar> <main className="deck-main flex-1 px-4 pb-6 pt-2"> @@ -194,7 +214,7 @@ export default async function WorkPage({ searchParams }: { searchParams: Promise <EmptyState title={all.length === 0 ? "No pieces: no articles and no projects" : "Nothing matches that filter"} /> ) : ( <> - <div className={cn(COLS, "gap-x-3.5 pb-1.5 pl-5 pr-3 pt-2")}> + <div className={cn(COLS, "gap-x-3.5 pb-1.5 pl-5 pr-3 pt-2 max-md:hidden")}> <span className="micro">Piece</span> <span className="micro">Stage</span> <span className="micro max-md:hidden">Kind</span> @@ -244,8 +264,8 @@ function groupBySite(rows: WorkRow[]): { key: string; title: React.ReactNode; ro })); } -/** The list's columns; below md, the piece and its stage only. */ -const COLS = "grid grid-cols-[minmax(0,1fr)_190px_160px_130px_56px] max-md:grid-cols-[minmax(0,1fr)_auto]"; +/** The list's columns on the desk; below md a row is a card (one column). */ +const COLS = "grid grid-cols-[minmax(0,1fr)] md:grid-cols-[minmax(0,1fr)_190px_160px_130px_56px]"; function Row({ r }: { r: WorkRow }) { return ( @@ -258,14 +278,24 @@ function Row({ r }: { r: WorkRow }) { data-audience={r.audience ?? undefined} data-open-notes={r.counts.notes} data-recurring={r.recurring ? "" : undefined} - className={cn(COLS, "items-center gap-x-3.5")} + className={cn(COLS, "items-center gap-x-3.5 max-md:gap-y-1.5 max-md:py-3")} > <div className="flex min-w-0 items-center gap-2"> <div className="min-w-0 flex-1"> - <Link href={r.href} prefetch={false} className="block truncate font-medium text-inherit hover:underline" data-piece-link=""> + {/* On a phone the link covers the card (its ::after), so a tap anywhere opens the piece. */} + <Link + href={r.href} + prefetch={false} + className="block truncate font-medium text-inherit hover:underline max-md:line-clamp-2 max-md:whitespace-normal max-md:text-[15px] max-md:font-semibold max-md:leading-snug max-md:text-text max-md:after:absolute max-md:after:inset-0 max-md:hover:no-underline" + data-piece-link="" + > {r.title} </Link> - <small className="block truncate font-mono text-[11px] text-muted-2"> + <small className="mt-0.5 block truncate font-mono text-[12px] text-muted md:hidden" data-work-card-kind=""> + {[r.kindLabel, r.site, r.lifecycle !== "active" ? r.lifecycle : null].filter(Boolean).join(" · ")} + {r.chip && <span className="ml-2 font-sans text-meter">{r.chip}</span>} + </small> + <small className="block truncate font-mono text-[11px] text-muted-2 max-md:hidden"> {r.id} {r.chip && ( <span className="ml-2 font-sans text-meter" data-work-chip=""> @@ -274,7 +304,7 @@ function Row({ r }: { r: WorkRow }) { )} </small> </div> - <LitActions className="shrink-0 gap-0"> + <LitActions className="shrink-0 gap-0 max-md:hidden"> <Menu data-work-lifecycle={r.id} label={`Lifecycle: ${LIFE_LABEL[r.lifecycle]}`} diff --git a/umtool/components/ThumbBench.tsx b/umtool/components/ThumbBench.tsx @@ -175,7 +175,7 @@ export default function ThumbBench({ disabled={busy !== null} onClick={() => void accept(c.name, c.file)} data-accept={c.name} - className={buttonVariants({ size: "sm" })} + className={`${buttonVariants({ size: "sm" })} max-md:whitespace-normal`} > {busy === c.name ? "Accepting…" : `Accept — spends ${c.corners.length} videos`} </button> diff --git a/umtool/components/articles/ArticleTable.tsx b/umtool/components/articles/ArticleTable.tsx @@ -16,7 +16,9 @@ export { articleHref }; export default function ArticleTable({ articles }: { articles: ArticleRow[] }) { if (articles.length === 0) return <p className="text-[12px] text-[var(--color-dim)]">no articles</p>; + // Its own sideways scroll on a phone (`.scroll-x`): eight columns never fit 360 px. return ( + <div className="scroll-x"> <table className="w-full border-collapse text-[12px]" data-testid="article-table"> <thead> <tr className="text-left text-[11px] text-[var(--color-dim)]"> @@ -103,5 +105,6 @@ export default function ArticleTable({ articles }: { articles: ArticleRow[] }) { ))} </tbody> </table> + </div> ); } diff --git a/umtool/components/articles/IterationsTab.tsx b/umtool/components/articles/IterationsTab.tsx @@ -287,7 +287,7 @@ function IterationCard({ </Button> )} {task && !active && ( - <span className="flex items-center gap-1"> + <span className="flex items-center gap-1 max-md:flex-wrap"> <ModelSelect label={`copy ${it.label} on model`} value={copyModel} onChange={setCopyModel} models={ctx.allModels} /> {task === "sweep" && copyModel.startsWith("claude-") && ( <ExtractorSelect label={`extractor for the copy of ${it.label}`} value={copyExtractor} onChange={setCopyExtractor} models={ctx.policy?.models.api ?? []} /> diff --git a/umtool/components/articles/WorkspacePanel.tsx b/umtool/components/articles/WorkspacePanel.tsx @@ -22,11 +22,11 @@ export default function WorkspacePanel({ }) { if (workspaces.length === 0) return <p className="text-[12px] text-[var(--color-dim)]">no workspace found</p>; return ( - <div className="grid gap-4 min-[1100px]:grid-cols-[minmax(240px,320px)_1fr]" data-testid="workspace-panel"> + <div className="grid gap-4 max-md:grid-cols-1 min-[1100px]:grid-cols-[minmax(240px,320px)_1fr]" data-testid="workspace-panel"> <div className="space-y-3"> {workspaces.map((w) => ( <div key={w.name} data-workspace={w.name}> - <div className="mb-1 font-mono text-[11px] text-[var(--color-dim)]">{w.dir}</div> + <div className="mb-1 font-mono text-[11px] text-[var(--color-dim)] max-md:break-all">{w.dir}</div> <ul className="space-y-0.5"> {w.files.map((f) => { const on = opened?.ws === w.name && opened.rel === f.rel; diff --git a/umtool/components/inbox/InboxList.tsx b/umtool/components/inbox/InboxList.tsx @@ -7,6 +7,8 @@ import { LitList } from "@/components/ui/lit-list"; import { LitActions, LitGroup, LitLine } from "@/components/ui/lit-line"; import { cn } from "@/lib/utils"; import { LifecycleButton, MuteButton, type LifecycleState } from "@/components/piece/Lifecycle"; +import Menu from "@/components/piece/Menu"; +import { PhoneOnly } from "@/components/shell/phone"; // --------------------------------------------------------------------------- // The Inbox's cards as ONE lit list (canvas "Inbox"): a group head, then a @@ -18,6 +20,11 @@ import { LifecycleButton, MuteButton, type LifecycleState } from "@/components/p // kind of call on one piece (lib/mutes.ts, beside it). Both are the server's, // so every page and the API agree; a muted or parked card is listed again under // "Muted N" / "Show hidden" with Unmute / Reactivate. +// +// Park and Mute change state, so a tap on a line never reaches them: on the +// desk they take a press only on the LIT line (app/globals.css, `.lit-line`), +// and on a phone -- where nothing is hover-only -- they are behind the card's +// own ⋯, always drawn, which opens them in a sheet with their names on. // --------------------------------------------------------------------------- export type InboxCard = { @@ -132,18 +139,18 @@ function Card({ card: c }: { card: InboxCard }) { </span> <span className="sm:justify-self-end"> {c.muted && c.piece ? ( - <MuteButton piece={c.piece} kind={c.kind} title={c.title} muted variant="outline" size="md" className="lit-go" /> + <MuteButton piece={c.piece} kind={c.kind} title={c.title} muted variant="outline" size="md" className="lit-go max-md:min-h-11" /> ) : parked && c.piece ? ( - <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="active" label="Reactivate" variant="outline" size="md" className="lit-go" /> + <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="active" label="Reactivate" variant="outline" size="md" className="lit-go max-md:min-h-11" /> ) : c.finish && c.piece ? ( - <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="done" label="Mark done" variant="outline" size="md" className="lit-go" /> + <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="done" label="Mark done" variant="outline" size="md" className="lit-go max-md:min-h-11" /> ) : ( - <Link href={c.action.href} prefetch={false} data-action-link="" className={cn(buttonVariants({ variant: "outline", size: "md" }), "lit-go")}> + <Link href={c.action.href} prefetch={false} data-action-link="" className={cn(buttonVariants({ variant: "outline", size: "md" }), "lit-go max-md:min-h-11")}> {c.action.label} </Link> )} </span> - <LitActions className="ml-auto gap-0.5 sm:ml-0"> + <LitActions className="ml-auto gap-0.5 sm:ml-0 max-md:hidden"> {!parked && !c.muted && c.piece && ( <> <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="parked" label="Park" /> @@ -151,6 +158,29 @@ function Card({ card: c }: { card: InboxCard }) { </> )} </LitActions> + {!parked && !c.muted && c.piece && ( + <PhoneOnly> + <Menu + data-inbox-more={c.key} + className="ml-auto" + label={`${c.title} · ${c.what}`} + trigger={<span aria-hidden="true">⋯</span>} + triggerClassName={cn(buttonVariants({ variant: "quiet", size: "md" }), "min-h-11 min-w-11 text-[18px]")} + > + <LifecycleButton piece={c.piece} title={c.title} from={c.lifecycle} to="parked" label="Park — hide its calls" variant="outline" size="md" className="justify-start" /> + <MuteButton + piece={c.piece} + kind={c.kind} + title={c.title} + muted={false} + label={c.finish ? "Not yet — mute this suggestion" : "Mute this kind of call"} + variant="outline" + size="md" + className="justify-start" + /> + </Menu> + </PhoneOnly> + )} </LitLine> ); } diff --git a/umtool/components/piece/Lifecycle.tsx b/umtool/components/piece/Lifecycle.tsx @@ -188,7 +188,7 @@ export function UndoBar() { <div role="status" data-undo={last.piece} - className="fixed bottom-4 left-1/2 z-30 flex w-max max-w-[calc(100vw-2rem)] -translate-x-1/2 flex-wrap items-center gap-x-3 gap-y-1.5 rounded-[3px] border border-seam-2 bg-panel-2 px-3.5 py-2 text-[12.5px] text-text shadow-lg" + className="fixed bottom-[calc(var(--dock-h,0px)+1rem)] left-1/2 z-30 flex w-max max-w-[calc(100vw-2rem)] -translate-x-1/2 flex-wrap items-center gap-x-3 gap-y-1.5 rounded-[3px] border border-seam-2 bg-panel-2 px-3.5 py-2 text-[12.5px] text-text shadow-lg" > <span className="min-w-0"> <span data-undo-word=""> diff --git a/umtool/components/piece/LifecycleChip.tsx b/umtool/components/piece/LifecycleChip.tsx @@ -1,7 +1,9 @@ "use client"; import { LifecycleButton, type LifecycleState } from "@/components/piece/Lifecycle"; +import { usePhone } from "@/components/shell/phone"; import { badgeVariants } from "@/components/ui/badge"; +import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import Menu from "./Menu"; @@ -10,10 +12,52 @@ import Menu from "./Menu"; // is active, Reactivate (and Mark done) while it is parked, Reactivate once it // is done. The same POST and Undo bar as the Inbox's (components/piece/ // Lifecycle.tsx); the page re-reads on a change. +// +// On a phone it sits in the page's ⋯ sheet as THREE LABELLED BUTTONS -- Active, +// Parked, Done -- the current one marked and not pressable, so the state is read +// before it is changed and a change is one deliberate press with the Undo bar +// after it. A menu inside a sheet would be a second tap for no gain. const WORD: Record<LifecycleState, string> = { active: "Active", parked: "Parked", done: "Done" }; +const STATES: LifecycleState[] = ["active", "parked", "done"]; + export default function LifecycleChip({ piece, title, state }: { piece: string; title: string; state: LifecycleState }) { + const phone = usePhone(); + if (phone) { + return ( + <div role="group" aria-label="Lifecycle" data-lifecycle-choice={state} data-piece={piece} className="flex flex-col gap-1.5"> + <span className="micro">Lifecycle</span> + <div className="grid grid-cols-3 gap-1.5"> + {STATES.map((to) => + to === state ? ( + <span + key={to} + aria-current="true" + data-lifecycle-current={to} + className={cn(buttonVariants({ variant: "pressed", size: "md" }), "min-h-11 text-[13.5px]")} + > + {WORD[to]} + <span className="font-mono text-[10.5px] font-normal text-muted">now</span> + </span> + ) : ( + <LifecycleButton + key={to} + piece={piece} + title={title} + from={state} + to={to} + label={WORD[to]} + variant="outline" + size="md" + className="min-h-11 text-[13.5px]" + /> + ), + )} + </div> + </div> + ); + } return ( <Menu data-lifecycle-chip={state} diff --git a/umtool/components/piece/Menu.tsx b/umtool/components/piece/Menu.tsx @@ -1,6 +1,8 @@ "use client"; import { useEffect, useRef, useState } from "react"; +import { usePhone } from "@/components/shell/phone"; +import { Sheet } from "@/components/shell/Sheet"; import { useHydrated } from "@/components/ui/use-hydrated"; import { cn } from "@/lib/utils"; @@ -9,11 +11,17 @@ import { cn } from "@/lib/utils"; // a lifecycle change (the `umtool:lifecycle` event a LifecycleButton sends) // closes it. The trigger is disabled until hydration, the house rule: a press // before React is listening opens nothing. +// +// On a phone the panel is a BOTTOM SHEET (components/shell/Sheet.tsx), where +// the thumb is, its items full-width targets. `flatOnPhone`: a menu that is +// already inside a sheet (a piece's ⋯ items, in the page's ⋯ sheet) lays its +// items out there, with no trigger -- a menu inside a sheet is one tap too many. export default function Menu({ trigger, label, className, triggerClassName, + flatOnPhone = false, children, ...props }: { @@ -22,9 +30,12 @@ export default function Menu({ label?: string; className?: string; triggerClassName?: string; + /** On a phone: the items in place, no trigger (the menu is already in a sheet). */ + flatOnPhone?: boolean; children: React.ReactNode; } & Omit<React.ComponentProps<"div">, "children">) { const hydrated = useHydrated(); + const phone = usePhone(); const [open, setOpen] = useState(false); const ref = useRef<HTMLDivElement>(null); useEffect(() => { @@ -45,6 +56,13 @@ export default function Menu({ window.removeEventListener("umtool:lifecycle", changed); }; }, [open]); + if (phone && flatOnPhone) { + return ( + <div className={cn("flex flex-col items-stretch gap-0.5", className)} data-menu-flat="" {...props}> + {children} + </div> + ); + } return ( <div ref={ref} className={cn("relative", className)} {...props}> <button @@ -58,7 +76,12 @@ export default function Menu({ > {trigger} </button> - {open && ( + {open && phone && ( + <Sheet label={label ?? "Menu"} onClose={() => setOpen(false)} data-menu-panel=""> + {children} + </Sheet> + )} + {open && !phone && ( <div data-menu-panel="" className="absolute right-0 top-[calc(100%+4px)] z-30 flex min-w-[200px] flex-col items-stretch gap-0.5 rounded-[3px] border border-seam-2 bg-panel-2 p-1.5 shadow-lg" diff --git a/umtool/components/piece/PieceFrame.tsx b/umtool/components/piece/PieceFrame.tsx @@ -15,6 +15,7 @@ import { cn } from "@/lib/utils"; import LifecycleChip from "./LifecycleChip"; import Menu from "./Menu"; import PieceKeys from "./PieceKeys"; +import StagePips from "./StagePips"; // --------------------------------------------------------------------------- // THE PIECE PAGE's frame (plans/umtool-redesign.md, P4a-1; canvas "Piece · @@ -28,6 +29,13 @@ import PieceKeys from "./PieceKeys"; // open the tabs, in order, and `n` runs the Next card's action (PieceKeys). // A living report's article carries its schedule's cadence chip in the head, // with Pause/Resume and Tick now (`schedule`, R5); an edition says its series. +// +// ON A PHONE (the desk unchanged): the title block is in flow and scrolls away; +// the stepper is Work's stage pips with the lifecycle word; the lifecycle (three +// labelled buttons, LifecycleChip), the ⋯ items, the open-notes count and +// `head` (the policy chip) are the place bar's ⋯ sheet; the tabs are one +// sideways strip, sticky under the place bar (app/globals.css, "phone: the +// shell"). The Undo bar stays, above the dock. // --------------------------------------------------------------------------- export type FrameTab = { id: string; label: string; href: string }; @@ -88,6 +96,7 @@ export default function PieceFrame({ crumbs={crumbs} note={note} meta={meta} + sheet={head} actions={ <> {piece && <LifecycleChip piece={frame.pieceId} title={piece.title} state={frame.lifecycle} />} @@ -95,6 +104,7 @@ export default function PieceFrame({ <Menu data-piece-more="" label="More" + flatOnPhone trigger={<span aria-hidden="true">⋯</span>} triggerClassName={buttonVariants({ variant: "quiet", size: "md" })} > @@ -105,7 +115,8 @@ export default function PieceFrame({ } below={ <div className="flex flex-wrap items-center gap-x-6 gap-y-2" data-piece-frame={frame.pieceId} data-piece-stage={frame.stage} data-piece-lifecycle={frame.lifecycle}> - <Stepper steps={frame.steps} /> + <Stepper steps={frame.steps} className="max-md:hidden" /> + <StagePips steps={frame.steps} lifecycle={frame.lifecycle} className="md:hidden" /> {frame.board && ( <span className="text-[12.5px] text-muted" data-piece-from-board={frame.board.id}> from the board{" "} @@ -122,7 +133,7 @@ export default function PieceFrame({ </Link> </span> )} - {head} + {head && <span className="contents max-md:hidden">{head}</span>} {schedule && ( <span className="inline-flex flex-wrap items-center gap-2" data-piece-schedule={schedule.id}> <span className={cn(chipVariants({ variant: schedule.paused ? "state" : "meter", size: "md" }))} data-schedule-chip={schedule.chip}> diff --git a/umtool/components/piece/PolicyChip.tsx b/umtool/components/piece/PolicyChip.tsx @@ -1,4 +1,5 @@ import Link from "next/link"; +import { cache } from "react"; import { badgeVariants } from "@/components/ui/badge"; import { readPolicy, readToday } from "@/lib/articles/generation"; import { generationPolicyHref } from "@/lib/hrefs"; @@ -12,6 +13,11 @@ import { cn } from "@/lib/utils"; // Async: the policy is the editor's (askEditor), so the frame streams this in // under a <Suspense>; an editor that does not answer is said, not hidden. +// Once a request: a phone renders the chip twice (the stage row's, hidden, and +// the ⋯ sheet's -- PieceFrame), and the editor need not be asked twice. +const policyOnce = cache(() => readPolicy()); +const todayOnce = cache((daily: number) => readToday(daily)); + const usd = (v: number) => `$${v.toFixed(2)}`; const shortModel = (m: string) => m.replace(/^claude-/, ""); @@ -32,7 +38,7 @@ export function PolicyChipShell({ children, preset }: { children: React.ReactNod } export default async function PolicyChip() { - const policy = await readPolicy().catch(() => null); + const policy = await policyOnce().catch(() => null); if (!policy) { return ( <PolicyChipShell preset="unknown"> @@ -41,7 +47,7 @@ export default async function PolicyChip() { ); } const g = policy.generation; - const today = await readToday(g.caps.daily).catch(() => null); + const today = await todayOnce(g.caps.daily).catch(() => null); return ( <PolicyChipShell preset={g.preset}> <span>{g.preset}</span> diff --git a/umtool/components/piece/StagePips.tsx b/umtool/components/piece/StagePips.tsx @@ -0,0 +1,29 @@ +import type { Step } from "@/components/ui/stepper"; +import { cn } from "@/lib/utils"; + +// A piece's stage as Work's pips (app/work/page.tsx): a bar a stage, done in +// ink, the current one Signal, the rest seams -- and the stage's word after it. +// The phone's stepper (PieceFrame): the four-step stepper is two rows at 390 px +// and says no more than the pips do. `na` stages are seams, like the ones not +// reached; the stepper's title says why on the desk. +// +// No `data-step`: the stepper owns that attribute and specs count it. + +export default function StagePips({ steps, lifecycle, className }: { steps: Step[]; lifecycle?: string; className?: string }) { + const current = steps.find((s) => s.state === "current") ?? [...steps].reverse().find((s) => s.state === "done"); + return ( + <span role="img" className={cn("flex items-center gap-[3px]", className)} data-stage-pips={current?.label.toLowerCase() ?? ""} aria-label={`Stage: ${current?.label ?? "none"}`}> + {steps.map((s) => ( + <i + key={s.label} + aria-hidden="true" + className={cn("h-1 w-[22px] rounded-[1px]", s.state === "done" ? "bg-text-2" : s.state === "current" ? "bg-signal" : "bg-seam-2")} + /> + ))} + <span aria-hidden="true" className="ml-1.5 font-mono text-[12px] text-text-2"> + {current?.label.toLowerCase()} + {lifecycle && <span className="text-muted"> · {lifecycle}</span>} + </span> + </span> + ); +} diff --git a/umtool/components/projects/ProjectGrid.tsx b/umtool/components/projects/ProjectGrid.tsx @@ -25,7 +25,7 @@ export default function ProjectGrid({ } return ( - <ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4"> + <ul className="grid gap-3 max-md:grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4"> {projects.map((p) => { const c = counts?.get(p.id); // An unroutable or shadowed project keeps its card and its link -- the diff --git a/umtool/components/projects/song/CutsTab.tsx b/umtool/components/projects/song/CutsTab.tsx @@ -69,7 +69,7 @@ function CutCard({ data-present={shipped ? "1" : "0"} className="rounded border border-[var(--color-line)] bg-[var(--color-panel)]" > - <div className="flex items-start gap-3 p-3"> + <div className="flex items-start gap-3 p-3 max-md:flex-col"> {shipped ? ( /* eslint-disable-next-line @next/next/no-img-element */ <img @@ -85,7 +85,7 @@ function CutCard({ </div> )} - <div className="min-w-0 flex-1 space-y-1"> + <div className="min-w-0 flex-1 space-y-1 max-md:w-full"> <div className="flex flex-wrap items-baseline gap-2"> <Link href={cutHref(projectId, cut.name)} diff --git a/umtool/components/shell/AppHeader.tsx b/umtool/components/shell/AppHeader.tsx @@ -1,5 +1,7 @@ import Link from "next/link"; import { cn } from "@/lib/utils"; +import PageActions from "./PageActions"; +import PlaceBar from "./PlaceBar"; import { Mark } from "./Wordmark"; export type Crumb = { href?: string; label: string }; @@ -19,6 +21,14 @@ export type Crumb = { href?: string; label: string }; // 1366×768 and its rail is collapsed, so the mark links home from here. // // No hooks, no server imports: a client page (the song deck) renders it too. +// +// ON A PHONE (below md; the desk is unchanged) a PAGE head is three things: +// - the place bar (PlaceBar.tsx), fixed at the top: back, the trail, ⋯; +// - the title, the meta and `below` IN FLOW, so they scroll away -- the +// trail is not drawn here, it is the place bar's; +// - the actions and the note in the ⋯ sheet (PageActions.tsx), with +// `sheet`, what only the sheet carries. +// A BENCH head is left as it is: the bench draws its own phone head. // --------------------------------------------------------------------------- export default function AppHeader({ @@ -27,6 +37,7 @@ export default function AppHeader({ actions, meta, below, + sheet, variant = "page", clamp = false, className, @@ -39,6 +50,8 @@ export default function AppHeader({ meta?: React.ReactNode; /** A full-width row at the foot of the head (a piece's stage stepper). */ below?: React.ReactNode; + /** Page actions on a phone only, in the ⋯ sheet (a piece's policy chip): never on the desk. */ + sheet?: React.ReactNode; variant?: "page" | "bench"; /** A long title (a run's question) wraps to two lines, its full text in `title`, instead of one truncated line. */ clamp?: boolean; @@ -48,6 +61,8 @@ export default function AppHeader({ const here = crumbs[crumbs.length - 1]; const bench = variant === "bench"; return ( + <> + {!bench && <PlaceBar crumbs={crumbs} actions={!!(actions || note || sheet)} />} <header data-app-header={variant} className={cn( @@ -63,7 +78,7 @@ export default function AppHeader({ )} <nav aria-label="Breadcrumb" className={cn("min-w-0", bench ? "flex items-center gap-1.5 text-[12.5px]" : "flex flex-col gap-1")}> {trail.length > 0 && ( - <span className="flex flex-wrap items-center gap-1.5 text-[12px]"> + <span className={cn("flex flex-wrap items-center gap-1.5 text-[12px]", !bench && "max-md:hidden")}> {trail.map((c, i) => ( <span key={`${c.label}-${i}`} className="flex items-center gap-1.5"> {i > 0 && <span className="text-seam-2">/</span>} @@ -90,7 +105,7 @@ export default function AppHeader({ title={clamp ? here.label : undefined} className={cn( "display m-0 text-text", - clamp ? "line-clamp-2 max-w-[1000px] leading-[1.15]" : "truncate leading-none", + clamp ? "line-clamp-2 max-w-[1000px] leading-[1.15]" : "truncate leading-none max-md:line-clamp-2 max-md:whitespace-normal max-md:leading-[1.1]", here.label.length > 36 ? "text-[20px]" : "text-[26px]", // A place (no trail) is a title in sentence case; a piece's id // stays exactly as it is spelled. @@ -102,13 +117,21 @@ export default function AppHeader({ ))} </nav> {meta && <div className="text-[12.5px] text-muted">{meta}</div>} - {(actions || note) && ( - <div className="ml-auto flex flex-wrap items-center gap-3"> - {actions} - {note && <div className="micro">{note}</div>} - </div> - )} + {bench + ? (actions || note) && ( + <div className="ml-auto flex flex-wrap items-center gap-3"> + {actions} + {note && <div className="micro">{note}</div>} + </div> + ) + : (actions || note || sheet) && ( + <PageActions phone={sheet}> + {actions} + {note && <div className="micro">{note}</div>} + </PageActions> + )} {below && <div className="basis-full">{below}</div>} </header> + </> ); } diff --git a/umtool/components/shell/AppRail.tsx b/umtool/components/shell/AppRail.tsx @@ -1,11 +1,12 @@ import Link from "next/link"; import { cookies } from "next/headers"; -import AppNav from "@/components/AppNav"; +import AppNav, { placeOf } from "@/components/AppNav"; import { initialRunning } from "@/lib/activity"; import { homeHref } from "@/lib/hrefs"; import { THEME_COOKIE, parseTheme } from "@/lib/theme"; import CreateMenu from "./CreateMenu"; import JumpButton from "./JumpButton"; +import PhoneDock from "./PhoneDock"; import RunningList from "./RunningList"; import ThemeControl from "./ThemeControl"; import { Mark, Wordmark } from "./Wordmark"; @@ -26,11 +27,15 @@ import { Mark, Wordmark } from "./Wordmark"; // - Running (RunningList.tsx) is umtool's own jobs and the editor's live ones // with spend (lib/activity.ts readRunning, P2b). The server draws the last // view it has, never waiting on the editor; the browser asks after load. +// +// On a phone (below md) the rail is not drawn and the PHONE DOCK, rendered +// here beside it, carries the places at the foot of the screen (PhoneDock.tsx). // --------------------------------------------------------------------------- export default async function AppRail({ active }: { active: string }) { const theme = parseTheme((await cookies()).get(THEME_COOKIE)?.value); return ( + <> <div className="app-rail" data-app-rail=""> <Link href={homeHref()} prefetch={false} aria-label="umtool home" data-rail-home="" className="flex items-center gap-[9px] px-4 pb-3.5 pt-4 no-underline"> <Mark /> @@ -54,5 +59,7 @@ export default async function AppRail({ active }: { active: string }) { <ThemeControl initial={theme} /> </div> </div> + <PhoneDock place={placeOf(active)} theme={theme} /> + </> ); } diff --git a/umtool/components/shell/AppShell.tsx b/umtool/components/shell/AppShell.tsx @@ -9,6 +9,10 @@ export type { Crumb }; // page here already has. The rail is out of flow and the body pads for it // (app/globals.css, `body:has(.app-rail)`), so no page changes shape to get it. // +// On a phone (below md) the rail is not drawn: the PHONE DOCK at the foot of +// the screen carries the places (PhoneDock.tsx, rendered by AppRail), and the +// head becomes the place bar and a title in flow (AppHeader). +// // `rail="collapsed"` is a bench (canvas "Clip bench"): no rail, a compact head // whose mark links home, and the whole width for the work. // @@ -23,6 +27,7 @@ export default function AppShell({ actions, meta, below, + sheet, rail = "open", }: { /** The rail entry that is lit. */ @@ -33,6 +38,8 @@ export default function AppShell({ meta?: React.ReactNode; /** A full-width row at the foot of the head (a piece's stage stepper). */ below?: React.ReactNode; + /** Page actions on a phone only, in the ⋯ sheet (AppHeader). */ + sheet?: React.ReactNode; rail?: "open" | "collapsed"; }) { return ( @@ -44,6 +51,7 @@ export default function AppShell({ actions={actions} meta={meta} below={below} + sheet={sheet} variant={rail === "collapsed" ? "bench" : "page"} /> </> diff --git a/umtool/components/shell/FilterSheet.tsx b/umtool/components/shell/FilterSheet.tsx @@ -0,0 +1,63 @@ +"use client"; + +import { useEffect, useRef } from "react"; +import { useHydrated } from "@/components/ui/use-hydrated"; +import { cn } from "@/lib/utils"; +import { SheetHead, closeSheet, openSheet, useSheetFrame, useSheetOpen } from "./Sheet"; + +// --------------------------------------------------------------------------- +// A list's filter chips, which are two things in ONE element (as the page's +// actions are, PageActions.tsx): +// - the desk: the chip groups in the toolbar, exactly as they were -- the +// wrapper is `display: contents`, so they stay the toolbar's own items; +// - a phone: one summary line -- "Active · any stage · any kind — 77" -- that +// opens them in a bottom sheet, with "Show N" to close it. +// The chips are links, so a choice re-renders the page under the sheet and the +// sheet stays open for the next one; the summary and the count follow. +// --------------------------------------------------------------------------- + +export default function FilterSheet({ id = "filters", summary, count, children }: { id?: string; summary: string; count: number; children: React.ReactNode }) { + const hydrated = useHydrated(); + const open = useSheetOpen(id); + const panel = useRef<HTMLDivElement>(null); + const close = () => closeSheet(id); + useSheetFrame(open, close, panel); + // A soft navigation to another page leaves no sheet open behind it. + useEffect(() => () => closeSheet(id), [id]); + return ( + <> + <button + type="button" + disabled={!hydrated} + data-filter-summary="" + aria-expanded={open} + onClick={() => openSheet(id)} + className="flex min-h-11 w-full basis-full items-center gap-2 rounded-[3px] border border-seam-2 px-3 text-left text-[13px] text-text-2 md:hidden" + > + <span className="min-w-0 flex-1 truncate"> + {summary} <span className="font-mono text-meter">— {count}</span> + </span> + <span className="shrink-0 font-medium text-text">Filter ▾</span> + </button> + {open && <div className="sheet-backdrop" aria-hidden="true" onClick={close} />} + <div + ref={panel} + data-filter-sheet="" + data-open={open ? "" : undefined} + role={open ? "dialog" : undefined} + aria-modal={open ? true : undefined} + aria-label={open ? "Filters" : undefined} + tabIndex={open ? -1 : undefined} + className={cn("filter-sheet hidden md:contents")} + > + {open && <SheetHead label="Filters" onClose={close} panel={panel} />} + {children} + {open && ( + <button type="button" onClick={close} className="sticky bottom-0 mt-2 min-h-11 rounded-[3px] border border-signal bg-signal font-semibold text-on-signal"> + Show {count} + </button> + )} + </div> + </> + ); +} diff --git a/umtool/components/shell/PageActions.tsx b/umtool/components/shell/PageActions.tsx @@ -0,0 +1,54 @@ +"use client"; + +import { useEffect, useRef } from "react"; +import { cn } from "@/lib/utils"; +import { PhoneOnly } from "./phone"; +import { SheetHead, closeSheet, useSheetFrame, useSheetOpen } from "./Sheet"; + +// --------------------------------------------------------------------------- +// The page's actions and its one-line status (AppHeader's `actions` and +// `note`), in ONE element that is two things: +// - the desk: the row at the right of the head, exactly as it was; +// - a phone: the ⋯ sheet, opened from the place bar (PlaceBar.tsx) -- the +// head's controls leave the top of the screen, where the thumb is not. +// One element, not a copy per layout, so a control is never on the page twice +// (a spec's selector, a client component's request, a menu's state). +// +// `phone` is what only the sheet carries (a piece's policy chip, which the desk +// keeps in its stage row): rendered on a phone only (components/shell/phone.tsx). +// A lifecycle change closes the sheet, so the Undo bar it raises is in view. +// --------------------------------------------------------------------------- + +export const PAGE_SHEET = "page"; + +export default function PageActions({ phone, className, children }: { phone?: React.ReactNode; className?: string; children: React.ReactNode }) { + const open = useSheetOpen(PAGE_SHEET); + const panel = useRef<HTMLDivElement>(null); + const close = () => closeSheet(PAGE_SHEET); + useSheetFrame(open, close, panel); + useEffect(() => { + if (!open) return; + const changed = () => closeSheet(PAGE_SHEET); + window.addEventListener("umtool:lifecycle", changed); + return () => window.removeEventListener("umtool:lifecycle", changed); + }, [open]); + return ( + <> + {open && <div className="sheet-backdrop" aria-hidden="true" onClick={close} />} + <div + ref={panel} + data-page-actions="" + data-open={open ? "" : undefined} + role={open ? "dialog" : undefined} + aria-modal={open ? true : undefined} + aria-label={open ? "Page actions" : undefined} + tabIndex={open ? -1 : undefined} + className={cn("page-actions hidden md:ml-auto md:flex md:flex-wrap md:items-center md:gap-3", className)} + > + {open && <SheetHead label="Page actions" onClose={close} panel={panel} />} + {phone && <PhoneOnly>{phone}</PhoneOnly>} + {children} + </div> + </> + ); +} diff --git a/umtool/components/shell/PhoneDock.tsx b/umtool/components/shell/PhoneDock.tsx @@ -0,0 +1,102 @@ +"use client"; + +import Link from "next/link"; +import { useState } from "react"; +import { createHref, homeHref, researchHref, systemHref, toolsHref, workHref } from "@/lib/hrefs"; +import { useHydrated } from "@/components/ui/use-hydrated"; +import type { Theme } from "@/lib/theme"; +import { cn } from "@/lib/utils"; +import { JUMP_EVENT } from "./JumpPalette"; +import RailCount from "./RailCount"; +import { Sheet } from "./Sheet"; +import ThemeControl from "./ThemeControl"; + +// --------------------------------------------------------------------------- +// THE PHONE DOCK: the rail's places at the foot of a phone's screen, where the +// thumb is -- Inbox · Research · Work · Tools, and ≡ More (Settings, + Create, +// Jump to…, the theme), which is a sheet. 56 px and the safe area under it. +// The place you are in carries `aria-current` and the Signal edge along its +// top: the rail's lit edge, turned on its side. +// +// Rendered by AppRail beside the rail; the desk never draws it (md:hidden) and +// the rail is not drawn on a phone (app/globals.css, "phone: the shell"). Its +// counts are the rail's (RailCount), under their own attribute. +// --------------------------------------------------------------------------- + +const PLACES = [ + { id: "inbox", label: "Inbox", href: homeHref(), count: "inbox" as const }, + { id: "research", label: "Research", href: researchHref() }, + { id: "work", label: "Work", href: workHref(), count: "work" as const }, + { id: "tools", label: "Tools", href: toolsHref() }, +]; + +/** The theme as <html> says it now: a choice made since the page was served (ThemeControl stamps it there) wins. */ +function current(served: Theme): Theme { + if (typeof document === "undefined") return served; + const t = document.documentElement.dataset.theme; + return t === "light" || t === "dark" ? t : "auto"; +} + +export default function PhoneDock({ place, theme }: { place: string; theme: Theme }) { + const hydrated = useHydrated(); + const [more, setMore] = useState(false); + const moreLit = place === "settings" || place === "create"; + return ( + <> + <nav aria-label="Places" data-phone-dock="" className="phone-dock md:hidden"> + {PLACES.map((p) => ( + <Link key={p.id} href={p.href} prefetch={false} data-dock-place={p.id} aria-current={place === p.id ? "page" : undefined} className="dock-item"> + <span>{p.label}</span> + {p.count && <RailCount which={p.count} dock />} + </Link> + ))} + <button + type="button" + data-dock-place="more" + disabled={!hydrated} + aria-expanded={more} + aria-current={moreLit ? "page" : undefined} + className="dock-item" + onClick={() => setMore(true)} + > + <span aria-hidden="true" className="text-[15px] leading-none"> + ≡ + </span> + <span>More</span> + </button> + </nav> + {more && ( + <Sheet label="More" data-dock-more="" onClose={() => setMore(false)}> + <div className="flex flex-col gap-1"> + <Link + href={systemHref()} + prefetch={false} + aria-current={place === "settings" ? "page" : undefined} + className={cn("sheet-item", place === "settings" && "text-text")} + onClick={() => setMore(false)} + > + Settings + </Link> + <Link href={createHref()} prefetch={false} aria-current={place === "create" ? "page" : undefined} className="sheet-item" onClick={() => setMore(false)}> + + Create + </Link> + <button + type="button" + className="sheet-item" + onClick={() => { + setMore(false); + window.dispatchEvent(new Event(JUMP_EVENT)); + }} + > + Jump to… + </button> + </div> + <div className="mt-3 border-t border-seam pt-3"> + <p className="micro mb-2">Theme</p> + <ThemeControl initial={current(theme)} /> + </div> + </Sheet> + )} + </> + ); +} diff --git a/umtool/components/shell/PlaceBar.tsx b/umtool/components/shell/PlaceBar.tsx @@ -0,0 +1,146 @@ +"use client"; + +import Link from "next/link"; +import { useRouter } from "next/navigation"; +import { useEffect, useState } from "react"; +import { useHydrated } from "@/components/ui/use-hydrated"; +import type { Crumb } from "./AppHeader"; +import { PAGE_SHEET } from "./PageActions"; +import { openSheet, useSheetOpen } from "./Sheet"; +import { Mark } from "./Wordmark"; + +// --------------------------------------------------------------------------- +// THE PLACE BAR -- the top of a phone page: where am I, and nothing else to +// press but the way back and the page's ⋯. 44 px: +// +// ‹ articles / huck ⋯ +// +// back (the trail's last link, or the browser's back when you came from inside +// umtool), the trail in mono, and ⋯ for the page's actions (PageActions.tsx). +// A place with no trail shows the mark, home. Once the page's title has +// scrolled away the bar says the title instead of the trail. +// +// It hides on a scroll down and comes back on a scroll up -- a transform, so +// nothing reflows -- and says so on <html> (`data-place-hidden`), which moves +// a sticky tab strip up into its room. It never hides while a sheet is open. +// +// The desk never draws it (md:hidden): the head is the desk's place bar. +// --------------------------------------------------------------------------- + +/** How far a scroll must go, in one direction, before the bar moves. */ +const SLACK = 8; + +export default function PlaceBar({ crumbs, actions }: { crumbs: Crumb[]; actions: boolean }) { + const router = useRouter(); + const hydrated = useHydrated(); + const trail = crumbs.slice(0, -1); + const here = crumbs[crumbs.length - 1]; + const back = [...trail].reverse().find((c) => c.href)?.href ?? null; + const pageOpen = useSheetOpen(PAGE_SHEET); + const [titled, setTitled] = useState(false); + + // Hide on the way down, return on the way up. + useEffect(() => { + const root = document.documentElement; + let last = window.scrollY; + let frame = 0; + const read = () => { + frame = 0; + const y = window.scrollY; + if (root.hasAttribute("data-sheet-open")) { + last = y; + return; + } + if (y <= 44) root.removeAttribute("data-place-hidden"); + else if (y > last + SLACK) root.setAttribute("data-place-hidden", ""); + else if (y < last - SLACK) root.removeAttribute("data-place-hidden"); + else return; + last = y; + }; + const on = () => { + if (!frame) frame = requestAnimationFrame(read); + }; + window.addEventListener("scroll", on, { passive: true }); + return () => { + window.removeEventListener("scroll", on); + if (frame) cancelAnimationFrame(frame); + root.removeAttribute("data-place-hidden"); + }; + }, []); + + // The title in the bar once the page's own has scrolled away. + useEffect(() => { + const h1 = document.querySelector("[data-app-header=page] h1"); + if (!h1 || typeof IntersectionObserver === "undefined") return; + const io = new IntersectionObserver(([e]) => setTitled(!e.isIntersecting), { rootMargin: "-44px 0px 0px 0px" }); + io.observe(h1); + return () => io.disconnect(); + }, []); + + // A tab strip that scrolls sideways starts at the tab you are on. + useEffect(() => { + for (const strip of document.querySelectorAll<HTMLElement>(".tab-strip")) { + const cur = strip.querySelector<HTMLElement>("[aria-current=page]"); + if (cur && strip.scrollWidth > strip.clientWidth) strip.scrollLeft = Math.max(0, cur.offsetLeft - 16); + } + }, []); + + return ( + <div data-place-bar="" className="place-bar md:hidden"> + {back ? ( + <Link + href={back} + prefetch={false} + aria-label="Back" + data-place-back="" + className="place-bar-btn text-[22px] leading-none" + onClick={(e) => { + // Came from inside umtool: back is where you were, not the trail's parent. + if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return; + if (window.history.length > 1 && document.referrer.startsWith(window.location.origin)) { + e.preventDefault(); + router.back(); + } + }} + > + ‹ + </Link> + ) : ( + <Link href="/" prefetch={false} aria-label="umtool home" data-place-home="" className="place-bar-btn"> + <Mark size={20} /> + </Link> + )} + <span className="min-w-0 flex-1 truncate font-mono text-[12px] text-muted-2" data-place-trail=""> + {titled || trail.length === 0 ? ( + <span className={titled ? "font-sans text-[13.5px] font-medium text-text" : "text-muted-2"}>{titled ? here?.label : ""}</span> + ) : ( + trail.map((c, i) => ( + <span key={`${c.label}-${i}`}> + {i > 0 && <span className="text-seam-2"> / </span>} + {c.href ? ( + <Link href={c.href} prefetch={false} className="text-muted-2 no-underline"> + {c.label} + </Link> + ) : ( + c.label + )} + </span> + )) + )} + </span> + {actions && ( + <button + type="button" + disabled={!hydrated} + aria-label="Page actions" + aria-expanded={pageOpen} + data-place-more="" + className="place-bar-btn text-[20px] leading-none" + onClick={() => openSheet(PAGE_SHEET)} + > + ⋯ + </button> + )} + </div> + ); +} diff --git a/umtool/components/shell/RailCount.tsx b/umtool/components/shell/RailCount.tsx @@ -20,7 +20,8 @@ function counts(): Promise<Counts | null> { return p; } -export default function RailCount({ which }: { which: keyof Counts }) { +/** `dock`: the same count in the phone dock (PhoneDock.tsx), under its own attribute so the rail's stays the one `data-rail-count`. */ +export default function RailCount({ which, dock = false }: { which: keyof Counts; dock?: boolean }) { const [n, setN] = useState<number | null>(null); useEffect(() => { let live = true; @@ -32,6 +33,12 @@ export default function RailCount({ which }: { which: keyof Counts }) { }; }, [which]); if (n === null) return null; + if (dock) + return ( + <span className="font-mono text-[10.5px] text-meter" data-dock-count={which} aria-hidden="true"> + {n} + </span> + ); return ( <span className="rail-n" data-rail-count={which} aria-hidden="true"> {n} diff --git a/umtool/components/shell/Sheet.tsx b/umtool/components/shell/Sheet.tsx @@ -0,0 +1,155 @@ +"use client"; + +import { useCallback, useEffect, useRef, useSyncExternalStore } from "react"; +import { cn } from "@/lib/utils"; + +// --------------------------------------------------------------------------- +// THE BOTTOM SHEET -- the phone's one surface for "more than fits": the page's +// ⋯ actions, the dock's ≡ More, Work's filters, a row's ⋯ menu. On a phone the +// actions live where the thumb is, so a menu that drops from the top of the +// screen becomes a sheet that rises from the bottom. +// +// A sheet is at most 80% of the viewport, its body scrolls on its own (the one +// inner scroll a phone page has: a sheet's list is its own thing), and it +// closes four ways, all of them visible or obvious: the Close button, a tap on +// the dimmed page, a drag down on its handle, and Escape. While one is open the +// page under it does not scroll, and the place bar does not hide. +// +// No motion: the lit line's glide is the app's one movement. A drag follows the +// finger (that is the finger moving it, not an animation) and lets go. +// +// Two shapes share the look (app/globals.css, "phone: the shell"): +// <Sheet> mounted while open (a menu's panel, More, a row's ⋯). +// useSheetFrame() for a container that is ALWAYS rendered and is only a +// sheet on a phone (the page's actions, Work's filters): on +// the desk the same element sits inline, as it always did. +// Which sheet is open is a tiny shared store, so a trigger in one place (the +// place bar's ⋯) can open a container rendered in another (the page head). +// --------------------------------------------------------------------------- + +let current: string | null = null; +const listeners = new Set<() => void>(); +const emit = () => listeners.forEach((l) => l()); + +export function openSheet(id: string) { + current = id; + emit(); +} +export function closeSheet(id?: string) { + if (id && current !== id) return; + current = null; + emit(); +} + +/** Whether the named sheet is the open one. */ +export function useSheetOpen(id: string): boolean { + return useSyncExternalStore( + (on) => { + listeners.add(on); + return () => listeners.delete(on); + }, + () => current === id, + () => false, + ); +} + +/** How many sheets are open, on <html> as `data-sheet-open` (the page holds still, the place bar stays). */ +let opened = 0; +function hold(on: boolean) { + opened = Math.max(0, opened + (on ? 1 : -1)); + if (opened > 0) document.documentElement.setAttribute("data-sheet-open", ""); + else document.documentElement.removeAttribute("data-sheet-open"); +} + +/** + * The behaviour every open sheet has: Escape closes it, the focus moves into + * it and goes back to what opened it, and the page under it holds still. + */ +export function useSheetFrame(open: boolean, onClose: () => void, panel: React.RefObject<HTMLElement | null>) { + const close = useRef(onClose); + close.current = onClose; + useEffect(() => { + if (!open) return; + const opener = document.activeElement as HTMLElement | null; + hold(true); + panel.current?.focus({ preventScroll: true }); + const key = (e: KeyboardEvent) => { + if (e.key === "Escape") close.current(); + }; + document.addEventListener("keydown", key); + return () => { + document.removeEventListener("keydown", key); + hold(false); + if (opener && opener.isConnected) opener.focus({ preventScroll: true }); + }; + }, [open, panel]); +} + +/** + * The sheet's head: the grab handle (drag it down to close), what this sheet + * is, and Close. Rendered only while the sheet is open. + */ +export function SheetHead({ label, onClose, panel }: { label: React.ReactNode; onClose: () => void; panel: React.RefObject<HTMLElement | null> }) { + const drag = useRef<{ y: number; id: number } | null>(null); + const end = useCallback( + (e: React.PointerEvent, cancel = false) => { + const d = drag.current; + if (!d || d.id !== e.pointerId) return; + drag.current = null; + const dy = e.clientY - d.y; + if (panel.current) panel.current.style.translate = ""; + if (!cancel && dy > 56) onClose(); + }, + [onClose, panel], + ); + return ( + <div + data-sheet-head="" + className="sheet-head" + onPointerDown={(e) => { + if ((e.target as HTMLElement).closest("button")) return; + drag.current = { y: e.clientY, id: e.pointerId }; + (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId); + }} + onPointerMove={(e) => { + const d = drag.current; + if (!d || d.id !== e.pointerId || !panel.current) return; + panel.current.style.translate = `0 ${Math.max(0, e.clientY - d.y)}px`; + }} + onPointerUp={(e) => end(e)} + onPointerCancel={(e) => end(e, true)} + > + <i aria-hidden="true" className="sheet-grip" /> + <span className="micro min-w-0 truncate">{label}</span> + <button type="button" onClick={onClose} className="sheet-close"> + Close + </button> + </div> + ); +} + +/** A bottom sheet, mounted while open. */ +export function Sheet({ + label, + onClose, + className, + children, + ...props +}: Omit<React.ComponentProps<"div">, "children"> & { + /** What this sheet is ("Page actions", "More", a menu's name): its head and its accessible name. */ + label: string; + onClose: () => void; + children: React.ReactNode; +}) { + const panel = useRef<HTMLDivElement>(null); + useSheetFrame(true, onClose, panel); + return ( + <> + <div className="sheet-backdrop" aria-hidden="true" onClick={onClose} /> + <div ref={panel} role="dialog" aria-modal="true" aria-label={label} tabIndex={-1} className={cn("sheet-panel", className)} {...props}> + <SheetHead label={label} onClose={onClose} panel={panel} /> + {children} + </div> + </> + ); +} diff --git a/umtool/components/shell/phone.tsx b/umtool/components/shell/phone.tsx @@ -0,0 +1,44 @@ +"use client"; + +import { useSyncExternalStore } from "react"; + +// --------------------------------------------------------------------------- +// THE PHONE, as a fact a client component can read (the mobile-first layout, +// 2026-10-24): below `md` (768 px) is the phone, `md` and up the desk exactly +// as it was. +// +// Most of the phone is CSS -- base styles below md, the desk's behind `md:`. +// This is for the few places where the phone needs a DIFFERENT control rather +// than the same one laid out differently (the lifecycle as three labelled +// buttons, a menu as a bottom sheet) or a second copy of something in another +// place (the policy chip in the ⋯ sheet). The rule that keeps the desk +// unchanged: a phone-only copy is rendered only when the phone is true, so on +// the desk the DOM is what it always was -- no hidden twin for a selector to +// find twice. +// +// The server cannot know the width, so it renders the desk; a phone swaps on +// hydration. Everything that swaps sits inside a closed sheet, so nothing is +// seen to change. +// --------------------------------------------------------------------------- + +export const PHONE_QUERY = "(max-width: 767.98px)"; + +function subscribe(on: () => void) { + const mq = window.matchMedia(PHONE_QUERY); + mq.addEventListener("change", on); + return () => mq.removeEventListener("change", on); +} + +/** True below `md`; false on the server and on the desk. */ +export function usePhone(): boolean { + return useSyncExternalStore( + subscribe, + () => window.matchMedia(PHONE_QUERY).matches, + () => false, + ); +} + +/** Its children on a phone only: never in the desk's DOM. */ +export function PhoneOnly({ children }: { children: React.ReactNode }) { + return usePhone() ? <>{children}</> : null; +} diff --git a/umtool/components/system/Maintenance.tsx b/umtool/components/system/Maintenance.tsx @@ -92,7 +92,7 @@ export function StoragePanel({ rows, tiered, mediaRoot }: { rows: StorageRow[]; {outs.length === 0 && rows.length === 0 ? ( <p className="m-0 text-[12px] text-muted">No projects.</p> ) : ( - <ul aria-label="projects' storage" className="m-0 grid max-h-[420px] list-none overflow-auto p-0 text-[12px]"> + <ul aria-label="projects' storage" className="m-0 grid max-h-[420px] list-none overflow-auto p-0 text-[12px] max-md:max-h-none max-md:overflow-visible"> {rows.map((r) => ( <li key={r.id} data-storage-row={r.id} data-out={r.out} className="flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-seam py-1.5 first:border-t-0"> <span className="min-w-0 flex-1 truncate font-mono text-[11.5px] text-text">{r.id}</span> diff --git a/umtool/components/tools/ToolList.tsx b/umtool/components/tools/ToolList.tsx @@ -21,12 +21,18 @@ export default function ToolList({ groups }: { groups: { title: string; tools: T {groups.map((g) => ( <LitGroup key={g.title} title={g.title} count={g.tools.length} className="mt-[18px] first:mt-0"> {g.tools.map((t) => ( - <LitLine key={t.href} id={t.testid} data-tool-entry={t.testid} className="grid grid-cols-[180px_minmax(0,1fr)_auto] items-baseline gap-x-3.5"> - <Link href={t.href} prefetch={false} className="font-medium text-inherit hover:underline"> + <LitLine + key={t.href} + id={t.testid} + data-tool-entry={t.testid} + className="grid grid-cols-[minmax(0,1fr)] items-baseline gap-x-3.5 max-md:py-2.5 md:grid-cols-[180px_minmax(0,1fr)_auto]" + > + {/* On a phone the line is the link (its ::after covers it), the address left out. */} + <Link href={t.href} prefetch={false} className="font-medium text-inherit hover:underline max-md:text-[15px] max-md:text-text max-md:after:absolute max-md:after:inset-0"> {t.name} </Link> <span className="truncate text-[12.5px]">{t.what}</span> - <span className="font-mono text-[11px] text-muted-2">{t.href}</span> + <span className="font-mono text-[11px] text-muted-2 max-md:hidden">{t.href}</span> </LitLine> ))} </LitGroup> diff --git a/umtool/components/ui/table.tsx b/umtool/components/ui/table.tsx @@ -5,7 +5,7 @@ import { cn } from "@/lib/utils"; // server page builds one with no client JS. export function Table({ className, ...props }: React.ComponentProps<"table">) { return ( - <div className="overflow-x-auto"> + <div className="scroll-x overflow-x-auto"> <table className={cn("w-full border-collapse text-[12.5px]", className)} {...props} /> </div> ); diff --git a/umtool/components/ui/tabs.tsx b/umtool/components/ui/tabs.tsx @@ -9,6 +9,9 @@ import { cn } from "@/lib/utils"; // No prefetch: every page here is dynamic, so a prefetched tab is a full server // render of a page nobody asked for yet -- seven of them per piece page (P3 // found the rail's prefetches keeping the server busy enough to fail specs). +// +// On a phone the strip is one row that scrolls sideways and snaps (`.tab-strip`, +// app/globals.css "phone: the shell"), starting at the tab you are on. export type TabItem = { href: string; label: React.ReactNode; current?: boolean; count?: number | string; testid?: string }; export function Tabs({ @@ -18,7 +21,7 @@ export function Tabs({ ...props }: React.ComponentProps<"nav"> & { items: TabItem[]; label: string }) { return ( - <nav aria-label={label} className={cn("flex flex-wrap gap-0.5 border-b border-seam", className)} {...props}> + <nav aria-label={label} className={cn("tab-strip flex flex-wrap gap-0.5 border-b border-seam", className)} {...props}> {items.map((t) => ( <Link key={t.href} diff --git a/umtool/e2e/phone.spec.ts b/umtool/e2e/phone.spec.ts @@ -0,0 +1,362 @@ +import { test, expect, type APIRequestContext, type Page } from "@playwright/test"; +import * as urls from "./urls"; +import { researchArchiveHref, researchHref } from "../lib/research/hrefs"; +import { runsHref } from "../lib/research/runs-hrefs"; +import { warm, WARM_TIMEOUT } from "./warm"; + +// --------------------------------------------------------------------------- +// umtool ON A PHONE (the mobile-first layout, 2026-10-24): below md the shell +// is the place bar (back, the trail, ⋯) fixed at the top, the title in flow, +// a piece's tab strip sticky under the bar, and the dock (Inbox · Research · +// Work · Tools · ≡ More) fixed at the foot. The desk is unchanged -- the last +// test here holds that at the suite's own desktop viewport. +// +// What this proves, at 390×844 with touch (and 360×740 for the overflow): +// - the pinned chrome stays within 15% of the screen after a 600 px scroll, +// on a piece page and on /work; +// - no top-level page scrolls sideways; +// - a /work card opens its piece on a tap anywhere, and never changes its +// lifecycle (the operator marked a piece done by tapping a row); +// - the piece's ⋯ → Done says what it did, and Undo puts it back in Active; +// - a tap on an Inbox line never parks it; Park is a named button in the +// line's ⋯ sheet. +// +// WRITES the fixture's REPORTS_ROOT/.umtool/lifecycle.json (the report +// fixture marked done and parked, then active again). +// --------------------------------------------------------------------------- + +const PROJECT = "reports/report-fixture"; +const PIECE = `p:${PROJECT}`; +const ZETA = "a:articles/zeta"; +const PHONE = { width: 390, height: 844 }; +/** The budget: 15% of the screen, pinned while reading. */ +const BUDGET = Math.round(PHONE.height * 0.15); + +type Piece = { id: string; lifecycle: string }; +const life = async (request: APIRequestContext, id: string) => + ((await (await request.get("/api/pieces")).json()) as { pieces: Piece[] }).pieces.find((p) => p.id === id)?.lifecycle; +const setLife = (request: APIRequestContext, piece: string, state: string) => request.post("/api/pieces/lifecycle", { data: { piece, state } }); +const hydrated = (page: Page) => expect(page.locator("[data-place-more]:not([disabled]), [data-place-home]").first()).toBeVisible(); + +/** How many px of the screen's height fixed or sticky things cover (their union), with nothing open. */ +async function pinned(page: Page): Promise<{ px: number; what: string[] }> { + return page.evaluate(() => { + const spans: [number, number][] = []; + const what: string[] = []; + for (const el of document.querySelectorAll<HTMLElement>("body *")) { + const pos = getComputedStyle(el).position; + if (pos !== "fixed" && pos !== "sticky") continue; + const r = el.getBoundingClientRect(); + const top = Math.max(0, r.top); + const bottom = Math.min(innerHeight, r.bottom); + if (r.width < 4 || bottom - top < 1) continue; + // A sticky thing pins only where it has stuck; in flow, it is content. + if (pos === "sticky" && Math.round(r.top) !== Math.round(parseFloat(getComputedStyle(el).top) || 0)) continue; + spans.push([top, bottom]); + what.push(`${el.tagName.toLowerCase()}[${[...el.attributes].map((a) => a.name).filter((n) => n.startsWith("data-")).join(",")}] ${Math.round(top)}–${Math.round(bottom)}`); + } + spans.sort((a, b) => a[0] - b[0]); + let px = 0; + let end = -1; + for (const [a, b] of spans) { + if (b <= end) continue; + px += b - Math.max(a, end); + end = b; + } + return { px: Math.round(px), what }; + }); +} + +/** Scroll the window down 600 px the way a thumb does (wheel steps), after making sure the page is that long. */ +async function read600(page: Page) { + await page.evaluate(() => { + // The fixture's pages are short; the chrome is what is measured, not the + // content, so a page shorter than a screen and 600 px gets room to scroll. + const need = innerHeight + 700 - document.documentElement.scrollHeight; + if (need > 0) { + const pad = document.createElement("div"); + pad.style.height = `${need}px`; + (document.querySelector("main") ?? document.body).append(pad); + } + }); + for (let i = 0; i < 6; i++) { + await page.mouse.wheel(0, 100); + await page.waitForTimeout(60); + } + await expect.poll(() => page.evaluate(() => Math.round(scrollY))).toBeGreaterThanOrEqual(590); + // The place bar has slid away on the way down. + await expect(page.locator("html")).toHaveAttribute("data-place-hidden", ""); + await page.waitForTimeout(250); +} + +test.beforeAll(async ({ playwright }) => { + test.setTimeout(WARM_TIMEOUT); + await warm(playwright, ["/", "/work", urls.projectHref(PROJECT), urls.projectHref(PROJECT, { tab: "cut" }), "/api/pieces"]); +}); + +test.describe("on a phone (390×844)", () => { + test.use({ viewport: PHONE, isMobile: true, hasTouch: true }); + + test("the shell: the place bar and the dock, the title in flow, no rail", async ({ page }) => { + await page.goto(urls.projectHref(PROJECT)); + await hydrated(page); + await expect(page.locator("[data-app-rail]")).toBeHidden(); + const bar = page.locator("[data-place-bar]"); + await expect(bar).toBeVisible(); + expect((await bar.boundingBox())!.height).toBe(44); + await expect(bar.locator("[data-place-trail]")).toContainText("Projects"); + await expect(bar.locator("[data-place-back]")).toBeVisible(); + // The title is in flow, under the bar, and the head's controls are not on the page. + const h1 = page.getByRole("heading", { level: 1 }); + await expect(h1).toHaveText("The Report Fixture"); + expect(await h1.evaluate((el) => getComputedStyle(el.closest("header")!).position)).toBe("static"); + await expect(page.locator("[data-page-actions]")).toBeHidden(); + // Stage pips, not the stepper. + await expect(page.locator("[data-stage-pips]")).toBeVisible(); + await expect(page.getByRole("list", { name: "Stage" })).toBeHidden(); + // The dock: the rail's places and More, the place you are in lit. + const dock = page.locator("[data-phone-dock]"); + await expect(dock).toBeVisible(); + await expect(dock.locator("[data-dock-place]")).toHaveText([/^Inbox/, "Research", /^Work/, "Tools", /More/]); + await expect(dock.locator("[data-dock-place=work]")).toHaveAttribute("aria-current", "page"); + const d = (await dock.boundingBox())!; + expect(Math.round(d.y + d.height)).toBe(PHONE.height); + expect(d.height).toBeGreaterThanOrEqual(56); + // Every place in the dock is a thumb's target. + for (const b of await dock.locator("[data-dock-place]").all()) expect((await b.boundingBox())!.height).toBeGreaterThanOrEqual(44); + }); + + test("≡ More is a sheet: Settings, + Create, Jump, the theme; it closes on the dimmed page", async ({ page }) => { + await page.goto(urls.workHref()); + await hydrated(page); + await page.locator("[data-dock-place=more]").tap(); + const sheet = page.getByRole("dialog", { name: "More" }); + await expect(sheet).toBeVisible(); + await expect(sheet.getByRole("link", { name: "Settings" })).toHaveAttribute("href", urls.systemHref()); + await expect(sheet.getByRole("link", { name: "+ Create" })).toHaveAttribute("href", urls.createHref()); + await expect(sheet.getByRole("group", { name: "Theme" })).toBeVisible(); + // At most 80% of the screen, from the bottom. + const b = (await sheet.boundingBox())!; + expect(Math.round(b.y + b.height)).toBe(PHONE.height); + expect(b.height).toBeLessThanOrEqual(PHONE.height * 0.8 + 1); + await page.mouse.click(195, 40); + await expect(sheet).toHaveCount(0); + }); + + test("pinned chrome after a 600 px scroll is within 15% of the screen: a piece page and /work", async ({ page }) => { + for (const url of [urls.projectHref(PROJECT, { tab: "cut" }), urls.workHref()]) { + await page.goto(url); + await hydrated(page); + await read600(page); + const { px, what } = await pinned(page); + test.info().annotations.push({ type: "pinned", description: `${url}: ${px}px of ${PHONE.height} (${what.join("; ")})` }); + expect(px, `${url}: ${what.join("; ")}`).toBeLessThanOrEqual(BUDGET); + } + // The piece's tabs are still in reach: stuck under where the bar was. + await page.goto(urls.projectHref(PROJECT, { tab: "cut" })); + await hydrated(page); + await read600(page); + const tabs = page.locator("[data-piece-tabs]"); + await expect.poll(async () => Math.round((await tabs.boundingBox())!.y)).toBe(0); + // A scroll back up brings the place bar back. + await page.mouse.wheel(0, -120); + await expect(page.locator("html")).not.toHaveAttribute("data-place-hidden", ""); + await expect.poll(async () => Math.round((await tabs.boundingBox())!.y)).toBe(44); + }); + + test("a /work card opens its piece on a tap anywhere, and never changes its lifecycle", async ({ page, request }) => { + try { + await page.goto(urls.workHref()); + await expect(page.locator("[data-lit-list]").first()).toHaveAttribute("data-hydrated", ""); + const card = page.locator(`[data-lit-line][data-piece='${PIECE}']`); + // A card: the title, kind · site, the pips -- and no lifecycle control, drawn or not. + await expect(card.locator("[data-piece-link]")).toBeVisible(); + await expect(card.locator("[data-work-card-kind]")).toBeVisible(); + await expect(card.locator("[data-work-stage]")).toBeVisible(); + await expect(card.locator("[data-lifecycle-to]")).toHaveCount(0); + await expect(card.locator("[data-work-lifecycle]")).toBeHidden(); + // No table head on a phone. + await expect(page.locator("main .micro", { hasText: /^Piece$/ })).toBeHidden(); + // A tap on the stage pips -- where Park and Mark done once sat -- opens the piece. + const stage = (await card.locator("[data-work-stage]").boundingBox())!; + const box = (await card.boundingBox())!; + await card.tap({ position: { x: stage.x - box.x + stage.width / 2, y: stage.y - box.y + stage.height / 2 } }); + await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}`)); + expect(await life(request, PIECE)).toBe("active"); + // And a tap at the card's far edge does the same. + await page.goBack(); + await expect(card).toBeVisible(); + await card.tap({ position: { x: box.width - 6, y: box.height - 6 } }); + await expect(page).toHaveURL(new RegExp(`/projects/${PROJECT}`)); + expect(await life(request, PIECE)).toBe("active"); + } finally { + await setLife(request, PIECE, "active"); + } + }); + + test("Work's filters fold into one line that opens them in a sheet; a chip filters under it", async ({ page }) => { + await page.goto(urls.workHref()); + await hydrated(page); + await expect(page.locator("[data-facet=kind]")).toBeHidden(); + const summary = page.locator("[data-filter-summary]"); + await expect(summary).toContainText(/^Active · any stage · any kind — \d+/); + await summary.tap(); + const sheet = page.getByRole("dialog", { name: "Filters" }); + await expect(sheet).toBeVisible(); + await sheet.locator("[data-facet=kind]").getByRole("link", { name: /^Article \d+$/ }).tap(); + await expect(page).toHaveURL(/kind=article/); + await expect(summary).toContainText("Active · any stage · Article"); + await sheet.getByRole("button", { name: /^Show \d+$/ }).tap(); + await expect(sheet).toHaveCount(0); + for (const id of await page.locator("[data-lit-line][data-piece]").evaluateAll((els) => els.map((e) => e.getAttribute("data-piece")))) expect(id).toMatch(/^a:/); + }); + + test("the piece's ⋯ → Done says what it did; Undo puts it back in Active", async ({ page, request }) => { + try { + await page.goto(urls.projectHref(PROJECT)); + await hydrated(page); + await page.locator("[data-place-more]").tap(); + const sheet = page.getByRole("dialog", { name: "Page actions" }); + await expect(sheet).toBeVisible(); + // Three labelled buttons, the current one marked and not a button. + const choice = sheet.locator("[data-lifecycle-choice]"); + await expect(choice).toHaveAttribute("data-lifecycle-choice", "active"); + await expect(choice.locator("[data-lifecycle-current=active]")).toHaveText(/Active/); + await expect(choice.getByRole("button")).toHaveText(["Parked", "Done"]); + // The ⋯ items and the status line are in the sheet too. + await expect(sheet.locator("[data-piece-more]")).toBeVisible(); + await expect(sheet.locator(".micro").last()).toHaveText(/4 clips/i); + + await choice.locator("[data-lifecycle-to=done]").tap(); + const bar = page.locator(`[data-undo='${PIECE}']`); + await expect(bar).toContainText("Marked done — hidden from Active."); + await expect(sheet).toBeHidden(); + expect(await life(request, PIECE)).toBe("done"); + // The bar sits above the dock, on the screen. + const b = (await bar.boundingBox())!; + const dock = (await page.locator("[data-phone-dock]").boundingBox())!; + expect(b.y + b.height).toBeLessThanOrEqual(dock.y); + expect(b.x).toBeGreaterThanOrEqual(0); + expect(b.x + b.width).toBeLessThanOrEqual(PHONE.width); + + await bar.getByRole("button", { name: "Undo" }).tap(); + await expect(bar).toHaveCount(0); + await expect.poll(() => life(request, PIECE)).toBe("active"); + await page.locator("[data-place-more]").tap(); + await expect(page.locator("[data-lifecycle-choice]")).toHaveAttribute("data-lifecycle-choice", "active"); + } finally { + await setLife(request, PIECE, "active"); + } + }); + + test("a tap on an Inbox line never parks it; Park is a named button in the line's ⋯ sheet", async ({ page, request }) => { + try { + await page.goto(urls.homeHref()); + await expect(page.locator("[data-lit-list]").first()).toHaveAttribute("data-hydrated", ""); + const line = page.locator(`[data-lit-line][data-piece='${ZETA}'][data-card='iteration-ready']`); + await expect(line).toBeVisible(); + await line.scrollIntoViewIfNeeded(); + // The desk's Park / Mute are not drawn on a phone; ⋯ is, always. + await expect(line.locator("[data-lit-act]")).toBeHidden(); + const more = line.locator(`[data-inbox-more] > button`); + await expect(more).toBeVisible(); + // Taps across the line -- its title, and the gap between its one action + // and ⋯, where Park and Mute sit on the desk -- light it and nothing else. + const box = (await line.boundingBox())!; + const m = (await more.boundingBox())!; + const go = (await line.locator(".lit-go").boundingBox())!; + const row = m.y - box.y + m.height / 2; + for (const x of [8, box.width * 0.5, box.width - 8]) await line.tap({ position: { x, y: 10 } }); + for (const x of [go.x - box.x + go.width + 8, (go.x + go.width + m.x) / 2 - box.x, m.x - box.x - 6]) await line.tap({ position: { x, y: row } }); + await expect(page.locator("[data-undo]")).toHaveCount(0); + expect(await life(request, ZETA)).toBe("active"); + await expect(line).toBeVisible(); + + await more.tap(); + const sheet = page.getByRole("dialog"); + await expect(sheet.getByRole("button", { name: /^Park/ })).toBeVisible(); + await expect(sheet.getByRole("button", { name: /^Mute/ })).toBeVisible(); + await sheet.getByRole("button", { name: "Close" }).tap(); + await expect(sheet).toHaveCount(0); + expect(await life(request, ZETA)).toBe("active"); + } finally { + await setLife(request, ZETA, "active"); + } + }); +}); + +// ── no sideways scroll at 360×740 ─────────────────────────────────────────── + +const PAGES = [ + urls.homeHref(), + researchHref(), + researchArchiveHref(), + runsHref(), + urls.workHref(), + urls.projectsHref(), + urls.siteHref("priv"), + urls.createHref(), + urls.toolsHref(), + urls.findHref(), + urls.phraseFinderHref(), + urls.mixHref(), + urls.facesHref(), + urls.sourcesHref(), + urls.benchHref(), + urls.songToolsHref(), + urls.systemHref(), + urls.generationPolicyHref(), + ...["overview", "article", "iterations", "cut", "media", "build", "deliver", "sources", "history"].map((tab) => urls.articleHref({ site: "articles", id: "zeta" }, { tab })), + ...["overview", "cut", "sources"].map((tab) => urls.projectHref(PROJECT, { tab })), +]; + +test.describe("at 360×740", () => { + test.use({ viewport: { width: 360, height: 740 }, isMobile: true, hasTouch: true }); + test.describe.configure({ timeout: 90_000 }); + for (const url of PAGES) { + test(`${url} does not scroll sideways`, async ({ page }) => { + const res = await page.goto(url); + expect(res?.status(), url).toBeLessThan(400); + await page.waitForLoadState("networkidle", { timeout: 5_000 }).catch(() => {}); + const over = await page.evaluate(() => { + const W = document.documentElement.clientWidth; + const out: string[] = []; + for (const el of document.querySelectorAll<HTMLElement>("body *")) { + const r = el.getBoundingClientRect(); + if (r.right > W + 1 && r.width > 0 && getComputedStyle(el).position !== "fixed") out.push(`${el.tagName.toLowerCase()}.${String(el.className).slice(0, 60)}`); + } + return { scroll: document.documentElement.scrollWidth - W, out: out.slice(0, 5) }; + }); + expect(over.scroll, `${url} is ${over.scroll}px too wide: ${over.out.join(", ")}`).toBeLessThanOrEqual(0); + }); + } +}); + +// ── the desk is unchanged ─────────────────────────────────────────────────── + +test("on the desk the head is as it was: the rail, the trail, the actions inline, the stepper; no phone chrome", async ({ page }) => { + await page.goto(urls.projectHref(PROJECT)); + await expect(page.locator("[data-app-rail]")).toBeVisible(); + await expect(page.locator("[data-place-bar]")).toBeHidden(); + await expect(page.locator("[data-phone-dock]")).toBeHidden(); + const head = page.locator("header[data-app-header=page]"); + // The trail above the title, in the Breadcrumb. + await expect(head.getByRole("navigation", { name: "Breadcrumb" }).getByRole("link", { name: "Projects" })).toBeVisible(); + // The actions sit in the head's row, right of the title, inline -- not a sheet. + const actions = head.locator("[data-page-actions]"); + await expect(actions).toBeVisible(); + expect(await actions.evaluate((el) => getComputedStyle(el).position)).toBe("static"); + await expect(head.locator("[data-lifecycle-chip]")).toBeVisible(); + await expect(head.locator("[data-lifecycle-choice]")).toHaveCount(0); + const t = (await head.locator("h1").boundingBox())!; + const a = (await actions.boundingBox())!; + expect(a.x).toBeGreaterThan(t.x + t.width); + // The stepper, not the pips; the tabs wrap and do not stick. + await expect(page.getByRole("list", { name: "Stage" })).toBeVisible(); + await expect(page.locator("[data-stage-pips]")).toBeHidden(); + expect(await page.locator("[data-piece-tabs]").evaluate((el) => getComputedStyle(el).position)).toBe("static"); + // The page's column is still the scroller: the head never leaves the screen. + await page.mouse.wheel(0, 600); + await page.waitForTimeout(200); + expect(await page.evaluate(() => scrollY)).toBe(0); +}); diff --git a/umtool/e2e/work.spec.ts b/umtool/e2e/work.spec.ts @@ -12,8 +12,10 @@ import { warm, WARM_TIMEOUT } from "./warm"; // // A row's Park / Mark done are behind its own ⋯ menu (data-work-lifecycle), // never on the line: on a phone the line's buttons were drawn over the stage -// pips and a tap on the row marked a piece done. The phone block below holds -// that, at 390×844 with touch. +// pips and a tap on the row marked a piece done. On a phone a row is a card +// with no lifecycle control at all -- phone.spec.ts holds that, at 390×844 +// with touch (a tap anywhere opens the piece; Done and its Undo are the +// piece's ⋯ sheet). // --------------------------------------------------------------------------- type Piece = { id: string; kind: string; lifecycle: string; title: string }; @@ -114,72 +116,3 @@ test("Park takes a piece out of the active list, Parked lists it, Reactivate bri await request.post("/api/pieces/lifecycle", { data: { piece: REPORT, state: "active" } }); } }); - -test.describe("on a phone (390×844)", () => { - test.use({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true }); - - const life = async (request: APIRequestContext) => (await pieces(request)).find((p) => p.id === REPORT)?.lifecycle; - const box = async (l: import("@playwright/test").Locator) => { - const b = await l.boundingBox(); - expect(b).not.toBeNull(); - return b!; - }; - const apart = (a: { x: number; y: number; width: number; height: number }, b: typeof a) => - a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y; - - test("a row shows its title, its ⋯ is drawn over nothing, and a tap on the row changes no lifecycle", async ({ page, request }) => { - try { - await page.goto(urls.workHref()); - await expect(page.locator("[data-lit-list]").first()).toHaveAttribute("data-hydrated", ""); - const line = page.locator(`${rows}[data-piece='${REPORT}']`); - const title = line.locator("[data-piece-link]"); - const more = line.locator("[data-work-lifecycle] > button"); - const stage = line.locator("[data-work-stage]"); - // Lit, so its ⋯ is drawn. - await line.tap({ position: { x: 4, y: 4 } }); - await expect(line).toHaveAttribute("data-lit", ""); - await expect(more).toBeVisible(); - const [t, m, s] = [await box(title), await box(more), await box(stage)]; - expect(t.width).toBeGreaterThan(80); - expect(apart(t, m)).toBe(true); - expect(apart(m, s)).toBe(true); - // No lifecycle button on the line until its menu is opened. - await expect(line.locator("[data-lifecycle-to]")).toHaveCount(0); - // Taps across the row -- the edge, the stage pips -- light it and nothing else. - const row = await box(line); - for (const x of [8, s.x - row.x + 4, s.x - row.x + s.width / 2, row.width - 6]) { - await line.tap({ position: { x, y: row.height / 2 } }); - } - await expect(page.locator("[data-undo]")).toHaveCount(0); - expect(await life(request)).toBe("active"); - await expect(line).toBeVisible(); - } finally { - await request.post("/api/pieces/lifecycle", { data: { piece: REPORT, state: "active" } }); - } - }); - - test("Mark done says what it did and offers Undo, which brings the piece back to Active", async ({ page, request }) => { - try { - await page.goto(urls.workHref()); - await expect(page.locator("[data-lit-list]").first()).toHaveAttribute("data-hydrated", ""); - const line = page.locator(`${rows}[data-piece='${REPORT}']`); - await line.locator("[data-work-lifecycle] > button").tap(); - await line.locator("[data-lifecycle-to=done]").tap(); - const bar = page.locator(`[data-undo='${REPORT}']`); - await expect(bar).toContainText("Marked done — hidden from Active."); - await expect(line).toHaveCount(0); - expect(await life(request)).toBe("done"); - // The bar fits the phone. - const b = await box(bar); - expect(b.x).toBeGreaterThanOrEqual(0); - expect(b.x + b.width).toBeLessThanOrEqual(390); - - await bar.getByRole("button", { name: "Undo" }).tap(); - await expect(bar).toHaveCount(0); - await expect(line).toBeVisible(); - expect(await life(request)).toBe("active"); - } finally { - await request.post("/api/pieces/lifecycle", { data: { piece: REPORT, state: "active" } }); - } - }); -});