Skip to content

Make strict checking the default for maintained browser modules - #4873

Merged
max-sixty merged 4 commits into
mainfrom
codex/strict-browser-default
Nov 1, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex/strict-browser-default

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Most browser modules previously ran through a relaxed type check, so untyped inputs could bypass contracts such as Said. This makes strict checking the default for maintained runtime modules, bundled widgets, render checks and browser vendor entry modules, including files no entry point imports yet. The relaxed program and pragma-based diagnostic selection are removed; JavaScript remains directly runnable.

The migration types values at their owners: served records derive from canonical schemas, renderers retain initialized DOM/state resources, and vendor imports resolve through checked source entries to native dependency declarations. Declaration patches correct specific upstream signatures without adding any or suppressing library errors. A negative compiler test proves that new unimported modules fail on implicit any without needing a pragma.

The large diff includes regenerated bundles, JSDoc contracts and formatting. A source audit found about 6,800 net comment lines and 3,900 net non-comment JavaScript lines; generated output contributes substantial additional churn. The runtime changes include retaining summary/list ownership once instead of rediscovering it or adding invariant throws. Pending widget input remains unknown until admission and is checked where its text is interpreted.

Review the checker and alias generation in build/browser/build.mjs, build/vendor.mjs and browser/types/, then the owner contracts in runtime modules. Public API adjustments are documented and all in-tree consumers are migrated: key-dependent commands use runKey(binding), loadDraft returns the stored record, contribution registrations expose focus ownership, and canvas2D supplies the native context capability.

Validation: strict/type and lint gates; reproducible generated outputs and a clean frozen dependency install; 737 runtime, 29 build and 88 Worker tests; focused real-browser checks for revision comparisons, composing, streaming thread placement, page inspection and offline exports. The field's Enter binding is covered in ordinary/joined and editable/read-only states to preserve native indentation and editability. A compiled base/candidate startup comparison used the same 36 requests, with 60 KB more bytes (+2.3%), no console errors and no layout shifts. The full browser corpus was not run locally; CI supplies the repository-wide gate.

The 150-page website build and native Linux CI deployment verification pass. Local macOS verification built the image successfully but timed out activating a page through the Cloudflare storage/proxy setup; standalone container reads and controlled publication checks passed for both base and candidate. That local end-to-end limitation remains unproven as a migration regression.

This was written by Codex on behalf of max-sixty

Replace the opt-in strict and relaxed passes with one strict program covering runtime, widgets, render checks, and vendor source entries. Derive boundary records from canonical schemas and retain initialized DOM/state resources explicitly rather than adding casts or any.

Check native dependency declarations and cover unimported modules. Preserve pending input interpretation at its rendering boundary; retain each summary range last message once instead of rescanning it. Runtime, build, Worker and focused browser checks pass.
…default

# Conflicts:
#	browser/runtime/annotation-overlay/comment-placement.js
#	browser/runtime/annotation-overlay/margin-layout.js
#	browser/runtime/annotation-overlay/thread-preview.js
#	browser/runtime/composing/field-editor.js
#	browser/runtime/composing/target-picker.js
#	browser/runtime/floating-panel.js
#	browser/runtime/markdown.js
#	browser/runtime/obligations/view.js
#	browser/runtime/page-about.js
#	browser/runtime/page-inspection.js
#	browser/vendor/codemirror.esm.js
#	browser/vendor/markdown-it.esm.js
#	build/vendor.mjs
#	dist/kernel/kernel.json
#	dist/kernel/leaf.js
#	dist/kernel/runtime/bundle-annotation-overlay.js
#	dist/kernel/runtime/bundle-comment-placement.js
#	dist/kernel/runtime/bundle-data.js
#	dist/kernel/runtime/bundle-page-inspection.js
#	dist/kernel/runtime/bundle-page-layout.js
#	packages/default/widgets/lf-options.js
#	packages/default/widgets/lf-text-document.js
#	packages/playground/widgets/lf-playground.js

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enter loses its existing indentation behavior in the field editor; the inline suggestion preserves the original CodeMirror command. I can apply the correction and rebuild the bundles upon request.

