diff --git a/robot-docs/web.md b/robot-docs/web.md index 585f181a5..f0c48e3fb 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, 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. +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 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. + 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). @@ -39,7 +39,7 @@ On a narrow screen (760 px or less) the client is a plain chat app unless settin The (?) beside the wordmark opens an about pane (`About.svelte`): a one-line description (a placeholder for now), the main contributors with their Bluesky handles, thanks to everyone else with a link to the full history on tangled, and the libraries the client is built on with their licences, linking `THIRD_PARTY_NOTICES.md`. -Settings (the sliders button at the top right, or ⌘,) is a non-modal pane over the board: the theme (follow the system, the default; light; dark), each mode's colours, and the canvas dots. A mode's colours are three seeds and a contrast, as in the Codex app: accent, background (the ground), foreground (the ink) as hex, with a native picker beside each, and contrast from 0 to 100; accent presets fill the accent for the mode being edited, and a theme copies and pastes as JSON (both modes, or one palette for the mode being edited). `app.css` derives every other token from the seeds with `color-mix` in OKLab (surfaces, chrome, fields, secondary text, hover, dots, shadow tint) and relative `oklch()` (the brand's second stop, and "you" opposite the accent), so any three colours make a whole theme; contrast scales how far each step goes. The colours are [madoromi](https://madoromi.moonwit.ch/)'s (MPL-2.0, credited in the pane and in `THIRD_PARTY_NOTICES.md`): the defaults are its spring, haru, by day (`#f6eff8` paper, `#584a5c` ink, `#6928bd` wisteria) and by night (`#241c26`, `#e1d1e7`, `#ddb3ff`); its four seasons set both modes at once, keeping each mode's contrast, and the accent presets are its spring inks. Preferences live in this browser (`prefs.svelte.ts`, `albedo.prefs.v4`, carrying the theme and dots over from earlier keys) and in an `albedo_prefs` cookie, which every port on the host shares, so the dev server and each `albedo web` port open the same way; the cookie wins when both exist, and `albedo web` drops it before forwarding to the daemon. Settings also take an interface and a code font by name (a comma adds fallbacks; each name is quoted and nothing that could end the value survives, see `fontStack`), set as `--sans` and `--mono` on `` ahead of the default stacks; where the browser offers `queryLocalFonts`, the installed families are suggested. The resolved mode is `data-theme` on `` and its seeds are inline custom properties there; a small script in `index.html` applies both before the first paint, and `prefs` follows system changes while the theme is `system`. +Settings (the sliders button at the top right, or ⌘,) is a non-modal pane over the board: the theme (follow the system, the default; light; dark), each mode's colours, the canvas dots, and which side the sessions sit on ("sessions on the right" mirrors the shell: the sidebar, its toggle and the brand on the right, search and settings on the left, and the settings and about panes open under their buttons; set on `` as `data-sidebar`). A mode's colours are three seeds and a contrast, as in the Codex app: accent, background (the ground), foreground (the ink) as hex, with a native picker beside each, and contrast from 0 to 100; accent presets fill the accent for the mode being edited, and a theme copies and pastes as JSON (both modes, or one palette for the mode being edited). `app.css` derives every other token from the seeds with `color-mix` in OKLab (surfaces, chrome, fields, secondary text, hover, dots, shadow tint) and relative `oklch()` (the brand's second stop, and "you" opposite the accent), so any three colours make a whole theme; contrast scales how far each step goes. The colours are [madoromi](https://madoromi.moonwit.ch/)'s (MPL-2.0, credited in the pane and in `THIRD_PARTY_NOTICES.md`): the defaults are its spring, haru, by day (`#f6eff8` paper, `#584a5c` ink, `#6928bd` wisteria) and by night (`#241c26`, `#e1d1e7`, `#ddb3ff`); its four seasons set both modes at once, keeping each mode's contrast, and the accent presets are its spring inks. Preferences live in this browser (`prefs.svelte.ts`, `albedo.prefs.v4`, carrying the theme and dots over from earlier keys) and in an `albedo_prefs` cookie, which every port on the host shares, so the dev server and each `albedo web` port open the same way; the cookie wins when both exist, and `albedo web` drops it before forwarding to the daemon. Settings also take an interface and a code font by name (a comma adds fallbacks; each name is quoted and nothing that could end the value survives, see `fontStack`), set as `--sans` and `--mono` on `` ahead of the default stacks; where the browser offers `queryLocalFonts`, the installed families are suggested. The resolved mode is `data-theme` on `` and its seeds are inline custom properties there; a small script in `index.html` applies both before the first paint, and `prefs` follows system changes while the theme is `system`. The chat view (`chat/`) reads `GET /sessions/{id}/history` (newest page, then `before=` as the reader scrolls up, and `after=` when the stream says something committed) and sends with `PUT /sessions/{id}/inputs/{uuidv7}`; while the session works, a stop button beside send (or Escape in an empty field) reads the session's `run_id` and `input_order` fresh and posts `/sessions/{id}/interrupt`, so a stop never reaches a later run, `{kind: "message", text}`; images attach by paste, drop or the composer's picture button (`chat/attachments.ts`, the terminal client's scheme: each image leaves an `[Image #n]` marker at the cursor, deleting the marker drops the image, sending renumbers the marked images 1..n in reading order and sends them base64 as `images`, at most 10); a user entry's images show above its bubble from their history references (`/api/sessions/{id}/history/{entry}/image-n`). a send stays on screen as pending until its `input_id` appears in history, and a failed one offers retry with the same id. Your newest message carries a receipt until a reply follows it, drawn as Signal's (`chat/Receipt.svelte`): a dashed ring while sending, a ring with a check once the daemon has accepted it (sent), two filled ones once its entry is in history (seen), which the daemon commits in the same transaction that takes it into the conversation, so the model has it (a message sent while albedo works stays `sent` until the loop takes it at its next step). Until it is seen the bubble stays faded. A waiting input is not listed anywhere, so after a reload it shows nothing until it commits. `transcript.svelte.ts` turns entries into blocks: user bubbles, assistant markdown, and each run of thinking and tool calls between messages folded into one "Worked" line (open while it is the live run). Referenced message text is fetched with the page; tool arguments and output only when their run is opened. Markdown is rendered by `marked` with raw HTML escaped and only http(s)/mailto links (`markdown.ts`), because transcripts carry model and tool text into a page that can reach the daemon. The session list (`sessions.svelte.ts`) follows the collection's stream (`GET /sessions?scope=roots` as server-sent events, `followSessions` in `stream.ts`): each `activity` event patches that session's status and activity in place, so the sidebar, window titles and faces change as the daemon does, and `reset`, `overflow` or `invalidate` reads the list again (once for a burst). While that stream is up the list is also read once a minute in case; while it is down, every 4 s. Both stop while the tab is hidden. diff --git a/web/src/App.svelte b/web/src/App.svelte index 458e6f795..dd7b63584 100644 --- a/web/src/App.svelte +++ b/web/src/App.svelte @@ -29,10 +29,10 @@ $effect(() => localStorage.setItem(RAIL_KEY, railOpen ? 'open' : 'closed')); $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, 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. + // With the sessions hidden, the pointer at the canvas's edge on their side + // brings them out floating over it, at once. How near counts as the edge + // grows with how fast the pointer is heading there, so a flick toward the + // edge opens it early and a slow drift along the canvas only right at it. // 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 @@ -41,13 +41,13 @@ // the page. const PEEK_EDGE = 20; const PEEK_FLICK_EDGE = 50; - /** px of edge gained per px/ms of leftward speed */ + /** px of edge gained per px/ms of speed toward it */ 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. */ + /** The pointer's last distance from that edge, and its speed toward it, smoothed. */ const heading = { x: 0, t: 0, speed: 0 }; let peekTimer: ReturnType | undefined; let pointerNear = false; @@ -57,10 +57,11 @@ function edge(event: PointerEvent) { if (railOpen || peek) return; - const x = event.clientX - (event.currentTarget as HTMLElement).getBoundingClientRect().left; + const canvas = (event.currentTarget as HTMLElement).getBoundingClientRect(); + const x = prefs.sidebarRight ? canvas.right - event.clientX : event.clientX - canvas.left; 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; + const toward = dt > 0 && dt < 100 ? Math.max(0, (heading.x - x) / dt) : 0; + heading.speed = heading.speed * 0.5 + toward * 0.5; heading.x = x; heading.t = event.timeStamp; const reach = Math.min(PEEK_FLICK_EDGE, PEEK_EDGE + heading.speed * PEEK_PER_SPEED); @@ -73,7 +74,8 @@ return; } const card = peekEl.getBoundingClientRect(); - pointerNear = event.clientX <= card.right + PEEK_NEAR && event.clientY <= card.bottom + PEEK_NEAR; + const beside = prefs.sidebarRight ? event.clientX >= card.left - PEEK_NEAR : event.clientX <= card.right + PEEK_NEAR; + pointerNear = beside && event.clientY <= card.bottom + PEEK_NEAR; if (pointerNear) clearTimeout(peekTimer); else unpeek(); } @@ -213,10 +215,10 @@ {#if layout.phone} (settingsOpen = !settingsOpen)} onnew={() => (newOpen = true)} /> {:else} -
+
- albedo @@ -311,14 +313,59 @@ display: grid; grid-column: 1 / -1; grid-template-columns: 264px 1fr auto auto; + grid-template-areas: 'start tabs link end'; align-items: stretch; background: var(--rail); } .rail-closed .topbar { grid-template-columns: auto 1fr auto auto; } + .topbar > :global(.tabs) { + grid-area: tabs; + } + .link { + grid-area: link; + } + .end { + grid-area: end; + } + /* Mirrored: the sessions on the right, with their toggle and the brand + above them, and search and settings on the left. */ + .shell.right { + grid-template-columns: 1fr 264px; + } + .shell.right.rail-closed { + grid-template-columns: 1fr; + } + .shell.right > :global(aside) { + grid-area: 2 / 2; + } + .shell.right > main { + grid-area: 2 / 1; + } + .right .topbar { + grid-template-columns: auto 1fr auto 264px; + grid-template-areas: 'end tabs link start'; + } + .right.rail-closed .topbar { + grid-template-columns: auto 1fr auto auto; + } + .right .start { + flex-direction: row-reverse; + padding: 0 10px 0 14px; + } + .right .about { + margin: 0 -4px 0 0; + } + .right .end { + padding: 0 6px 0 8px; + } + .right .rail-toggle svg { + transform: scaleX(-1); + } .start { display: flex; + grid-area: start; align-items: center; gap: 8px; padding: 0 14px 0 10px; @@ -411,6 +458,10 @@ .peek > :global(aside) { flex: 1; } + .right .peek { + right: 8px; + left: auto; + } /* Hidden, it lets clicks through to whatever window sits under it. */ .view { visibility: hidden; diff --git a/web/src/lib/About.svelte b/web/src/lib/About.svelte index e94f0c9a1..37da7a1db 100644 --- a/web/src/lib/About.svelte +++ b/web/src/lib/About.svelte @@ -80,6 +80,11 @@