diff --git a/robot-docs/web.md b/robot-docs/web.md index c5f56c75..db0a6514 100644 --- a/robot-docs/web.md +++ b/robot-docs/web.md @@ -23,7 +23,7 @@ Returning to the tab (focus or becoming visible) clears the count and closes its Words: a **board** is a named canvas of panels, and the open boards are the tabs along the top (`boards.svelte.ts`). A board holds sessions from any folders. **Workspace** keeps its albedo meaning, a session's folder, and the sidebar shows each session's folder under its name. Its sections are headed as the terminal heads them, the label in the text colour, its count faint, then a thin rule to the edge (the one place lines separate, as `sectionRule` does in the TUI); its rows alternate as the phone's list does, every other row in a section on `--rail-stripe` (the phone's step from its ground, taken from the rail's, about 1.06:1), hover lays a step over a row's own tone, and a session open on the board sits on `--open-tint`, the rail with a flat step of the accent (12% in light, 18% in dark), opaque so the stripes don't show through: a hue over the stripes' tones, under hover's step, and open rows that meet square their corners so a run of them reads as one block. `[` (shown on the sidebar's toggle, as search shows ⌘K; those key chips sit a 12% step of ink above their button) hides or shows the sidebar; hidden, it pops out floating over the canvas, without animation, as soon as the pointer is within 20 px of the canvas's edge on its side, or further out the faster it is heading there (15 px more per px/ms, up to 50 px), so a flick toward the edge opens it early (`App.svelte`, watched from the canvas so the edge still pans). It stays while the pointer is on it or within 48 px of it, the top bar above it included, or while its filter has focus, and goes 100 ms after the pointer is clearly elsewhere or leaves the page; `/` brings it out the same way with the filter focused (Escape clears it and puts it away), and only focuses the filter when the sidebar is shown. `+` makes a new board; double-click or F2 renames one; closing a tab keeps the board, which the palette reopens (`Open board: `); `Delete board` removes it. The last tab cannot be closed, so there is always a canvas. -A board is an open canvas. **Windows** sit anywhere on it; the view pans freely and zooms out to an overview. Svelte Flow draws, drags and resizes the windows; `board.svelte.ts` places new ones (right of the selected window, top-aligned, stepping past overlaps) and owns the viewport. The wheel is handled in `Canvas.svelte` rather than by Svelte Flow, because windows and canvas share the trackpad: a pinch (ctrl-wheel) zooms around the pointer anywhere, a mouse wheel's notch with ctrl or ⌘ by one 10% step (a notch is a jump of 50 px or more, or any line-mode delta, where a pinch moves a few pixels at a time), an up-down scroll over a window that can scroll scrolls it while the zoom is readable (60% and up), so does a sideways scroll over anything under the pointer that scrolls sideways (a diff's code inside Pierre's shadow root, a wide table; found through `composedPath()`), and every other scroll pans. Dragging empty canvas pans; holding Space (unless a text field has focus) or the middle button drags the canvas from anywhere, over windows too, taking the pointer before Svelte Flow or the window sees it; holding Alt (Option), a drag anywhere on a window or note moves it, not only by its title bar, without selecting text, and the click that ends it is swallowed (Option-click would download a link), and Space with a double-click anywhere glides the view there, centred at 90% (`Board.centreOn`, 300 ms from the middle of the pane up to 500 ms from a corner), where a plain double-click on empty canvas leaves a note. + and − zoom in and out by 5 points (the buttons too), ⇧1 fits all windows, ⇧0 returns to 100%, M shows an overview map, ⌥←/⌥→ moves between windows. The view controls (zoom, fit, map) in the bottom-right corner, under the overview map when it shows (as wide as the controls, measured, and showing and fading with them), and key hints in the bottom-left as the terminal's footer lists them (spc and a grab to pan, ⌥ and a move to move a window, cmd and a scroll to zoom, ⇧1, ⌥←→, spc and two clicks to zoom at a spot, two clicks for a note; the mouse gestures are Lucide's icons, drawn in `Gesture.svelte`, to keep them short; keys in the text colour, what they do muted, each pair on a surface of its own with a small gap between), fade in while the view moves and fade out 4 s after it stops; hovering or focusing them keeps them, and once faded they let clicks through to the windows beneath. What a window shows is a **view**, each framed by `nodes/WindowFrame.svelte`: a session's chat, or a review of one turn's changes; files, terminals and agent-made pages are meant to follow. A view opened from a window names it as its `parent`, opens beside it, and the canvas draws a faint dashed line between them (the board derives Svelte Flow edges from those parents; every window carries invisible handles for them). +A board is an open canvas. **Windows** sit anywhere on it; the view pans freely and zooms out to an overview. Svelte Flow draws, drags and resizes the windows; `board.svelte.ts` places new ones (right of the selected window, top-aligned, stepping past overlaps) and owns the viewport. The wheel is handled in `Canvas.svelte` rather than by Svelte Flow, because windows and canvas share the trackpad: a pinch (ctrl-wheel) zooms around the pointer anywhere, a mouse wheel's notch with ctrl or ⌘ by one 10% step (a notch is a jump of 50 px or more, or any line-mode delta, where a pinch moves a few pixels at a time), an up-down scroll over a window that can scroll scrolls it while the zoom is readable (60% and up), so does a sideways scroll over anything under the pointer that scrolls sideways (a diff's code inside Pierre's shadow root, a wide table; found through `composedPath()`), and every other scroll pans. Once a pinch goes quiet (200 ms), and again when the pointer next moves, the zoom settles on the nearest tenth of a percent, a step further when it is already within a twentieth of one: Chrome keeps drawing an artifact's page, a frame in a process of its own, at the scale a trackpad pinch began at even after the pinch ends, until the canvas takes a scale the pinch never set (returning to one it did set shows the stale drawing again), so without it a page pinched to a new zoom stays blurry until the next zoom. Measured in Chrome 155 (Helium) with `Input.synthesizePinchGesture`; a ctrl-wheel zoom, a mouse wheel's notch and the zoom keys never left it blurry, and same-document text (a chat) stays sharp either way. Dragging empty canvas pans; holding Space (unless a text field has focus) or the middle button drags the canvas from anywhere, over windows too, taking the pointer before Svelte Flow or the window sees it; holding Alt (Option), a drag anywhere on a window or note moves it, not only by its title bar, without selecting text, and the click that ends it is swallowed (Option-click would download a link), and Space with a double-click anywhere glides the view there, centred at 90% (`Board.centreOn`, 300 ms from the middle of the pane up to 500 ms from a corner), where a plain double-click on empty canvas leaves a note. + and − zoom in and out by 5 points (the buttons too), ⇧1 fits all windows, ⇧0 returns to 100%, M shows an overview map, ⌥←/⌥→ moves between windows. The view controls (zoom, fit, map) in the bottom-right corner, under the overview map when it shows (as wide as the controls, measured, and showing and fading with them), and key hints in the bottom-left as the terminal's footer lists them (spc and a grab to pan, ⌥ and a move to move a window, cmd and a scroll to zoom, ⇧1, ⌥←→, spc and two clicks to zoom at a spot, two clicks for a note; the mouse gestures are Lucide's icons, drawn in `Gesture.svelte`, to keep them short; keys in the text colour, what they do muted, each pair on a surface of its own with a small gap between), fade in while the view moves and fade out 4 s after it stops; hovering or focusing them keeps them, and once faded they let clicks through to the windows beneath. What a window shows is a **view**, each framed by `nodes/WindowFrame.svelte`: a session's chat, or a review of one turn's changes; files, terminals and agent-made pages are meant to follow. A view opened from a window names it as its `parent`, opens beside it, and the canvas draws a faint dashed line between them (the board derives Svelte Flow edges from those parents; every window carries invisible handles for them). The review (`nodes/ReviewNode.svelte`, `review.ts`) opens from "review N files +a −r" on a turn's sign-off, or from the +a −r on any work line, which also scrolls it to the first file that stretch of work changed (`data.jump`). It needs no daemon support beyond history: every tool call's trace records each file it changed, with the unified diff (`changes[].diff`, or `reason` when the file was binary, unreadable or too large). Writes the harness makes for itself stay out of it (`albedo_trace.unobserved()`): the browser plugin's profile lock and marker and its auto-named `.browser-artifacts` screenshots among them; a screenshot saved to a path the cell chose is still the cell's change. The window keeps the session, the turn and the turn's first history position, reads that turn's entries (`after=`, until the next turn starts), hydrates their traces, and shows the files with their counts, then each file's diffs in order. Diffs are drawn by `@pierre/diffs` (Shiki highlighting, `pierre-dark`/`pierre-light` tokens over the canvas's own ground and diff colours; `views/DiffView.svelte`), loaded with the first review so the rest of the client stays small. The margin button beside a line (drag for several) leaves a note on the canvas beside the window, tied to those lines; "send review" sends every unsent note tied into the review as one message, after an optional overall line. While the session works, the review reads what came after the entries it has every 2.5 s, and once more when it stops (`readTurn` without `seek` ends at the first entry of another turn, so an older turn's review costs one page a read); results already filled in are kept, and a file whose changes grew glows in the index for a moment. diff --git a/web/src/lib/Canvas.svelte b/web/src/lib/Canvas.svelte index a62bfc76..e674c9d3 100644 --- a/web/src/lib/Canvas.svelte +++ b/web/src/lib/Canvas.svelte @@ -63,9 +63,39 @@ // A pinch moves a few pixels at a time, a mouse wheel's notch a hundred or // so (or a few lines), so a notch is one fixed step rather than a jump. const NOTCH = 1.1; + function wheelPixels(event: WheelEvent) { + return event.deltaMode === WheelEvent.DOM_DELTA_PIXEL ? event.deltaY : event.deltaY * 40; + } + function notch(pixels: number) { + return Math.abs(pixels) >= 50; + } function zoomFactor(event: WheelEvent) { - const pixels = event.deltaMode === WheelEvent.DOM_DELTA_PIXEL ? event.deltaY : event.deltaY * 40; - return Math.abs(pixels) >= 50 ? NOTCH ** -Math.sign(pixels) : Math.exp(-pixels * 0.01); + const pixels = wheelPixels(event); + return notch(pixels) ? NOTCH ** -Math.sign(pixels) : Math.exp(-pixels * 0.01); + } + + // Chrome keeps drawing an artifact's page (a frame in a process of its + // own) at the scale a trackpad pinch began at, even after the pinch ends, + // until the canvas takes a scale the pinch never set; returning to one it + // did set shows the stale drawing again. So once a pinch goes quiet, and + // again when the pointer next moves (the fingers may only have rested), the + // zoom settles on a tenth of a percent, a step off when it is near one already. + let pinched: { x: number; y: number } | null = null; + let quiet: ReturnType | undefined; + + function pinching(point: { x: number; y: number }) { + pinched = point; + clearTimeout(quiet); + quiet = setTimeout(settle, 200); + } + + function settle() { + clearTimeout(quiet); + if (!pinched) return; + const zoom = board.viewport.zoom; + let next = Math.round(zoom * 1000) / 1000; + if (Math.abs(next - zoom) < 0.0005) next += next < ZOOM.max ? 0.001 : -0.001; + board.zoomAt(next / zoom, pinched); } let hand = $state(false); @@ -107,6 +137,10 @@ } function drag(event: PointerEvent) { + if (pinched) { + settle(); + pinched = null; + } if (carrying) { const { pointer, from } = carrying; const zoom = board.viewport.zoom; @@ -142,7 +176,9 @@ // A readable window that zooms itself (a trace's timeline) takes the pinch. if (board.viewport.zoom >= READABLE && (event.target as HTMLElement | null)?.closest('.zooms-itself')) return; event.preventDefault(); - board.zoomAt(zoomFactor(event), { x: event.clientX - rect.left, y: event.clientY - rect.top }); + const point = { x: event.clientX - rect.left, y: event.clientY - rect.top }; + board.zoomAt(zoomFactor(event), point); + if (!notch(wheelPixels(event))) pinching(point); return; } const vertical = Math.abs(event.deltaY) >= Math.abs(event.deltaX); @@ -155,6 +191,7 @@ element.addEventListener('wheel', wheel, { passive: false, capture: true }); element.addEventListener('pointerdown', grab, { capture: true }); return () => { + clearTimeout(quiet); element?.removeEventListener('wheel', wheel, { capture: true }); element?.removeEventListener('pointerdown', grab, { capture: true }); };