Skip to content

Place annotations in owning pane rails - #680

Merged
max-sixty merged 6 commits into
mainfrom
codex/region-aware-annotations
Sep 13, 2026
Merged

max-sixty merged 6 commits into
mainfrom
codex/region-aware-annotations

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Bounded pane annotations currently fall into inline flow, separating their marker from the passage and consuming vertical space. This gives opt-in reading regions a local annotation rail: default pane bodies reserve stable room, margin rows pack independently within each pane, and the thread card stays inside its owning region without covering the visible source.

The same annotation returns to inline flow when the workspace narrows or auxiliary chrome would cover the content frame. The existing controls survive that posture change, including keyboard navigation and an in-progress reply draft. Reading-region opt-in keeps ordinary documents on the existing page-margin behavior.

The browser coverage exercises two-pane packing, direct marker interaction, region-bounded conversation placement, draft and keyboard continuity across posture changes, covering-width fresh load, nested-region isolation, the visual-review consumer, and print behavior.

This was written by Codex on behalf of max-sixty

# Conflicts:
#	skills/leaf/assets/runtime/margin-projection.js
#	tests/test_render_navigation.py

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

Two findings on the local-rail path, plus a reference gap. The PR's own browser case passes here (uv run pytest tests/test_render_navigation.py -n0 -k "pane or reading_region", 13 passed).

A nested region inherits a rail it never reserved

--lf-reading-region-rail is an ordinary inheriting custom property, so marginRegionFor's getComputedStyle(region.body) reads 44px on every descendant of a bounded .lf-pane-body — including a nested registered region that reserved no room of its own. lf-visual-review registers exactly that: #registerCaseRegion binds each case's .lf-vr-shot-host as a region body inside the evidence pane. Its shot's margin contribution (lf-shot's registerMarginContribution, live whenever the inspector is in Flip view) therefore stops docking and hangs over the capture.

Measured on a root <lf-visual-review> at 1400x950 in Flip view:

reading this branch with the @property registration
--lf-reading-region-rail on .lf-vr-shot-host 44px (inherited) 0px
padding-inline-end on .lf-vr-shot-host 0px 0px
cluster data-lf-margin-region lf-region:visual-run:case-run-list absent
cluster placement hangs, 9px inside the capture's right edge docked, as before

This is the accident the hangs comment the PR deletes named: "Dock every contributed entry even when a positioned widget happens to leave enough local room for the absolute prototype; that accident must not give one nested target a desktop posture." Registering the property with inherits: false keeps the declaration local to the body that reserves the padding — the inline suggestion on theme.css does that, and with it applied the pane rail this PR adds still works and the new browser case still passes.

Reading order

Separate inline comment on moveExternalHost.

The new package contract isn't in the public reference

data-lf-reading-region plus --lf-reading-region-rail is a new package-facing contract — a package declares the width and reserves the padding, core reads it and moves the annotation into that room. skills/leaf/references/packages.md's reading-region section already carries registerReadingRegion, readingPosture, and shownRegionBounds, but says nothing about this. Per the root CLAUDE.md ("Keep the implementation, tests, and any owning protocol or reference aligned"), a package author needs to read there that declaring the property is what opts a region in, and that reserving the matching padding is theirs.

Happy to push all three as one commit if you'd like.

Comment thread skills/leaf/assets/theme.css Resolved

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

The two findings from the last round are fixed, and the nested-region case now has a browser test that pins it. One new finding on the same path.

A bounded region under the covering media query loses its cluster entirely

marginRegionFor admits a local rail on bounded posture alone, but renderMargin then routes a region-owned entry to moveExternalHost, which declines to place anything while panelWouldCover(). Those two readings disagree inside a reachable band: COVERING is (width <= 840px) (chrome-layout.js, THREAD_PANEL_W 420), while a root lf-workspace holding a single pane reaches bounded posture at MIN_PANE_WIDTH 240 plus its frame (packages/default/widgets/lf-workspace.js). A page that loads in that band creates the cluster host detached and never inserts it, so the reader sees the inline mark with no margin control to open the thread. layoutMarginRows then drops the row on its !row.isConnected sweep.

Measured on a single-pane lf-workspace with one anchored comment, fresh load at 800x900:

