Skip to content

Make read marks layout-neutral so reading moves nothing - #1025

Merged
max-sixty merged 4 commits into
mainfrom
layout-neutral-read-marks
Sep 23, 2026
Merged

max-sixty merged 4 commits into
mainfrom
layout-neutral-read-marks

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Marking a thread read moved the reader. The unread rail indented a message's content by 8px, and each New since you last looked / End of this new section boundary added 29px of height. A receipt removed both, so the prose rewrapped, the card got shorter, the scroller clamped, and a landing could cut through a text block. #999 handled one trigger with a microtask in thread-card.js that re-landed the focused reply after a receipt. This PR removes the reflow itself.

Every read mark now takes space the layout already has:

  • Rail: a border-image outset into the message's inline margin. It uses no space, and neither the message nor the hoisted root header needs a positioning context. A position: relative on the root header would have pulled .lf-going's absolutely placed actions 8px inward.
  • Boundary: a zero-height block. Its margins collapse through it, so it sits at the next message's edge, and its label sits in the 16px gap between messages. A boundary that is the first child of its container, like the one opening a checkpoint's originals, has no margin above it to collapse with. It sits at the start of its gap, so its label hangs below it.
  • Hoisted root header: the row now uses align-items: center instead of baseline. With baseline alignment, removing Mark thread read shifted the author line down by 4px.
  • The re-land microtask from Keep one thread expanded in Threads panel #999 is deleted.

skills/leaf/assets/AGENTS.md now includes the rule next to the single reading of unread: reading is bookkeeping, and a receipt changes no box the reader is looking at.

Tests

  • New test_reading_a_thread_moves_nothing_in_it: records the box of every element in a card before and after a server read receipt, and requires every one to stay the same. The only exception is the summary row, message metadata, and header actions: when they lose a label or control, they may close up horizontally but not vertically. The thread has two new boundaries, one end boundary, and a root rail. On main's CSS the test fails (the card goes from 606 to 526px tall, and 62 boxes move).
  • The summary-originals test now also checks that the opening boundary's label clears the Show messages control.
  • test_pressing_a_page_mark_stands_in_the_thread_it_opens (all 4 params, --run-nightly) passes without the microtask. It also passed on main's CSS without the microtask in 20 of 20 concurrent runs, so it no longer reproduces the race Keep one thread expanded in Threads panel #999 addressed. The new test is what pins the no-reflow property.
  • --run-nightly for test_render_navigation.py, test_render_conversations.py, test_render_read_state.py, and test_chrome_contracts.py after merging current main: all 328 pass.
  • npm run test:runtime and pre-commit pass.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 3 commits September 23, 2026 10:59
Marking a thread read took away an 8px unread rail indent and each
"New since you last looked" boundary's 29px of height, so the prose the
reader was looking at rewrapped, the card shrank, the scroller clamped,
and a landing could cut through a text block. #999 re-landed the reply
in a microtask after a receipt to paper over one trigger.

Every read mark now draws in room the content keeps either way. The rail
is a border image outset into the message's inline margin, and a
boundary is a zero-height block whose margins collapse through it, its
label hanging in the gap between messages. The hoisted root header
centres its row, so the Mark thread read control leaving no longer moves
the author line's baseline. The re-land microtask is gone.

A new browser test reads every element box in a card before and after a
read receipt and requires them unchanged, allowing only rows that lose
a label or control to close up sideways. The assets AGENTS.md states
the rule beside the one reading of unread.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

Expanding a checkpoint's originals draws New since you last looked on top of the Show/Hide N messages button. The label and the button's text overlap on the same line, and the label's leading rule runs through it.

The label hangs above the boundary's own origin (bottom: 2px), which works wherever a preceding sibling's bottom margin opens the gap it hangs in — the boundary then lands at the end of that collapsed margin, at the next message's top edge. Inside .lf-summary-messages it doesn't: that element is a grid item, so it establishes a block formatting context, the boundary is its first child with nothing above to collapse against, and the boundary lands at the start of the 16px gap instead. .lf-summary-expand's margin: 6px 0 -6px pulls the button down into exactly that strip, which is what the in-flow boundary's margin: 9px 0 7px used to clear.

Measured on this head, with test_new_since_last_looked_bounds_each_unread_run_and_summary_originals's fixture at 1440×1000, originals expanded: .lf-summary-expand occupies y 340–364 and the first .lf-read-boundary > span occupies y 350–363. On the base commit the same boundary sits at y 374–387, clear of the button. The suite stays green because that test asserts boundary counts and .lf-msg visibility, never the boundary's own box.

The inline suggestion flips the label below the origin for that one position, where the 16px the first original's margin already reserves is under the boundary rather than over it. With it applied the label lands at y 367–380 and tests/test_render_read_state.py --run-nightly passes (19 tests). It is layout-neutral in the sense the PR is after — the span stays out of flow, so the receipt still changes no box.

