Repository navigation
Serve the runtime's source modules from every install, and commit no kernel - #5287
Merged
Merged
Conversation
…names A page load asks its server for a few hundred resources under `/revisions/<name>/<execution identity>/`. For each one the server called `executing` three times: once to check the address's identity, once for the root it rewrites imports against, and once for the bytes. Each call resolved the page's layer selection again, which walks the page's package copies with `stat` to notice a `page init` that replaced one. That cost about 1.3 ms per request on a loaded Mac, and the requests queue on the browser's six connections, so a cold open of `pr-walkthrough` spent about 330 ms of serialized server time on its 247 source modules. `runtime_selection.named_execution` answers from the execution the process already holds when its identity is the one the address names, and calls `executing` only otherwise; the request reuses that execution for the root and the bytes. A document load still calls `executing`, so it is where a replaced package copy shows, as before. Behavior change: after a page's package copy is replaced, a resource request at the old identity's address is answered with the old bytes, which that address names, while the artifact stays held. It used to 404. Measured on `pr-walkthrough`, 247 sequential module requests: 1.3 ms median before, 0.30 ms after. Cold open, median of 6 interleaved rounds on a loaded Mac, presented: 583 → 479 ms with the kernel, 1233 → 615 ms from source modules; `triage-board` 199 → 140 ms with the kernel. Checks: the model tests for module URL delivery, live shells, revision delivery, layers and documents; `tests/process/test_interact_server.py` and the website server's routes. > _This was written by Claude Code on behalf of max-sixty_
…kernel Every branch that touched `browser/` carried a rebuilt kernel in `dist/kernel/`, so any two such branches conflicted there, in `kernel.json`'s per-module hashes and in the shared chunks, whatever their sources did. Each merge of `main` then took `checkout --theirs`, a `pnpm run build:browser`, and a commit. Installs already ran the source modules wherever a merge had left the kernel stale (`runtime_selection.read_runtime`), so the source path needed no new code. What changes: - The tree commits no kernel, and `pnpm run build:browser` and `check:browser` no longer write or compare one. A runtime edit takes no build. - Installs, developer checkouts, previews, probes, benches and the suite's browser tiers serve the source modules. `current_kernel`, the in-place compile under `.tmp/kernel.lock`, the `compiled_checkout` and `compiled_pages` fixtures and the dead `ASSETS` redirects in two widget journeys are gone. - Only a prepared installation compiles a kernel: `prepare`, which the website's build and container use, always compiles one into its own `dist/kernel/` with `build/runtime-bundle.mjs`, and `read_runtime` serves it while it matches that tree's modules, as before. `kernel.json` drops the blank lines that let neighbouring modules merge. - The lint, typos, prettier, pre-commit and Dependabot publisher exclusions for `dist/kernel/` go, as does the site workflow's trigger. Behavior changes: - An install opens a page from about 250 more module requests. Measured cold, median of 6 interleaved rounds on a loaded Mac, presented: `pr-walkthrough` 583 ms on `main` with the kernel, 615 ms from source modules on this branch (479 ms with the kernel and the previous commit's server fix); `triage-board` 199, 273 and 140 ms. A reload from the browser cache costs 15–40 ms more than the kernel. Without the previous commit, source modules took 1233 and 920 ms. - `tests/smoke/test_smoke.py` no longer asserts that the page loads kernel chunks, and `test_native_document_layout.py` imports `/runtime/content-layout.js` rather than its kernel chunk. Checks: `pnpm run check:tools`, `check:framework` (`check:browser` and the build tests), the Dependabot publisher's tests; `tests/model/test_distribution.py`, `tests/smoke`, `tests/journeys/test_distribution.py` (a prepared install compiles and serves its kernel), and the edited native-layout browser test. `dev/tests/model/test_interact_preview.py` passes but for `test_preview_file_subscription_follows_atomic_replacements`, which fails on `main` too. > _This was written by Claude Code on behalf of max-sixty_
With nothing compiling in a preview, `LEAF_PREVIEW_COMPILER_ROOT` only told a selected-runtime worker which checkout's launcher owns the session's hooks. It is now `LEAF_PREVIEW_LAUNCHER_ROOT`, read by `preview.launching_checkout`, and `prepare` compiles with this checkout's bundler directly. The scaling command's header no longer sends a profile reader from kernel bundles to the source, since profiles name the source modules. > _This was written by Claude Code on behalf of max-sixty_
# Conflicts: # dist/kernel/kernel.json # dist/kernel/runtime/bundle-content-layout.js # dist/kernel/runtime/bundle-user-view.js
# Conflicts: # dist/kernel/kernel.json # dist/kernel/leaf.js # dist/kernel/runtime/bundle-data.js # dist/kernel/runtime/bundle-page-layout.js
leaf-agent
previously approved these changes
Nov 4, 2026
# Conflicts: # dist/kernel/kernel.json # dist/kernel/leaf.js # dist/kernel/runtime/bundle-comment-placement.js # dist/kernel/runtime/bundle-data.js # dist/kernel/runtime/bundle-portable.js # dist/kernel/runtime/check-api.js
leaf-agent
approved these changes
Nov 4, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 4, 2026
…#5300) This removes two pieces of dead code. Neither changes behavior. - **`scrollStill` in `tests/page_scripts/harness.js`.** The harness returned it, but nothing loads it. `tests/render_harness.py` pulls only `browserState`, `armRest` and `readRest` from that script through `browser_function`, and a grep across `tests/` and `dev/` finds no other reference. The reading that is in use is `SCROLL_STILL` in `dev/leaf_dev/browser.py`. - **`"!dist/**"` in `knip.config.js`.** knip skipped `dist/**` because the tree used to commit `dist/kernel/`. Since #5287 the tree commits no kernel, and a prepared installation compiles its own into its output directory outside the checkout. `dist/` is never in the tree now, so the pattern excludes nothing. `prek run` passes on both files, including eslint, prettier and knip. Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 4, 2026
… Find's reach (#5314) A page of large text documents now shows the open one at once, and every document's text, a closed tab's included, stays in the page for the browser's Find. `lf-text-document` holds each document as plain rows, one a line, and paints syntax colour only on the runs of lines the browser draws and their neighbours, as CSS custom highlights rather than spans. This builds the option chosen for "Must browser Find reach text in tabs nobody has opened?": keep Find reaching every tab, with plain rows. ## Before and after The page is #4781's repro, exported: an `lf-tabs list="side"` of 30 tabs, each an `lf-text-document` bound to its own source, with a word at the top and foot of each source for Find. `all` holds 4 MB a source in lines of 300–600 words; `short` holds the same 4 MB in lines of about 80 characters, 1.5 million lines in all; `md` holds 400 KB a source of 80-character Markdown with `language="markdown"`, so the colouring is measured too. Main's exports (40e8104) beside this branch's at its head, the arms alternated on the same host, whose one-minute load stood at 20–45 for this final run and up to 100 in earlier ones from other sessions, so compare within a row. - **Open document shows**: the first animation frame in which the open tab's listing holds its text and is visible. - **All drawn**: the first frame in which all 30 listings are built. - **Longest frame gap**: the longest the main thread went without a frame between navigation and the last listing. - **Peak RSS**: the largest resident size of any process the measuring script's own browser ran (its renderer or content process). | Page | Engine | Open document shows | All drawn | Longest frame gap | Peak RSS | | --- | --- | --- | --- | --- | --- | | `all` | Chromium 156 | 4.55 s → **0.56 s** | 4.55 s → 1.01 s | 4.03 s → 0.23 s | 2.69 → **1.20 GB** | | `short` | Chromium 156 | 22.9 s → **0.67 s** | 22.9 s → 3.04 s | 22.4 s → 0.27 s | 8.59 → **2.16 GB** | | `md` | Chromium 156 | 3.01 s → **0.35 s** | 3.01 s → 0.64 s | 2.83 s → 0.11 s | 1.83 → **0.48 GB** | | `all` | Firefox 157 | 25.0 s → **0.85 s** | 25.0 s → 3.31 s | 24.2 s → 0.34 s | 9.92 → **2.49 GB** | | `md` | Firefox 157 | 15.2 s → **0.52 s** | 15.2 s → 2.75 s | 14.9 s → 0.33 s | 7.92 → **1.65 GB** | | `short` | Firefox 157 | 217 s → **1.64 s** | 217 s → 24.4 s | 216 s → 3.15 s | 17.3 → **13.2 GB** | Firefox `short` is from an earlier round of this branch, before the review's fixes, which change nothing on a page with no `language`; main took 3.6 minutes to show its open document there. Chromium is Playwright's headless shell 156.0.8078.4; Firefox is Playwright's build 1555. On main the page draws nothing between the side list and the moment every document is built, so the open document waits on all 30. Here the document the page shows draws in the first task, and each hidden one takes a task of its own after it, so the page paints between them and stays answerable while the closed tabs fill in. Reloading on the 30th tab of `short`, which tab memory restores, shows its document at 0.64 s in Chromium and 2.44 s in Firefox, where drawn in page order it took 2.8 s and 33.4 s. **Find.** In Firefox 157, `window.find` reaches a word only the last, unopened tab's document holds, selects it there, and opens that tab, on this branch as on main. Chromium's `window.find` searches no `hidden="until-found"` content on either arm, so there the new test asserts the word stands in the closed tab's listing; its find bar wasn't driven. **A jump far down a long document.** On one 4 MB Python document (757 runs), End scrolls the last run into view, and it is coloured two frames later (40 ms in Chromium, 66 ms in Firefox), painted from a fresh grammar state; main colours it in its first frame. It is painted again with its exact state once the runs before it have been tokenized, a slice at a time. After End, Chromium drew no frame over 51 ms on that document or on a 2 MB one that opens with a long docstring. In Firefox the colouring no longer holds a frame: each token colour's `::highlight()` rule was inserted into a sheet the first time it appeared, and Firefox restyled the whole page for each, 0.85 s a rule, so End's scroll appeared 1.5–1.9 s after the press. The rules are now declared in the stylesheet. Firefox still drew one frame of 0.40–0.49 s after End on both documents (two runs each, a browser warmed by an earlier load of the page); an uncoloured document does the same, so it is below under the follow-ups. **Growth.** `leaf-dev scaling document --base` (a new axis: one ask and a text document of 64·n lines of Python, n = 8–256, so up to 16,384 lines; Chromium main-thread CPU, against ecf4dc1): main's load went 262 → 1,018 ms and a click on the ask 28 → 99 ms, an exponent of 0.88, above the 0.5 an input is held to; here load goes 213 → 283 ms (exponent 1.25, under the 1.5 for superlinear), a click 26 → 33 ms (too little growth to fit) and a wheel step 3.3 → 4.9 ms. The axis joins the daily `test_scaling.py`. `leaf-dev scaling` failed on every axis on current main (`no median for empty data`): since #5287 a page loads more than 250 modules, which fill resource timing's buffer before the `/api/event` answers it reads, so the tab now raises the buffer before loading the page; the daily test shares that `measure`. ## Calls for you These are what the change costs a reader, each kept on purpose: - **Comments in a text document stand upright.** `::highlight()` carries only properties that don't change layout, so a token keeps its colour but not its font style: a comment or docstring, italic in main's text documents, is upright here, while `lf-code` and diffs keep their italic. `notes/browser-support.md`, "Font style in syntax highlights", records it. Still pairs (main | branch), Chromium light, dark, and Firefox: `~/.tmp/leaf.agent-a6a4236750c25a2da/long-source-selected.png`, `long-source-selected-dark.png`, `long-source-selected-firefox.png`; each pair differs only there. - **A far jump is coloured two frames late, and may read wrong at first.** As above: the run shows plain for two frames, then from a fresh state, so a construct open across its first line, such as a docstring, reads wrong until its exact state arrives. - **A printed long document colours only the runs that were near the screen.** Chromium prints highlights (checked in a PDF), but runs never near the view were never tokenized. A document of 128 lines or fewer is one run and prints coloured, as before. - **The render gate's contrast check doesn't see document tokens.** `unread-syntax` reads token spans, and a text document has none; the same palette is still checked wherever code blocks or `lf-code` stand. ## What changed in the widget's contract - **Rows.** `listing` builds a `pre > code` of runs of 128 rows; a row is a `div` holding one line's text and its ending, exactly as the source has them, so the listing's text is the source. Pierre no longer renders documents: no gutter cells, `data-line*` attributes or token spans, and no Pierre sheet, so `listingSheet`, `scopedSheet` and #5226's shared-sheet adoption go. `pierre.js` and the Pierre bundle stay for `lf-diff`. - **Numbers.** A row's number is `::before` generated content, a CSS counter each run starts on its first row from `--lf-lines-before`, with empty alt text, so selection, copy and screen readers never take it. A counter started on the run's own box didn't reach its rows: a skipped run's style containment scoped it, and every run after the first numbered from 1. The first stills showed it, and `test_a_text_document_update_keeps_a_selection_it_carries_into_another_run` now reads the drawn numbers off Chromium's layout tree; it fails with the count on the run's box. A folded panel's rows (`hidden="until-found"`) count nothing until it opens: Firefox styles and builds the generated content of rows it doesn't draw, about 120 of the 150 ms a folded 70,000-line document cost it. - **Colour.** `RunColours` tokenizes the runs the browser draws (`contentvisibilityautostatechange`, or at once for a lone run) and the run on either side of each, while the listing has a box, and paints each token as a `StaticRange` in one `Highlight` per token colour, named by the theme's colour variable (`lf-token-syn-keyword` and so on). `text-document.css` declares the `::highlight()` rule for each, and `tests/runtime/text-document-colours.test.mjs` holds that list to the token theme's, so painting never adds a rule. A run that leaves that set drops its ranges; each highlight it touches is rebuilt from the ranges it keeps, since Firefox finds a range to delete by walking the highlight's list, and deleting two runs' ranges one by one took over 100 ms of a frame. Firefox reports a closed tab's runs drawn, and coloured every document in a closed tab as the page loaded, so a listing with no box takes no colour. Painted only as it was drawn, a run scrolling into view showed one uncoloured frame in Firefox; with its neighbours painted, a wheel scroll through a document showed none in either engine. A run starts from the grammar state the run before it ended in, so a run beginning inside a docstring or a fenced block is coloured as the whole text is; a run whose state isn't known yet is painted from a fresh state and repainted once `walk` finds it. A new text keeps the paint and states before its first changed line. Tokens come from the highlighter the page's code blocks and `lf-code` share, so a Markdown fence's language is coloured where another block on the page has loaded its grammar, as in `lf-code`; main's text documents left fences flat. `syntax(source, lang, state)` in the portable API now resolves to `{tokens, state}` and continues from a state it's given (`module-reading.md`); `lf-code`, the page's code blocks and `test_render_anchors.py` take `.tokens`. - **First draw.** A document the page shows draws without waiting; a hidden one first draws in a task of its own. The runs are first sized by the listing's size observer rather than in the draw: read in each draw, every closed tab's listing was a read of the page's layout, which Chromium answered more slowly for each document already drawn, 0.8 s over the 30 documents of `short`. - **Kept as they were.** Runs and `content-visibility: auto`, `sizeRuns` and its forgetting, `reconcileRuns` and the selection it carries across runs, the runtime's `drawForLanding`/`skippableBox` (untouched), the bounded viewport, `holdSource` and `cut`, the previews, and the datum marks comments anchor to. Line numbers, selection, the selected text and copy read the same as on main in light and dark, in Chromium and Firefox: `leaf-dev stills` on `captured-source` and a new state, `long-source-selected`, which selects across the edge of two runs in the PR walkthrough's Rust capture. A selection across rows reads exactly the source's characters on both arms in both engines. A comment on a line deep in a long document stands its pin at the same offset from its line on both arms in both engines, moves with a scroll of the listing, and hides once the line scrolls out of it; the comment-follows-its-lines test (#5223) passes in both. An independent review confirmed these, `t` travel and a live data update in both engines and schemes. ## Checks run - On the head: `pnpm run test:runtime` (778 pass, the new colour-rule test among them, which fails with a rule renamed), `pnpm run check:browser`, `pnpm run test:browser`, pre-commit on the changed files; `uv run pytest` on `test_render_anchors.py`, `test_code_and_documents.py`, `test_projected_data.py`, `test_targets.py`, `test_code_review.py`, `test_render_export.py`, `test_render_gate.py` and `test_render_code_reading.py` `-k "shell or syntax or document or find or captured_source or long_quote_of_replaced or source_replacement_preserves or keeps_comments_on_their_lines or interactive_export or language or colo or highlight or token or lf_code or excerpt or code_line"` (51 pass, Chromium and Firefox where parametrized, `test_shell_commands_share_colors_in_plain_code_widgets_and_diffs` among them); and, before this last change, the two thread tests that read message code colour. - `test_find_reaches_the_text_of_a_document_in_a_tab_nobody_opened` now asserts the opened document's lines carry `lf-token-*` ranges and the unopened one's carry none; with `RunColours.follow` a no-op it fails in both engines. - Earlier, before the merges: the bounds, focus-ring and interactive-export tests that hold text documents. `test_code_wrapping_keeps_source_copy_and_reader_choice` failed the same way on main then (a tap on the shortcut list's Copy code timed out). - The measuring scripts (`build.py`, `build_code.py`, `frames.py`, `memory.py`, `endframes.py`, `lasttab.py`, `find_test.py`, `ffinval.py`) and probes stay in the worktree's `.tmp/perf/` and `.tmp/js/`. ## Not verified - Printing in Firefox and WebKit: only Chromium's PDF was read. - Chromium's find bar on a closed tab: `window.find` there searches no fold. - WebKit: the Highlight API check ran in Playwright's WebKit 27.2 (colour, `StaticRange`, shadow root), but no text-document test or still did. - The daily `test_scaling.py` with the new `document` axis and the buffer fix was not run as the daily suite runs it, only `leaf-dev scaling document --base` and `leaf-dev scaling asks --sizes 32`. - In Chromium, a document whose tab the reader closes keeps the colour of the runs it last drew, since Chromium reports neither a skipped run nor a size for a closed tab's listing; a handful of runs per document opened. ## Found along the way, not changed here - **Firefox restyles the whole page on an insertion near its top.** Appending a `<p>` to `main` on the `all` page costs Firefox 157 a 2.6 s style flush on main and about 0.27 s here, and 6–16 s on `short`; Chromium takes 7 ms. A rule-by-rule bisect of the page's stylesheets found no single rule behind more than 15% of it. A Gecko profile of `short`'s load spent most of its time in style flushes that the runtime's visibility reads force (`skipped` in `shown-box.js`, from a frame callback and a mutation observer), which I take to be this restyle, not shown; any interaction that inserts near the top of a large page would pay it too. - **Two runtime passes walk every element a widget draws.** On `short` in Chromium, keyboard-scope marking (`markScopedIn`, `keyboard/scopes.js`) took about 1.0 s and the `watchArrivals("*")` owner watch (`arrivals.js`) about 0.8 s of the 3.2 s of main-thread CPU, walking 1.5 million rows that hold no scope and no owner. - **Firefox restyles every row once, about half a second on 4 MB.** On the 4 MB Python document and the 2 MB docstring one, a Firefox profile shows two style passes of 194,538 elements each (every row and its number), with no selector matching, so a recascade from above. In a browser warmed by an earlier load one lands after End (0.40–0.49 s); in a freshly launched one, two land about 6 s after load with no input at all (0.39–0.64 s each), at the moment `sizeRuns` resizes every run as the face arrives. An uncoloured document does the same; main's builds of these documents draw no frame over about 115 ms. Not the cause, each tried: the inherited `--lf-lines-before` on every run (made non-inherited), `sizeRuns`' forgetting step (turned off), the numbers' absolute positioning (floated) and one counter name for every run. Adding any stylesheet to the page after load pays the pass early, so something leaves the whole listing's style dirty; finding what is a follow-up. - **Firefox's peak on `short` is 13 GB.** Taking the closed tabs' listings out of rendering (`display: none`) left it at 13.1 GB, so their frames aren't the cause. The review's control: the same 1.5 million rows built by a bare script take 2.4 GB in Firefox, so most of the 13 GB is Leaf's own work per row. - **Pierre now serves only `lf-diff`**; its bundle and `pierre.js` could move from the default package to the diff package. Part of #4781: the open document no longer waits on every source, which is what the issue reports; the issue stays open for the follow-ups above until they have issues of their own. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Every branch that touched
browser/carried a rebuilt kernel indist/kernel/, so any two such branches conflicted there, whatever their sources did. Each merge ofmainthen took acheckout --theirs, apnpm run build:browserand a commit. This PR stops committing the kernel. Every install, checkout, preview and test serves the runtime's source modules, which installs already did wherever a merge left the kernel stale. Only a prepared installation, the website's build and container, compiles one.Why this design
I replayed with
git merge-treethe 102 merges ofmaininto a PR branch since #5060 spacedkernel.json's entries. 51 conflicted, 35 of them only indist/kernel/. With no kernel committed, 16 would conflict, all in hand-written files. In 26 of the 35, both sides edited one runtime module, which git merged cleanly in the source. Its hash line inkernel.jsonconflicted anyway, since no build had read the merged module, so no layout of a committed kernel avoids those.The goal was no merge conflicts in generated files, with no build on the consumer's side, no build machinery of Leaf's own, no commit after a merge and no second branch. Each alternative breaks one of those:
.gitattributesmerge driver has to be configured in every clone, and GitHub's mergeability check ignores it, so PRs still show the conflicts.What changes
runtime_selection.named_executionserves a revision's resources from the execution the process already holds under the identity in their URL. Before, each request re-resolved the page's layer selection, a stat walk of its package copies, three times. A source module now costs the server about 0.3 ms rather than 1.3 ms. After a page's package copy is replaced, a request at the old address gets the old bytes that address names, where it used to get a 404; the next document load picks up the new copy.dist/kernel/leaves the tree, andpnpm run build:browserandcheck:browserno longer write or compare one.current_kernel, the in-place compile under.tmp/kernel.lock, and thecompiled_checkoutandcompiled_pagesfixtures are gone, so the suite's browser tiers test the source modules installs run.preparealways compiles a kernel into its own tree withbuild/runtime-bundle.mjs, andread_runtimeserves it while it matches that tree's modules, as before.dist/kernel/go, as does the site workflow's trigger on it.LEAF_PREVIEW_COMPILER_ROOTis nowLEAF_PREVIEW_LAUNCHER_ROOT, read bypreview.launching_checkout. All a selected-runtime preview still takes from the checkout that launched it is the launcher that owns the session's hooks.Costs
A page opens from about 250 more module requests. Median time to first showing the server's state, over 6 interleaved rounds with a cold browser cache on a loaded Mac:
main: kernelmain: source modulespr-walkthroughtriage-boardA reload from the browser cache costs 15–35 ms more than the kernel.
Before merge, only a pull request's website gate (the site build and
leaf-dev verify-site website-worker) compiles the kernel and opens pages under it.wt mergeskips that gate, as it does every site delivery check.kernel_runtime_pathsreads the kernel only where one exists, so a package that ships aruntime/bundle-*.jspassespackage checkon a git install and is refused on a prepared one.Tests
tests/smoke/test_smoke.pyno longer asserts that the page loads kernel chunks, andtest_native_document_layout.pyimports/runtime/content-layout.jsrather than its kernel chunk.dev/tests/model/test_distribution.py, which held the committed kernel current, is deleted.Checks run:
pnpm run check:toolsandcheck:framework, the Dependabot publisher's tests, the model tests for revision delivery, layers and distribution, the server and website-route process tests,tests/smoke,tests/journeys/test_distribution.py(a prepared install compiles and serves its kernel) and the edited native-layout browser test.