Repository navigation
Add flowchart node comment anchors - #56
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
Three things, none blocking. The main one is the re-vendor door: visual_anchor_error guards POST /api/event but nothing guards page init, so a layer that stops declaring x-visual.parts orphans every recorded visual anchor silently. Details inline; happy to push the fix if you'd rather not.
…mments # Conflicts: # plugins/leaf/skills/leaf/assets/leaf.js
…mments # Conflicts: # plugins/leaf/skills/leaf/assets/leaf.js
leaf-agent
left a comment
There was a problem hiding this comment.
The relocation into composing/aim.js and composing/surface.js reads correct, and the id requirement visualAt now carries closes a hole the pre-merge shape had — an outerVisualAt match with no id-bearing seat above it would have opened a composer on {section: undefined}.
Two small things left, both inline.
The anchor schema accepts {section, quote, visual} and {section, datum, visual} — dependentRequired is the only constraint on visual, and I checked both shapes against $events.kinds.comment.record.properties.anchor with a Draft2020 validator. leaf comment refuses the equivalent (--part names a visual box; use it without --quote), so the two doors disagree about the same combination. It matters because each shape resolves inconsistently rather than being rejected: with a quote alongside, resolveAnchor takes the anchor.visual branch and outlines the node while anchorLabel and cmd_transcript both test anchor.quote first, so the panel names a passage and the page marks a diagram box; with a datum alongside, the anchor.datum branch runs first and the visual token is dropped with nothing said.
Worth knowing about the neighbours: #48 moves pointerAt() onto pointermove for the sub-pixel position, and aimedTarget() here resolves the visual part through that same record — so whichever of the two lands second inherits both the conflict in these files and the precision.
leaf-agent
left a comment
There was a problem hiding this comment.
Both remaining threads are addressed — the mixed-anchor refusal reads right where it is, after the if not visual guard and before the section lookup, so a {section, quote, visual} now dies at the same door the CLI already refused it at, and the browser only ever builds {section, visual} so no live gesture loses anything. I've resolved both.
test is red on the merged tree, and it isn't flaky — this PR and current main disagree about x-visual. main's ceb4214 ("Draw a page's numbers with lf-chart") added an lf-chart entry declaring "x-visual": true, which was the whole of the key's vocabulary at the time. This PR replaces that vocabulary with "whole" | {parts: ATTR}, so the merged default package carries an entry the merged schema rejects:
merged registry (…/assets/registry.json, …/packages/default/registry.json):
<lf-chart> registry extensions are invalid: True is not valid under any of the given schemas
That fires inside page init, so it isn't one test — it's every fixture that vendors a layer. I reproduced it locally on the merge commit: tests/test_interact_anchors.py, test_interact_server.py and test_interact_contract.py collect 272 errors, all with that one message.
The fix is "x-visual": "whole" on lf-chart in plugins/leaf/skills/leaf/packages/default/registry.json — the direct translation of what true meant, and correct for a chart: the render gate's provider requirement (entry['x-visual'] && typeof entry['x-visual'] === 'object' in rendering.py) only reaches object-valued declarations, so whole owes no lfVisualPartAt/lfVisualPart. With that one line changed the same three modules pass 272, and uv run pytest tests is 590 passed / 6 skipped (the one error is this runner having no Playwright browser installed).
I can't put it inline — lf-chart arrived from main after this branch last merged, so the line is outside the PR's diff. Happy to push it if you'd like; say the word.
Move widget upgrade guards, data-body access, fail-soft rendering, and the async settlement queue from leaf.js into their runtime owner. Export the public helpers directly from widget-api.
lf-diagram draws the graphs a page needs; this draws its numbers. The body is data rather than a chart spec — a header row naming the x column, then one row per x value — and `kind` says which picture it is: bars, rows, stack, line or dots. There is no pie, because the comparison a pie asks for is between angles and the comparison bars ask for is between lengths. Observable Plot draws it, bundled with d3 by scripts/vendor-plot.sh and imported lazily, since every x-upgrade module is imported on every page. Plot draws SVG, which is the half that matters here: an export strips scripts, so a canvas would leave an empty box on the page it was exported from. Plot's marks also take currentColor, so one class per series and one rule per --series-N paint the whole chart and no colour is resolved in JavaScript — a scheme flipped mid-read repaints with the page, and a copy exported from a light window opens honestly for a dark reader. The palette's five steps clear a separation floor under protan and deutan simulation, which test_interact_document.py computes rather than takes on trust; past the last step a chart refuses rather than drawing two series in one colour. mermaid's xychart was the alternative already vendored, and it has no (x, y) pairs at all — x is the array index — so an irregular series is plotted at even spacing, two bar series overdraw each other, and bars do not start at zero. It draws a false picture where this draws an error. The widget is fenced like every other data-bodied widget, so a comment made inside the drawing anchors to the chart rather than to a tick label the file cannot see and a narrow window would drop. The chart is drawn for the room it has and drawn again when that changes, because an SVG scaled into a narrower box takes its labels under legibility with it, and its margins are measured against the painted text rather than estimated from the tick values. examples/heat-loss.html carries all five kinds through the corpus sweeps.
Move reduced-motion policy, shared scroll behavior, Web Animations playback, and fold timing from leaf.js into their runtime owner. Export the widget-facing surface directly from widget-api.
…mments # Conflicts: # plugins/leaf/skills/leaf/CLAUDE.md # plugins/leaf/skills/leaf/assets/leaf.js # plugins/leaf/skills/leaf/assets/runtime/widget-api.js
leaf-agent
left a comment
There was a problem hiding this comment.
f2ca9b6 is the right value, but the tree it lands in already has a second lf-chart entry, so ci is still fully red — 745 failed / 471 errors on run 33015389255, every one of them the same message.
packages/default/registry.json on the merge commit carries "lf-chart" twice: once from this branch's 7ce199b, now reading "x-visual": "whole", and once from main's ceb4214, still reading "x-visual": true. The two blocks were added at different offsets in the file, so git merged both in without raising a conflict. Two things then fail off that one duplication: check json refuses the file outright (Failed to json decode (Duplicate key: lf-chart)), which is the whole of lint; and Python's last-wins parse takes the true, which the new x-visual schema rejects, so page init errors and every fixture that vendors a layer dies at setup. It isn't a second bug — it's the same one the last review named, still standing because the fix went into the branch's own copy rather than the one the merge produces.
The blocks are identical apart from that single line, so the resolution is just to drop main's. I checked it on this merge checkout: with one lf-chart carrying "x-visual": "whole", tests/test_interact_contract.py is 182 passed and tests/test_interact_anchors.py + tests/test_interact_server.py are 90 passed, against 272 setup errors before.
Worth doing as part of a real merge rather than a spot edit, because the same shape is waiting in three other files. main has since squash-landed this branch's 9433f52, 7ce199b and 341e8f3 as 1961d27, ceb4214 and 5c7c413, so the branch and main now hold byte-identical copies of the chart widget, the plot bundle, heat-loss.html, vendor-plot.sh, motion.js and widget-upgrade.js under different SHAs. git merge-tree cae9ea5 f2ca9b6 conflicts in CLAUDE.md, assets/leaf.js and runtime/widget-api.js for exactly that reason. Those three at least announce themselves; the registry is the one that merged silently and reached CI as 745 red.
One consequence worth knowing before review: because those commits are duplicated rather than shared, this PR's diff reads 2683 additions, while its net contribution over current main is about 955 added / 327 deleted — the visual-subtarget contract and the flowchart-node adapter, which is what the title describes. Everything else in the diff is already on main.
Happy to push the merge and the dedupe if you'd rather not — say the word. I've left it alone since resolving a merge is your call, not something to do under you.
leaf-agent
left a comment
There was a problem hiding this comment.
The two merges cleared the duplicate lf-chart the last review named — the merged packages/default/registry.json now carries one entry reading "x-visual": "whole", and lint is green on cccc75f. test is still running as I write this.
The merges cost two things of their own, both from 4063cc5's conflict resolution.
plugins/leaf/skills/leaf/CLAUDE.md lost the contract this PR adds. ab01323 appended five lines to the widget-module obligations list, right after the quoted(el) bullet:
- A visual declaring `{parts: ATTR}` must implement `lfVisualPartAt(target)` to
return one token from ATTR and `lfVisualPart(part)` to return its current
`{element, label}`. The authored widget remains the comment seat, the token is
recorded as `anchor.visual`, and the returned element supplies only mark and
travel geometry. The render gate refuses either missing method.
That file was one of the three the merge conflicted in, and the resolution dropped the block: it is absent from the merged tree and it is not on main either, so nothing restores it. The obligation itself survives — rendering.py fails a page whose instance is missing either method, and test_the_render_gate_requires_a_visual_parts_provider proves it — so the effect is a gate a module author is refused by with no line in the file the root CLAUDE.md sends them to for "detailed browser, widget, and theme rules". The list is intact around where it belongs, between the quoted(el) bullet and the projectData one, so re-applying it verbatim is the whole fix.
assets/leaf.js gained a line nothing asked for, export { quoted };, sitting between two import statements. It is on neither main nor any of the branch's own four commits — 4063cc5 introduced it, resolving leaf.js against a main that had just moved quoted out to runtime/widget-elements.js. Nothing consumes it: the only importer of leaf.js is widget-api.js, whose export * from "../leaf.js" is already shadowed for this name by its own explicit export { quoted } from "./widget-elements.js". Suggestion inline.
One minor thing on the new code itself, also inline — openOnVisual recomputes a section id the record it is handed already carries.
Happy to push the CLAUDE.md restoration and the stray export if you'd rather not; say the word.
Move keyed DOM reconciliation and coalesced anchor repaint scheduling out of the browser entry module. Keep construction at the existing startup boundary and document the projection owner.
Move deferred geometry measurement and its one-shot observer into the widget element owner. Construct it at the existing startup boundary and document the expanded ownership.
…mments # Conflicts: # plugins/leaf/skills/leaf/assets/leaf.js # plugins/leaf/skills/leaf/assets/runtime/widget-elements.js
|
One current-head cleanup remains from the earlier review: the effective merge tree for |
leaf-agent
left a comment
There was a problem hiding this comment.
The two merges cleared the duplication the last two reviews were chasing — gh pr diff now reads 757 added / 67 deleted, which is the feature and nothing else — and both earlier threads are genuinely closed: f30131e puts the five-line visual-module block back between the quoted(el) and projectData bullets, and openOnVisual({ id, part }) now takes the id off the record visualAt already built. lint is green on this head; test is still running as I write.
The re-vendor door the first review asked about is shut, and shut in the right place: vocabulary_gaps runs visual_anchor_error against the incoming registry for every logged comment, so a layer that drops x-visual.parts is counted as vocabulary the page's log speaks and the layer no longer does. test_init_refuses_to_orphan_a_logged_visual_anchor proves it end to end. dropped_parts in cmd_check mirrors the existing dropped-ids error exactly, down to the section in parser.ids guard that stops a removed widget from being reported twice.
Three things inline, none blocking. One is the stray export from the last review — the line stayed and picked up a justification that doesn't hold. The other two are on c0829f5, the date-axis commit.
What I checked and didn't find a problem with
held_comment_errornow runs on comments carrying onlyanchor.visual(noholds), which is new — it early-returnsNoneon a missingholds, so the widenedifinexecute_eventis safe.anchor["section"]invisual_anchor_erroris safe on both doors:_postrunsevent_record_errorbeforecoordinate_event, and the newdependentRequired: {"visual": ["section"]}makes the key present; a literalnullsection falls throughpage_by_id.get(None)to the "not declared" refusal rather than raising.- A partially-populated
visualPartsafter themissing.lengththrow can't leak an anchor:visualPartgates oncontainsAcross(visual, element), andfailSofthas replaced the subtree by then. - A mistyped
partstoken failsversion check --renderrather than only drawing an error box — the gate reads.lf-errortext atrendering.py'squerySelectorAll('.lf-error'). x-visual: {parts}is exercised by the corpus (examples/ship-review.html's#off-flow, gallery regenerated from it), so the render gate's new provider requirement is observed on a shipped page.
|
The two fresh |
leaf-agent
left a comment
There was a problem hiding this comment.
The stray export { quoted }; is gone, and all three open threads are addressed: readAxis now returns a granularity and dateLabelers.month uses it, so a month body reads Sep rather than Sep 1; and the greedy pass over scale positions replaces the band-style i % every thinning, with #crowd-clustered-dates as the fixture that fails under the old rule. I've resolved all three.
The thing to flag is scope rather than code: c4dbb52 is what the comment above it asked not to do — "rather than broadening this PR into month granularity and irregular time-scale thinning" names both halves of the commit, and the push landed seven minutes after it. Quite possibly it went out before that comment was read; if the intent changed, ignore this.
One technical reason to prefer #58 beyond scope. The workaround is bounded to values.length <= 10. Above that, timeAxis returns only ticks and no tickFormat, so Plot's multi-tier formatter is back and with it the tick that reads 1 over Dec — the exact two-line label #58 identifies as a false collision. An eleventh row in heat-weekly reddens the gate again. So the short-axis branch doesn't close the class it was added for; #58 does, and the axis work then stands or falls on whether the reader wants it rather than on whether the gate is quiet.
One inline, relevant only if the lf-chart work stays.
|
Adding one fact the review above couldn't have had: #58 landed on On
That is the whole of the removal, and it leaves the PR at the visual-subtarget contract and the flowchart-node adapter, which is what the title describes. Happy to push it if you'd rather not — say the word. What I rangit worktree add --detach /tmp/wt-56 aef35f8f
git -C /tmp/wt-56 merge --no-edit origin/main # e8b2e30, no conflicts
git -C /tmp/wt-56 checkout origin/main -- plugins/leaf/skills/leaf/packages/default/widgets/lf-chart.js
# plus: drop the three crowd-* <lf-chart> bodies from tests/render_cases_widgets.py
# and the month_ticks block from tests/test_render_widgets.py
uv run pytest tests/test_render_widgets.py -q -n0 -k chart --run-nightly # 8 passed
uv run pytest "tests/test_render_gate.py::test_example_renders[heat-loss]" -q -n0 --run-nightly # 1 passed
uv run pytest tests/test_interact_anchors.py tests/test_interact_contract.py tests/test_interact_server.py -q # 273 passed
uv run pytest tests/test_render_controls.py -q -n0 --run-nightly -k "visual or part or diagram" # 3 passedNet after the drop: |
…mments # Conflicts: # plugins/leaf/skills/leaf/assets/runtime/conversation/reconcile.js
…mments # Conflicts: # plugins/leaf/skills/leaf/assets/leaf.js # plugins/leaf/skills/leaf/assets/runtime/composing/aim.js # plugins/leaf/skills/leaf/assets/runtime/composing/surface.js # plugins/leaf/skills/leaf/assets/runtime/conversation/messages.js # plugins/leaf/skills/leaf/assets/runtime/conversation/reconcile.js # plugins/leaf/skills/leaf/scripts/leaf/http.py
leaf-agent
left a comment
There was a problem hiding this comment.
One finding from the merge, confirmed in a browser: a reaction on a declared visual part outlines the whole widget instead of the part. Detail inline. The fix is one line but sits outside the diff, so I can't put it in a suggestion — happy to push it if you'd rather not.
The two halves are each right and only disagree once merged. resolveAnchor's if (anchor.visual) branch returns { element: section, marks: [found.element] }, and this PR taught both readers of that record to prefer marks — the thread mark, and the draft's pendingMarks. main's reaction paint (the if (bareReaction(t)) block, in the same loop, from b270391) landed after that and still reads shownParts(found.element) on its own.
I measured it on PART_DIAGRAM_PAGE: click node S, press a token. The log takes {"section": "flow", "visual": "node:S"}, which is right, and .lf-react-el lands on flow — the dashed hairline is drawn round the whole diagram. A comment on that same node outlines flowchart-S-0, which test_a_declared_flowchart_node_keeps_its_comment_across_renderings already proves, so the two marks on one anchor point at different boxes and two reactions on two nodes are indistinguishable. With found.marks ?? shownParts(found.element) there — the same expression as the two lines that already carry it — .lf-react-el lands on flowchart-S-0, tests/test_render_reactions.py is 7 passed and the three visual cases in tests/test_render_controls.py are 3 passed.
A smaller one from the same seam, read rather than run: anchorWord — "What the bar's target is called, for the line, the reference and the announcement" — still branches on anchor.quote alone, so a {section, visual} falls through to itemWord(elementById(anchor.section)) and both the send announcement and the ? row name the diagram. anchorLabel does resolve the part (§ diagram · Start request), so the panel and the spoken line say different things about one anchor, and visualPartLabel is already wired into the conversation runtime.
Nothing else came out of the two merges. I checked every line main added since the parents' merge base against the merged tree: the only ones missing are the two this PR replaces on purpose — updateFab's visual branch, now found, and http.py's holds-only condition, now widened for anchor.visual. The dropped , whole on the ⌥ row is earned too, since ⌥ over a declared part no longer takes the item whole.
`test_local_work_chrome_does_not_take_its_holder_gesture` asserted an absence — no `action` in the log after clicking the work line — behind `page.wait_for_timeout(250)` and with no control. `tests/CLAUDE.md` names both halves of that: a wait consumes a fact the system states, and "an absence is also what a page that never had the behaviour produces, so a test asserting one names a control that must first produce the presence: the same gesture where it is supposed to work." The fix keeps the forbidden gesture, then presses a neighbouring option as that control and lets its send settle through `round_trip`. One outbox in gesture order means a pick the work line had taken would already stand ahead of it, so the whole log is read once and compared exactly — no budget, and the verdict now rests on a product fact. <details><summary>Bug-back, both directions</summary> The reading this guards is the `.lf-work-line` entry in `worksInside` ([leaf.js:842](https://github.com/max-sixty/leaf/blob/27631a26/plugins/leaf/skills/leaf/assets/leaf.js#L842)). **The new test still catches the real defect.** Dropping `".lf-work-line"` from that selector list makes the work line cast its holder's pick, and the new assertion fails on it: ``` At index 0 diff: ('jobs', {'options': ['job-mounts']}) != ('jobs', {'options': ['job-heater']}) ``` **The old test went green over a dead gesture.** With `lf-options`' click handler disabled outright — no option pickable anywhere on the page — the old form passed (`1 passed`), because nothing was left that could have written an `action`. The new form fails there, as a test with a control should: the control is not met. Worth being precise about what was *not* wrong: on this machine the 250 ms budget was not itself load-bearing. With the work-line defect injected, the old test failed even at `wait_for_timeout(0)` — the POST goes out inside the click and the server is in-process. The sleep is a convention violation and a standing hazard rather than the thing that hid a bug; the missing control is what made the test vacuous. </details> <details><summary>Verification</summary> - `uv run pytest tests/test_render_options.py -q --run-nightly` — 46 passed - `uv run pytest tests -q` — 549 passed, 6 skipped - `ruff format --diff` / `ruff check` — clean </details> --------- 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]>
## Problem This came out of reviewing #58, which landed as [999f933](999f933) while the review was running. The fix itself is right and this does not touch it — what it leaves behind is an exemption with one leg. `999f933c` holds a label's own lines out of `COVERED_WORDS`: an SVG `<text>` spells a line break as an element, so two lines of one tick are two nodes where a wrapped paragraph's are one, and the pair overlapped by construction on a drawing where no glyph comes near another. `test_the_gate_passes_a_chart_whose_tick_names_its_month_on_a_second_line` proves the hold fires. Nothing proves it is narrow. Widen `el.closest('text')` to `closest('g')` or `closest('svg')` — every tick of an axis sits inside both — and every word of a chart stops being read against every other word of that chart. The whole suite stays green. I ran it rather than reasoning about it: with the predicate widened, `tests/test_render_gate.py`, `tests/test_render_widgets.py` and `tests/test_render_export.py` give 18 passed over every case naming this pass, the new exemption test among them. Nothing else in the suite can see it, for four separate reasons: - The corpus sweeps and the copy assert this pass returns nothing, which a wider hold only makes more true. - `test_no_two_of_a_chart_s_words_land_in_the_same_place` reads `CHART_COLLISIONS`, which compares whole `<text>` boxes and never reaches this pass. - The exemption test defeats the predicate wholesale (`.replace("a.label && a.label === b.label", "false")`), so its `reported` leg is identical however `label` was computed. - The only standing bug-back on `COVERED_WORDS` *reporting* is `test_the_covered_words_gate_still_reads_a_control_in_the_flow`, and that is an HTML page whose runs never get an SVG label at all. That test's docstring is the precedent this is written from: "a gate that has only ever passed has been tested for nothing, and this one is one predicate away from exempting every control there is." The same sentence is true of the new predicate one element up. `tests/CLAUDE.md` states the general shape under **Make a green test non-vacuous** — "A reading blind to one mechanism does not report that it is blind — it returns the same clean result it returns when nothing is wrong." ## Solution The other half, put back as a bug, the way the float's two halves are already written. One whole `<text>` stood on another by copying its `transform`, so the labels stay whole and what lands is two of them rather than two lines of one. Arranged that way rather than by spreading a label's lines, because the hold asks which `<text>` drew a line and not how far a line was moved — and because it depends on neither the axis's leading nor a neighbouring chart's layout. Test-only. `render_checks.py` is untouched. ## Testing Every run below at `-n0` on this branch, based on `999f933c`. - `uv run pytest tests/test_render_widgets.py` — 58 passed. - Bug-back, `closest('text')` → `closest('svg')`: the new test fails on `two of a chart's labels stood on each other unreported: []`; the exemption test still passes. - Bug-back, `closest('text')` → `closest('g')`: same failure, same complement. - The complement, with `if (a.label && a.label === b.label) continue;` removed entirely: the exemption test fails on `held` with `<lf-chart id=c-line> draws "1" in the same place as <lf-chart id=c-line>'s "Jun"`, and the new test still passes. The two are about different halves and neither stands in for the other. - Repeated 5× at `-n0`: passed each time. - `pre-commit run --files tests/test_render_widgets.py` — passed. <details><summary>What the arrangement produces</summary> The two ticks and the finding, printed from the reading during development: ``` MOVED: ['20', '22'] FOUND: ['<lf-chart id=c-line> draws "20" in the same place as <lf-chart id=c-line>\'s "22"'] ``` The assertion matches on both labels in their quoted form rather than on the chart id, so a finding about some other pair in the same chart cannot satisfy it. </details> --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
…mments # Conflicts: # plugins/leaf/skills/leaf/scripts/leaf/registry.py
…mments # Conflicts: # plugins/leaf/skills/leaf/scripts/leaf/passages.py
…x retired (#65) ## Problem `main` had two independent stale layout assertions: - The margin-resident test expects a 720px column minus a 15px scrollbar gutter, although #64 now correctly preserves the full 720px column at and above the combined strip floor. - The option-address test pinned a digit to the old 6px inset, although the status stripe now occupies the start of that gutter and the digit correctly begins at 15px. #56 has since repaired the stale option-address assertion on `main` and directly checks the status/address/prose relation for the card form. This branch is therefore back to the scrollbar-gutter repair alone. #66 remains separate: it has been reopened to retain the corresponding row-form and cross-form coverage. ## Solution The runtime now has one `scrollerGutter` reading beside `pageScroller`; `stateStrip` and `stateRoom` both use it. The browser test asks that production helper for the width it drives, but first cross-checks it against an independent body-box reading. That guard catches a correlated overread before the helper can choose and judge the same viewport. The roomy column is then required to remain the full 720px; the retired gutter tolerance and its prose form are removed. ## Testing - `test_opposite_margin_residents_wait_for_the_room_they_need`, the current `test_a_questions_digits_are_drawn_whole`, and #56's direct option-pointer regression: 3 passed together after merging current `main`. - All four files changed relative to current `main` pass pre-commit. - Gutter overread bug-back: without the independent cross-check, a planted 30px reading passes; with the guard, it fails at `30 == 15`. - Removing `scrollerGutter()` from the strip calculation fails at `705 == 720`. Exact-head full CI and review remain the merge gate. --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
… places in continuity (#2560) The runtime now has one rule for whose a scroll position is, and one keeper for the reader's place in lf-trace's saved-element tree. This is item #56 of the Lit follow-up round (the round's own numbering, not a GitHub issue). It follows #2546. ## One rule for the reader's scrolls A box stands where the reader chose, or where layout put it. Continuity's shift restore (`version.js`, `restoreShifted`) should undo only layout's moves. #2546 counted Leaf's landings as the reader's choices. That missed the browser's own scrolls, such as find-in-page opening a closed tree onto its match, and counted a restore's focus reveal as a choice. The platform already draws this line. A scroll sequence ends with `scrollend` whoever started it: wheel, keys, `scrollTo`/`scrollBy`/`scrollTop`, smooth motion, `scrollIntoView`, and fragment navigation, including one that opens a closed `<details>`. A clamp as content shrinks, a scroll-anchoring adjustment, and a `<details>` reopening at the offset it kept end none. I measured each case in headless Chromium; the reviewer confirmed the ordering in WebKit. `scrolling.js` now owns the rule, and its header states it: - A `scrollend` on a box is the reader's choice (`chosenSince`). - A place keeper's write returns the reader to a place they already had, so it records where it left each box (`placeKept`). A sequence that ends there is the keeper's. This covers `restorePlace`, `placeKeeper`'s correction, and continuity's page-band move. - A landing in smooth motion counts from its start, since layout it caused can be announced before the motion ends. - Continuity takes a reading at each `scrollend` as well as on `scroll`. WebKit, and Chromium for touch, end a scroll frames after its last `scroll` event, and without that reading every reader scroll would look newer than its own reading. `landing-scroll.js` loses its own landing counter. ## One keeper for the saved-element tree lf-trace kept a place per checkpoint for its "Saved elements" tree and restored it on a summary press. Continuity restored the same box from its region reading. The two agreed only because focus on the summary made continuity's restore a no-op. A region can now show one subject of several in turn. Its owner replaces the body's contents inside `showReadingSubject(id, subject, render)` (`reading-regions.js`). Continuity keeps a reading per subject and returns the reader to it, both when the subject shows and when the tree opens. A region whose body is a closed `<details>` is concealed, so continuity no longer records a closed tree's reading. That reading had only the enclosing trace as its landmark, and restoring it scrolled the tree to its top. lf-trace drops `#treePlaces`, `#treeScope`, its scroll listener and its summary press handler. `readingRegion` leaves `widget-api.js`, since nothing imports it now. ## Behaviour changed - (c) When find-in-page opens the closed tree onto a match, the match stays shown; before, the shift restore put the tree back where the reader had left it. - (b) A restore's own scroll, its focus reveal included, is never the reader's choice, so the next frame's shift restore still corrects that box. - (a) Opening the tree, or returning to a checkpoint, puts the reader where they left that checkpoint's tree, through the runtime's keeper. A press now reopens the tree natively. For the same checkpoint, the browser keeps the offset. If the checkpoint changed while the tree was closed, the restore lands one frame after the opening rather than before its paint. - Focus on a closed tree's summary no longer makes the tree the region whose reading continuity records. - The per-checkpoint readings now live as long as the tree's reading region, so a trace that leaves the document and comes back starts without them; lf-trace's own map had kept them until the archive changed. ## Tests - `test_trace_tree_opened_by_the_browser_keeps_its_match` (c) fails on `main`: the row ends 572px down in a tree showing 54–154px. Headless Chrome has no find bar, and Leaf intercepts fragment navigation, so the page makes the find's two moves itself: it opens the tree and scrolls the row into view natively. - `test_trace_tree_opens_at_each_checkpoints_reading` (a) checks that a checkpoint left scrolled in its tree reopens there after another checkpoint was scrolled elsewhere and the tree was closed between. It fails if the subject's reading is not adopted (488 vs 40) or if the closed tree is not concealed (482 vs 40). - `test_a_split_drag_keeps_a_panes_reading`, in Chromium and WebKit, has the reader wheel-scroll a pane and then drags the split frame by frame, with scroll anchoring off as in Safari. It fails if a keeper's writes count as choices (1487px instead of 102px), and in WebKit it fails if continuity takes no reading at the scroll's end (51px instead of 101px). WebKit leaves the restored passage about 5px off on `main` too, so the test allows 8px. - (b) did not fail on `main` in any run I made. There, `restoreShifted` re-records right after its restore, so the counted reveal never predates a reading. The split-drag test guards the general form under the new rule. - The #2546 saved-element tests share a setup helper with the new ones and pass in both motions. ## Line deltas - Hand-written source (JS, excluding Markdown): +177 / −98, net +79 (`scrolling.js` +43, `version.js` +61/−13, `reading-regions.js` +28/−4, `lf-trace.js` +20/−56, `landing-scroll.js` +6/−15, `reading-place.js` +11/−6, `user-place.js` +7/−3, `widget-api.js` +1/−1). - Tests: +160 / −23, net +137. > _This was written by Claude Code on behalf of max-sixty_
Summary
Validation
pre-commit run --all-files