Repository navigation
Keep text-document comments on their lines, and give page to-dos no place on the page - #5223
Merged
Merged
Conversation
…lace on the page Things Leaf couldn't place collected at the top: a to-do on the page as a whole stood at the page's first heading, and a comment on a bound text document came off its lines on the first data update, every margin entry gathering at the document's top as one cluster. Now what has a place keeps it, and what has none stands nowhere on the page. Text documents: - `lf-text-document` marks its reading with an identity, its key, so a comment follows its words across source replacements: unchanged lines stay marked and their entries stay beside them (projection/data.js). Before, any update made every comment on the document "Earlier data". - A quote inside a datum now captures a prefix and suffix from the datum's own words (`fencedAt`), and detaches where those can't tell it from another copy, as authored text does. A comment on a line a document holds twice used to fall back to the whole document from the start. - A quote captured with datum words around it names a passage in the datum; once its words are gone it resolves nowhere, and its thread reads as page-level. A quote that was all of its datum's words still falls back to the datum, as a row's changed label does. Page to-dos: - `subjectPlace` gives the page as a whole no place, and `pageHead` goes. A to-do on the page has no margin entry or ring; On me lists it under "The whole page", after placed items. - `m` arrives at it on its On me card (`showOnMe(obligation)`), and a user on an On card is on the item it shows (`ON_CARD` in `currentLocationOrigin` and `currentLocationStop`), so the walk steps on from it and `x` ends it there. On a card, `x` ends the card's own to-do even where another shares its place; it used to end the first to-do at that place. Tests: new `test_a_text_document_keeps_comments_on_their_lines_across_updates` (Chromium and Firefox). The on-panel to-do tests now expect the page to-do on its card rather than at the heading, and the two-to-dos test covers a card. Across a text document's replacement, a comment on the whole document now follows it, and one whose quoted words the replacement took reads as page-level, where the tests expected "Earlier data".
# Conflicts: # dist/kernel/kernel.json # dist/kernel/leaf.js # dist/kernel/runtime/bundle-data.js
# Conflicts: # dist/kernel/kernel.json # dist/kernel/leaf.js # dist/kernel/runtime/bundle-data.js
leaf-agent
reviewed
Nov 3, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Two of the rewritten assertions in tests/browser/threads/test_targets.py fail on this head merged with main. Both quotes still resolve, so their heads say "Changed" and carry no data-lf-detached:
test_original_quoted_words_remain_readable_after_the_page_rewrites_them[rewritten-keyboard]quotes authored text, and a rewrite leaves its thread on its section (rewritten_from). This PR doesn't touch that path.- In
test_a_changed_datum_keeps_its_old_words_open_when_its_label_changes, the quote was all of the datum's words. So it falls back to the datum, as this PR intends, and the test itself assertsstatus: "fallback"a few lines earlier.
quoteReading sets found for any placement and changed for a non-exact datum placement, so the old Changed assertions were right. Restoring them (suggestions inline) leaves the remaining tests I ran on this head passing: test_a_long_quote_of_replaced_data_has_a_local_reading and the new test_a_text_document_keeps_comments_on_their_lines_across_updates, in both engines.
# Conflicts: # dist/kernel/kernel.json
Two test_targets assertions this branch rewrote expected a detached quote, but both quotes still resolve: a rewritten authored passage stays on its section, and a quote that was all of its datum's words falls back to the datum. Their heads read "Changed", as before.
leaf-agent
approved these changes
Nov 3, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 3, 2026
…ge per document (#5226) A page with one 4 MB `lf-text-document` and 29 empty ones in side tabs took 7.5–10.4 s to settle in Firefox, against 1.4–2.1 s with the empty documents removed. Every text document now draws from one shared copy of Pierre's stylesheet, and the same page settles in 1.6–2.4 s. ## Cause The Firefox Profiler (`MOZ_PROFILER_STARTUP`) put 5.7 s of the 7.7 s load in `refit` → `lineColumns` → `Element.clientWidth`, each read forcing a style flush. The profiler's Styles markers showed about 30 flushes of about 36,000 elements each: the whole page, rows inside the long document's skipped `content-visibility: auto` runs included. Pierre's static renderer writes two `<style>` elements into every file it renders, and `lf-text-document` kept them in each listing, wrapped in an implicit `@scope`. Firefox 157 restyles the whole document whenever a `<style>` holding `@scope` enters or leaves it. Timed in the settled page, inserting one such `<style>` that matched nothing cost a 110–370 ms flush, against 2–9 ms for the same rule without `@scope`. So each document that drew restyled every element of the page, and each restyle cost more as copies piled up (about 370 ms with 60 copies on the page, 110 ms with one). Chromium 156 showed only 0.7 s against 0.4 s; it likely skips styling inside skipped `content-visibility` boxes, which wasn't measured. ## Change `sourceListing` now takes Pierre's `<style>` elements out of the rendered listing and builds one `CSSStyleSheet` from the first listing's text, scoped by `@scope (.lf-text-document-listing)` in place of the implicit scope. `show` adopts that sheet into the document or shadow root the widget stands in, once. Pierre's sheets depend only on the syntax theme and the options `sourceListing` passes, so every listing on a page gets the same text. Each listing also no longer carries its own 32 kB of CSS in the DOM. ## Evidence Built with `build.py` from #4781's re-measure (30 `lf-text-document`s in `lf-tabs list="side"`, `d0` bound to a 4 MB source, `d1`–`d29` bound to sources with no data; the control is the single bound document), exported, and loaded in headless Firefox 157 by a script that waits for the tab list to be visible, `#d0 code` to show text, and `body[data-lf-data-version]`. Base and fix exports alternated on the same machine, three rounds: | | settled, base | settled, fix | | --- | --- | --- | | 30 documents, 29 empty | 7.91, 7.95, 7.79 s | 1.96, 2.17, 1.91 s | | 1 document (control) | 2.08, 1.82, 1.69 s | 1.88, 1.83, 1.63 s | The long document's text first showed at 7.56–7.86 s on base against 1.69–2.16 s on the fix, so the empty documents held its first draw back about 6 s. The tab list's first appearance varied with scheduling in both versions, at about 0.3 s or with that first draw, so it isn't the measure here. In Chromium 156 the 30-document page settled in 0.72 and 0.77 s on base against 0.50 and 0.49 s on the fix, with peak renderer memory falling from 606–617 MB to 430 MB. After merging main, whose #5223 and #5241 changed this widget's drawing, two more alternated Firefox rounds on a busier machine settled the 30-document page in 9.84 and 9.36 s on main against 2.21 and 2.08 s on this branch. The computed value of every property, on the first 400 elements of the bound listing and every element of an empty one, is identical before and after the change, in Chromium and in Firefox once its font list has loaded. ## Tests - `test_every_document_draws_from_one_copy_of_pierres_sheet` (new): three documents in tabs, one with text and two bound to empty sources. The page holds one copy of Pierre's sheet, and each document's first line number stands beside its line. It fails on main with three copies. With the adoption removed it fails with no copy, and with the count check skipped the line numbers stand 60 px above their lines. - Ran `tests/browser/widgets/test_code_and_documents.py`, the text-document tests in `test_render_gate.py`, `test_render_export.py`, `test_rings.py`, `threads/test_targets.py`, `startup/test_projected_data.py`, `test_workspaces_and_bounds.py` and `projection/test_code_review.py` (all passed), `tests/runtime/text-document-lines.test.mjs`, the browser type check (`tsc --project browser/types/tsconfig.json`), and `leaf page check --render` on a five-document page. No cost test: the load time depends on the machine and engine, and the new test holds the mechanism, one sheet per page, instead. ## Not verified - Safari/WebKit, and Firefox on Linux or Windows. - A document moved into another shadow root after it drew keeps drawing without Pierre's sheet until its text changes, since adoption happens when it draws. No Leaf path that moves a drawn document across roots turned up, but none was searched for exhaustively. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Nov 4, 2026
) Everything On me is now answered by the widget or thread that asks it. Leaf no longer puts a to-do on the user with a Done of its own, so a widget is never given an answer it doesn't declare. A step such as trying a build is asked in a thread, and the user's reply or a 👍 answers it. Before, `leaf task create <subject> --on user` put a to-do on the user on any thread, element or widget that had no open obligation, and the turn-end check did the same for each step it found. On me then offered that item a generic Done: on an `lf-code` block or a paragraph, the only answer was a check mark the widget never offered. This reverses the user's 2026-10 choice to keep such to-dos for steps. ## The rule, and where it lives - **On me holds obligations only.** Each comes from a widget that declares `x-awaits` (any widget: bundled, from a package or the page's own), an agent message sent with `--obligation`, or an update to send again. On the page, each is answered only through its source: the widget's declared actions, or a reply or settling reaction in the thread. A multi-select `lf-options` keeps its Done, since that is the widget's own control. An answer the user gives elsewhere, such as in chat, the agent still records with `leaf task end`. - **Content that asks nothing** (a paragraph, a chart) and a step the user takes get a thread whose message carries `--obligation`. - The rule is stated in `obligations.py`'s header, the `x-awaits` key in `browser/registry.json`, How it works ("On me and the agent's list", with a new paragraph on what can ask), `conversation-loop.md` ("The On lists", where the to-do row becomes an "action the user takes" row asked in a thread) and `authoring-on-me.md`. `todos.py`'s header records the decision. ## What goes - **Protocol 39 → 40.** A `todo` event has no `owner`; `todo_end` is the agent's alone, is no longer browser-postable or undoable, and its handling clause for the user's Done is gone. A Leaf at 39 would misread a 40 log and the reverse, hence the bump. (`main` took 38 → 39 for an undoable edit in #5221.) - **Model.** `user_task_obligations`, the `todo` obligation source, `--on`, the `duplicate-obligation`/`users-question`/`agents-todo` refusals, and `owner` on served to-dos. `queues.on_user` rows are `widget`, `message` or `update`; to-do rows stay on On <agent>. - **Clerk.** The fork's answer has no `kind`. Every ask, a step included, is a thread question whose message says what to do and asks for a reply. `turn-end-check.md` (#4900) asks the fork that way, and the fork eval (`dev/leaf_dev/fork_eval.py`, `evals/workflows/fork_eval.yaml`) labels the step cases as questions. - **Browser.** The To-do Done on panel rows, On me cards and a thread's head; the `x` key and its "On a to-do waiting on me" stance; `queueActions.done` (public package API); local `todo_end` folding and its undo words; `offers`; `showOnMe`, which #5223 had extended to land `m` on a page to-do's card; the `done` action face and `checked` icon. A stance's exit is always Close's ✕, since no stance names another action now. The margin card's grid loses the row the to-do header held; `leaf-dev probe review-a-plan --do drive:card-by-keyboard --base` measures identical child boxes in both arms. ## A cost this keeps A reply answers a step's question whatever it says. A to-do stayed open until Done, so "where do I get the build?" left the step On me; now that reply answers the question, and a plan step naming it reads done until the agent asks again with `--obligation` and points the step at the new question. `conversation-loop.md` tells the agent to ask again, and the clerk's header records the trade. ## Tests and evals Behavior changed on purpose: - `todo-on-the-user` becomes `step-on-the-user-takes-a-thread` (pass: a thread message with `--obligation`). - `closeout-asks-take-their-route` now requires the `/reload-plugins` step as a thread question. - `on-lists-read-todo-records` puts the phone build on the user as a question. - Tests that protected to-dos on the user (their Done, `x`, undo of Done, the To-do placeholder, the thread-head line, and #5223's page to-do on its card) are deleted. Tests that used one as a convenient On me item now use a question in a thread. On the candidate tree (Claude Code, 2 runs each): `step-on-the-user-takes-a-thread` 2/2, `closeout-asks-take-their-route` 2/2, `on-lists-read-todo-records` 1/2. The failed run listed both user items correctly and failed on the agent side, doubting that the benchmark re-run was under way. No base arm was run: the base instructions route a step through `leaf task create --on user`, which these rubrics now fail by construction. `pnpm run check:browser`, `pnpm run test:runtime` (775) and the model selections covering to-dos, the clerk, obligations, hooks, undo and the protocol pass, as do the resolved browser tests and #5232's Back-from-an-obligation tests. `test_an_item_arriving_above_takes_its_walk_place_and_moves_no_card_read` fails here and on `main` alike since #5318: the card read moves down by the new card's height (116px on `main`, 95px here), so the list no longer holds its place when an item arrives above. > _This was written by Claude Code on behalf of max-sixty_
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.
Things Leaf couldn't place collected at the top. A to-do on the page as a whole stood at the page's first heading. In an
lf-text-documentbound to page data, the first data update took every comment off its lines, unchanged lines included, and their margin entries gathered at the document's top as one cluster. A comment on a line the document holds twice sat at the top from the start. Now what has a place keeps it, and what has none gets no pin: it lives in On me or Threads, as a general thread does.Cause. A comment in a text document anchors to a datum, here the whole document, and a datum with no identity is bound to its revision, so any update made each comment "Earlier data", which falls back to the whole widget. A quote inside a datum recorded no surrounding words, so a repeated line couldn't be told from its other copy and fell back to the datum too.
subjectPlacesent a whole-page subject topageHead(), the first heading (#3880).Text documents (
lf-text-document.js,anchor-resolution.js,passages.js)lf-text-documentgives its reading an identity, its key, so a comment follows its words across source replacements. Unchanged lines stay marked and their entries stay beside them.fencedAt), and detaches where those can't tell it from another copy, as a quote of authored text does.projection/data.jsandevents.mdstate the rule.Page to-dos (
obligations/place.js,queue-walk.js,current-target.js,floating-panel.js)subjectPlacegives the page as a whole no place, andpageHeadgoes. A page to-do has no margin entry or ring; On me lists it under "The whole page", after placed items.marrives at it on its On me card (showOnMe(obligation)), and the page doesn't scroll. A user on an On me card is on the item that card shows (ON_CARDincurrentLocationOriginandcurrentLocationStop), so the walk steps on from it andxends it there. On a card,xends that card's to-do even where another to-do shares its place; it used to end the first to-do there.Left as it was. Comments on
lf-diffandlf-call-difflines still go to "Earlier data" at the file header once the patch changes, since a diff line's key is its line number in one revision of the patch. Page to-dos come after placed items in On me, as general threads come after placed ones in Threads. The text document's caption counts as words around a quote, so a selection of a document's whole text is a passage and loses its pin when that text is replaced.Test.
test_a_text_document_keeps_comments_on_their_lines_across_updates(Chromium and Firefox) comments on a line at a run's edge and on the second copy of a repeated line, prepends one line and then 200, then rewrites the first commented line, and checks that no entry stands at the document's top. It and the rewritten to-do tests innavigation/test_on_panel.pyfail on main and pass here, and removing the null rule inresolveAnchoror the card branch indoneTodofails them again. Tests that expected the old placements now expect the new: a page to-do on its card, and a page-level quote where they expected "Earlier data".pnpm run test:runtimeandpnpm run check:browserpass.