It is also a second placement rule beside the first, which the boundary may not want to accumulate. The alternative that removes the case rather than adding one is to give the label a fixed side — always below its origin — and let the boundary sit at the top of the gap everywhere, which needs the non-first boundary to stop absorbing the preceding margin. Your call which is worth the churn.

Everything else checks out. The #999 microtask is safe to drop: across a receipt that zeroes a thread's unread count I measured .lf-threads' scrollHeight, clientHeight and scrollTop, and the panel and chrome boxes, all identical — only .lf-first-unread leaves, moving nothing. The border-image rail paints with border-style: none in both Chromium and WebKit, and under forced-colors: active. The zero-height boundary still reports as a non-ignored separator with its label in the accessibility tree. tests/test_render_read_state.py, tests/test_chrome_contracts.py and tests/test_render_conversations.py pass under --run-nightly (151 tests).

Comment thread skills/leaf/assets/runtime/chrome.css Resolved
A boundary that is the first child of its container, such as the one
opening a checkpoint's originals, has no preceding margin to collapse
with, so it stands at the start of its gap and its label drew over the
Show messages control. It now hangs below. The summary-originals test
checks the label clears that control.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit cd3a6d8 into main Sep 23, 2026
5 checks passed
@max-sixty
max-sixty deleted the layout-neutral-read-marks branch September 23, 2026 18:51
max-sixty added a commit that referenced this pull request Sep 23, 2026
Marking a thread read moved the reader. The unread rail indented a
message's content by 8px, and each **New since you last looked** / **End
of this new section** boundary added 29px of height. A receipt removed
both, so the prose rewrapped, the card got shorter, the scroller
clamped, and a landing could cut through a text block. #999 handled one
trigger with a microtask in `thread-card.js` that re-landed the focused
reply after a receipt. This PR removes the reflow itself.

Every read mark now takes space the layout already has:

- **Rail**: a `border-image` outset into the message's inline margin. It
uses no space, and neither the message nor the hoisted root header needs
a positioning context. A `position: relative` on the root header would
have pulled `.lf-going`'s absolutely placed actions 8px inward.
- **Boundary**: a zero-height block. Its margins collapse through it, so
it sits at the next message's edge, and its label sits in the 16px gap
between messages. A boundary that is the first child of its container,
like the one opening a checkpoint's originals, has no margin above it to
collapse with. It sits at the start of its gap, so its label hangs below
it.
- **Hoisted root header**: the row now uses `align-items: center`
instead of `baseline`. With baseline alignment, removing **Mark thread
read** shifted the author line down by 4px.
- The re-land microtask from #999 is deleted.

`skills/leaf/assets/AGENTS.md` now includes the rule next to the single
reading of unread: reading is bookkeeping, and a receipt changes no box
the reader is looking at.

## Tests

- New `test_reading_a_thread_moves_nothing_in_it`: records the box of
every element in a card before and after a server read receipt, and
requires every one to stay the same. The only exception is the summary
row, message metadata, and header actions: when they lose a label or
control, they may close up horizontally but not vertically. The thread
has two `new` boundaries, one `end` boundary, and a root rail. On main's
CSS the test fails (the card goes from 606 to 526px tall, and 62 boxes
move).
- The summary-originals test now also checks that the opening boundary's
label clears the **Show messages** control.
- `test_pressing_a_page_mark_stands_in_the_thread_it_opens` (all 4
params, `--run-nightly`) passes without the microtask. It also passed on
main's CSS without the microtask in 20 of 20 concurrent runs, so it no
longer reproduces the race #999 addressed. The new test is what pins the
no-reflow property.
- `--run-nightly` for `test_render_navigation.py`,
`test_render_conversations.py`, `test_render_read_state.py`, and
`test_chrome_contracts.py` after merging current main: all 328 pass.
- `npm run test:runtime` and pre-commit pass.

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 24, 2026
The [failed main
run](https://github.com/max-sixty/leaf/actions/runs/40075126204) has one
remaining test failure on current `main`:
`test_reading_a_thread_moves_nothing_in_it`. After #3794 replaced the
unread rail with a New label beside the time, marking a reply read
removes that label and narrows only `.lf-msg-meta`. The thread's content
and reading position stay fixed. This change permits that metadata width
to close while still requiring its position and height, and every other
retained element's full box, to stay fixed.

The test originally allowed metadata to close sideways in #1025. The
allowance was lost when the old card view was replaced by the panel
thread view in #3100. The run's three other failures, which expected the
former wide layout size, are already corrected by #3798 on current
`main`.

The first PR check passed its Python tests but failed pre-commit because
Ruff added a missing blank line between imports in
`tests/journeys/test_thread_titles.py`. That formatting correction is
included here; the focused `ruff-check` hook passes locally.

Verification: the read-position test failed before this change and
passes after it. All four failing cases from the main run pass locally
as six parameterized cases with `uv run pytest -q -n0`.

---------

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