diff --git a/.agents/skills/verify-screens/features/camera-focus.md b/.agents/skills/verify-screens/features/camera-focus.md index 513554a..441eeca 100644 --- a/.agents/skills/verify-screens/features/camera-focus.md +++ b/.agents/skills/verify-screens/features/camera-focus.md @@ -5,6 +5,7 @@ A person pans with Hand, Shift-drag, the middle button or the wheel. They zoom w ## Sub-features - `cam-pan`: Hand, Shift-drag and the wheel pan by the screen delta, with no revision. +- `minimap`: the map is off by default. Turn it on to see the canvas and navigate by click or drag. The choice survives a reload. - `cam-zoom`: zoom out and in around the centre; Cmd+0 goes to 100%; Fit all frames everything and turns auto-fit back on. - `focus`: the Focus action, or the agent's `focus_item`, fits one frame and hides the others. Exit focus or Escape returns. - `focus-wheel`: in focus with Move, the wheel over the live page pans the camera, as Hand does. A scroll area inside the page keeps the wheel while it can still scroll. @@ -22,6 +23,7 @@ A person pans with Hand, Shift-drag, the middle button or the wheel. They zoom w ## How to get to it (user POV) - Press H or hold Shift and drag. Use the zoom buttons, Cmd+wheel, the Focus action on a selected frame, and Escape. +- Click the map icon in the zoom controls. Click the overview to jump or drag the viewport outline to pan. - An agent calls `show_items`, `focus_item`, `get_view` and `open_screen`. ## Driving it with screens-cli @@ -59,6 +61,30 @@ fit expect view.autoFit=true ``` +```screens id=minimap +expect dom.minimap=null +click ui:Minimap +expect dom.minimap.items=0 +add_object title=A files=fixture:plain x=0 y=0 height=300 as=@A +zoom 100 +add_object title=B files=fixture:plain x=8000 y=0 height=300 as=@B +expect dom.minimap.items=2 +mark +click ui:"Canvas overview" +expect view.camera.x<-3000 view.camera.z=1 dom.minimap.x>3000 doc.rev=+0 storage.rev=doc.rev +mark +drag ui:"Canvas overview" by 20,0 +expect view.camera.x<+-500 view.camera.z=1 dom.minimap.x>+500 doc.rev=+0 +mark +zoom in +expect view.camera.z=1.25 dom.minimap.width<+0 +view reload +wait dom.minimap.items=2 +click ui:Minimap +view reload +expect dom.minimap=null +``` + ```screens id=focus add_object title=A files=fixture:plain x=0 y=0 height=300 as=@A add_object title=B files=fixture:plain x=500 y=0 height=300 as=@B diff --git a/.agents/skills/verify-screens/features/cli-sessions.md b/.agents/skills/verify-screens/features/cli-sessions.md index 701851c..6b1dced 100644 --- a/.agents/skills/verify-screens/features/cli-sessions.md +++ b/.agents/skills/verify-screens/features/cli-sessions.md @@ -57,10 +57,8 @@ get service.conns expect service.dev=true events.revisions>0 console.errors=0 dump all as=state theme dark -invert-scroll on -expect view.theme=dark view.invertScroll=true +expect view.theme=dark theme light -invert-scroll off ``` ## Gotchas diff --git a/.agents/skills/verify-screens/features/keyboard.md b/.agents/skills/verify-screens/features/keyboard.md index fba59f1..93f65ac 100644 --- a/.agents/skills/verify-screens/features/keyboard.md +++ b/.agents/skills/verify-screens/features/keyboard.md @@ -10,7 +10,7 @@ Every canvas action works from the keyboard. On a canvas, arrow keys move the se - `kbd-camera`: with nothing selected the arrows pan. Shift+1 fits all, Shift+2 frames the selection, and Cmd+= and Cmd+- zoom. - `kbd-focus`: Enter renames the selected item. F focuses it, Tab moves focus to the next item, and F or Escape leaves. - `kbd-toolbar`: clicking a toolbar button leaves keyboard focus on the canvas, so the arrows still pan. -- `wheel-zoom`: Cmd plus scrolling up (deltaY < 0) zooms in and scrolling down zooms out, a pinch outward (Ctrl, deltaY < 0) zooms in, and Invert scroll flips both. +- `wheel-zoom`: Cmd plus scrolling up (deltaY < 0) zooms in and scrolling down zooms out, a pinch outward (Ctrl, deltaY < 0) zooms in. - `lib-kbd-open`: in the library, Cmd+Down opens the focused Screen. ## How to get to it (user POV) @@ -128,11 +128,6 @@ expect view.camera.z>1 zoom 100 wheel 0,100 --pinch expect view.camera.z<1 -invert-scroll on -zoom 100 -wheel 0,-100 --cmd -expect view.camera.z<1 -invert-scroll off ``` ```screens id=lib-kbd-open diff --git a/packages/canvas/src/engine/controller.ts b/packages/canvas/src/engine/controller.ts index 8376695..256b2ed 100644 --- a/packages/canvas/src/engine/controller.ts +++ b/packages/canvas/src/engine/controller.ts @@ -94,7 +94,6 @@ export interface ViewState { readonly comment: CommentSession & { readonly showResolved: boolean; readonly restore: CommentSession | null }; /** The command's deadline uses the animation clock, independently of its wire timestamp. */ readonly deferredCommand: (ViewCommand & { readonly expiresAt: number }) | null; - readonly invertScroll: boolean; readonly capabilities: { readonly comments: boolean }; /** The participant whose work the camera follows (roster Follow). Any press, wheel, zoom or Escape releases it. */ readonly following: string | null; @@ -137,8 +136,8 @@ export type CanvasInput = export type WheelZoom = "none" | "cmd" | "pinch"; /** Wheel delta to zoom exponent. Scrolling up (deltaY < 0) with Cmd or Ctrl zooms in, and so does a trackpad pinch - * outward, which browsers report as a Ctrl wheel with deltaY < 0. Invert scroll flips it. */ -export const wheelZoom = (dy: number, invert: boolean): number => -dy * WHEEL_ZOOM_K * (invert ? -1 : 1); + * outward, which browsers report as a Ctrl wheel with deltaY < 0. */ +const wheelZoom = (dy: number): number => -dy * WHEEL_ZOOM_K; /** A file the shell has already read. No Blob reaches the engine: the runtime keeps the bytes under the hash. */ export interface DroppedImage { readonly hash: string; readonly mediaType: string; readonly width: number; readonly height: number; readonly title: string } @@ -162,7 +161,7 @@ export type Command = | { readonly kind: "focus"; readonly itemId: ItemId } | { readonly kind: "exit-focus" } | { readonly kind: "select-tool"; readonly tool: ToolId } | { readonly kind: "delete" } | { readonly kind: "undo" } | { readonly kind: "redo" } | { readonly kind: "pencil-color"; readonly color: string } | { readonly kind: "pencil-size"; readonly size: PencilSize } - | { readonly kind: "invert-scroll"; readonly on: boolean } | { readonly kind: "edit"; readonly editing: Editing } + | { readonly kind: "center-camera"; readonly at: Point } | { readonly kind: "edit"; readonly editing: Editing } /** Panel row or card Close (null). */ | { readonly kind: "open-thread"; readonly threadId: ThreadId | null } | { readonly kind: "resolve-thread"; readonly threadId: ThreadId; readonly resolved: boolean } @@ -206,12 +205,12 @@ export interface Step { readonly state: ViewState; readonly effects: readonly Ef export const ESCAPE_CHAIN = ["cancel-gesture", "clear-stroke-selection", "clear-comment", "clear-interacting", "exit-focus", "clear-selection", "tool-move"] as const; -export function initialViewState(o: { viewport: Size; pointer: "fine" | "coarse"; dpr: number; theme: "light" | "dark"; invertScroll?: boolean }): ViewState { +export function initialViewState(o: { viewport: Size; pointer: "fine" | "coarse"; dpr: number; theme: "light" | "dark" }): ViewState { return { viewport: o.viewport, pointer: o.pointer, dpr: o.dpr, theme: o.theme, camera: { x: 0, y: 0, z: 1 }, autoFit: true, moving: false, animation: null, focus: { mode: "none" }, tool: "move", shiftPanning: false, pencil: { color: defaultInk(o.theme), size: 6 }, selection: { kind: "items", ids: [] }, interacting: null, gesture: null, wheel: { dx: 0, dy: 0, zoom: 0, anchor: { x: 0, y: 0 }, scheduled: false }, - editing: null, comment: { draft: null, activeThreadId: null, parkedDraft: null, showResolved: false, expanded: false, panelOpen: false, editingCommentId: null, composing: false, restore: null }, deferredCommand: null, invertScroll: o.invertScroll ?? false, capabilities: { comments: true }, following: null, + editing: null, comment: { draft: null, activeThreadId: null, parkedDraft: null, showResolved: false, expanded: false, panelOpen: false, editingCommentId: null, composing: false, restore: null }, deferredCommand: null, capabilities: { comments: true }, following: null, pages: SCROLL, }; } @@ -277,7 +276,7 @@ function stepInner(s: ViewState, input: CanvasInput, doc: BaseDoc, env: Env, fx: const w = s.wheel; if (input.zoom === "none" && policy(s, doc).wheel === "vertical") input = { ...input, dx: 0 }; const next = input.zoom !== "none" - ? { ...w, zoom: w.zoom + wheelZoom(input.dy, s.invertScroll), anchor: input.client } + ? { ...w, zoom: w.zoom + wheelZoom(input.dy), anchor: input.client } : { ...w, dx: w.dx + input.dx, dy: w.dy + input.dy }; if (!w.scheduled) fx.push({ type: "request-frame" }); return { ...s, wheel: { ...next, scheduled: true } }; @@ -307,7 +306,7 @@ function stepInner(s: ViewState, input: CanvasInput, doc: BaseDoc, env: Env, fx: // A wheel the page cannot scroll itself pans the canvas, as it would outside a live page. if (m.kind === "pan") return stepInner(s, { type: "wheel", dx: m.dx, dy: m.dy, zoom: "none", client: { x: s.viewport.width / 2, y: s.viewport.height / 2 } }, doc, env, fx); const anchor = { x: s.camera.x + (it.x + m.x) * s.camera.z, y: s.camera.y + (it.y + m.y) * s.camera.z }; - return userCamera(s, zoomAround(s.camera, Math.exp(wheelZoom(m.dy, s.invertScroll)), anchor), doc, fx); + return userCamera(s, zoomAround(s.camera, Math.exp(wheelZoom(m.dy)), anchor), doc, fx); } case "command": return command(s, input.command, doc, env, fx); case "title-commit": { @@ -895,6 +894,11 @@ function command(s: ViewState, c: Command, doc: BaseDoc, env: Env, fx: Effect[]) case "zoom-in": return userCamera(s, zoomAround(s.camera, ZOOM_STEP_IN, center), doc, fx); case "zoom-out": return userCamera(s, zoomAround(s.camera, ZOOM_STEP_OUT, center), doc, fx); case "zoom-100": return userCamera(s, zoomAround(s.camera, 1 / s.camera.z, center), doc, fx); + case "center-camera": { + if (s.focus.mode === "focused" || presenting(s, doc)) return s; + const { z } = s.camera; + return userCamera({ ...s, animation: null }, { x: center.x - c.at.x * z, y: center.y - c.at.y * z, z }, doc, fx); + } case "fit-all": { if (s.focus.mode !== "none") return s; const cam = fitFor(s, doc, boundsOf(doc.items.map((i) => i.rect))); @@ -986,7 +990,6 @@ function command(s: ViewState, c: Command, doc: BaseDoc, env: Env, fx: Effect[]) case "redo": fx.push({ type: "redo" }); return s; case "pencil-color": return { ...s, pencil: { ...s.pencil, color: c.color } }; case "pencil-size": return { ...s, pencil: { ...s.pencil, size: c.size } }; - case "invert-scroll": return { ...s, invertScroll: c.on }; case "edit": return { ...s, editing: c.editing }; case "pages-view": return pagesView(s, c.view, doc, env, fx); } diff --git a/packages/canvas/src/shell/Minimap.tsx b/packages/canvas/src/shell/Minimap.tsx new file mode 100644 index 0000000..7e76cb8 --- /dev/null +++ b/packages/canvas/src/shell/Minimap.tsx @@ -0,0 +1,82 @@ +import { useLayoutEffect, useRef, type PointerEvent } from "react"; +import type { Point, Rect } from "@screens/core"; +import { boundsOf, containsPoint, strokeBounds, strokePath, viewportWorldRect, type BaseDoc } from "../engine/index.ts"; +import type { CanvasRuntime } from "./runtime.ts"; + +const WIDTH = 200, HEIGHT = 132, INSET = 10; + +function mapBounds(content: Rect | null, viewport: Rect): Rect { + const b = content ? boundsOf([content, viewport])! : viewport; + const unitsPerPixel = Math.max(b.w / (WIDTH - 2 * INSET), b.h / (HEIGHT - 2 * INSET)); + const w = WIDTH * unitsPerPixel, h = HEIGHT * unitsPerPixel; + return { x: b.x + (b.w - w) / 2, y: b.y + (b.h - h) / 2, w, h }; +} + +export function Minimap({ rt, doc }: { rt: CanvasRuntime; doc: BaseDoc }) { + const svg = useRef(null); + const outline = useRef(null); + const projection = useRef(null); + const drag = useRef<{ id: number; bounds: Rect; offset: Point } | null>(null); + const items = doc.items.filter((it) => !it.removing); + const ink = doc.strokes.filter((s) => !s.removing && s.anchor.kind === "world" && s.points.length > 0); + const content = boundsOf([...items.map((it) => it.rect), ...ink.map((s) => strokeBounds(s.points, s.size))]); + + const paint = () => { + const map = svg.current, rect = outline.current; + if (!map || !rect) return; + const viewport = viewportWorldRect(rt.view.camera, rt.view.viewport); + if (viewport.w <= 0 || viewport.h <= 0) return; + // Keep the map still under a captured pointer while the camera moves. + const bounds = drag.current?.bounds ?? mapBounds(content, viewport); + projection.current = bounds; + map.setAttribute("viewBox", `${bounds.x} ${bounds.y} ${bounds.w} ${bounds.h}`); + rect.setAttribute("x", String(viewport.x)); + rect.setAttribute("y", String(viewport.y)); + rect.setAttribute("width", String(viewport.w)); + rect.setAttribute("height", String(viewport.h)); + }; + useLayoutEffect(() => { + paint(); + return rt.onPaint(paint); + }); + + const worldPoint = (e: PointerEvent, b: Rect): Point => { + const r = e.currentTarget.getBoundingClientRect(); + const fraction = (n: number) => Math.max(0, Math.min(1, n)); + return { x: b.x + fraction((e.clientX - r.left) / r.width) * b.w, y: b.y + fraction((e.clientY - r.top) / r.height) * b.h }; + }; + const navigate = (p: Point, offset: Point) => rt.dispatch({ + type: "command", command: { kind: "center-camera", at: { x: p.x + offset.x, y: p.y + offset.y } }, + }); + const start = (e: PointerEvent) => { + const bounds = projection.current; + if (e.button !== 0 || !bounds || drag.current || rt.view.gesture) return; + const p = worldPoint(e, bounds); + const v = viewportWorldRect(rt.view.camera, rt.view.viewport); + const inside = containsPoint(v, p); + const offset = inside ? { x: v.x + v.w / 2 - p.x, y: v.y + v.h / 2 - p.y } : { x: 0, y: 0 }; + e.currentTarget.setPointerCapture(e.pointerId); + drag.current = { id: e.pointerId, bounds, offset }; + if (!inside) navigate(p, offset); + }; + const move = (e: PointerEvent) => { + const active = drag.current; + if (active?.id === e.pointerId) navigate(worldPoint(e, active.bounds), active.offset); + }; + const end = (e: PointerEvent) => { + if (drag.current?.id !== e.pointerId) return; + drag.current = null; + paint(); + }; + + return ( +
+ + {items.map(({ id, rect: r }) => )} + {ink.map((s) => )} + + +
+ ); +} diff --git a/packages/canvas/src/shell/ScreenCanvas.tsx b/packages/canvas/src/shell/ScreenCanvas.tsx index af8b6b3..e8d13e7 100644 --- a/packages/canvas/src/shell/ScreenCanvas.tsx +++ b/packages/canvas/src/shell/ScreenCanvas.tsx @@ -7,11 +7,12 @@ import { HANDLES, PENCIL_COLORS, PRESENT_KEYS, PRESENT_PRELOAD, boundsOf, copyableItem, nextItem, PENCIL_SIZES, TOOLS, policyOf, presentFrame, presentIndex, presentThread, renderDocOf, slotBar, strokeBounds, strokePath, type DisplayItem, type DisplayStroke, type FramePresentation, type PagesView, type ViewState, } from "../engine/index.ts"; -import { CanvasRuntime, hitTargetOf, isControl, isEditable } from "./runtime.ts"; +import { CanvasRuntime, hitTargetOf, isControl, isEditable, safeStore } from "./runtime.ts"; import { Icon } from "./icons.tsx"; import { dockAt, Grip, SPOTS, useDock, type DockSpot } from "./Dock.tsx"; import { CommentLayer, CommentOverlay, CommentsPanel } from "./Comments.tsx"; import { PieceEditor } from "./Layers.tsx"; +import { Minimap } from "./Minimap.tsx"; import { Filmstrip } from "./Filmstrip.tsx"; import { PresenceLayer, PresenceOverlay, PresenceRoster } from "./Presence.tsx"; @@ -112,6 +113,11 @@ export function ScreenCanvas({ client, viewId, onRuntime, leading, trailing }: { const [compactLayersOpen, setCompactLayersOpen] = useState(false); // On a wide canvas the person's choice to hide Layers holds across focus; on a compact one it starts closed each time. const [wideLayersOpen, setWideLayersOpen] = useState(() => { try { return localStorage.getItem("screens.layersOpen") !== "0"; } catch { return true; } }); + const [minimapOpen, setMinimapOpen] = useState(() => safeStore.get("screens.minimapOpen") === "1"); + const toggleMinimap = () => { + safeStore.set("screens.minimapOpen", minimapOpen ? "0" : "1"); + setMinimapOpen(!minimapOpen); + }; const compactCanvas = v.viewport.width <= 700; const focusId = v.focus.mode === "focused" ? v.focus.itemId : null; useEffect(() => { setCompactLayersOpen(false); }, [focusId]); @@ -266,10 +272,11 @@ export function ScreenCanvas({ client, viewId, onRuntime, leading, trailing }: { )} + {minimapOpen && !presenting && !focusId && }
s !== toolsAt && !pagesHold.includes(s))} onDock={setZoomSpot} /> - + diff --git a/packages/canvas/src/shell/app.css b/packages/canvas/src/shell/app.css index 8cf7696..dd2445f 100644 --- a/packages/canvas/src/shell/app.css +++ b/packages/canvas/src/shell/app.css @@ -237,13 +237,28 @@ body { background: var(--window); color: var(--text); font: var(--text-md) / var .chrome[data-dock="bottom-center"] { left: 50%; transform: translateX(-50%); } .chrome[data-dock="bottom-left"] { left: var(--chrome-inset); } .chrome[data-dock="bottom-right"] { right: var(--chrome-inset); } +.stage { --zoom-bottom: var(--chrome-inset); } +.chrome.screens-zoom[data-dock^="bottom"] { bottom: var(--zoom-bottom); } +.chrome.screens-minimap { + right: var(--chrome-inset); + bottom: calc(var(--zoom-bottom) + var(--shell-height) + var(--chrome-inset)); + overflow: hidden; + border-radius: var(--radius-panel); + background: var(--surface); + box-shadow: var(--shadow-panel); +} +.screens-minimap svg { display: block; width: min(200px, 42vw); height: auto; aspect-ratio: 200 / 132; cursor: crosshair; touch-action: none; } +.screens-minimap svg:active { cursor: grabbing; } +.screens-minimap-item { fill: var(--text-secondary); opacity: 0.45; } +.screens-minimap-viewport { fill: var(--accent); fill-opacity: 0.09; stroke: var(--accent); stroke-width: 1.5px; pointer-events: none; } .chrome[data-moving] { z-index: 40; opacity: 0.85; } .screens-grip.tool { width: 18px; cursor: grab; touch-action: none; } .chrome[data-moving] .screens-grip { cursor: grabbing; } .screens-pencil { width: 360px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 2 * var(--chrome-inset)); height: auto; } .screens-canvas-head .icon-button { flex: none; } @media (max-width: 700px) { - .stage:not([data-tools-dock="top-center"]) .chrome.screens-zoom[data-dock^="bottom"] { bottom: calc(var(--shell-height) + 2 * var(--chrome-inset)); } + .stage:not([data-tools-dock="top-center"]) { --zoom-bottom: calc(var(--shell-height) + 2 * var(--chrome-inset)); } + .stage[data-tool="pencil"]:not([data-tools-dock="top-center"]) .screens-minimap { bottom: calc(var(--zoom-bottom) + 3 * (var(--shell-height) + var(--chrome-inset))); } .chrome[data-dock="top-center"] { top: calc(var(--control-lg) + 2 * var(--chrome-inset) + 6px); } .screens-pencil { width: min(360px, calc(100vw - 2 * var(--chrome-inset))); border-radius: var(--radius-panel); margin-bottom: calc(var(--shell-height) + var(--chrome-inset)); } .screens-pencil > .shell-divider { display: none; } @@ -264,7 +279,7 @@ body { background: var(--window); color: var(--text); font: var(--text-md) / var .chrome.screens-pages-controls { bottom: calc(var(--shell-height) + 2 * var(--chrome-inset)); } } @media (max-width: 420px) { - .stage[data-layout="slides"]:not([data-tools-dock="top-center"]) .chrome.screens-zoom[data-dock^="bottom"], .stage[data-layout="a4"]:not([data-tools-dock="top-center"]) .chrome.screens-zoom[data-dock^="bottom"] { bottom: calc(2 * var(--shell-height) + 3 * var(--chrome-inset)); } + .stage:is([data-layout="slides"], [data-layout="a4"]):not([data-tools-dock="top-center"]) { --zoom-bottom: calc(2 * var(--shell-height) + 3 * var(--chrome-inset)); } } .screens-present-controls { left: 50%; bottom: var(--chrome-inset); transform: translateX(-50%); white-space: nowrap; } .screens-slide-position { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text-secondary); } diff --git a/packages/canvas/src/shell/icons.tsx b/packages/canvas/src/shell/icons.tsx index 9028108..a9a6e48 100644 --- a/packages/canvas/src/shell/icons.tsx +++ b/packages/canvas/src/shell/icons.tsx @@ -12,7 +12,7 @@ const paths: Record = { back: "m15 18-6-6 6-6", sun: "M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8zM12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41", moon: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", - scroll: "m21 16-4 4-4-4M17 20V4M3 8l4-4 4 4M7 4v16", + map: "M3 6l6-3 6 3 6-3v15l-6 3-6-3-6 3V6Zm6-3v15m6-12v15", alert: "M12 8v4M12 16h.01M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0Z", image: "M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2zM9 11a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM21 15l-3.09-3.09a2 2 0 0 0-2.82 0L6 21", code: "m16 18 6-6-6-6M8 6l-6 6 6 6", diff --git a/packages/canvas/src/shell/runtime.ts b/packages/canvas/src/shell/runtime.ts index 963e5ae..c459797 100644 --- a/packages/canvas/src/shell/runtime.ts +++ b/packages/canvas/src/shell/runtime.ts @@ -97,7 +97,7 @@ export class CanvasRuntime { const theme = (safeStore.get("screens.theme") as "light" | "dark" | null) ?? (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"); document.documentElement.dataset.theme = theme; this.view = initialViewState({ viewport: { width: innerWidth, height: innerHeight }, pointer: matchMedia("(pointer: coarse)").matches ? "coarse" : "fine", - dpr: devicePixelRatio, theme, invertScroll: safeStore.get("screens.invertScroll") === "1" }); + dpr: devicePixelRatio, theme }); this.env = { now: () => performance.now(), reducedMotion: matchMedia("(prefers-reduced-motion: reduce)").matches, newId: () => Array.from(crypto.getRandomValues(new Uint8Array(12)), (b) => (b % 36).toString(36)).join("") }; this.unsubClient = client.subscribe(() => this.onClient()); @@ -345,7 +345,6 @@ export class CanvasRuntime { requestAnimationFrame(() => requestAnimationFrame(() => still.remove())); safeStore.set("screens.theme", theme); this.dispatch({ type: "theme", theme }); } - setInvertScroll(on: boolean) { safeStore.set("screens.invertScroll", on ? "1" : "0"); this.dispatch({ type: "command", command: { kind: "invert-scroll", on } }); } // ── Live frames ── diff --git a/packages/canvas/src/shell/testHook.ts b/packages/canvas/src/shell/testHook.ts index c1a6dc5..240b9d1 100644 --- a/packages/canvas/src/shell/testHook.ts +++ b/packages/canvas/src/shell/testHook.ts @@ -27,7 +27,7 @@ export const VIEW_PROBE = { viewport: "include", pointer: "include", dpr: "include", theme: "include", camera: "include", autoFit: "include", moving: "include", animation: "summary", focus: "summary", tool: "include", shiftPanning: "include", pencil: "include", selection: "summary", interacting: "include", gesture: "summary", wheel: "omit:transient wheel accumulator", editing: "summary", comment: "include", deferredCommand: "summary", following: "include", - invertScroll: "include", capabilities: "include", pages: "include", + capabilities: "include", pages: "include", } as const satisfies Record; /** What the person sees of agents: cursors and what they rest on, their labels, placeholders and their phase, off-screen markers, @@ -147,7 +147,10 @@ export function installTestHook(rt: CanvasRuntime): void { } else if (root === "history") out.history = { ...st.history }; else if (root === "dom") { + const map = document.querySelector(".screens-minimap"); + const viewport = map?.querySelector(".screens-minimap-viewport"); const d: Record = { + minimap: viewport ? { items: map!.querySelectorAll(".screens-minimap-item").length, x: Number(viewport.getAttribute("x")), width: Number(viewport.getAttribute("width")) } : null, toast: toastText(), reconnecting: !!document.querySelector(".toast:not(.error)"), saving: !!document.querySelector(".screens-saving"), diff --git a/packages/cli/src/bindings.ts b/packages/cli/src/bindings.ts index df61502..f73a305 100644 --- a/packages/cli/src/bindings.ts +++ b/packages/cli/src/bindings.ts @@ -10,7 +10,7 @@ import type { Layer } from "./script.ts"; export const COMMAND_VERBS = { "zoom-in": "zoom", "zoom-out": "zoom", "zoom-100": "zoom", "fit-all": "fit", focus: "focus", "exit-focus": "exit-focus", "select-tool": "tool", delete: "delete", undo: "undo", redo: "redo", "pencil-color": "pencil", "pencil-size": "pencil", - "invert-scroll": "invert-scroll", edit: "edit-title", + "center-camera": "click", edit: "edit-title", // Comment card and panel controls are reached by clicking them: @T.row, ui:Resolve, ui:Reopen, ui:Close, @c (Delete), ui:Resolved. "open-thread": "click", "resolve-thread": "click", "delete-comment": "click", "comment-filter": "click", "comments-panel": "click", "edit-comment": "click", reorder: "key", nudge: "key", "resize-by": "key", "select-next": "key", "zoom-to-selection": "key", "copy-image": "click", @@ -25,7 +25,7 @@ export const INPUT_SOURCES = { "pointer-down": ["click", "drag", "press", "draw"], "pointer-move": ["drag", "move", "draw"], "pointer-up": ["click", "drag", "release", "draw"], "pointer-cancel": "runtime: lost pointer capture", "double-click": ["click", "edit-title"], wheel: ["wheel"], "key-down": ["key", "type", "undo", "redo", "delete", "zoom", "cancel"], "key-up": ["key"], "window-blur": ["inside"], bridge: ["inside"], tick: "runtime: animation frame", "camera-settled": "runtime: settle timer", - resize: "runtime: ResizeObserver (up --viewport)", "document-changed": "runtime: revision event", command: ["tool", "pencil", "zoom", "fit", "focus", "exit-focus", "invert-scroll", "rename-screen"], + resize: "runtime: ResizeObserver (up --viewport)", "document-changed": "runtime: revision event", command: ["tool", "pencil", "zoom", "fit", "focus", "exit-focus", "click", "drag", "rename-screen"], "title-commit": ["edit-title", "rename-screen"], "title-cancel": ["key"], "view-command": "runtime: agent show_items and focus_item", theme: ["theme"], "comment-submit": ["key"], "comment-composing": ["type"], "comment-cancel": ["key"], // Finder drops and paste, and dragging a Media drawer tile onto the canvas. diff --git a/packages/cli/src/driver.ts b/packages/cli/src/driver.ts index 85d6198..29f4063 100644 --- a/packages/cli/src/driver.ts +++ b/packages/cli/src/driver.ts @@ -711,7 +711,6 @@ function actionText(a: import("./script.ts").PersonAction): string { case "zoom": return `zoom ${a.how}`; case "focus": return `focus ${targetText(a.target)}`; case "theme": return `theme ${a.theme}`; - case "invert-scroll": return `invert-scroll ${a.on ? "on" : "off"}`; case "edit-title": return `edit-title ${targetText(a.target)} ${JSON.stringify(a.text)}`; case "rename-screen": return `rename-screen ${JSON.stringify(a.text)}`; case "drop": return `drop ${a.files.join(" ")} at ${targetText(a.at)}`; diff --git a/packages/cli/src/person.ts b/packages/cli/src/person.ts index 436f2a0..c8b8af9 100644 --- a/packages/cli/src/person.ts +++ b/packages/cli/src/person.ts @@ -215,7 +215,6 @@ export async function act(v: PersonView, a: PersonAction): Promise<{ readonly no case "redo": await key(v, "Mod+Shift+z"); return {}; case "delete": await key(v, "Backspace"); return {}; case "theme": if ((await probeView(v)).theme !== a.theme) await ui(v, "Theme"); return {}; - case "invert-scroll": if ((await probeView(v)).invertScroll !== a.on) await ui(v, "Invert scroll"); return {}; case "edit-title": { if (a.target.kind !== "ref") throw new Error("edit-title needs an item"); const p = await locate(v, { ...a.target, part: "title", offset: null }); diff --git a/packages/cli/src/script.ts b/packages/cli/src/script.ts index 1ddba32..18d81e7 100644 --- a/packages/cli/src/script.ts +++ b/packages/cli/src/script.ts @@ -36,7 +36,6 @@ export type PersonAction = | { readonly verb: "exit-focus" } | { readonly verb: "undo" } | { readonly verb: "redo" } | { readonly verb: "delete" } | { readonly verb: "theme"; readonly theme: "light" | "dark" } - | { readonly verb: "invert-scroll"; readonly on: boolean } | { readonly verb: "edit-title"; readonly target: Target; readonly text: string } | { readonly verb: "rename-screen"; readonly text: string } | { readonly verb: "toast"; readonly button: "retry" | "dismiss" } @@ -238,7 +237,6 @@ export const VERBS: Readonly> = { redo: { group: "person", summary: "redo (Mod+Shift+z)", parse: (c) => person(c, { verb: "redo" }) }, delete: { group: "person", summary: "delete (Backspace on the selection)", parse: (c) => person(c, { verb: "delete" }) }, theme: { group: "person", summary: "theme light|dark", parse: (c) => person(c, { verb: "theme", theme: one(c.words[0], ["light", "dark"], "theme") }) }, - "invert-scroll": { group: "person", summary: "invert-scroll on|off", parse: (c) => person(c, { verb: "invert-scroll", on: one(c.words[0], ["on", "off"], "invert-scroll") === "on" }) }, "edit-title": { group: "person", summary: "edit-title T TEXT", parse: (c) => person(c, { verb: "edit-title", target: parseTarget(c.words[0] ?? usage("edit-title needs a target")), text: c.words.slice(1).join(" ") }) }, "rename-screen": { group: "person", summary: "rename-screen TEXT", parse: (c) => person(c, { verb: "rename-screen", text: c.words.join(" ") }) }, toast: { group: "person", summary: "toast retry|dismiss", parse: (c) => person(c, { verb: "toast", button: one(c.words[0], ["retry", "dismiss"], "toast") }) },