Comment thread build/entries/codemirror/entry.mjs Resolved
@max-sixty
max-sixty merged commit e698b75 into main Nov 1, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex/strict-browser-default branch November 1, 2026 04:21
max-sixty added a commit that referenced this pull request Nov 1, 2026
…d a page's (#4889)

Leaf showed a set of labelled values four ways. About's CSS counts stood
as tiles, each label over its number. Visual review's capture details
split into two equal columns of label-over-value pairs, which broke the
observation time after its hyphen and left "px" alone on a line. A
worktree's snapshot details had a two-column list of its own. The
reading theme's `dl.facts` (the command hub's counts, a task card's
worktree evidence, a release page's rail) was a two-column list that
stacked into label-over-value under a 640px container, so the hub's
narrow panel stacked its four counts down the column.

This change gives them one layout, `dl.facts` for a page's markup and
`dl.lf-facts` for what Leaf draws itself, stated once in
`browser/styles/components/reading.css`. Each label stands beside its
value, muted and a step smaller: a list Leaf draws sets its labels in
the small font of the label over a field, and the reading theme steps a
page's labels down from its prose. The labels take a column as wide as
the longest of them, up to two fifths of the list, and wrap past that,
so a long label never leaves its value a few words a line. That cap
replaces the 640px stacking rule, which existed for the same reason. The
values line up on one edge, in tabular figures, and break anywhere only
where they must.

### Where it lives

The rule is a component, outside markup's reading face, like
`.lf-media-frame` beside it. `lf-worktree` declares a shadow tree, and
its authored snapshot details are slotted into it, where `:host` turns
the reading face off; a rule inside the face never reached them, which
is why the diff package kept its own copy. Outside the face it holds on
any page and in slotted content.

