From d02ee0088d78eff22b7d42c51b9f3658d185f437 Mon Sep 17 00:00:00 2001 From: Gregory Kieffer Date: Fri, 20 Nov 2026 15:27:14 +0100 Subject: [PATCH 1/2] Give the scrollbars the theme's colors The web UI had no scrollbar styling, so every pane showed the browser's default bar, light grey and wide on a dark theme. All elements now get a thin thumb in --border on a transparent track, brightening to --gutter-fg on hover, with ::-webkit rules for browsers without scrollbar-color. Bump version to 0.12.0 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ --- AGENTS.md | 1 + README.md | 1 + diffui/static/style.css | 33 +++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 6c12c3a..1e953fc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -102,6 +102,7 @@ Frontend changes follow these rules: - Fonts: `--font-ui` for chrome (bars, buttons, tree, panels, dialogs, toasts), `--font-mono` for code, line numbers, diff paths and comment code blocks. - Borders: only where they carry structure (the bar bottom edge, the tree/diff divider). Use spacing or a background shift elsewhere. - Animations: 0.15s, only where they mean something. +- Scrollbars: styled once for every element at the top of `style.css`, from `--border` and `--gutter-fg`. Do not add per-component scrollbar rules. - No emoji as UI elements. Use text labels or CSS indicators. - Every async action has a loading state. Every interactive element works. diff --git a/README.md b/README.md index 8d37e88..fe2da79 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ The header shows the current scope. The browser has the same choices in its view - `.md` files get a rendered preview and images show inline. Markdown is sanitized before rendering, and diagram blocks go to kroki.io. - Font size and line wrap are in Settings and the command palette. - `w` or the Whitespace button toggles ignore whitespace. +- Scrollbars take the theme's colors: a thin thumb in the border color that brightens on hover. - `ctrl+click` (`cmd+click` on macOS) a line to open it in VS Code, Cursor, Vim or Neovim. Pick the editor in Settings. ## Keybindings diff --git a/diffui/static/style.css b/diffui/static/style.css index eaf70ff..9977fe7 100644 --- a/diffui/static/style.css +++ b/diffui/static/style.css @@ -42,6 +42,39 @@ box-sizing: border-box; } +/* Scrollbars follow the theme: a thin thumb in the border color on a + transparent track, brighter on hover. Firefox and Chromium read the + standard properties; Safari falls back to the ::-webkit rules. */ +* { + scrollbar-width: thin; + scrollbar-color: var(--border) transparent; +} + +*:hover { + scrollbar-color: var(--gutter-fg) transparent; +} + +@supports not (scrollbar-color: auto) { + ::-webkit-scrollbar { + width: 8px; + height: 8px; + } + + ::-webkit-scrollbar-track, + ::-webkit-scrollbar-corner { + background: transparent; + } + + ::-webkit-scrollbar-thumb { + background: var(--border); + border-radius: var(--radius-sm); + } + + ::-webkit-scrollbar-thumb:hover { + background: var(--gutter-fg); + } +} + html, body { height: 100%; background: var(--bg); diff --git a/pyproject.toml b/pyproject.toml index 99cf8a6..657fee7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "diffui" -version = "0.11.2" +version = "0.12.0" description = "UI for reviewing AI agent diffs" requires-python = ">=3.10" dependencies = [ From 758973ba451f5181106c734c8e500625e0017986 Mon Sep 17 00:00:00 2001 From: Gregory Kieffer Date: Fri, 20 Nov 2026 15:51:49 +0100 Subject: [PATCH 2/2] Keep the two sides of the split view scrolled together The split panes copied scrollTop to each other one animation frame late, and cleared their guard before the other pane's scroll event arrived, so that event was synced back and the panes could fight during a fast or smooth scroll. Sideways scrolling was not synced at all. And since a comment thread or comment box takes room on one side only, equal scrollTops drifted apart below every thread. syncScroll now runs straight from the scroll event, copies scrollLeft, and scrolls the other pane so the row at the top of this one is at its top too. It remembers the position it set, so the other pane's echo is ignored. The file tree and the unified view are untouched. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ --- AGENTS.md | 1 + README.md | 1 + diffui/static/components/SplitDiffViewer.js | 50 +++++++++++++++++---- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1e953fc..13e98b4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,6 +86,7 @@ diffui/ - `treeOrder()` in `FileTree.js` gives the file order that prev/next file and next-unreviewed follow. `_order_files` in `routes_diff.py` mirrors it for the TUI. Sort by risk turns the tree into one flat list. - The top bar holds navigation and global actions. `FileHeader` above the active viewer holds the per-file ones (view mode, whitespace, blame, resolve all, Mark reviewed). +- Split scrolling: each `.split-pane` scrolls itself, and `syncScroll` in `SplitDiffViewer.js` copies `scrollLeft` and aligns the top row (`alignedScrollTop`), since comment threads take room on one side only. `echo` holds the position it set on the other pane, so that pane's scroll event is not synced back. - `FullFileViewer` renders a window of lines. Hunk blocks use `content-visibility: auto`. - `SearchDialog` calls `/api/search` 150ms after the last keystroke and aborts the request it replaces. `handleSearchOpen` in `app.js` scrolls to the line the diff shows nearest to a hit (`nearestNewLine`). A file outside the diff sets `browsing` and opens in `FullFileViewer` with `readOnly`, because the server reports an unchanged file as all added. `browsing` swaps `FileHeader` for a short one, makes `handleToggleReview` return, stops `fetchFiles` from resetting the active file, and keeps `activeFile` out of the session save. It ends when the file joins the diff or another file is picked. - Keep the accessibility basics: `role="treeitem"` on tree items, focus trapping in the settings dialog, `:focus-visible` outlines on buttons, and `+`/`-` prefixes next to the diff colors. diff --git a/README.md b/README.md index fe2da79..cbadce7 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,7 @@ The header shows the current scope. The browser has the same choices in its view - Font size and line wrap are in Settings and the command palette. - `w` or the Whitespace button toggles ignore whitespace. - Scrollbars take the theme's colors: a thin thumb in the border color that brightens on hover. +- In split view the two sides scroll together, up and down and sideways, and paired lines stay level even when a comment thread sits on one side only. - `ctrl+click` (`cmd+click` on macOS) a line to open it in VS Code, Cursor, Vim or Neovim. Pick the editor in Settings. ## Keybindings diff --git a/diffui/static/components/SplitDiffViewer.js b/diffui/static/components/SplitDiffViewer.js index 1e62ccc..70ef9e3 100644 --- a/diffui/static/components/SplitDiffViewer.js +++ b/diffui/static/components/SplitDiffViewer.js @@ -38,6 +38,35 @@ function splitHunkLines(lines) { return { left, right }; } +// Hunk headers and lines sit at the same index in both panes, but a comment thread +// or comment box takes room on one side only, so equal scrollTops drift apart below +// every thread. The target is scrolled to put the row at the top of the source pane +// at its own top, the same distance into it. While the source scrolls through a thread +// the other side lacks, the target waits at the start of the next row. +const ROWS = ':scope > .split-hunk-header, :scope > .split-line'; + +function lastRowAtOrAbove(rows, y) { + let lo = 0; + let hi = rows.length - 1; + while (lo < hi) { + const mid = (lo + hi + 1) >> 1; + if (rows[mid].offsetTop <= y) lo = mid; + else hi = mid - 1; + } + return lo; +} + +function alignedScrollTop(source, target) { + const sourceRows = source.querySelectorAll(ROWS); + const targetRows = target.querySelectorAll(ROWS); + if (!sourceRows.length || sourceRows.length !== targetRows.length) return source.scrollTop; + const sourceTop = source.scrollTop + sourceRows[0].offsetTop; + const i = lastRowAtOrAbove(sourceRows, sourceTop); + const into = sourceTop - sourceRows[i].offsetTop; + const room = i + 1 < targetRows.length ? targetRows[i + 1].offsetTop - targetRows[i].offsetTop : Infinity; + return targetRows[i].offsetTop - targetRows[0].offsetTop + Math.min(into, room); +} + function SplitLine({ line, side, onRightClick, commentRanges }) { if (!line) return html`
`; @@ -57,17 +86,22 @@ export function SplitDiffViewer({ data, comments, actions, containerRef }) { const [commentingLine, setCommentingLine] = useState(null); const leftRef = useRef(null); const rightRef = useRef(null); - const syncing = useRef(false); + // The position each pane was last scrolled to by syncScroll, so its own scroll + // event is recognised as the echo and not synced back. + const echo = useRef(new Map()); const localContainerRef = useRef(null); const { selMenu, pendingSelection, setPendingSelection, commentFromSelection } = useRangeSelection('.split-code', localContainerRef, '.split-pane'); - const syncScroll = (source, target) => { - if (syncing.current) return; - syncing.current = true; - requestAnimationFrame(() => { - if (target.current) target.current.scrollTop = source.current.scrollTop; - syncing.current = false; - }); + const syncScroll = (sourceRef, targetRef) => { + const source = sourceRef.current; + const target = targetRef.current; + if (!source || !target) return; + const expected = echo.current.get(source); + echo.current.delete(source); + if (expected && expected.top === source.scrollTop && expected.left === source.scrollLeft) return; + target.scrollTop = alignedScrollTop(source, target); + target.scrollLeft = source.scrollLeft; + echo.current.set(target, { top: target.scrollTop, left: target.scrollLeft }); }; const handleRightClick = (line) => { setPendingSelection(null); setCommentingLine(line.index); };