From 99307e829049f83ba2da64fcabb6ecd5e2fd742b Mon Sep 17 00:00:00 2001 From: dawn <90008@klbr.net> Date: Tue, 20 Oct 2026 07:11:08 +0300 Subject: [PATCH] web: the hidden sidebar opens further out on a flick and closes less easily Opening: within 20 px of the canvas's left edge as before, or further out the faster the pointer heads left (15 px more per px/ms of smoothed leftward speed, up to 50 px), so a flick toward the edge opens it early. Closing was easy to set off by accident: 16 px past the card, any move into the top bar (which left the canvas), or a wobble. It now goes 100 ms after the pointer is more than 48 px clear of the card, the top bar above it counting as near, or leaves the page; and the filter losing focus closes it only when the pointer is not on it. Signed-off-by: dawn <90008@klbr.net> --- robot-docs/web.md | 2 +- web/src/App.svelte | 52 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/robot-docs/web.md b/robot-docs/web.md index 01dddd4b0..585f181a5 100644 --- a/robot-docs/web.md +++ b/robot-docs/web.md @@ -13,7 +13,7 @@ In development, `npm run dev` in `web/` proxies `/api` the same way from `$ALBEDO_HOME/daemon.json`, read once at start (only when serving, so a build needs no daemon), dropping `Origin` and `Cookie`. It listens on the local network, open, so other devices at home can try the client; the `Host` it answers is limited to the machine's own name (bare and `.local`) and Tailscale's `*.ts.net`, since the proxy holds the token and a rebound name must not reach it. -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. `[` hides or shows the sidebar; hidden, it pops out floating over the canvas, without animation, when the pointer comes within 20 px of the canvas's left edge (`App.svelte`, watched from the canvas so the edge still pans), and goes 20 ms after the pointer wanders past it or leaves the canvas, unless its filter has focus; `/` 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. +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. `[` 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 left edge, or further out the faster it is heading left (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. + 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), and beside them a card of key hints as the terminal's footer lists them (space drag, ⌘ scroll zoom, ⇧1, ⌥←→, `[`, double-click for a note; keys muted, what they do faint, dots 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). diff --git a/web/src/App.svelte b/web/src/App.svelte index 91eb59442..458e6f795 100644 --- a/web/src/App.svelte +++ b/web/src/App.svelte @@ -30,26 +30,52 @@ $effect(() => localStorage.setItem(MINIMAP_KEY, minimap ? 'on' : 'off')); // With the sessions hidden, the pointer at the canvas's left edge brings - // them out floating over it, until it wanders past them or leaves the - // canvas. It is watched from the canvas rather than a strip along the edge, - // so the edge still pans and clicks like the rest of the canvas. + // them out floating over it, at once. How near counts as the edge grows + // with how fast the pointer is heading left, so a flick toward the edge + // opens it early and a slow drift along the canvas only right at the edge. + // It is watched from the canvas rather than a strip along the edge, so the + // edge still pans and clicks like the rest of the canvas. Out, the card + // stays while the pointer is on it or near it (the top bar above it + // included, for an overshoot toward the first rows), while its filter has + // focus, and goes soon after the pointer is clearly elsewhere or leaves + // the page. const PEEK_EDGE = 20; - const PEEK_WIDTH = 264; - const PEEK_LINGER_MS = 20; + const PEEK_FLICK_EDGE = 50; + /** px of edge gained per px/ms of leftward speed */ + const PEEK_PER_SPEED = 15; + const PEEK_NEAR = 48; + const PEEK_LINGER_MS = 100; let peek = $state(false); let peekEl = $state(); + /** The pointer's last place on the canvas, and its leftward speed, smoothed. */ + const heading = { x: 0, t: 0, speed: 0 }; let peekTimer: ReturnType | undefined; + let pointerNear = false; $effect(() => { if (railOpen) peek = false; }); function edge(event: PointerEvent) { - if (railOpen) return; + if (railOpen || peek) return; const x = event.clientX - (event.currentTarget as HTMLElement).getBoundingClientRect().left; - if (!peek) { - if (x <= PEEK_EDGE && !event.buttons) peek = true; - } else if (x > PEEK_WIDTH + 16) unpeek(); - else clearTimeout(peekTimer); + const dt = event.timeStamp - heading.t; + const leftward = dt > 0 && dt < 100 ? Math.max(0, (heading.x - x) / dt) : 0; + heading.speed = heading.speed * 0.5 + leftward * 0.5; + heading.x = x; + heading.t = event.timeStamp; + const reach = Math.min(PEEK_FLICK_EDGE, PEEK_EDGE + heading.speed * PEEK_PER_SPEED); + if (x <= reach && !event.buttons) peek = true; + } + + function near(event: PointerEvent) { + if (!peek || !peekEl) { + pointerNear = false; + return; + } + const card = peekEl.getBoundingClientRect(); + pointerNear = event.clientX <= card.right + PEEK_NEAR && event.clientY <= card.bottom + PEEK_NEAR; + if (pointerNear) clearTimeout(peekTimer); + else unpeek(); } function unpeek() { @@ -182,7 +208,7 @@ const linkLabel = { connecting: 'connecting', online: 'connected', offline: 'daemon unreachable', unauthorized: 'signed out: open the link albedo web printed' }; - + peek && !event.relatedTarget && ((pointerNear = false), unpeek())} /> {#if layout.phone} (settingsOpen = !settingsOpen)} onnew={() => (newOpen = true)} /> @@ -215,12 +241,12 @@ {#if railOpen} (newOpen = true)} />{/if} -
peek && unpeek()}> +
{#if peek}
!peekEl?.contains(event.relatedTarget as Node) && unpeek()} + onfocusout={(event) => !pointerNear && !peekEl?.contains(event.relatedTarget as Node) && unpeek()} > (newOpen = true)} />
-- knotmirror 0.0.1