Repository navigation
Tell lf-diff's added rows from its removed rows at a glance, in the theme's hues - #6050
Merged
Merged
Conversation
…heme's hues Under the reading theme lf-diff filled an added row #e0eae3 and a removed row #f3e0de: 16% of --ok and of --danger mixed into --pre-bg in sRGB. Leaf's status colours are muted, so that mix stays near grey (Oklab chroma 0.015 and 0.021), and the two rows were 0.032 apart in Oklab where GitHub's light rows are 0.057 apart. A larger share of the token only darkens the rows. The diff package's palette now states each fill as its token's hue at a lightness and chroma given for each scheme, `oklch(from var(--ok) 0.93 min(c, 0.034) h)` in light and lightness 0.29 in dark. The rows differ in hue alone and follow whatever --ok and --danger a theme sets. The word marks move into the palette in the same form, at lightness 0.86 in light and 0.38 in dark with chroma 0.065, because the old 34% sRGB mix was less colourful than the row it now sits on. `min(c, …)` keeps a grey token's rows grey rather than reading its missing hue as 0, a pink. Painted colours, sampled from `leaf-dev stills --state diff-separator` crops of the pr-walkthrough's key hunk in Chromium (Firefox paints the light crop identically): | Scheme | Rows apart | Added mark to its row | Removed mark to its row | | ------ | ---------- | --------------------- | ----------------------- | | Light, before | 0.033 | 0.083 | 0.090 | | Light, after | 0.059 | 0.076 | 0.076 | | Dark, before | 0.031 | 0.101 | 0.096 | | Dark, after | 0.057 | 0.096 | 0.096 | Code on the marks reads better too. With every file of the pr-walkthrough open, the render gate's syntax probe (`unreadSyntax`) found a light-scheme comment token at 4.4:1 on a word mark on main and finds nothing now, in either scheme, on that page, diff-thread-gallery, worktree-diffs, live-progress or file-tree. Line numbers, syntax colour, folded context and notes anchored to lines are unchanged: stills list only row and mark backgrounds among the computed styles that differ. test_a_diff_is_colored_by_each_files_own_path asked only that the two fills differ. It now has the browser convert each row and mark paint to Oklab, in both schemes, and requires the rows at least 0.05 apart and each mark at least 0.05 from its row. On main it fails with "dark: added and removed rows 0.032 apart". Relative colour from a `light-dark()` token resolves to the expected oklch() in both schemes in Playwright's Chromium, Firefox and WebKit.
leaf-agent
reviewed
Nov 15, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The new fills and marks take a fixed lightness from the page's colour scheme instead of following the theme's --pre-bg. That rules out a theme whose code ground and the page differ in lightness (inline).
… light page stays readable The first commit stated each fill's lightness per colour scheme: 0.93 in light, 0.29 in dark. A theme or page may set the code inputs apart from the scheme (package-themes.md, "Theme colors"). With dark code tokens on :root under the light scheme, the changed rows painted at lightness 0.93 under light code ink, 1.00-1.02:1, where main's sRGB mix followed --pre-bg and read 7.9-12.3:1. Each colour now mixes its status token into --pre-bg, stripped of chroma and hue, in oklch (15% for a row, 30% for a mark) and triples the mix's chroma up to the same caps as before. A row's lightness follows the code canvas and its hue is the token's. On Leaf's own tokens the light colours match the first commit's (lightness 0.930 and 0.860), and in dark the rows move from 0.29 to 0.295-0.299 and the marks from 0.38 to 0.369-0.375. Stripping the canvas's hue keeps the mix from turning toward a tinted canvas's hue; mixing in oklab instead leaves the hue powerless at that chroma in Chromium, which then reads it as 0. On the reviewer's page of dark code under the light scheme (Chromium), the rows stand 0.047 lighter than the canvas, code reads 8.0-12.3:1 on them and 10.1-10.8:1 on the marks, and the render gate's syntax probe finds nothing (five findings at 1.2-1.5:1 with the fixed lightness). The marks stay at 30%. At 35% they would stand further from their rows (0.070 rather than 0.056 on that dark code canvas) but take the default light scheme's code on a mark to 4.4:1, the finding main has; at 30% it is 4.7:1. test_a_diff_is_colored_by_each_files_own_path now also sets dark code tokens under the light scheme and requires each changed row within 0.1 of the canvas's lightness and the syntax probe to find nothing. On the first commit it fails with "a added row +0.708 in lightness from dark code".
…d its test Both conflicts keep this branch's side with the renamed tokens: the palette reads var(--lf-ok), var(--lf-danger) and var(--lf-pre-bg), and widget-shadow.css's marks read the palette's --lf-code-add-mark and --lf-code-del-mark. The test's dark code tokens move to --lf-pre-bg, --lf-code-ink and --lf-syn-*. Under the old names they reached no canvas, so the dark-code check passed even with lightness stated per scheme; the test now first requires the canvas to turn dark. With the first push's palette, renamed, it fails with "a added row +0.708 in lightness from dark code", and it passes with this one.
max-sixty
marked this pull request as ready for review
November 15, 2026 19:47
leaf-agent
approved these changes
Nov 15, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Closes #5857 would close the issue with half of it still to do. #5857 also asks for word marks only where the old and new lines are mostly the same, so a rewritten line shows as a plain removed row above a plain added row (delta's --max-line-distance). This PR changes only the mark colours. Part of #5857, naming the mark suppression as what's left, would keep that work on the open list.
max-sixty
added a commit
that referenced
this pull request
Nov 16, 2026
…on a light page reads (#6201) A theme or page can now draw code in a scheme of its own: `--lf-code-scheme: dark` on the root draws every code block dark under the light scheme (or `light` the reverse). Before, a theme could only restate the code tokens dark, and every other token used on a code surface still resolved `light-dark()` in the page's scheme. With dark code tokens under the light scheme on main, a diff's changed line numbers and signs read 2.15–2.34:1, its change counts 2.2–2.5:1, a diff's author note 1.08:1, lf-code's highlighted line 1.15:1, a text document's caption 2.83:1 and its diff inks 2.4–2.7:1, and Copy drew as a light control on the dark block. Each code surface's own stylesheet sets `color-scheme: var(--lf-code-scheme, inherit)`: - native `pre` (`reading.css`), lf-code (`code.css`), lf-diff and lf-call-diff (the diff package's `defaults.css`), and the composer's code fence (`text-field.js`); - lf-text-document's whole frame, or only its Source tab where it previews its text, which now takes the code's canvas to its foot (`text-document.css`); - a document code block's Copy, which stands in chrome rather than in its block (`integration.css`); a widget's Copy inherits its widget's scheme. Unset, the fallback gives each block the scheme of whatever holds it, the page's or a part of it the author set, so it draws as it does today. Chromium, Firefox and WebKit honour `inherit` as a `var()` fallback. The token has no value at the root, since one naming the root's scheme would draw light code in a page's dark panel. Set, every token inside takes that scheme's branch: the code tokens, the syntax colours, the page's status inks, its muted words and the highlight's tint. `tokens.css` says so beside the code tokens, and `package-themes.md` lists the token in its Code row. This replaces this PR's first commit, which derived diff-local inks (`--lf-code-add-ink`, `--lf-code-del-ink`) from the code canvas, a second way to compute a status ink that left every other page token on a code surface light. The diff's numbers, signs, counts and call markers take `--lf-ok-ink` and `--lf-danger-ink` again, as on main. ## Evidence WCAG ratios on the pr-walkthrough with an lf-code with notes, a native `pre`, a diff with an author note and a text document added (`leaf-dev probe … --base` in Chromium and Firefox, which read identically): - Token unset: every reading equals main's (36 per run) in Chromium and Firefox, under the light and the dark preference and with the root forced to `only dark`. Apart from a previewed document's Source tab (above), `leaf-dev stills` for `diff-separator`, `walkthrough-calls`, `walkthrough-code`, `native-code`, `annotated-code` and `captured-source`, light and dark, finds no style changed. `diff-file-reply` changed only in a message's clock time. - `--lf-code-scheme: dark` under the light scheme: nothing below 4.5:1. The lowest reading is 5.59:1 (lf-code's line numbers, the diff's separator, the call diff's locations). The diff's changed numbers and signs read 6.44 / 7.42:1, its counts 7.29 / 8.71:1, its note 12.56:1, lf-code's highlighted line 11.08:1 and its note 13.93:1. The text document's caption reads 7.46:1 and its diff inks 9.42 / 7.89:1. ## Where the code's scheme stops - **A thread among a diff's rows** draws dark with the rows. It stands inside the diff's frame, whose canvas has to take the code's scheme, and nothing inside the frame can return to the page's scheme, since CSS has no keyword for it. It reads as a dark page's thread does. - **A text document that previews its text** keeps the page's scheme in its frame, caption, tabs and preview, since its frame stands on the page's paper and the preview is prose. Its Source tab is code and takes the code's scheme and canvas down to its foot, since the tab takes the preview's height and a short listing left a strip of paper under it. In the page's own scheme that strip turns from paper to the code's white, the one change with the token unset (`leaf-dev stills` lists only those tabs' backgrounds, hidden in every state). Drawn dark, the preview inherited the page's ink from the body and read dark on dark. - **lf-worktree-diffs** keeps the page's scheme: its worktree cards stand on the page's paper, and each diff in them is an lf-diff, which sets its own. Still pairs, main beside this branch with `--lf-code-scheme: dark` (main ignores the token): `~/.tmp/leaf.agent-a344de8d55ee8c5b2/item2b/` (`rv-note-diff.png` for the thread, `rv-md.png` and `rv-md-source.png` for the preview and its listing). ## Tests - `test_a_theme_draws_its_code_in_the_scheme_it_names` (`tests/browser/controls/test_theme_and_device.py`, Chromium and Firefox) draws lf-code with a highlighted line and a note, a native `pre`, a `pre` inside a part of the page set `color-scheme: dark`, a diff text document, a previewed Markdown document and an lf-diff with a note. Unset, every canvas stays light but the dark part's, which stays dark, and every reading clears 4.5:1. With `--lf-code-scheme: dark`, every canvas turns dark (the plain block, lf-code, the listing, the previewed document's Source tab, the diff's rows), every line number, sign, count, note, caption, highlighted line and status ink reads 4.5:1 or more, both Copy controls (the plain block's in chrome, lf-code's on its toolbar) stand on a dark ground, and the syntax probe finds nothing. It fails with main's sheets, and with any one of the lf-diff, lf-code or Copy declarations removed. - `tests/browser/test_render_anchors.py`, `test_render_gate.py`, `test_render_code_reading.py`, `controls/test_theme_and_device.py` with `-k "colored_by_each or syntax_probe or copy or theme_draws or paper_and_ink"` (15 passed); `tests/model/test_interact_layer.py` (which holds every `var()` without a fallback to a token something sets), `test_theme_tokens.py`, `test_themes.py` (184 passed); `pnpm run test:runtime` (993 pass). ## Calls Max may reverse - The token's name and its two values; a theme that restates the code tokens individually still works as before for those tokens, and the Code row says it leaves the status inks and highlights in the page's scheme. - A diff's threads draw dark with its rows rather than in the page's scheme. - A previewed text document stays in the page's scheme except for its listing. ## Not changed `test_a_diff_is_colored_by_each_files_own_path` still sets dark code tokens individually under the light scheme, the way a theme without the token states them, and holds the diff's row fills to the canvas there (#6050). Nothing the token makes redundant was found to delete: the code tokens set a code look of their own in both schemes, and the diff palette derives its fills from the canvas for separation in either.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under the reading theme lf-diff filled an added row
#e0eae3and a removed row#f3e0de: 16% of--lf-okand of--lf-dangermixed into--lf-pre-bgin sRGB. Leaf's status colours are muted, so that mix stays near grey (Oklab chroma 0.015 and 0.021), and the two rows were 0.032 apart in Oklab where GitHub's light rows are 0.057 apart. A larger share of the token only darkens the rows.The diff package's palette (
packages/diff/styles/palette.css) now mixes each status token into--lf-pre-bg, stripped of chroma and hue, in oklch (15% for a row, 30% for a word mark), and triples the mix's chroma up to a cap (0.034 for a row, 0.065 for a mark). So the row fills and word marks follow--lf-pre-bg's lightness and the tokens' hue, whatever a theme or page sets for each, a dark code canvas on a light page included. The marks move fromwidget-shadow.cssinto the palette in the same form, because the old 34% sRGB mix was less colourful than the row it now sits on. Stripping the canvas's hue keeps the mix from turning toward a tinted canvas; mixing in oklab instead leaves the hue powerless at that chroma in Chromium, which reads it as 0. A grey token mixes to a grey row.Painted colours, sampled from
leaf-dev stills --state diff-separatorcrops of the pr-walkthrough's key hunk in Chromium:A theme may set the code inputs apart from the scheme (
package-themes.md, "Theme colors"). With dark code tokens on:rootunder the light scheme, the rows stand 0.047 lighter than the dark canvas and code reads 8.0–12.3:1 on them (main: 7.9–12.3:1). Marks there stand 0.056 from their rows. The line numbers and +/− signs on changed rows, and the change counts, still take--lf-ok-ink/--lf-danger-ink, which follow the page's scheme rather than the code canvas, so on that page they read 2.15–2.34:1, as on main (2.14–2.30:1); this PR leaves them. A 35% mark would stand 0.070 from its row there, but would take the default light scheme's code on a mark to 4.4:1, the finding main has; at 30% it is 4.7:1.Code on the marks reads better than on main. With every file of the pr-walkthrough open, the render gate's syntax probe (
unreadSyntax) found a light-scheme comment token at 4.4:1 on a word mark on main and finds nothing now, in either scheme, on that page, diff-thread-gallery, worktree-diffs, live-progress or file-tree. Line numbers, syntax colour, folded context and notes anchored to lines are unchanged: the stills list only row and mark backgrounds among the computed styles that differ (statesdiff-separator,walkthrough-callsfor lf-call-diff,diff-author-notes,diff-long-lines,worktree-startup; light and dark).test_a_diff_is_colored_by_each_files_own_pathasked only that the two fills differ. It now has the browser convert each row and mark paint to Oklab, in both schemes, and requires the rows at least 0.05 apart and each mark at least 0.05 from its row. It also sets dark code tokens (--lf-pre-bg,--lf-code-ink,--lf-syn-*) under the light scheme, requires the canvas to turn dark, and requires each changed row within 0.1 of the canvas's lightness and the syntax probe to find nothing. On main it fails withdark: added and removed rows 0.032 apart; with lightness stated per scheme it fails witha added row +0.708 in lightness from dark code.Browser support
The palette needs relative colour syntax: Chrome 122, Firefox 128, Safari and iOS 18. On Safari 17.4–17.6 the declarations fail at computed-value time and changed rows lose their fill. The colours resolve to the same
oklch()values in both schemes in Playwright's Chromium, Firefox and WebKit; the review also checked Safari on an iOS 26.1 simulator.Calls Max may reverse
--lf-code-add-mark/--lf-code-del-mark, so the four colours have one home.--lf-add-tint/--lf-del-tint(inserted and deleted prose, lf-shot's difference, chips) are unchanged, still 0.039 apart.Ran
uv run pytest tests/browser/test_render_anchors.py tests/browser/test_render_gate.py -k "test_a_diff_is_colored_by_each_files_own_path or test_a_diff_marks_changed_words or test_the_syntax_probe_reports or test_a_diff_can_start": 4 passed; the first fails with main's sheets and with the first commit's.uv run pytest tests/model/test_interact_layer.py tests/model/test_interface_fonts.py: 178 passed on the first commit. After merging main (Step the theme's neutrals from three colours, prefix every token, and rank a page's reset below Leaf's layers #6025's--lf-names):tests/model/test_theme_tokens.pyandtests/model/test_themes.pypass; twotest_interface_fonts.pytests fail on main too, on.lf-msg-endinginbrowser/styles/components/surfaces.css, which still names--font-small.leaf-dev stillsfor the five states above, light and dark, base5cc9aef6a7, before the merge; the merge renames the tokens and leaves their values.Not verified
test_page_fixture_renders(journeys tier) was not run; its syntax-contrast part was run by hand on the five pages above.Closes #5857