From bef64b77e8fcbc79aa42d2be42b8cc6cbb667ebd Mon Sep 17 00:00:00 2001 From: "nekomimi.pet" Date: Mon, 2 Nov 2026 09:46:05 -0500 Subject: [PATCH] web: the diff client on the phone (a sheet over the chat) and in the focus desk, with j/k n/p v o [ ] keys; ReviewView goes --- robot-docs/web.md | 4 +- web/src/lib/FocusChat.svelte | 25 +-- web/src/lib/chat/Chat.svelte | 87 ++++++---- web/src/lib/chat/panel.ts | 4 +- web/src/lib/views/DiffClient.svelte | 75 +++++++- web/src/lib/views/ReviewView.svelte | 256 ---------------------------- 6 files changed, 147 insertions(+), 304 deletions(-) delete mode 100644 web/src/lib/views/ReviewView.svelte diff --git a/robot-docs/web.md b/robot-docs/web.md index 7f926795c..637528c74 100644 --- a/robot-docs/web.md +++ b/robot-docs/web.md @@ -61,7 +61,7 @@ Window connectors stay behind windows while at rest, even when a linked window i Board-level SVG links follow the same rule: list-to-window links (agents, jobs, artifacts), note curves and the hovered trace connection are clipped outside visible window interiors while at rest (`ConnectorClip.svelte`, `connectorOcclusion.ts`). Window dragging temporarily lifts them. The clip also excludes invisible note-line hit areas, including where windows overlap; target highlights and short note endpoint stubs remain visible, and windows panned outside a nested canvas do not occlude neighbouring tiles. -The diff client (`nodes/ReviewNode.svelte`, `views/DiffClient.svelte`, `changeset.ts`, `review.ts`) is one window per session (`review:`). It shows one turn's changes (`scope: 'turn'`, read from history as below) or the checkout's against HEAD or where its branch left its upstream (`'uncommitted'`, `'upstream'`, from `GET /sessions/{id}/changes`, read again every 2.5 s with `If-None-Match` while the session works and once when it stops). "review N files +a −r" on a turn's sign-off opens it on that turn; the +a −r on a work line opens it on the uncommitted changes at the first file that stretch of work changed (`data.jump`); a trace's edit opens the turn's changes at that file. Changed files read top to bottom, each with its status, counts, notes waiting and a read mark that folds it; beside them a rail lists them and lights the one in view (a click lands on it without redrawing), or shows the project as a tree read a folder at a time (`views/FileTree.svelte`, `GET /workspaces?location=&include=files`). Any file opens in a tab of its own (`views/FileView.svelte`, `GET /sessions/{id}/files`), highlighted by Pierre's `File`; a Markdown file reads rendered through `renderDocument` (markdown.ts, the same sanitizer), with the blocks the change touched marked, or as source. A note works on a file's lines as on a diff's: the file is listed for anchors.ts as a diff of context lines under change `-1` (`FILE_CHANGE`; the checkout's bases use `-2` and `-3`, a turn's parts their index, so notes from one scope never land on another's lines). Narrower than 720 px the rail folds behind ☰ and slides over the stream. A board saved before scopes reopens a turn's review as before. A turn's changes need 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 screenshots (in the cache, see [kernel](kernel.md#browser-gestures)) 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, a file whose changes grew glows in the index for a moment, and the review follows its end as new changes arrive while the reader is at the bottom. +The diff client (`nodes/ReviewNode.svelte`, `views/DiffClient.svelte`, `changeset.ts`, `review.ts`) is one window per session (`review:`). It shows one turn's changes (`scope: 'turn'`, read from history as below) or the checkout's against HEAD or where its branch left its upstream (`'uncommitted'`, `'upstream'`, from `GET /sessions/{id}/changes`, read again every 2.5 s with `If-None-Match` while the session works and once when it stops). "review N files +a −r" on a turn's sign-off opens it on that turn; the +a −r on a work line opens it on the uncommitted changes at the first file that stretch of work changed (`data.jump`); a trace's edit opens the turn's changes at that file. Changed files read top to bottom, each with its status, counts, notes waiting and a read mark that folds it; beside them a rail lists them and lights the one in view (a click lands on it without redrawing), or shows the project as a tree read a folder at a time (`views/FileTree.svelte`, `GET /workspaces?location=&include=files`). Any file opens in a tab of its own (`views/FileView.svelte`, `GET /sessions/{id}/files`), highlighted by Pierre's `File`; a Markdown file reads rendered through `renderDocument` (markdown.ts, the same sanitizer), with the blocks the change touched marked, or as source. A note works on a file's lines as on a diff's: the file is listed for anchors.ts as a diff of context lines under change `-1` (`FILE_CHANGE`; the checkout's bases use `-2` and `-3`, a turn's parts their index, so notes from one scope never land on another's lines). Narrower than 720 px the rail folds behind ☰ and slides over the stream. A board saved before scopes reopens a turn's review as before. A turn's changes need 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 screenshots (in the cache, see [kernel](kernel.md#browser-gestures)) 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, a file whose changes grew glows in the index for a moment, and the review follows its end as new changes arrive while the reader is at the bottom. Keys work while the client has focus (a press in it gives it focus) and stay there, so the board's shortcuts don't also fire: j/k the next or previous file, n/p the next or previous run of changed lines across files, v marks the file in view read, o opens it in a tab, [ and ] step through the tabs, and Esc goes from a tab back to the changes. The **terminal** (`nodes/TerminalNode.svelte`, `views/TerminalView.svelte`, `jobs.svelte.ts`) shows one background job's output, read-only. An activity pulse in a chat's title bar (`JobsButton.svelte`; not a prompt, which is kept for a live terminal: the chat's own `>_` button beside its folder chip opens one in the session's folder, and the folder chip only names the folder; on the phone above the composer, shown once the session has had a job; it and the artifacts icon share `MenuButton.svelte`) counts the running jobs and lists them, finished ones with their exit codes while the kernel keeps their output; the list polls `GET /extensions/run/sessions/{id}/jobs/recent` every 2 s while a job runs, 6 s otherwise. Choosing one opens a window beside the chat, tied to it like a review. The window opens on the last page of `.../jobs/{job}/output` and follows `next_offset` every 700 ms while the job runs (once more after it ends), keeps at most 400,000 characters, drops colour codes and shows a `\r`-redrawn line as its last draw. Its stop button asks twice, then posts `.../jobs/{job}/stop`. A job the kernel no longer has (a restarted kernel) says so. On a phone the same view opens in the chat's dock, above the composer. @@ -94,7 +94,7 @@ While the grip is dragged, what it would land on is outlined (`pick` in `anchors Notes are drafts, as a pending review's comments are: every written, unsent note tied into a session, to its chat or any of its windows (`Board.sessionOf`), goes with that chat's next message: the chat's own notes first, then each window's in board order, each from the top (`drafts` in `notes.ts`). The notes are not drawn in the composer, since each is already tied to its window by a line; the send button widens to a note icon and how many go with the message. A note's footer says what it will do, `with next message` or `on its own`, and a click on it switches (`alone`, saved with the board; boards saved with `held` read as `alone`): a note on its own is sent only by its own button. Sending the composer sends what was typed as the lead and every note that goes with it after it, as one message, through the chat's own send (so it shows as pending and can be retried); with notes going, an empty field sends just them. Your bubble shows a sent note's quoted lines as a quote and its fenced code as code; the rest of a message stays as typed, not markdown. A note also sends alone (⌘↵ or its send button), a review's notes with "send review" (they go with the next message too, and are done once sent), and the palette's "send all notes" sends every session's notes, except those on their own, as one message each. Each note quotes only what it was tied to (a note tied to a chat window itself is just a message; one tied to a part or passage of a page names the artifact, the version and the selector). Sent notes stay on the board, quieter, until dismissed. -On a narrow screen (760 px or less) the client is a plain chat app unless settings ask for the canvas (`canvasOnPhone`): `layout.svelte.ts` and `Phone.svelte` show the session list, then one session's chat filling the screen, with a back button and the browser's back between them (`history.pushState`). There a review opens inside the chat, under the line that asked for it (`views/ReviewView.svelte`, the review window's body too), and notes and pop-out are off. The phone's session list and drawer are one picker (`SessionPicker.svelte`): up to six tiles (pinned, then sessions opened three or more times, most first, then today's), every other session as a list under them (three dots between the two, and every other row takes a softer step of the tiles' tone, so the stripes don't read as tiles; the chat you are in, tile or row, takes a calm tint of the accent over its tone), and a search field with a new-session button docked at the bottom on the ground's tone, within thumb reach; while searching it is all list. The phone's chat reads at 16 px unscaled with narrow margins, its composer floats over the thread (which scrolls on under it and ends clear of it), a slim bar names the session and leads back to the list (the browser's back does too), with the model and the artifacts, skills and jobs buttons on its right, the chat takes no gesture from the browser, and a handle on top of the composer raises the session picker as a drawer over the chat. Its composer stands on a band of the chat's ground, so the thread fades out behind the handle and composer rather than showing between them. The drawer and the composer are one surface: the handle is the sheet's top edge, resting there when closed, and the sheet stands on the composer's bottom edge rather than the page's, so nothing of it reaches under what floats there (Safari's toolbar) and its search lands where the composer was. Dragging it up (or a quick swipe up from the composer itself, unless it would scroll the draft or follows a hold) raises the sheet with the finger while the composer fades into the search bar pinned in its place; dragging it down from its grip, or from anywhere while its list is at the top, lowers it. Let go and it settles open when past half (lowering: while still two thirds up) or flicked up, and otherwise sinks back into the composer; settling tweens the same number a finger moves, so the sheet, the composer's fade and the scrim stay one motion. A tap on the handle opens it, and a tap on its grip or above it, or choosing a session, closes it, and the browser's back still returns to the list, and the composer is one row (picture, field, stop, send). +On a narrow screen (760 px or less) the client is a plain chat app unless settings ask for the canvas (`canvasOnPhone`): `layout.svelte.ts` and `Phone.svelte` show the session list, then one session's chat filling the screen, with a back button and the browser's back between them (`history.pushState`). There the diff client (`views/DiffClient.svelte`) opens as a sheet covering the chat, with the same scopes and jumps as the review window and its list of files folded behind a button, and notes and pop-out are off; the full-screen chat's desk holds it as one tab. The phone's session list and drawer are one picker (`SessionPicker.svelte`): up to six tiles (pinned, then sessions opened three or more times, most first, then today's), every other session as a list under them (three dots between the two, and every other row takes a softer step of the tiles' tone, so the stripes don't read as tiles; the chat you are in, tile or row, takes a calm tint of the accent over its tone), and a search field with a new-session button docked at the bottom on the ground's tone, within thumb reach; while searching it is all list. The phone's chat reads at 16 px unscaled with narrow margins, its composer floats over the thread (which scrolls on under it and ends clear of it), a slim bar names the session and leads back to the list (the browser's back does too), with the model and the artifacts, skills and jobs buttons on its right, the chat takes no gesture from the browser, and a handle on top of the composer raises the session picker as a drawer over the chat. Its composer stands on a band of the chat's ground, so the thread fades out behind the handle and composer rather than showing between them. The drawer and the composer are one surface: the handle is the sheet's top edge, resting there when closed, and the sheet stands on the composer's bottom edge rather than the page's, so nothing of it reaches under what floats there (Safari's toolbar) and its search lands where the composer was. Dragging it up (or a quick swipe up from the composer itself, unless it would scroll the draft or follows a hold) raises the sheet with the finger while the composer fades into the search bar pinned in its place; dragging it down from its grip, or from anywhere while its list is at the top, lowers it. Let go and it settles open when past half (lowering: while still two thirds up) or flicked up, and otherwise sinks back into the composer; settling tweens the same number a finger moves, so the sheet, the composer's fade and the scrim stay one motion. A tap on the handle opens it, and a tap on its grip or above it, or choosing a session, closes it, and the browser's back still returns to the list, and the composer is one row (picture, field, stop, send). **Pin and archive** (`Rail.svelte`, `Sessions.mark`): a row in the sidebar shows a full-screen, a pin and an archive button while pointed at or focused. Full screen (`FocusChat.svelte`, `layout.focus`) is zen mode: the session as one calm chat over the whole window, and its window opens on the board too, so it is there after. The chat is `inline` and `full` (`Chat.svelte`): nothing floats over the thread, and the model, artifacts, background jobs and a terminal button sit in a row under the composer's field (`Composer`'s `tools`). The header and those chips rest dim until pointed at or focused. What the work makes lands on a desk beside the chat instead of in the stream, right of it by default (settings: "zen desk on the left", `prefs.deskLeft`) (`onopen`, `chat/panel.ts`): an artifact as it is made or picked (`ArtifactView` with `fill`, at 1:1 off the canvas), a turn's changes when it is reviewed or when a turn that changed files ends, a job's output, and the shell, a `PtyView` in the workspace. The desk keeps up to six tabs for the sitting, never dropping the shell; the gap beside it resizes it (drag, ← → when focused, double-click resets; `albedo.focus.desk`). Escape only hides, an open menu or a field first, then the desk (the shell and page live on under it), then the chat; ⌘\ shows or hides the desk; a tab's × closes it, and closing the shell's tab or the chat ends the shell. Each is `PATCH /sessions/{id}?view=configuration` with `preferences: {pinned}` or `{archived}` (`configureSession`, read at its ETag first), updated in place on that session alone without a full list refresh (ignoring the daemon's self-triggered collection invalidation for the just-saved session), and put back with the daemon's reason if refused. Archived sessions leave the sections and sit under a collapsed "archived" fold (open while filtering), dimmed, with an unarchive button. Pinned rows sort by `pin_order` and move among themselves, dragged (a line marks where one lands) or with Alt and ↑ ↓ on the focused row: `Sessions.movePin` patches `preferences: {pin_before: | null}` (null is last), shown at once and put back if refused, and the daemon renumbers every pin from 0 in the same commit, bumping each moved session's revision so a stale ETag on it fails with 412. Today and this week are ordered by activity and cannot be moved. The phone's picker offers neither pinning nor moving yet. diff --git a/web/src/lib/FocusChat.svelte b/web/src/lib/FocusChat.svelte index e29d27129..405626a53 100644 --- a/web/src/lib/FocusChat.svelte +++ b/web/src/lib/FocusChat.svelte @@ -13,7 +13,7 @@ import { deleteTerminal } from './terminals.svelte'; import ArtifactView from './views/ArtifactView.svelte'; import PtyView from './views/PtyView.svelte'; - import ReviewView from './views/ReviewView.svelte'; + import DiffClient from './views/DiffClient.svelte'; import TerminalView from './views/TerminalView.svelte'; import ShellCommandView from './views/ShellCommandView.svelte'; @@ -52,7 +52,7 @@ if (tab.kind === 'artifact') return `artifact:${tab.id}`; if (tab.kind === 'job') return `job:${tab.job}`; if (tab.kind === 'command') return `command:${tab.commandId}`; - if (tab.kind === 'review') return `review:${tab.turnId}`; + if (tab.kind === 'review') return 'review'; return 'terminal'; } @@ -195,10 +195,17 @@ {@const id = panel.commandId} {#key id} (commands[id] = found.command)} />{/key} {:else if panel.kind === 'review'} + {@const review = panel}
- {#key panel.turnId} - `focus:${sessionId}#${path}#${change}`} /> - {/key} + open({ ...review, scope })} + jump={review.jump} + keyOf={(path, change) => `focus:${sessionId}#${path}#${change}`} + />
{/if} {#if shell} @@ -457,14 +464,10 @@ background: var(--title-bar); } .review { + display: flex; flex: 1; + flex-direction: column; min-height: 0; - padding: 12px 14px 16px; - overflow-y: auto; - overscroll-behavior: contain; - scrollbar-width: thin; - --review-ground: var(--title-bar); - --review-sticky-top: -12px; } .shell { display: flex; diff --git a/web/src/lib/chat/Chat.svelte b/web/src/lib/chat/Chat.svelte index 678b1f014..678886562 100644 --- a/web/src/lib/chat/Chat.svelte +++ b/web/src/lib/chat/Chat.svelte @@ -68,7 +68,8 @@ import WorkSteps from './WorkSteps.svelte'; import ShellCommand from './ShellCommand.svelte'; import { pendingShell, resolveShell } from './shellAttempts'; - import ReviewView from '../views/ReviewView.svelte'; + import DiffClient from '../views/DiffClient.svelte'; + import type { Scope } from '../changeset'; import TerminalView from '../views/TerminalView.svelte'; import ShellCommandView from '../views/ShellCommandView.svelte'; import ArtifactsButton from '../ArtifactsButton.svelte'; @@ -112,7 +113,8 @@ onback?: () => void; } = $props(); - let shown = $state<{ at: string; turnId: string; from: number; jump?: { path: string; at: number } } | null>(null); + /** The phone's diff client, open as a sheet over the chat. */ + let shown = $state<{ at: string; turnId: string; from: number; scope: Scope; jump?: { path: string; at: number } } | null>(null); /** A job's output opened inside the phone's chat, where there is no canvas to put a window on. */ let terminal = $state<{ job: string; command: string } | null>(null); /** Human command output opened in the phone's dock; its process outlives the view. */ @@ -131,12 +133,16 @@ else boards.board?.openArtifact(made.id, sessionId, made.version, windowId); } - /** Opens a turn's review: beside the window, or under the line it was asked from. */ + /** + * Opens the diff client: beside the window, or over the phone's chat. A line + * of work about one file opens the checkout's changes there, as on the board. + */ function review(at: string, turnId: string, from: number, path?: string) { if (!inline) return boards.board?.openReview(sessionId, turnId, from, windowId, path); const jump = path ? { path, at: Date.now() } : undefined; - if (onopen) return onopen({ kind: 'review', turnId, from, jump }); - shown = shown?.at === at && shown.turnId === turnId && !path ? null : { at, turnId, from, jump }; + const scope: Scope = path ? 'uncommitted' : 'turn'; + if (onopen) return onopen({ kind: 'review', turnId, from, scope, jump }); + shown = { at, turnId, from, scope, jump }; } // svelte-ignore state_referenced_locally @@ -637,15 +643,6 @@ {:else if group.kind === 'compaction'}

{'(>_<)'} earlier context was compacted here

{/if} - {#if shown?.at === group.key} -
-
- changes - -
- `${windowId}#${path}#${change}`} onfiles={() => pinned && toBottom()} /> -
- {/if} {/each} {#if running} @@ -700,6 +697,24 @@ {/if} + {#if inline && shown} + {@const open = shown} +
+
+ changes + +
+ (shown = { ...open, scope })} + jump={open.jump} + keyOf={(path, change) => `${windowId}#${path}#${change}`} + /> +
+ {/if} {#snippet tools()} @@ -1039,35 +1054,41 @@ opacity: 0.6; } } - .inline-review { - margin: 4px 0 14px; - padding: 10px 12px 14px; - background: var(--well); - border-radius: 12px; - --review-ground: var(--well); - --review-sticky-top: -1px; + /* The phone's diff client covers the whole chat, its header and composer too. */ + .review-sheet { + position: absolute; + inset: 0; + z-index: 11; + display: flex; + flex-direction: column; + padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); + background: var(--surface); } - .inline-review header { + .review-sheet header { display: flex; + flex: none; align-items: center; justify-content: space-between; - margin-bottom: 8px; + gap: 8px; + padding: 10px 10px 10px 16px; color: var(--muted); - font-size: calc(12px * var(--canvas-scale)); + font-size: calc(13px * var(--canvas-scale)); } - .inline-review header button { - padding: 2px 8px; - color: var(--muted); + .review-sheet header span { + min-width: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + .review-sheet header button { + padding: 6px 12px; + color: var(--text); font: inherit; - background: none; + background: var(--well); border: 0; - border-radius: 6px; + border-radius: 8px; cursor: pointer; } - .inline-review header button:hover { - color: var(--text); - background: var(--hover); - } .inline-terminal, .inline-artifact { display: flex; diff --git a/web/src/lib/chat/panel.ts b/web/src/lib/chat/panel.ts index c73c51119..9615e7022 100644 --- a/web/src/lib/chat/panel.ts +++ b/web/src/lib/chat/panel.ts @@ -1,7 +1,9 @@ +import type { Scope } from '../changeset'; + /** What the full-screen chat opens in the panel beside it. */ export type Panel = | { kind: 'artifact'; id: string; version: number; title: string } | { kind: 'job'; job: string } | { kind: 'command'; commandId: string } - | { kind: 'review'; turnId: string; from: number; jump?: { path: string; at: number } } + | { kind: 'review'; turnId: string; from: number; scope: Scope; jump?: { path: string; at: number } } | { kind: 'terminal' }; diff --git a/web/src/lib/views/DiffClient.svelte b/web/src/lib/views/DiffClient.svelte index cdcacd4e2..3ad194c77 100644 --- a/web/src/lib/views/DiffClient.svelte +++ b/web/src/lib/views/DiffClient.svelte @@ -199,6 +199,63 @@ active = null; } + // Keys work while the client has focus (a press anywhere in it gives it focus), + // and stop there, so the board's own shortcuts (n for a note) don't also fire. + function keydown(event: KeyboardEvent) { + if (event.metaKey || event.ctrlKey || event.altKey || (event.target as HTMLElement).closest('input, textarea, [contenteditable]')) return; + if (!act(event.key)) return; + event.preventDefault(); + event.stopPropagation(); + } + + /** Does what `key` asks, and says whether the key is the client's. */ + function act(key: string): boolean { + if (key === '[' || key === ']') { + const order = [null, ...tabs]; + const at = order.indexOf(active); + active = order[(at + (key === ']' ? 1 : order.length - 1)) % order.length]; + return true; + } + if (active !== null) { + if (key !== 'Escape') return false; + active = null; + return true; + } + const at = shown.findIndex((file) => file.path === inView); + const here = shown[Math.max(0, at)]; + if (key === 'j' || key === 'k') { + const next = shown[Math.min(shown.length - 1, Math.max(0, at + (key === 'j' ? 1 : -1)))]; + if (next) goto(next.path); + } else if (key === 'n' || key === 'p') hunk(key === 'n' ? 1 : -1); + else if (key === 'v' && here) { + if (read.has(here.path)) read.delete(here.path); + else read.add(here.path); + } else if (key === 'o' && here && here.status !== 'deleted') open(absolute(here.path)); + else return 'jknpvo'.includes(key); + return true; + } + + /** Scrolls to the next or previous run of changed lines, across files. */ + function hunk(direction: 1 | -1) { + if (!stream) return; + // On a zoomed canvas the window is scaled: measure in its own pixels. + const scale = stream.clientHeight ? stream.getBoundingClientRect().height / stream.clientHeight : 1; + const origin = stream.getBoundingClientRect().top; + const tops: number[] = []; + for (const host of stream.querySelectorAll('diffs-container')) { + let before = false; + for (const row of host.shadowRoot?.querySelectorAll('[data-line]') ?? []) { + const changed = /addition|deletion/.test(row.dataset.lineType ?? ''); + if (changed && !before) tops.push(stream.scrollTop + (row.getBoundingClientRect().top - origin) / scale); + before = changed; + } + } + tops.sort((a, b) => a - b); + const from = stream.scrollTop + 60; + const target = direction > 0 ? tops.find((top) => top > from + 1) : tops.findLast((top) => top < from - 1); + if (target !== undefined) stream.scrollTo({ top: target - 60, behavior: 'instant' }); + } + /** The lines of a file this checkout changed, for marking a Markdown document's blocks. */ function addedLines(path: string): Set { const file = changedFile.get(path); @@ -216,7 +273,8 @@ } -
+ +