reading b12829c (merge base) this branch with the suggestion
data-lf-reading-posture bounded bounded bounded
.lf-margin-cluster nodes in the document 1 0 1
.lf-mark-note in the passage 1 1 1

Resizing into the band from a wide window shows the other half of the same disagreement: the host is already placed, so it keeps data-lf-margin-region="left-reading" while hangs — which does test !panelWouldCover() — docks it. At 840, 800, and 700 the branch reports the region attribute on a docked cluster; with the suggestion applied it reports none.

The inline suggestion puts the covering reading in marginRegionFor itself, so lane, hangs, place, and both placement paths cannot disagree about it. With it applied, tests/test_render_navigation.py -k "pane or region" (14 passed), tests/test_render_visual_review_journey.py (2 passed), and tests/test_render_margin.py (102 passed) stay green. packages.md's "Core uses the rail only in bounded posture" wants the covering condition alongside it, since a package reserving the padding gets no rail there.

Happy to push the change together with a browser case for a bounded pane loaded at a covering width.

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

The rail's release at 840px happens before the transition reads the reader's place

692bf62a moves the default package's rail declaration into @media screen and (not (width <= 840px)). A media query applies with the viewport change itself, before any JavaScript observes it, so the pane body has already reflowed by the time readingRegionTransition's before phase runs — and that phase is contracted to read the old geometry: packages.md says watchReadingRegionTransitions(listener) "receives a before reading while old geometry is intact". It now reads the reflowed one, so the landmark it writes down hands the reader back somewhere else.

tests/test_render_navigation.py::test_a_tall_local_comment_survives_its_panes_posture_and_return (added in #499, unrelated to this branch) fails deterministically at this head and passes at 5fb66476, this PR's own previous commit, in the same container:

reading 5fb66476 692bf62a
pane padding-inline-end at the bounded → flow before phase 58px 14px
pane scrollHeight at that phase 1358 1330
right pane scrollTop after 1200 → 520 → 1200 320 266

That is a reader losing their place in a pane they never scrolled, by whatever the released rail's reflow is worth on the document at hand. The rest of the file is unaffected — uv run pytest tests/test_render_navigation.py here is 1 failed, 131 passed — and the two commits' own cases all pass.

This PR's gate does not see it: test_render_navigation.py is nightly-marked and ci.yaml's nightly job is if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch', so the failure would land on main and surface on the daily schedule.

Two ways out, differing in which runtime owns the release:

  • Drop 692bf62a. 5fb66476 leaves 44px of unused inline-end room at covering widths, which is cosmetic, and the reader keeps their place.
  • Publish covering as a declared fact the runtime flips, the way data-lf-reading-posture and data-lf-auxiliary-surface already are, and key the package's declaration on that. The release then happens inside the transition, after before has been read, and the package sheet stops spelling a core constant — which is the coupling the new test_the_layer_sheets_spell_the_runtime_s_layout_numbers assertion now exists to hold still.

If a viewport query stays in some form, packages.md owes a package author the rest of the contract. It says only that "at the covering breakpoint the annotation returns to inline flow" — naming neither the width nor the fact that releasing the reservation is the package's job — so a third-party rail goes on reserving room core has stopped using, at the widths where it is worth most.

Happy to push either route.

How the readings were taken

A watchReadingRegionTransitions listener registered from the page records the right pane's box at each phase around resized(page, 520, 900) and back. At 5fb66476 the bounded → flow before phase reads padding-inline-end: 58px; at 692bf62a it reads 14px, the viewport having already crossed 840px while the arrangement is still bounded. The single case passes at 5fb66476 and at main's tip 3ebd5a86, and fails at 692bf62a with assert 266 == 320 ± 1.

Narrowing without a posture change shows the CSS half on its own: at 900, 860 and 841 the pane reads padding-inline-end: 58px, and at 840 it reads 14px while data-lf-reading-posture is still bounded.

Comment thread skills/leaf/packages/default/theme.css Resolved
@max-sixty
max-sixty merged commit 76a2990 into main Sep 13, 2026
7 checks passed
@max-sixty
max-sixty deleted the codex/region-aware-annotations branch September 13, 2026 21:34
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