Repository navigation
Fix UI coordinate plane ownership - #166
Conversation
…ordinate-planes # Conflicts: # skills/leaf/CLAUDE.md # skills/leaf/assets/runtime/living-margin.js
leaf-agent
left a comment
There was a problem hiding this comment.
The coordinate-plane work reads well — forcing the root/body/chrome/legend chain static, centralising the shell's repaint door, and letting the target decide the paint plane all land where they should, and the DOM order in chromeRoot happens to preserve the old legend → aim → fab → composer → inspect painting order that the removed z-indexes used to state explicitly. Two things I'd look at before this lands.
The designIsOn() guard in showPreview costs the design-mode send its landing. Detail in the inline comment. Verified in a real browser on both trees: on main, sending a design comment on #bracket leaves focus on a visible TEXTAREA with the preview open; on this branch focus ends on BODY with neither the preview nor the panel open. Moving the guard to openInlineThread (if (!entry || designIsOn()) return null;) keeps test_design_mode_retires_and_suppresses_the_top_layer_margin_preview green and restores the landing to the Threads panel — I ran both. Happy to push that two-line change if you'd like.
skills/leaf/CLAUDE.md still states the old shell-observer contract. Under Layout and motion it says layoutSizes watches body's content-box width "and reads nothing else off that box", and the later syncLayout paragraph repeats it. chrome-layout.js now reads contentRect.height as well and routes a height-only change straight to pageShifted, which is the whole point of dropping legendSizes.observe(document.body) — so the file's own description of the observer is now false while the module-ownership lines two sections up have been updated to match. That paragraph is also where the "a ResizeObserver callback must not resize the box it observes" invariant lives, and the new else if (shellMoved) pageShifted() branch is the first writer that runs inside delivery rather than in the following frame (safe today only because refreshHover defers to its own rAF and refreshAim writes the unobserved aimBox) — worth saying, since the block comment above it still claims writes land in the following frame.
leaf-agent
left a comment
There was a problem hiding this comment.
One finding on 423cc3de. The guard move does fix the send — I checked it in the browser, and a design-mode send now lands focus in the visible Threads reply with the preview shut. But moving it out of showPreview reopened a door I told you was closed: keyboard activation of the margin marker still opens the top-layer preview while design mode stands. My earlier comment said togglePinned was unreachable in design mode; that holds for a pointer press and not for Enter, and I should have checked the keyboard path before recommending the move. Detail and the measurement inline.
The skills/leaf/CLAUDE.md paragraphs and the chrome-layout.js block comment now state the width/height split and the in-delivery write, so the observer contract reads true again — nothing further there.
…text (#173) ## Problem The nightly `test` job on [run 33425820038](https://github.com/max-sixty/leaf/actions/runs/33425820038) (afd65dd) came back `15 failed, 1561 passed`. Thirteen of the fifteen are the failure shape that has been red on main since `bba885a`, and #169 already fixes them; this PR is the fourteenth, `test_render_widgets.py::test_suggestion_controls_stay_out_of_the_column`, which is new on this run and is a real layout bug rather than the test's timing. A margin row that docks next to an inline perch lands **on** the line it decides instead of under it. `.lf-margin-item` is `display: inline-flex`, and it is `position: absolute` that blockifies it while it hangs in the rail. Docking only swaps `position: static` back in, so the row becomes inline-level again and joins whatever line box its perch sits on. For a change inside a card the perch is the inline `lf-suggestion` element itself — `externalPerch` takes `blockAt(target) ?? target`, and `TEXT_BLOCK` matches no ancestor inside `lf-card` — so the ✓/✗ row is baseline-aligned onto the last line of the sentence it decides. <details><summary>Measured, at 820×900 with the panel closed</summary> The row (`.lf-margin-item.lf-docked`, `display: inline-flex`, no transform) and the two line boxes of the inline `#sug-in-card` it is a sibling of: | box | top | bottom | | --- | --- | --- | | `#sug-in-card` line 1 | 511.09 | 530.09 | | **docked row** | **536.28** | **566.28** | | `#sug-in-card` line 2 | 539.53 | 558.53 | `#sug-in-card.contains(row)` is `false` and the row's parent is `LF-CARD#card-heater`, so this is not overflow out of the widget — the row is inline content sharing the widget's last line, extending above and below the text because an inline-flex box 30px tall is baseline-aligned against a 19px line. </details> ## Why it went twelve commits without failing The test read the layout while it was still moving. Closing the thread panel gives the room back on an eased `margin-right`, and the column re-wraps for the whole ~0.2s of it; the test clicked **Close threads**, resized, waited for the docked class, and measured. On an unloaded machine every read landed with body margin still at ~152px, where the narrower column wrapped the card's sentence onto enough lines that the row fell below it and the assertion held. A machine loaded enough to reach the settled layout first reads the real one. The transient and settled readings, same test, same commit: | body margin at the read | row top | `#sug-in-card` bottom | verdict | | --- | --- | --- | --- | | 151.9px (transition running) | 563.47 | 557.28 | passes | | 0px (settled) | 536.28 | 558.53 | fails | So this is not a regression from #166, and reverting all of `skills/` to `28b0e2b` — the commit before it — reproduces the identical `assert 536.28125 >= 558.53125`, 6/6. It is a bug the suite could not see. #167, which adds a rendering turn to `resized()`, would have surfaced it the same way. ## Solution - `.lf-margin-item.lf-docked` states its own `display: flex`, so a docked row is a line of its own wherever it comes to rest rather than inheriting the inline level the absolute position was covering for. `width: fit-content` keeps the box the width it had in the margin: `.lf-margin-item` carries `pointer-events: auto`, and a block-level row stretched to the column would take presses across a whole line the reader may be selecting in. - The test says the ordering it depends on: `panel_settled(page, open=False)` before the resize, so it reads the layout the reader ends up in. Without it the test proves the transient one, which is how it stayed green. Fixed in the theme rather than in `externalPerch`, because the perch is the right one — the row belongs beside the change, not after the card — and "docked is a line of its own" is the property every perch needs, not just an inline one. ## Testing - `test_suggestion_controls_stay_out_of_the_column`: 3/3 unloaded and 4/4 with the machine loaded, on the rebased head. Bug-back: with `theme.css` alone reverted to `origin/main`, it fails on the first run, unloaded — the ordering statement makes it deterministic in both directions. - Everyday suite: `740 passed, 6 skipped`. - Complete nightly suite, run file by file: the only failures left are the thirteen #169 covers (`test_render_controls` ×2, `test_render_widgets` ×5, `test_render_export`, `test_render_navigation`, `test_render_outbox`, `test_render_projection` ×2, `test_site`). No new ones, and `test_render_margin.py`, `test_render_pages.py` and `test_render_aim.py` are green. - `pre-commit` on both changed files: pass. <details><summary>The fifteenth failure, left alone</summary> `test_render_navigation.py::test_composer_marks_the_passage_instead_of_quoting_it` failed once on this run (`assert 'specimen' in ''`) and I could not reproduce it: 5 runs at `-n0`, 12 more with the machine loaded, and 3 whole-file runs at `-n 2`, all green, including on the rebased head. It stays unclassified rather than fixed — a guess at a wait for a failure that reproduces nowhere is how a test stops proving anything. </details> --- Automated fix for [failed run](https://github.com/max-sixty/leaf/actions/runs/33425820038) Co-authored-by: leaf-agent <[email protected]>
Leaf’s document-attached comment chrome could drift when a workspace changed the page shell, and page overlays could paint over covering workspaces. The margin table of contents also kept an independent fixed coordinate system, leaving it behind a standing Asks tray.
This change makes the root/body/chrome/legend chain explicitly static, centralizes repaint invalidation for size and margin motion, and splits page-attached paint from chrome-target paint. It also lets the sticky sidebar own table-of-contents placement and prevents design mode from competing with browser top-layer previews.
Verification: 746 everyday tests and 7 focused browser regressions pass; live transition checks measured zero aim and legend drift.