Repository navigation
Read markHere in the module that defines it, not in the file it left - #51
leaf-agent wants to merge 2 commits into
Conversation
The ask runtime split moved markHere into runtime/asks/view.js, and the theme-exclusion test read it out of leaf.js by name, so a commit that changed no behaviour reddened main. Read the function through _runtime_function, which finds the single module defining it and bounds the source at the closing brace standing at the declaration's own indentation. That is also stronger than the search it replaces: the old unbounded regex ran past markHere and would have accepted a later writer in the same file painting the mark markHere had stopped painting.
leaf-agent
left a comment
There was a problem hiding this comment.
One observation on _runtime_function, plus what I checked.
The fix is right about the coupling it removes, and the bound is real — I read the returned source back for markHere and it stops at runtime/asks/view.js's closing } at declaration indentation, 17 lines, not one writer further. The bug-backs in the description cover both the vacuity the old unbounded regex allowed and the two-definitions case.
What the fix narrows rather than removes is the shape of the declaration. opening matches function NAME( only, and runtime/asks/view.js already mixes both forms — readingBlock sits three lines under markHere as a const … = () =>. So rewriting markHere into that form changes no behaviour and still reddens the suite, which is the case this PR exists to close, and the message it fails with sends the reader looking for a function that left the layer rather than one that changed shape. Widening the pattern means a second close form (}; for the expression), which is more machinery than the case earns; naming the actual reading in the message costs nothing and makes that false red self-diagnosing.
Checked
uv run pytest tests/test_interact_document.py -k ancestor_exclusions -n0passes.reis still used throughouttest_interact_document.pyafter the removedjs = …line, and nothing else in that test referencedjs.- The
from interact_support import (…)insertion keeps isort order (_report<_runtime_function<_status);ci'slintis green on this head. - No existing helper in
interact_support.pyreads a runtime function by name — the neighbouring readings (_paint_names,_marker_for) take module-level constants out ofpresentation.jsby path, which is a different question. - The walk covers
assets/leaf.jsandassets/runtime/**/*.jsand does not reachassets/vendor/, so the highlight bundle is not scanned. ci'stestwas still in progress when I read the rollup.
`_runtime_function` reads a `function NAME(` declaration and no other form, and `runtime/asks/view.js` already mixes both — `readingBlock` sits three lines under `markHere` as a `const … = () =>`. Rewriting `markHere` into that form changes no behaviour and still reddens the suite, which is the case this branch exists to close, and the message it failed with sent the reader looking for a writer that had left the layer rather than one that had changed shape. Widening the pattern needs a second close form for the expression, which is more machinery than the case earns. Naming the actual reading costs nothing and makes that false red self-diagnosing.
|
The three commits main has taken since this branch's base (803c593, da57c46, 8ba3077) all split further runtime out of No new fix opened — this PR is the fix. |
|
Superseded — main fixed this test itself. 3b9ea44 ("Add contextual glosses to authored text") carries Verified on main at 3b9ea44: Closing rather than rebasing: 3b9ea44 is a decision about how this assertion should find |
|
Agreed on the close — One thing the supersession leaves behind, though: 3b9ea44 repointed the assertion at Carried the path-independent, bounded reading onto main on its own in #55, with a bug-back showing the pinned regex failing where the new reading holds. |
## Problem `seenScroller` asked the layout, not the reader: `panelCovers() ? threadsBox : pageScroller`. Beside the page — the ordinary wide window — a reader standing in the comment list pressed `d` and the document behind them stepped instead. That is the same nothing the covering rule was written to prevent: the region being read does not move, and the document is somewhere else when the reader looks back at it. This is item 1 of #53. ## Solution Focus is the first answer, covering is still the second: `inPanel() || panelCovers()`. The second is not the first restated — under the sheet the reader may be standing outside the panel altogether (the Comments button that raised it is the banner's), and the page behind the sheet is a page nobody can see. Focus says which region is the reader's; covering says which one the window will show them. `inPanel` is one predicate rather than two readings of the same line — `PANEL.at` was already spelling it (`panelOpen && containsAcross(panel, focused())`) and now reads it from the same place. `seenScroller` also serves the chord's `g g` / `g G`, so those edges now name the list's top and bottom when the reader is standing in it. That follows the same sentence the row already lived by under a covering panel, and keeping one reading of "the box the reader is reading" is what stops the two coming apart — but it is the one behaviour change here beyond `d`/`u`, so it's worth a maintainer's eye. Items 2–4 of #53 are design calls left untouched; I've commented on the issue with what the code says about each. ## Testing `test_the_half_page_keys_follow_the_reader_into_the_panel` in `tests/test_render_drafts.py`, beside the existing `..._move_the_region_the_reader_is_scrolling`. One factor separates its two presses — the window, the layout, the panel and the list are identical, and only where the focus stands changes — so the first press is the control that says the panel is beside the page (focus on the banner button, the document steps), and the second is the subject (focus on the list via `c`, the list steps). It fails on the current runtime at `assert 0 > 0` — the list did not move — and passes with the fix. Also run: `tests/test_render_navigation.py` (38 passed), `tests/test_render_drafts.py` + `tests/test_render_conversations.py` (81 passed), and `uv run pytest tests` (585 passed, 1 failed). That one failure is `test_the_ancestor_exclusions_ask_for_a_marker_and_not_a_tag`, which fails identically on this branch's base with the change stashed; #51 is the open fix for it. --- Refs #53 — automated triage --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
## Problem `seenScroller` asked the layout, not the reader: `panelCovers() ? threadsBox : pageScroller`. Beside the page — the ordinary wide window — a reader standing in the comment list pressed `d` and the document behind them stepped instead. That is the same nothing the covering rule was written to prevent: the region being read does not move, and the document is somewhere else when the reader looks back at it. This is item 1 of #53. ## Solution Focus is the first answer, covering is still the second: `inPanel() || panelCovers()`. The second is not the first restated — under the sheet the reader may be standing outside the panel altogether (the Comments button that raised it is the banner's), and the page behind the sheet is a page nobody can see. Focus says which region is the reader's; covering says which one the window will show them. `inPanel` is one predicate rather than two readings of the same line — `PANEL.at` was already spelling it (`panelOpen && containsAcross(panel, focused())`) and now reads it from the same place. `seenScroller` also serves the chord's `g g` / `g G`, so those edges now name the list's top and bottom when the reader is standing in it. That follows the same sentence the row already lived by under a covering panel, and keeping one reading of "the box the reader is reading" is what stops the two coming apart — but it is the one behaviour change here beyond `d`/`u`, so it's worth a maintainer's eye. Items 2–4 of #53 are design calls left untouched; I've commented on the issue with what the code says about each. ## Testing `test_the_half_page_keys_follow_the_reader_into_the_panel` in `tests/test_render_drafts.py`, beside the existing `..._move_the_region_the_reader_is_scrolling`. One factor separates its two presses — the window, the layout, the panel and the list are identical, and only where the focus stands changes — so the first press is the control that says the panel is beside the page (focus on the banner button, the document steps), and the second is the subject (focus on the list via `c`, the list steps). It fails on the current runtime at `assert 0 > 0` — the list did not move — and passes with the fix. Also run: `tests/test_render_navigation.py` (38 passed), `tests/test_render_drafts.py` + `tests/test_render_conversations.py` (81 passed), and `uv run pytest tests` (585 passed, 1 failed). That one failure is `test_the_ancestor_exclusions_ask_for_a_marker_and_not_a_tag`, which fails identically on this branch's base with the change stashed; #51 is the open fix for it. --- Refs #53 — automated triage --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
… pages and exports (#2549) From the review of the Lit survey PRs (item #51 in that review's numbering, not a GitHub issue). **#51: a command scope's attachment reads its own element only.** An imperative `keys()` attach called `paintKeys()`, which made the next frame re-read the `aria-keyshortcuts` of every scoped element on the page. A declaration changes no other element's shortcuts, and the attached element was already read on its own at the head of the next frame (`unpainted`, drained by `reflectFirstScopes`). So `attachScope` now only schedules that frame, the same rule #2504 gave a `commandsOn` re-render. `commandsOn`'s two attach branches become one `attachScope` call, `standScope` folds into `attachScope`, and the directive's withdrawal schedules a frame instead of a page-wide pass, since `detachScope` already re-reads the element. **Interactive exports now take that reading too.** An export's repaint frame mounted only `reflectKeys`, so it never drained `unpainted` or ran the head-of-frame button passes. Before this PR, the attach's own `paintKeys()` was what read a late scope there. Even then, a `commandsOn` re-render or withdrawal in an export was read only if another owner dirtied the frame. The export now mounts `reflectFirstScopes` as well (`leaf.js`), and `repaint.js` records that the two key slots go together. I found no shipped page where an export showed the gap: a test exporting a screenshot comparison, whose divider attaches after presentation, passed with and without this change, because another owner dirties that frame. So the PR adds no browser test for it. Behaviour that changed: an attach no longer marks the whole page's shortcuts for re-reading. A scope that a painter attaches mid-frame (the banner's touch controls, 18 per page) now gets its `aria-keyshortcuts` at the head of the next frame rather than at the tail of the current one. Measured: | | `paintKeys()` on attach (main) | this PR | |---|---|---| | happy-dom, one `keys()` attach beside 300 scoped elements: `getAttribute` calls | 1,813 | 7 | | happy-dom, same, time per attach | 1.4 ms | 0.19 ms | | Chrome, full `reflectKeys` passes over one key journey (review-a-plan / triage-board / pr-walkthrough / ship-review / command-hub) | 9 / 3 / 6 / 10 / 4 | 9 / 3 / 6 / 10 / 4 | On the shipped pages, the change saves no full passes: in each frame where an attach lands, another owner has already called `paintKeys()`. The saving is for an attach in an otherwise quiet frame on a page with many scoped elements. The case for the change is that both attachment paths now follow one rule, which removes a branch. History: `keys()` called `repaint()` until #1788 changed it to `paintKeys()`, the same commit that added the button-availability pass to `reflectFirstScopes`. That commit gives no reason for the switch, and that button pass now runs at the head of every frame either way. Line deltas: | | source | tests | |---|---|---| | #51 (`keyboard/scopes.js`, `repaint.js`, `leaf.js`) | −9 (+21 −30) | +8 (+9 −1) | Checks: all 361 runtime tests. The extended `command-controls` case attaches imperatively beside another scoped element and asserts that the other element isn't read; that assertion fails on `main`. Also 63 browser cases that assert `aria-keyshortcuts`, the shortcut bar or the command reference, run from `test_render_navigation`, `_controls`, `_anchors`, `_options`, `_widgets`, `_margin`, `_threads`, `_reactions`, `_drafts`, `_projection` and `_semantic_selection`, plus six interactive-export cases in `test_render_export`. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Problem
cion main is red attests/test_interact_document.py::test_the_ancestor_exclusions_ask_for_a_marker_and_not_a_tag. The commit under it, 9664448 ("Split ask model and view runtimes"), movedmarkHereout ofleaf.jsintoruntime/asks/view.jsand changed no behaviour. The test read the function out ofleaf.jsby name, so the split took its grounding with it and the assertion failed for the one thing it does not mean to hold still — which file the runtime keeps a writer in.Solution
The test asks whether
markHerestill writesPAGE_PAINT_ATTRIBUTE.ask, because the theme's:not(:where([data-lf-ask]) *)exclusions answer for a mark nothing would otherwise leave on the page. Which module holdsmarkHereis a separate fact about the runtime's own composition, so the reading no longer asserts it:_runtime_function(name)ininteract_support.pywalksleaf.jsandruntime/**/*.js, requires exactly one module to define the name, and returns that function's source.The bound is the second half of the fix, and it makes the reading stricter than the one it replaces. The old
function markHere\(\)(?:.|\n)*?PAGE_PAINT_ATTRIBUTE\.askhad no end, so any later writer in the same file could answer formarkHere._runtime_functionstops at the closing brace standing at the declaration's own indentation — which prettier guarantees, and which a brace count over strings, comments, and${}holes does not.Testing
uv run pytest tests -q— 585 passed, 6 skipped; the one error is this sandbox having no Chromium installed (test_smoke.pybrowser gate), unrelated to a file-side change.pre-commit run --fileson both changed files passes. The nightlytest_render_*modules need that browser, and this change touches no runtime, theme, or registry source, so CI covers them.Bug-backs run against the working tree, each reverted after:
Bug-backs
markHere, a later writer in the same file keeps it. RewrotemarkHere's body toPAGE_PAINT_ATTRIBUTE.exhibitand appended adecoyPaintfunction writingPAGE_PAINT_ATTRIBUTE.askafter it. The new reading fails; the regex it replaces returns a match on that same file, which is the vacuity the bound closes.function markHere()toruntime/asks/model.js— fails withthe runtime defines markHere() 2 times, rather than reporting on whichever file the walk reached first.Automated fix for failed run