Skip to content

d and u step the region the reader is standing in - #54

Merged
max-sixty merged 8 commits into
mainfrom
fix/issue-53
Aug 26, 2026
Merged

max-sixty merged 8 commits into
mainfrom
fix/issue-53

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

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

seenScroller asked the layout — the thread list only where the panel covers
the page — so beside the page, the ordinary wide window, a reader working
down the comment list pressed d and the document behind them stepped. 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.

Focus is the first answer and covering is still the second, because under
the sheet the reader may be standing outside the panel altogether and the
page behind it is a page nobody can see. inPanel is one predicate, PANEL's
own scope line, read by the scope and by seenScroller alike.

Refs #53

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review of my own PR, so this is a COMMENT rather than a verdict.

The predicate itself reads right: inPanel is the line PANEL.at was already drawing, and collapsing the two readings into one is what stops them coming apart later. The d/u case the PR names is a real gap and the new test isolates it with one factor, which is the right shape. What I'd want a maintainer's eye on is how far "focus is the reader's region" reaches — it lands on more presses than d and u, and one of those is j (inline on navigation.js).

g g / g G still say "the page". seenScroller is also the chord's edge box, and its row in assets/runtime/keyboard/address.js reads does: "Go to the top / bottom of the page", with leaf.js's own header saying the same thing (g g and g G are the page's own edges, addresses with no list to name). Under the old rule that only diverged under a covering sheet, where "the page" is the sheet and nothing else is visible. Now, on an ordinary wide window with focus in the list, g g moves the list while the reference open beside it promises the page — the reader can read both at once and they disagree. The Escape row directly below already takes a function for does, so naming the box it means is in reach, and line could stay "top / bottom" so the two key-line tests go on reading. I've left it alone rather than pushing it: which words are right depends on the g g question the PR body already hands over, and if the answer is that the edges stay the page's, the label needs no change at all.

Nothing in the diff looks wrong to me on its own terms; the rest is inline and small.

// is the banner's — and the page behind the sheet is a page nobody can see, so a key
// is no different from a wheel there. Focus says which region is the reader's;
// covering says which one the window will show them. A press wants both answers.
const seenScroller = () => (inPanel() || panelCovers() ? threadsBox : pageScroller);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j/k are page-scope keys whose landing is inside the panel — stepThread opens the panel if it is shut, calls next.focus({preventScroll: true}) on a .lf-thread, and then scrollToThread moves the document to that thread's anchor. So a reader on the page who presses j once is now standing in the panel by this predicate, and the next d steps the comment list instead of reading on from the anchor j just travelled to. That leaves d doing roughly what j already does, and the only keyboard way back out is Escape, which closes the panel (rung() → setPanel(false)).

The codebase has already met this exact ambiguity and answered it the other way: PANEL_SAY.when stands the row down for precisely this case, and says why — "j is a page key that lands focus in the panel … A gesture the reader made outranks the room they happen to be standing in." Focus alone was not taken as the reader's region there.

I don't think this is obviously wrong — a reader who walked to a comment may well want the list to step — but it is a second behaviour change beyond the one the PR names, it disagrees with a rule the register already wrote down, and no test pins either answer. Worth deciding explicitly rather than inheriting.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading PANEL_SAY at its when rather than at its comment, I think the register already answers this the way the predicate does. The row stands down for fabAnchorAt() and standingConversation() — a live 💬 or a conversation the reader is in — and for nothing else, so after a bare j/k walk, with neither in hand, the panel's own c is live and the reader is treated as standing in the panel. The sentence the comment draws ("a gesture the reader made outranks the room they happen to be standing in") is about the selection still being live, not about focus-in-panel being an unreliable reading of the room: the room is the default there, and only a gesture displaces it. seenScroller now reads it the same way, with no gesture in the way of that press either.

Two corrections to the shape of the ambiguity, which don't settle it but change what is being weighed. d is not roughly what j does: j moves focus and travels the page to the next thread's anchor, while d moves neither — it scrolls the list under the standing card, which is what a thread longer than the list's scrollport needs and what j cannot give. And j/k still walk on from that card afterwards, page half included, so the reader is not stranded in the list.

What does stand, and is the sharp end of it: getting focus back out to the page costs the panel. rung() has one panelOpen branch, so the Escape that hands back the rung j pushed also shuts the comments. A reader who pressed j to look at a comment and then wants to read on down the page pays the panel for it. That is the case where "focus is the reader's region" is expensive, and it is a fact about the stack rather than about this predicate.

So I've left it. The reading it inherits is the register's own, and which way it should go depends on what j is meant to leave the reader doing — intent the repository doesn't state either way. Flagging it here rather than pinning it, since a test would make the answer durable before it has been chosen.

Comment thread plugins/leaf/skills/leaf/assets/leaf.js Resolved
Comment thread tests/test_render_drafts.py Resolved
`inPanel` is a module-level const several hundred lines above the
`createNavigation` call, so it goes by name the way `panelCovers` two
lines below does. The wrapper `inChrome` wears is there because that one
is destructured out of a module built further down the file; copying it
here would leave a deferral with no reason behind it for the next helper
to inherit.

The new test's stillness assert takes the tolerance its own wait was
granted. `< 1` on the control's glide is a tolerance rather than a rest —
the ease is inside a pixel about a frame before the last write lands — so
an exact equality could fail by a fraction and report the page stepping
behind the reader, which is not what happened. `rests_at` already pairs
the same wait with `abs=1`, and a page that stepped moves ~400px, so the
assertion gives up nothing it is for.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Pushed 506555e for the review's two small corrections — inPanel by name, and the stillness assert taking the tolerance its own wait was granted. Replies are inline; the j one is where the substance is.

On g g / g G in the review body: I've left the label alone, and I think the reasoning that argues for leaving it is the reasoning that argues against fixing it now. The two available fixes are mutually exclusive — either the edges follow seenScroller and the row names the box it lands in, or the edges are the page's own and g g stops reading seenScroller at all. The second is a behaviour change, not a wording one, so rewording the row would quietly settle the question it is a symptom of. Both are small once the answer is chosen: the Escape row directly below already takes a function for does, though address.js would need a noun for the region from somewhere — neither threadsBox nor pageScroller is in its scope today.

So there are two decisions here for a maintainer, and they're independent of each other: how far "focus is the reader's region" reaches past d/u (the j thread), and which box the chord's edges name. The d/u fix this PR is titled for stands either way.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two corrections from the previous review landed correctly — inPanel resolves as a module-level const well above the destructuring site, and pytest is already imported in the test module, so both are safe as written.

.claude/settings.local.json was committed by mistake. 506555e adds it as a new tracked file, and it is the CI harness's own local settings rather than anything this PR is about: {"permissions":{"defaultMode":"bypassPermissions", ...},"skipDangerousModePermissionPrompt":true}. Tracking it means every checkout of this repo — a contributor's, a maintainer's — inherits bypassPermissions for Claude Code, silently, from a file nobody chose. It also isn't atomic: a PR titled for d/u shouldn't carry a harness config change.

The repo's .gitignore covers __pycache__/, *.pyc, .DS_Store, .tmp/, .venv/ and nothing under .claude/, so nothing stopped it and nothing stops the next session repeating it — lint and test don't look at tracked config. I'm pushing the removal plus a one-line ignore entry, since no author is going to act on an offer here. If you'd rather keep this PR strictly to the navigation change, drop the .gitignore hunk and take it separately; the removal itself has to stay either way.

Nothing else new in the increment. The j/k question on navigation.js and the g g / g G label are still the two open decisions, both already stated in the thread — not restating them here.

leaf-agent and others added 3 commits August 26, 2026 20:27
506555e added .claude/settings.local.json by accident. It is the CI
harness's own file, and tracking it hands every checkout
bypassPermissions from a config nobody chose. Ignore it so the next
session cannot repeat the leak.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review of my own PR, so this is a COMMENT rather than a verdict.

seenScroller back to panelCovers() alone settles the g g / g G question the thread handed over, and it settles it the way that needs no label change: beside the page the edges are the document's, so does: "Go to the top / bottom of the page" in address.js is honest again, and under a covering sheet "the page" is the sheet, which is the reading that shipped before this PR. Two names, one question each.

The new .lf-threads assertion in the g chord test cannot fail. In that fixture the list does not overflow — I measured [scrollTop, scrollHeight, clientHeight] = [0, 592, 592] at the point threads_was is read — so scrollTop is pinned at 0 under both the fixed and the unfixed predicate, and assert … == threads_was is 0 == 0 either way. tests/CLAUDE.md names this shape under Make a green test non-vacuous: "A test is vacuous when some unrelated mechanism makes its assertion true under both the good and bad implementation."

The block does still gate the regression, just not where it reads as if it does. I reverted seenScroller to inPanel() || panelCovers() and ran the test: it fails at page.wait_for_function("() => document.body.scrollTop === 0"), after 30s, with Page.wait_for_function: Timeout 30000ms exceeded and nothing said about what broke. So the line the comment presents as the protection is decoration, and the line carrying the weight reports a timeout — the second half of Fail with the evidence needed to act.

This PR already carries the guard that would have caught it. test_the_half_page_keys_follow_the_reader_into_the_panel opens with exactly the premise check missing here — t.scrollHeight > t.clientHeight, with the message "the thread list does not overflow, so it could not be seen to scroll below" — and it has the fixture behind it (serve(LONG_PAGE, comments=12)). The g g case reads better beside that one than here: there the list has already been seen to move under d, so one g g afterwards shows the edges staying the page's while the step is the list's, which is this commit's whole claim in a single fixture with both halves observable. The inline suggestion is the smaller alternative — drop the assertion that can't fail rather than leave it standing as a gate.

The j/k thread on navigation.js is untouched by this increment and still open; not restating it.

Reproduction

Measured by adding a probe beside threads_was in test_the_g_chord_addresses_every_list_the_page_has and running uv run pytest tests/test_render_navigation.py -q -n0 -k the_g_chord_addresses_every_list --run-nightly -s:

PROBE [0, 592, 592]
1 passed, 38 deselected in 5.76s

Bug-back, with seenScroller in navigation.js put back to inPanel() || panelCovers() and nothing else changed:

E  playwright._impl._errors.TimeoutError: Page.wait_for_function: Timeout 30000ms exceeded.
FAILED tests/test_render_navigation.py::test_the_g_chord_addresses_every_list_the_page_has
1 failed, 38 deselected in 35.82s

Unmodified, the test passed 5/5 at -n0, so nothing here is a flake report.

Comment thread tests/test_render_navigation.py Resolved

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review of my own PR, so this is a COMMENT rather than a verdict.

The g g case reads right where it now sits, and it is no longer vacuous: with seenScroller put back to inPanel() || panelCovers(), the block fails at assert edge_page == pytest.approx(0, abs=1) with g g left the page at 423 and moved the panel to 0 — both offsets, named. That closes the finding from the last review, and the fixture is the one that gives it both halves: the list has been seen to move under d before g g is pressed, so the contrast is observable rather than asserted over a list that could not scroll.

The settle-wait that made it observable took the d/u failure onto a bare timeout. The new thread_half wait (tests/test_render_drafts.py, the Math.abs(… .scrollTop - e) < 1 call between the movement wait and page_now, threads_now = offsets()) expects one answer, and the regression this PR is titled for produces the other: under stepScroller reverted to seenScroller the document steps and the list never reaches thread_half, so the test dies at Page.wait_for_function: Timeout 5000ms exceeded after 5 seconds instead of at assert threads_now > threads_was with "the list the reader is standing in did not move for the key they pressed". At c23a661 that same revert reported the message; the increment is what moved it.

This is the shape tests/CLAUDE.md names under Fail with the evidence needed to act — "When a wait times out, its message must say what evidence was missing" — and it is the same one the commit's own comment three lines below states the cure for: wait for either answer. The inline suggestion applies that to this wait. I verified it in all three directions: passing unchanged on the fix, reporting the named d/u message under the stepScroller revert, and still reporting g g left the page at 423 … under the seenScroller revert.

The j/k question on navigation.js is untouched by both increments and still open; not restating it.

Reproduction

All at f4509c2, uv run pytest tests/test_render_drafts.py -q -n0 -k half_page_keys_follow --run-nightly.

Unmodified: 1 passed. With stepPage taking seenScroller() again — the d/u regression:

>       page.wait_for_function(
E       playwright._impl._errors.TimeoutError: Page.wait_for_function: Timeout 5000ms exceeded.
tests/test_render_drafts.py:2272: TimeoutError

With the suggestion applied, the same revert:

E       AssertionError: the list the reader is standing in did not move for the key they pressed
E       assert 0 > 0
tests/test_render_drafts.py:2280: AssertionError

And with the suggestion applied and seenScroller reverted instead, the g g half still reports as before (Obtained: 423 / Expected: 0 ± 1).

tests/test_render_navigation.py and tests/test_render_drafts.py together: 84 passed at -n0 on f4509c2.

Comment thread tests/test_render_drafts.py Resolved
@max-sixty
max-sixty merged commit e13f5d5 into main Aug 26, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/issue-53 branch August 26, 2026 23:52
max-sixty added a commit that referenced this pull request Aug 27, 2026
## 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]>
max-sixty added a commit that referenced this pull request Aug 27, 2026
## Problem

The comment panel could not hand focus back to the document without
closing or widening itself, and a reader standing on a long comment had
no direct way to place that card at either edge of the list.

## Solution

- Add `g p` as an address-chord completion that focuses the document
while preserving the open panel and its current narrowing when the panel
sits beside the page. A covering panel keeps ordinary Escape as the
honest route back.
- Add `g t` / `g b` completions for placing the focused comment at the
top or bottom of the panel list. The placement uses the list’s existing
`scroll-padding`, so sticky headings and focus rings remain clear.
- Keep ordinary Escape’s narrowing rung: `w` only owns Waiting-on-you,
while Escape must still release a text search after Enter leaves its
box.
- Item 1 was already fixed by #54; this completes the remaining
actionable parts of the report.

## Testing

- `uv run pytest tests/test_render_conversations.py -q -n0` — 39 passed
after merging current `main`
- `uv run pytest tests/test_render_navigation.py -q -n0` — 39 passed
after merging current `main`
- `uv run pytest tests` — 635 passed, 1 skipped after merging current
`main`
- UI sweep on `ship-review` at 1200×900 and 800×900 — no crowding or
console errors; `g p` is offered only beside the page
- `uv run pre-commit run --all-files`

Closes #53

Thanks @leaf-agent for the report and the follow-up analysis.

> _This was written by Codex on behalf of max-sixty_

---------

Co-authored-by: leaf-agent <[email protected]>
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