Skip to content

fix(browser): a same-document back/forward returns at its own commit, not the 1.2 s grace - #742

Merged
Hona merged 1 commit into
devfrom
browser-tools/samedoc-settle
Nov 22, 2026
Merged

Hona merged 1 commit into
devfrom
browser-tools/samedoc-settle

Conversation

@Hona

@Hona Hona commented Nov 22, 2026

Copy link
Copy Markdown
Member

What

An agent's browser.back / browser.forward over a same-document entry (a pushState entry or an anchor) returned only at the 1.2 s grace: such an entry sends no new document, so none of #696's commit signals arrive. Official returns it as soon as the tab stops loading.

The main frame's Page.navigatedWithinDocument is that entry's commit, and only its address bumps the tab's generation. The wait now ends once:

  • the address moved,
  • the main frame's Page.navigatedWithinDocument count rose,
  • no new document began (contexts-cleared and main-frame navigation counts unchanged),
  • the main frame has an execution context, and the tab is not loading.

Unchanged: cross-document entries (#696), a back with no entry, and same-document entries while extensions keep Page.* to themselves still end at the grace.

Files: rpc/frames.rs (count main-frame navigatedWithinDocument), rpc/exec/settle.rs (the rule), rpc/exec/nav.rs (pass the count). No engine input.

Checked

settle's table program (outside the repo, includes settle.rs by path): 20 rows ok, including 6 new same-document rows (event before address, address before event, a new document begun, still loading, extensions with no event).

Not proved in this PR

  • Timings on a build: I measure same-document back on the merged dev and post them here.

… not the 1.2 s grace

A back or forward over a pushState or anchor entry sends no new document, so it waited the full 1.2 s grace. The main frame's Page.navigatedWithinDocument is that entry's commit, and only its address bumps the tab's generation: the wait now ends once the address moved and that event arrived, with no new document begun and the tab not loading. Official returns these as soon as the tab stops loading. With extensions (which keep Page.* to themselves) and with no entry, it still ends at the grace.
@Hona
Hona merged commit 1a84208 into dev Nov 22, 2026
@Hona
Hona deleted the browser-tools/samedoc-settle branch November 22, 2026 22:14
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

Hona added a commit that referenced this pull request Nov 22, 2026
…e extensions run, too (#762)

With extensions active the engine keeps Page.* to itself, so #742's Page.navigatedWithinDocument never reaches the app and the wait ran to the 1.2 s grace. The page's main execution context answers instead: a same-document entry keeps it, a new document destroys it. Once the address moved, that context is asked for location.href; the new address from it is the commit. At most 6 asks; anything else ends at the grace as before.
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.

1 participant