fix(record): record a page reload instead of dropping it as a same-URL navigation - #184
Open
MaxFreedomPollard wants to merge 1 commit into
Open
fix(record): record a page reload instead of dropping it as a same-URL navigation#184MaxFreedomPollard wants to merge 1 commit into
MaxFreedomPollard wants to merge 1 commit into
Conversation
…L navigation `observeRecordedNavigation` opens with a same-URL guard so the `webNavigation.onCommitted` / `onCompleted` pair of one navigation yields a single step. A reload commits to the URL the tab is already on, so the same guard swallowed it: a recording in which the user pressed F5 or the reload button exported no step at all, and replaying the trace stalls on any page that only takes effect after a refresh (issue Tencent#139). Let a commit whose transition type is `reload` through the guard. Only the committed event carries the transition type, so the completion that follows still collapses onto the recorded reload, and the `reload` entry that the v3 reducer's transition-cause table has carried all along (unreachable until now) turns the step into `{op: "navigate", to: <url>, cause: "reload"}`, the shape the protocol already defines. Fixes Tencent#139
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.
Problem
During recording, a page reload (F5, the reload button, or
location.reload()) leaves no step in the trace. A flow that only takes effect after a refresh therefore stalls on replay, because the trace never says to reload (#139).Root cause
observeRecordedNavigationopens withThe guard is there so the
webNavigation.onCommitted/onCompletedpair of one navigation yields one step. A reload commits to the URL the tab is already on, so the same guard swallows it on the same line. The rest of the pipeline was already prepared for reloads:trace-reducer-v3.tshas carriedreload: "reload"inTRANSITION_CAUSES, and the protocol definesNavigationCause::Reload, but the buffer never produced a draft that reached either.Reproduced through the real recorder (start on
https://example.com/,onCommittedwithtransitionType: "reload",onCompleted, stop): onmainthe exported v3 trace hassteps: [].Fix
One condition in
step-buffer.ts: a commit whosetransitionTypeisreloadpasses the same-URL guard. Only the committed event carries the transition type, so the completion that follows (same URL, no type) still collapses onto it and no duplicate is produced. The step reduces to{ op: "navigate", to: <url>, cause: "reload" }, the shape the protocol already defines, so whoever replays the trace can issuebsk reloadat that point.Everything else is unchanged: action-caused navigations still annotate the action with
navigatedTo, redirect hops still coalesce, and a reload triggered by pressing Enter in the address bar carriesfrom_address_bar, which the reducer already maps touser_typed.One consequence worth stating: Chrome reports
reloadfor script-initiated reloads too, so a page that reloads itself is now recorded as well. Replayingbsk reloadthere is harmless and matches what the page actually did.Tests
Three tests added (846 → 849), all failing on
mainwithsteps: []:step-buffer.test.ts: a reload of the current page is appended as a navigate draft withtransitionType: "reload"; the completion that follows still collapses onto it, so there is no duplicate.record-steps.test.ts: end to end throughhandleRecordStart→onCommitted(reload)→onCompleted→handleRecordStop, the exported v3 trace has exactly one step,{ op: "navigate", to: START_URL, cause: "reload" }, with pre- and post-states.Verification
pnpm lint— exit 0 (biome, stylelint, dsh-plugin typecheck and tests)pnpm --filter @browser-skill/extension compile— cleanpnpm ext:test— 76 files, 849 passedpnpm ext:build— cleanNot exercised in a live Chrome here; the recorder harness in
record-steps.test.tsdrives the samewebNavigationlisteners the extension installs.Closes #139