Repository navigation
Land Back and Forward in Firefox where Chromium does, after the browser applies the traversal - #5196
Merged
Merged
Conversation
…er applies the traversal Firefox restores an entry's saved offset just after a same-document traversal's popstate, even when Leaf intercepted it with scroll: "manual", and WebKit scrolls to the fragment as it applies one. Both overwrote Leaf's placement: Back to a place the user had hidden since landed 471 px down in Firefox against 59 px in Chromium. The traversal handler still places the page before the browser applies the traversal, so the claimant and travel read the page while it hides what the user hid. It then scrolls the page back by however far the first block on screen moved once the browser has applied it. test_back_to_a_fragment_the_page_has_hidden_since_lands_on_it now runs in Firefox too and checks the landing edge, which changes what it protects from "in view" to "landed".
leaf-agent
approved these changes
Nov 3, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 4, 2026
…weep (#5291) A sweep on 2026-11-03 found 39 capabilities implemented more than once in Leaf. Tend's review had approved all 10 of the introducing pull requests checked, and 15 nightly surveys that carried the instruction to look for "several implementations of one capability" reported none. This changes the instructions behind both, and adds a weekly sweep for what review still misses. - **Review loads `/developing-leaf`.** running-tend's Review threshold named that skill's "Weigh what a change adds" without saying to load it, and none of 11 production reviews on 2026-11-03 did. The section now opens "Load `/developing-leaf`"; 16 of 16 replayed reviews then loaded it. - **"What it repeats"** joins "Weigh what a change adds": search for the question each new helper, constant, selector, style rule or inline check answers rather than its name, count a copy whose comment names its source as a copy, and export, move or generate the owner rather than copy it. "Regular maintenance" points its "Several implementations of one capability" bullet at it, since the nightly survey reads one file at a time. - **Weekly: duplicate implementations** sweeps one area a week, chosen by ISO week number modulo 4, searching the whole tree by question. Each copy's introducing pull request goes in the sweep's description, so the copies added since the area's last sweep show what review let through. Replaying four pull requests that each introduced a copy (#3832, #5196, #2345, #3137), reviewers caught the copy 2 of 9 times with the old text, 3 of 8 when told to load the skill, and 5 of 8 with "What it repeats", whose wording was revised after the replay. That difference is within noise at this size, and no arm caught a one-line copy inside a new helper; the weekly sweep is there for those. This changes agent instructions, so it lands with the control-plane owner's approval (running-tend, "Landing"). > _This was written by Claude Code on behalf of max-sixty_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Firefox, Back or Forward to a place the page had hidden since, such as an element in a tab the user closed, left it at the offset the entry had been saved at. On a fixture with a disclosure opened above the tab set, Back put a plain
#tabbedtarget 471 px down in Firefox, where Chromium lands it at 59 px. Main has the same bug, and #5034's widget-key links, such as#tabbed:20-22, go through the same path.Cause. Firefox applies a same-document traversal some milliseconds after its
navigateevent. As it does, it firespopstateand then restores the destination entry's saved offset, even though Leaf intercepted the traversal withscroll: "manual":nsDocShell::HandleSameDocumentNavigationnever reads the suppression flag thatNavigation.cppsets. Leaf's handler has usually landed the place by then, so Firefox overwrote the landing. WebKit 27.2 reveals the fragment's target and scrolls to it as it applies a traversal, which overwrites Leaf's placement the same way.Fix (
browser/runtime/history.js). The traversal handler places the page as before: the claimant, travel or the entry's checkpoint, each reading the page before the browser applies the traversal and reveals what it names. The handler then notes where the first block on screen stands, waits for the rendering update after the traversal'spopstate(traversalApplied), and scrolls the page back by however far that block moved. Scroll anchoring holds that block still through a layout change above it. A traversal Leaf leaves to the browser, one with no checkpoint, is unchanged.Review turned down three other designs, each with a probe. Placing only after the browser applied the traversal let Firefox and WebKit reveal the target before travel read the page, so a root-tab entry whose target sat in a disclosure closed since stayed at the stale offset, and a rapid second Back saved the wrong offset for the entry in between. Putting back the handler's own offset undid legitimate scroll anchoring in Chromium.
history.scrollRestoration = "manual"stops the browser's restore in both engines, but Firefox then put a Forward that Leaf had no checkpoint for at the top of the page, and every traversal after a reload has none.Measured with
leaf-dev probe --baseon fixtures covering plain-id and widget-key entries, an entry whose target is still shown, root tabs, and a target in a disclosure closed since, in Playwright's Chromium 156, Firefox 157 and WebKit 27.2:popstatekeeps the intermediate entry's offset, as on main.Left as it was. Firefox blurs the focused element as it applies a traversal, so focus still ends on
bodyafter Back there, as on main. Content growing inside the first block on screen in the frame after Back, or a pinned (fixed or sticky) first block, defeats the measurement; the first scrolls that block back as on a browser move, the second leaves Firefox at its restored offset as on main. Back pressed while Leaf's own landing is still scrolling can let Firefox reveal a root-tab target before travel reads the page; main fails that case too.Test.
test_back_to_a_fragment_the_page_has_hidden_since_lands_on_itnow runs in Chromium and Firefox, opens a disclosure above the tab set before going Back, and checks that the target lands at the scroller's landing edge rather than only somewhere in view. Its Firefox cases fail on main (the target at 2,480 px and 202 px against 59 px) and fail with the step afterpopstateremoved. The browser tests that go Back or Forward pass (51 cases), as dopnpm run test:runtimeandpnpm run check:browser.notes/browser-support.mdrecords the Firefox and WebKit behaviour and how to recheck it.