Skip to content

Complete the visual review keyboard journey - #624

Merged
max-sixty merged 5 commits into
mainfrom
codex/visual-review-foundation
Sep 12, 2026
Merged

max-sixty merged 5 commits into
mainfrom
codex/visual-review-foundation

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Visual-review evidence can overflow inside its own stage, but the shared reading keys previously selected the outer pane, and changing cases or refreshing the source could leave keyboard focus on the document body. This makes every visual case a nested reading region and preserves the active inspection or disposition destination through case selection and source updates.

Nested regions distinguish the semantic host used by reading commands from the body that actually contains a control. Response placement, thread-preview placement, and reading-position continuity now share the same outward containment walk as scroller selection, so case conversation stays visible through bounded/flow changes without treating the capture stage as its boundary. Reading keys still use the semantic host, preserving pane ownership from frame controls. Moving an outdated draft from an inline case outlet back to the floating response surface also preserves its exact focused control and text selection without reclaiming focus if the reader moved elsewhere.

The end-to-end journey now uses rendered Go-to and target-chooser hints to inspect evidence, page through an overflowing capture, review cases, preserve an exact case comment and draft across a 390px covering Threads view and desktop nonmodal Threads, update source data while that draft is open, apply corrected evidence, and record the final disposition. It uses Leaf's canonical focus-ring reading and asserts exact source provenance and that local inspection creates no durable actions. The broader two-pane landmark and focus-paint audit remains tracked in the workspace follow-up for TODO #14.

Tests: uv run pytest tests/test_render_visual_review_journey.py -q -n0 -x; uv run pytest tests/test_render_navigation.py -q -n0 -x; uv run pytest tests/test_render_conversations.py -q -n0 -x; uv run pytest tests/test_render_projection.py::test_a_source_replacement_preserves_the_focused_draft_and_its_original_anchor -q -n0 -x; bin/leaf package check skills/leaf/packages/visual-review; uv run pre-commit run --all-files. The full two-worker suite previously reached 1,037/1,038; its sole runtime-banner startup timeout reproduced on the frozen merge base under the same platform, selection, and parallelism.

This was written by Codex on behalf of max-sixty

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

Registering each case article as a reading region changes a shared reading the runtime uses for more than scrolling, and the new resize handler compensates for one consequence of that in the package rather than at the seam.

readingRegionFor returns the deepest live region whose host contains the node, so every node in a case article — heading, dispositions, thread outlet, the datum a reader addresses — now resolves to the new case region, whose body is .lf-vr-shot-host. placeFab in skills/leaf/assets/runtime/composing/surface.js takes its placement boundary straight from that reading: const readingRegion = owner && readingRegionFor(owner), then shownRegionBounds(...). So the response surface for a comment on a visual case is now bounded by the capture stage instead of the evidence pane.

I measured the three states with the locked headless shell, same page, same addressed datum, resizing to 540×760 with a draft open. At the merge base the reading is lf-region:journey:evidence (bounds 92→622) and the field stays in view at 582–614 with the page scrolled to 163. At 430d6491 the reading is lf-region:journey:case-follow-release-link (bounds 468→698) and the field comes to rest at 745–777 in a 760-high viewport — I polled it for ten seconds and it never moved, so it is a placement, not a settle race. At f2475ceb the field still arrives at 745–777 and is then pulled back by the new handler. The compensation is load-bearing: stubbing the early return in #onResize reddens the journey case again at 390 too.

That leaves the displacement in place and a corrective scroll bound to window resize alone. Anything else that moves the case's thread outlet in flow — a source update that swaps in a differently sized capture, a details fold opening above it — moves an open draft the same way with nothing listening. Narrowing the case region's host to the stage it actually scrolls, or giving placeFab the containment walk scrollerFor already does in runtime/reading-regions.js, would remove the displacement instead of chasing it; which of those is right is a runtime-contract call, so it is worth saying which one this is.

One smaller consequence of the same reading: outlineSubjectFor in runtime/conversation/placement.js disambiguates repeated subjects with readingRegionFor(target)?.host.getAttribute("aria-label"). The new region host is the .lf-vr-case article, which carries no aria-label, so that context is now the empty string where it used to be "Selected visual evidence".

Separately, moving the journey's narrow posture from 540 to 390 is what makes the assertion land inside the viewport. It is worth a word in the commit or the test on why 390 is the width the case is written against, since the width it left is the one where the behaviour was visible.

@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 nested-region split lands at the seam and the journey now proves it end to end. Two things left: a call to state, inline on version.js, and one consumer that didn't come along.

placeThreadPreview in runtime/margin-projection.js is the other place a floating surface takes its boundary from shownRegionBounds, and it still resolves the region with readingRegionFor(previewEntry?.target) — the reading placeFab just left. I traced the visual-review path and could not reach a bad bound through it: a thread on an unselected case resolves to a hidden article, so shownRegionBounds returns null, and an outdated or fallback placement resolves to the lf-visual-review element itself, which no region's host contains. So this is not a regression the PR causes. It is a trap the PR opens: registerReadingRegion is public in widget-api.js and nesting is now a supported shape, so the next package whose region body is narrower than its host gets its thread preview confined to that body, exactly as the response surface was. Say the word and I'll push the switch with a case that reaches it.

Comment thread skills/leaf/assets/runtime/version.js 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 increment's new test passes on the regression it names, so it does not hold the seam it was added for.

test_a_pane_frame_comment_preview_is_not_confined_to_its_body reads the card's box straight after to_be_visible(), but the card is visible before it is placed: opening it runs resetThreadPreviewPosition, which clears data-lf-thread-placement, and the position lands a frame later through placeThreadPreview's promise. The unplaced card sits at the viewport origin, and all three assertions hold there — left >= 0 is 0 >= 0, right <= viewport.width is 460 <= 1200, and left < pane.left is 0 < 24. A read that beats the placement is green whether or not containingReadingRegionFor is in margin-projection.js.

I measured it. Reverting that one line to readingRegionFor and stalling the placement promise by 600ms makes the test pass, reporting box {x: 0, y: 0, width: 460} against pane {left: 24, right: 599.5}. Reverting it without the stall fails on the placed box — assert (32 < 24 or 492 > 599.5) — in three consecutive runs, so the reading discriminates; it is only the ordering that is missing.

#627 is adding that same ordering statement to test_a_pane_comment_stays_in_its_reading_region in this file and to test_the_thread_card_survives_trays_and_authored_sidebars, against the same unplaced frame. The direction differs here, which is what makes it worth pinning: those two go red on the race, this one goes green.

Comment thread tests/test_render_navigation.py Resolved
@max-sixty
max-sixty merged commit 4455ac0 into main Sep 12, 2026
7 checks passed
@max-sixty
max-sixty deleted the codex/visual-review-foundation branch September 12, 2026 16:40
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