The reading theme keeps only what is the theme's: a list's margin in the
column, and labels that step down to the apparatus size
(`min(var(--t-5), 1em)`, so a label is never larger than the words
around the list, as inside a worktree's smaller disclosure). The diff
package keeps its values in ink inside its muted disclosure.

### What changes on screen

- **About:** the five CSS counts read as a list, each label beside its
count, instead of a row of tiles, which on a phone cut off the last one.
The three JavaScript counts below them join the same list instead of a
sentence. The tab's observations stay a stacked list, since their values
are lists.
- **Capture details:** one list instead of two columns of stacked pairs.
The time and the focus box each fit on one line.
- **The command hub's counts and a release page's rail:** label beside
value instead of stacked, in their narrow columns.
- **A worktree's snapshot details:** unchanged apart from rows 4px
closer and values 8px closer to their labels.
- **A task card's worktree evidence and a wide `dl.facts`:** unchanged.

### Authoring change

A worktree's snapshot details are now written `<dl class="facts">`
(`packages/diff/instructions/author.md` and the worktree example). A
plain `<dl>` there takes the browser's definition list.

### Also: `leaf-dev stills` runs again

Since #4873, `image-difference.js` imports `/runtime/portable-api.js`,
and the tab where `leaf-dev stills` compares its pairs answered that
path with an empty page, so every run stopped before its first
comparison. The tab now serves the runtime as `read_runtime` reads it.

### Checks

- `test_interface_fonts.py`; the facts layout test in Chromium and
Firefox; the options rail tests; the visual review inspection test; the
worktree disclosure test.
- `leaf-dev stills` over About, capture details (light and dark), the
hub, the ship review's facts and option rail, and the worktree
summaries, and probes of the worktree's snapshot details, the hub's task
card evidence and the release rail on main and on this branch.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 1, 2026
Conflicts came from #4873's strict type check meeting this branch's placement and
motion changes. The resolution keeps the branch's code and gives it the types the
strict check asks for:

- The comment box's motion stays rooted on the composer, now reached as the
  composition frame's parent. Main's `response.composition().frame` is the same
  `display: contents` wrapper this branch moved off.
- The anchor a box stands by can be the start of what a scroller holds
  (css-anchors.js, `ContentStart`), which has no `isConnected`. `beside()` now
  checks that scroller instead, so a box anchored that way also measures how far
  its passage moved past it, rather than reading 0.
- `rebase()` returns the root's box with `past`, so `placed()` needs no null
  frame.
- The card's size observer passes its session to `placedThreadPreview`, which
  now takes one.

The kernel is rebuilt.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 2, 2026
The JavaScript export check (`tests/journeys/test_unused_exports.py`)
ran only in the daily `journeys` tier. That run has failed every day
this week, with over a hundred failures each time, so an orphaned export
reached main and stayed until Tend triaged the daily report: #4724 and
#4873 left seven on 30 and 31 October, and #5014 removed them on 1
November. Vulture, its Python counterpart, runs as a pre-commit hook,
which both landing paths (a pull request's lint step and `wt merge`'s
pre-merge) run over the whole tree, so the change that orphans a Python
definition is the one told.

This moves the export check beside vulture:

- `leaf-dev unused-exports` holds the check, unchanged, with the test's
docstring as its module header. It takes about two seconds.
- `.pre-commit-config.yaml` runs it as `unused-exports`, woken locally
by the file kinds that export or read (`.js`, `.mjs`, `.ts`, `.py`,
`.html`, `.md`, `worker/wrangler.toml`). CI runs every hook on every
file.

It also removes what #5014's deletion of `since-seen.js` left behind:

- the `keepalive` option of `deliverBookkeeping` and `postEvent`, which
only the departing `seen` send set, and `runtime.seen`, which only
`since-seen.js` read;
- the six arrival tests skipped while `since-seen.js` was unmounted. The
module, renamed `test_changes_in_place.py`, keeps the comparison and
at-work tests;
- the prose in `change-walk.js`, `events.md`, `read_state.py`,
`agent_state.py` and `browser/AGENTS.md` that described the turned-off
marking. The server's reading of `seen` events is unchanged, and no tab
posts one.

And it drops the `uuid` devDependency, which no module imports. A
one-off knip scan of dependencies flagged 33; the other 32 are bundled
from `build/entries`, loaded by evals or `tests/*.mjs`, or resolved as
types and peers. As #2326 and #3423 found for exports, knip would need
more configuration than it saves, so it is not added as a gate.

Validation: `leaf-dev unused-exports` and every pre-commit hook pass on
the changed files; `pnpm run check:browser`, the 737 runtime tests, and
the browser test for comparison bars and the `h` walk pass.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 2, 2026
…nMark does (#5029)

A Markdown file now reads indented code and setext headings the way
CommonMark does. That covers `renderMarkdown(text, false)`,
`lf-text-document`'s Markdown preview and every Markdown body
(`x-text-format: markdown`, such as `lf-draft`). A message reads as
before.

Before this change, a block indented four spaces after a blank line
rendered as a paragraph in the body face, so the issue's `sed` command
lost its code font and its quotes and regex read as prose. `Title` over
`=====` rendered as the words "Title =====", and a line over `---` as a
paragraph followed by a rule.

### Why it happened

#4738 turned off markdown-it's `code` and `lheading` rules so that a
person typing a message wouldn't get code from a leading indent, or a
heading from a `---` under a line. That reason holds for a message, but
`makeMarkdown` applied it to both readings, and the comment recording it
was later dropped in a type-checking pass (#4873).

### What changes

The reading now decides the grammar as well as the soft breaks.
`makeMarkdown`'s boolean is renamed from `breaks` to `message`, and it
turns the two rules off only for a message. The comment on
`renderMarkdown` says what each reading does and why. Every reader of a
Markdown file moves together:

- **Python's mirror.** `passages.markdown_dialect(message)` replaces
`block_markdown()`. A body's passages and its server prepaint read the
same blocks as the browser. The reply door's media check
(`text_media_errors`) reads a message as a message, so an indented
`![shot](/media/…)` in a reply is still checked, since the message
renders it as a picture.
- **The field that edits a Markdown body in place.** Its configuration
names its reading `message()`, the name markdown.js uses (it was
`joined()`, facet `joinsLines`). In a body it tokenizes with the file
reading, and so does `markdownSourceOffset`. A click in a draft's
indented code opens the editor at that character, and Return at the end
of an indented code line writes the code's next line. The field draws an
indented block the way it draws a fence's code. No fence line stands for
the pre's padding, so the block's first and last lines carry it
(`lf-md-code-pad-start`, beside the existing `pad-end`).
- **A draft's answer.** `markdownWords` takes the same reading argument
as `renderMarkdown`. `lf-draft.answerWords` passes the file reading, so
the On me row for a draft whose body shows a heading over `=====` says
"Answered: Title Body" rather than "Title ===== Body".
- **Contract text.** `module-reading.md` describes both readings, and
text-field.js's header names a setext heading's underline among the
constructs that keep their source lines.

The message reading keeps both rules off. A widget showing a model's
reply can already ask for CommonMark with `renderMarkdown(text, false)`,
but in that reading a single line break becomes a space. Neither reading
keeps message line breaks and also reads indented code. No caller in
this tree needs both, so this PR adds no third reading.

### Known limit

In the field that edits a body in place, a setext heading's underline
keeps a line of its own. Opening a draft that holds one moves the words
below the heading down by that line (probed). Before this change, the
same draft showed the heading as a paragraph in both views. Drafts
rarely hold setext headings: none of the 36 distinct `lf-draft` bodies
in pages on the author's machine changes structure under the new
reading, and neither does any string in the examples' data files.

### Evidence

- The issue's reply in an `lf-draft` renders as the blocks `p p p p p`
on main and `h1 p p pre p` on this branch (`leaf-dev probe --base`, a
page holding the issue's text under a setext heading).
- `tests/markdown_body_cases.json` now records each case's top-level
`blocks`, and both runtimes are held to them. The new indented-code and
setext cases, and the existing `<div>\nHeading\n---` case, failed on
main in both the browser (`body-text.test.mjs`) and Python
(`test_markdown_body_file_words_match_the_shared_browser_dialect`).
- A runtime test holds `lf-draft.answerWords` to the words its painted
body shows. It fails with the message reading.
- `markdown-preview.test.mjs` now checks both readings: the field must
draw every rule either reading's renderer enables.
`field-editor.test.mjs` checks that Return continues indented code in a
field editing a body. Both failed on main.
- `test_a_draft_edits_where_it_reads` now includes an indented block. It
fails if the field reads that block as a message, and it fails if the
block's top padding is dropped.
-
`test_live_revision_drafts_wait_for_the_complete_controller_publication`
indented its draft bodies only as Python layout, so the indent is
removed and they stay prose.

### Checks run

`pnpm run test:runtime` (739 passed), `pnpm run check:browser`, and the
model tests for passages, anchors, revision delivery, media and authored
markup (406 passed). Focused browser tests: draft editing (faces,
wrapping, arrow keys, exact source, continuation clicks, Enter, format
comparison), composer Markdown decoration and Return, the chrome
contracts for draft faces, nesting, drawn source, fences and bullets,
and the live-revision drafts test.
`test_on_panel.py::test_an_answered_obligations_words_are_its_widgets_semantic_state`
fails the same way with this branch's source and with the merge base's:
its playground output never shows the posted `strip` choice, before the
test reaches the draft's answer.

The open editor over an indented block draws the same in Firefox as in
Chromium (probed). Not checked: WebKit, and the broad suite, which runs
in this PR's checks.

Closes #5016

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 2, 2026
The shared-thread browser test rejected every `markup` key, but #4873
intentionally retained the original authored HTML in `body.markup` so
Copy preserves a complete reply. Assert that captured source while
continuing to exclude raw message markup and rendered HTML. The gesture,
pending-send, immutable-reading and live authored-widget state
assertions remain intact; product behavior is unchanged.

The focused `stay` case reproduced the reported failure before this
correction. Both `stay` and `choose-earlier` pass afterward (`uv run
pytest
tests/browser/test_render_application_boundary.py::test_packages_and_panel_share_threads_through_gestures_and_authored_content
-q -n0`). Ruff check, Ruff format and `git diff --check` pass.

Closes #5095 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 3, 2026
The generated Data structures reference linked nested served-state
properties and message records to nonexistent anchors. Resolve a nested
pointer to its owning definition and message records to their event-kind
entry, preserving the reference label for nested properties. This keeps
the schema changes from #4873 and #5057 while restoring navigation.

Move the existing schema-entry/link invariant into the product suite so
ordinary CI protects the published reference. It failed before the fix
with twelve missing targets and passes afterward; all eleven
product-page tests pass. Focused Ruff checks pass. An independent review
found no issues.

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 3, 2026
…olls (#5206)

A thread card on a row ⌥-clicked deep in a scrolling pane stood above
the pane once the row scrolled away (card top 24.9 px, pane top 370 px),
instead of stopping at the pane's top.
`test_a_row_pointed_in_a_scrolling_pane_keeps_its_card_in_the_pane` has
failed on every `ci` run on main since #4873.

**Cause.** #4873 changed `threadCardPlace` to return the thread's target
as the element its placement watches. Floating UI's `autoUpdate`
re-places on scrolls of that element's ancestors. When a pane's rows
have no ids, the target is the whole `lf-pane`, and its rows box sits
inside the pane rather than above it. So scrolling the rows never re-ran
placement, and the card's CSS anchor carried it out of the pane with the
row: after the scroll, `--lf-cut-top` and the anchor offset kept their
pre-scroll values. Before #4873, the watch used the attachment's element
(`point ?? target` in `commentAttachment`), whose ancestors include the
rows box. This PR goes back to that element and falls back to the target
when the target isn't drawn, as the code before #4873 did. #4873's own
intent, strict type checking, is unaffected.

**Verification.** `git bisect` over the test traced the failure to
e698b75 (#4873). The test fails on main and passes with this change,
and so do its neighbours on panes, logs and non-scrolling regions in
`test_render_send_placement.py`. `pnpm run check` passes, and the
rebuilt kernel matches `pnpm run build:browser`.

Closes #5161 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 3, 2026
…orpus ids unique (#5217)

The generated corpus failed `page check` for two separate reasons, and
each is fixed here:

- **Quoted playgrounds threw on connect.** #4873 (strict type checking)
replaced a cast with `if (!split) throw new Error("The playground needs
its rendered split view")`. A quoted playground, one inside
`data-lf-exhibit`, draws only its authored markup and never has a
`.lf-playground-split`, so every quoted playground failed. That includes
`quoted-alerts` in the corpus and the playground browser tests in #5072.
The split view's only job there is to receive the controls region's
height. A quoted playground has no controls region, so the lookup is
optional again (`split?.style`). This keeps #4873's typing without the
invariant it wrongly assumed.
- **Duplicate ids stopped the corpus from being generated.** #5118 added
`tests/fixtures/pages/page-annotations.html` with ids `title`, `plan`
and `tail`, which `thread-journey-inline.html` already uses. On current
main, `leaf-dev corpus` refuses to build ("id 'title' is in both …").
This landed after the scheduled run in the report, so the nightly would
have hit it next. The fixture's ids now have a `rollout-` prefix, and
the `proxy-note-own-annotations` still follows the paragraph's new id.
Nothing on screen changes apart from those ids.

Verification:
-
`tests/journeys/test_interact_product.py::test_page_fixtures_pass_check[corpus]`
(`--run-nightly`): fails on main at corpus generation. With only the id
rename it fails with the two `page-report` split-view errors. With both
changes it passes.
- `tests/browser/widgets/test_playgrounds.py`: the two quoted-playground
tests named in #5072 error at teardown on main. The whole file passes
with the change (38 passed).
- `pnpm run check:browser` passes.

The `measurement-lag` finding in the report is advice-level and doesn't
affect the check's status.

Closes #5173 — automated triage
Closes #5072 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 3, 2026
…t says

#4873 folded four rows' when into a run getter, so the register showed them live
while their run had nothing to do: the reference listed Copy message as Markdown
with words selected, and pressing it said it was available in a thread.
max-sixty added a commit that referenced this pull request Nov 3, 2026
… command's availability in its when (#5250)

Six keyboard tests in `tests/browser` fail on `main`, in CI and locally,
since #4873 and #4895. Three of the causes were in the runtime, and the
rest in fixtures that still used the API those changes replaced.

- **The command reference.** #4873 let a row declare `run` as a getter
that returns nothing while the command can't act, and the reference read
that value to decide whether a row runs at all. So Resolve, outside a
thread, became a disabled option rather than one the user can pick and
be told "Available in a thread". The reference now asks whether the row
declares a `run` (or a `runKey` for a keyed route), as registration
already does, and leaves "now" to availability.
- **Availability.** #4873 also folded the `when` of four rows
(`thread.primary`, `thread.resolution.toggle`, `message.copy`,
`message.edit.previous`) into such a getter, so every reader of
availability but dispatch took them as live while their `run` had
nothing to do: the reference listed "Copy message as Markdown" while
words were selected, and the message editor advertised ↑ with no message
above to edit. With the reference fix above, that row would also have
become one to pick. Their `when` is back, with a plain `run`, as
`bindings.js` asks ("Do not repeat a guard inside `run` if the guard
changes whether the key should be shown").
- **The panel's corner fold.** #4873 had the corner mark call the fold
directly instead of pressing the fold command's row, so the press was no
longer announced or logged. It presses the row again.
- **Fixtures.** Four declared a key-dependent action as `run(binding)`,
which #4873 renamed `runKey`, so they received `undefined`. Two lookups,
and a journey's two, still asked for reference rows as buttons, which
#4895 made listbox options.

`tests/AGENTS.md` now asks whether anyone is fixing a failure on `main`,
rather than who owns it. Tend had filed these causes (#5073, #5076) a
day earlier, with no pull request since, and the session that met them
took them for local-only: main's newest runs had all been cancelled by
later pushes, and a search for the test names joined with `OR` found
nothing. So the guidance names the latest finished run, says a cause
issue with neither Tend's eyes reaction nor a linked pull request is
still waiting, and has a session working for a maintainer start a local
session for a failure nobody is fixing.

Checked by node id: the six tests, the floating panel's fold tests, the
radio and slider fixture's test,
`tests/journeys/test_render_code_reading.py`, and the tests that press
Enter, `r`, the copy key and ↑ in a thread
(`test_key_surfaces::test_a_key_on_screen_is_a_key_that_works`,
`test_rewrites`' three walks, `test_layout`'s Markdown copy,
`test_commenting`'s native copy, `test_resolving`'s and
`test_seated_threads`' settling). `pnpm run test:runtime` and `pnpm run
check` pass. Five other keyboard failures on `main` (`test_focus`'s
reference-command gesture, `test_commenting`'s submit shortcuts and
`startup/test_keys`' early key) still fail with this change and have
other causes.

Closes #5073
Closes #5076

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 4, 2026
…#5313)

#4873 let a command row declare `run` as a getter that returns nothing
while the command can't act. Dispatch then fell through, but every other
reader of availability (the command reference, key hints,
`aria-keyshortcuts`) reads `when` and took such a row as live. #5250 put
four thread rows back on `when` with a plain `run`, as `bindings.js`
asks ("Do not repeat a guard inside `run` if the guard changes whether
the key should be shown"). This does the same for the six rows that were
left:

- `navigation.back` (`register.js`), `selection.restore`
(`composing/capture.js`) and the three `margin.card.*` rows
(`annotation-overlay/thread-preview.js`) already had a `when` that
matched their getter's guard, so their behavior is unchanged.
- `code.copy` (`code-copy.js`) had no `when`. Before its Copy button
upgraded, a code block advertised Enter as "copy code" and the press
fell through to the page. It now waits in its `when` for the button.

The detail dial's arrows (`packages/detail/widgets/lf-dial.js`) had the
same fault without a getter: `dial.less` and `dial.more` had no `when`,
and their `run` returned at the dial's ends. At Skim the dial advertised
← for Less detail, which does nothing. Each row now needs a depth beside
the current one in its `when`, and drawing a depth calls
`commandsChanged` so Leaf reads them again. A probe of `detail` reads
the dial's `aria-keyshortcuts` as `ArrowRight` at Skim, both arrows at
Read and `ArrowLeft` at Everything; on `main` it reads both arrows at
every depth.

With no getter left, a row's `run` and `runKey` are plain values again:

- `declaresCommandHandler` is deleted. Registration, the register's
touch check, button wiring and the command reference read `row.run` and
`row.runKey` directly.
- Go-to registers its direct destinations by spreading them, without
copying property descriptors.
- The three runtime tests that pinned the getter contract are deleted.

Three browser tests still looked up command reference rows as buttons,
which #4895 made listbox options. They now ask for options:

-
`controls/test_focus.py::test_a_reference_command_finishes_its_gesture_before_a_newer_control`,
which failed on `main` with no Tend cause issue.
-
`test_render_code_reading.py::test_code_wrapping_keeps_source_copy_and_reader_choice`,
which presses Unwrap lines and Copy code in the reference, then Enter on
the block.
-
`test_render_heading_links.py::test_a_heading_copies_the_link_to_the_section_it_opens`.

Checked by node id: those tests; `test_reading_place`'s Restore
selection; `test_render_code_reading`'s copy over plain HTTP;
`test_summaries`' margin paging, which Tabs into and out of a card;
`test_clusters`' reference row for Escape; four of `test_key_scopes`'
Escape and back-gesture tests; and `test_dial`. `pnpm run test:runtime`,
`pnpm run check:browser` and pre-commit pass. Locally, three of
`check:worker`'s bundle and storage tests hit their 5 s and 60 s
timeouts at a load average of 50 to 85, so the pull request's run is
their check.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 4, 2026
…d hold the shift watch's shadow roots weakly (#5316)

The render gate's thread-card round trips retained a whole margin card
per open on six corpus pages (#5190). This had two retainers, and both
had to go before the counts held steady.

- **Runtime
([`inline.js`](https://github.com/max-sixty/leaf/blob/cae775852afa544d1356c81733dca213b0c2973f/browser/runtime/thread/inline.js#L366)).**
Since #4873 the margin card builds a new `.lf-margin-thread` section and
seat body for each card it opens. Before that change, it reused the one
section. The seat commits while the body is still detached, and the
owner places it afterwards through `claimSeatReplies`. So `#connected`
stayed false, and `prune()` never disposed the seat. Each opened card
left its `ThreadSeat` in `activeSeats` and its `HeldNews` in `holders`,
and those kept the card's nodes and listeners alive. Now `claim()`, the
owner's placement signal, records that the seat stands in the document,
and the next commit prunes the card the user closed.
- **Test harness
([`shift_watch.js`](https://github.com/max-sixty/leaf/blob/cae775852afa544d1356c81733dca213b0c2973f/tests/shift_watch.js#L746)).**
The shift watch kept every shadow root ever attached in a strong `Set`.
A closed card's reply field (`leaf-text`'s shadow root) therefore kept
the card alive as long as the page lived, and `live_counts` read that as
a leak. It now holds roots by `WeakRef` and still walks every live one,
closed roots included. This fixes the measuring instrument and leaves
the leak thresholds unchanged.

**Verification.** On main, `test_page_fixture_renders[log-retention]`
reports `the thread card leaks nodes: [2210, 2519, 3304, 4089]`. With
this change, the thread-card leak is gone from log-retention,
review-a-plan, ship-review, thread-choice-hints, feature-gallery (nodes
and listeners) and thread-panel-gallery. A probe of six `t` + Escape
trips on log-retention reads a flat 2871 nodes and 1011 listeners. With
only the harness fix it climbs from the third trip, and with only the
runtime fix it climbs from the first. `git bisect` with that probe over
the last passing and first failing nightlies lands on #4873.

Those six cases still fail locally on findings this change doesn't
touch:
- `g opened no go-to`, on every page, which also happens on unmodified
main and is absent from the Nov 3 nightly.
- feature-gallery's `apparatus among authored` `<span>`, which the Nov 3
nightly also reports.

`pnpm run test:runtime` (776), `check:browser`, the shift watch's
shadow-root browser tests (23) and the margin card's reply tests pass.
The one failure in that selection,
`test_an_offscreen_thread_card_arrives_with_its_anchor[above-or-below-up]`,
also fails on main (#5146).

<details><summary>How the retainers were found</summary>

After four round trips, `DOM.getDetachedDomNodes` listed three detached
`SECTION.lf-margin-thread` trees of about 280 nodes each, while the
attached DOM stayed at 813 nodes. Shortest retainer paths in a heap
snapshot (excluding weak and ephemeron edges) ran through the shift
watch's `roots` Set (`ShadowRoot` → `leaf-text` → … → section). With
that scope excluded, they ran through `holders` → `HeldNews.#seat`, the
margin card's seat body, with `activeSeats` holding the seat itself.

</details>

Closes #5190 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Nov 4, 2026
…ts (#5330)

#4873 (strict type checking for browser modules) changed the stored
`lf-view` from the page's reading with `revision` and `regions` merged
in to `{page, revision, activeRegion, regions}`, with the page's reading
under `page`
([`captureView`](https://github.com/max-sixty/leaf/blob/4721b4fc7743402db38814cec46092d068629000/browser/runtime/version.js#L2281-L2304)).
Restoration reads the new shape, but three tests in
`tests/browser/projection/test_reading_position.py` still read `quote`
and `section` from the top level, so they failed with `KeyError` before
reaching their restoration checks. They now read `.page`, where the
producer stores the reading. Their assertions are unchanged, and nothing
in the runtime changes.

All three failed with the reported `KeyError` on current `main` and pass
with this change, including their checks that the reading position comes
back after the revision changes:

- `test_revision_changes_keep_the_complete_heading_below_user_chrome`
-
`test_revision_changes_follow_authored_text_into_declared_shadow_trees`
- `test_the_reading_position_restores_onto_a_section_that_draws_no_box`

Closes #5074 — automated triage

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 4, 2026
The probe no longer reads the widget's private FileEntry records, whose
reshaping (#4873) broke it. It checks each drawn .lf-diff-line directly:
one numbered control, followed by a source line whose datum names the
number the control shows, with the row's line type matching.
leaf-agent added a commit that referenced this pull request Nov 4, 2026
…not the widget's private file entries (#5374)

#4873 moved each diff file entry's drawn lines from `entry.lines` to
`entry.rendered.lines` (`FileEntry` in
`packages/diff/widgets/lf-diff.js`), but the gutter probe in
`test_a_diff_refresh_keeps_a_selection_in_unchanged_lines` still read
`entry.lines`. Its `page.evaluate` therefore threw `TypeError: Cannot
read properties of undefined (reading 'map')` before checking any row,
as in [push run
41576718956](https://github.com/max-sixty/leaf/actions/runs/41576718956).

The probe no longer reads the widget's private `fileEntries` records, so
a reshaping of them can't break it again. It reads each drawn
`.lf-diff-line` row of the diff and asserts there is at least one, and
that each row holds exactly one numbered control, followed by a source
line whose `data-lf-datum` names the number the control shows (the new
number for a context line), with the row's line type matching the
line's. The selection-refresh journey is unchanged, and the widget is
unchanged.

On current main the test fails with the reported TypeError; with this
change it passes locally (`uv run pytest
tests/browser/widgets/test_diffs.py::test_a_diff_refresh_keeps_a_selection_in_unchanged_lines`),
and fails when the expected number is taken from the wrong datum field.

Closes #5166 — automated triage

---------

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants